Database Reference
In-Depth Information
attrDefList.add(new
AttributeDefinition().withAttributeName("bookId").withAttributeType("N"));
attrDefList.add(new
AttributeDefinition().withAttributeName("yop").withAttributeType("S"));
// Define primary key schema
ArrayList<KeySchemaElement> ks = new
ArrayList<KeySchemaElement>();
ks.add(new KeySchemaElement("bookId",
KeyType.HASH));
ks.add(new KeySchemaElement("yop",KeyType.RANGE));
// Provision throughput settings
ProvisionedThroughput provisionedThroughput = new
ProvisionedThroughput()
.withReadCapacityUnits(20L)
.withWriteCapacityUnits(20L);
// Create table request with specifications
CreateTableRequest request = new CreateTableRequest()
.withTableName("book")
.withAttributeDefinitions(attrDefList)
.withKeySchema(ks)
.withProvisionedThroughput(provisionedThroughput);
// Submit create table request to client
CreateTableResult result =
dynamoDBClient.createTable(request);
Once the request is submitted, DynamoDB takes a couple of minutes to get the table ac-
tivated; meanwhile, the SDK provides an API to wait:
Tables.waitForTableToBecomeActive(dynamoDBClient, "Book");
Once the table is activated, you can continue with further execution.
Search WWH ::




Custom Search