use of com.amazonaws.services.dynamodbv2.document.DynamoDB in project qpp-conversion-tool by CMSgov.
the class AwsTestHelper method cleanDynamoDb.
/**
* Cleans dynamodb items until via batch scan and delete for performance purposes
*/
public static void cleanDynamoDb() {
ScanResult scanResult = DYNAMO_CLIENT.scan(TEST_DYNAMO_TABLE_NAME, Lists.newArrayList("Uuid"));
List<Map<String, AttributeValue>> metadataList = scanResult.getItems();
while (scanResult.getLastEvaluatedKey() != null && !scanResult.getLastEvaluatedKey().isEmpty()) {
scanResult = DYNAMO_CLIENT.scan(new ScanRequest().withTableName(TEST_DYNAMO_TABLE_NAME).withAttributesToGet("Uuid").withExclusiveStartKey(scanResult.getLastEvaluatedKey()));
metadataList.addAll(scanResult.getItems());
}
metadataList.forEach(map -> DYNAMO_CLIENT.deleteItem(TEST_DYNAMO_TABLE_NAME, map));
}
Aggregations