Example usage for com.amazonaws.services.dynamodbv2.model AttributeDefinition setAttributeType

List of usage examples for com.amazonaws.services.dynamodbv2.model AttributeDefinition setAttributeType

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.model AttributeDefinition setAttributeType.

Prototype


public void setAttributeType(ScalarAttributeType attributeType) 

Source Link

Document

The data type for the attribute, where:

  • S - the attribute is of type String

  • N - the attribute is of type Number

  • B - the attribute is of type Binary

Usage

From source file:org.apache.gora.dynamodb.store.DynamoDBUtils.java

License:Apache License

/**
 * Builds the necessary requests to create tables
 * //  w  ww  . ja  v  a2 s.  c om
 * @param tableName
 * @param keySchema
 * @param proThrou
 * @param attrs 
 * @return
 */
public static CreateTableRequest buildCreateTableRequest(String tableName,
        ArrayList<KeySchemaElement> keySchema, ProvisionedThroughput proThrou, Map<String, String> attrs) {
    CreateTableRequest createTableRequest = new CreateTableRequest();
    createTableRequest.setTableName(tableName);
    createTableRequest.setKeySchema(keySchema);
    ArrayList<AttributeDefinition> attributeDefinitions = new ArrayList<AttributeDefinition>();
    for (KeySchemaElement kEle : keySchema) {
        AttributeDefinition attrDef = new AttributeDefinition();
        attrDef.setAttributeName(kEle.getAttributeName());
        attrDef.setAttributeType(attrs.get(kEle.getAttributeName()));
        attributeDefinitions.add(attrDef);
    }
    createTableRequest.setAttributeDefinitions(attributeDefinitions);
    createTableRequest.setProvisionedThroughput(proThrou);
    return createTableRequest;
}