List of usage examples for com.amazonaws.services.dynamodbv2.model GlobalSecondaryIndexUpdate GlobalSecondaryIndexUpdate
GlobalSecondaryIndexUpdate
From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java
License:Open Source License
private TableDescription updateTable(TableDescription desc) { Preconditions.checkNotNull(desc, "table description must not be null"); UpdateTableSpec spec = null;// w w w . j av a 2 s .c om if (false == ptMap.get(tableNameSuffix).equals(convert(desc.getProvisionedThroughput()))) { //if the throughput of the table is not the same as the throughput in the ptMap configuration, //update the thruput of the table spec = new UpdateTableSpec().withProvisionedThroughput(ptMap.get(tableNameSuffix)); } final List<GlobalSecondaryIndexUpdate> gsiUpdates = new ArrayList<>(); if (desc.getGlobalSecondaryIndexes() != null && false == desc.getGlobalSecondaryIndexes().isEmpty()) { //if the table description has updates to secondary indexes desc.getGlobalSecondaryIndexes().forEach(gsi -> { //for each gsi in the table description final String indexName = gsi.getIndexName(); ProvisionedThroughput pt = ptMap.get(indexName); if (pt != null && false == pt.equals(convert(gsi.getProvisionedThroughput()))) { //if the throughput of the gsi in the description is not the same as the throughput in the pt map //add an update to the gsi's thruput gsiUpdates .add(new GlobalSecondaryIndexUpdate().withUpdate(new UpdateGlobalSecondaryIndexAction() .withIndexName(indexName).withProvisionedThroughput(pt))); } }); } if (false == gsiUpdates.isEmpty()) { if (spec == null) { spec = new UpdateTableSpec(); } spec.withGlobalSecondaryIndexUpdates(gsiUpdates); } return spec == null ? null : table.updateTable(spec); }