Database Reference
In-Depth Information
The next method will return a ProvisionedThroughput instance with the populated
read/write throughput capacities for our table. The long number ( 2L ) here means the max-
imum read or write data size per second. This is usually measured in kB/s. So here we are
restricting the read/write speed to 2 kB/s. Have a look at the following code:
private static ProvisionedThroughput
getProvisionedThroughput() {
ProvisionedThroughput provisionedThroughput =
newProvisionedThroughput()
.withReadCapacityUnits(2L)
.withWriteCapacityUnits(2L);
return provisionedThroughput;
}
The following code tries to update the already created table; here we are modifying only
the ProvisionedThroughput capacity units. During table creation we have set this
value to 2L ; now we are updating it to 4L . The UpdateTableRequest instance will
allow us to change only a few parameters such as changing the provisioned throughput ca-
pacity of the table and (if required) the secondary index throughput capacity. If you have
the question, say can we update (add or remove) secondary indexes of the table? The an-
swer is no: we cannot add or remove secondary indexes using UpdateTableRequest .
Tip
We can specify an index for a table only during table creation. After that, we cannot up-
date or add a secondary index.
private static UpdateTableRequest
getUpdateTableRequest(String tableName) {
ProvisionedThroughput upt = new ProvisionedThroughput()
.withReadCapacityUnits(4L)
.withWriteCapacityUnits(4L);
UpdateTableRequest updateTableRequest =
newUpdateTableRequest()
.withTableName(tableName)
.withProvisionedThroughput(upt);
return updateTableRequest;
}
Search WWH ::




Custom Search