in src/main/java/com/amazonaws/partners/saasfactory/metering/aggregation/BillingEventAggregation.java [253:279]
private Update buildUpdate(Long eventCount, Map<String, AttributeValue> compositeKey) {
List<String> updateStatements = new ArrayList<>();
Map<String, String> expressionAttributeNames = new HashMap<>();
expressionAttributeNames.put(QUANTITY_EXPRESSION_NAME, QUANTITY_ATTRIBUTE_NAME);
Map<String, AttributeValue> expressionAttributeValues = new HashMap<>();
AttributeValue countByProductionCodeValue = AttributeValue.builder()
.n(eventCount.toString())
.build();
expressionAttributeValues.put(ADD_TO_AGGREGATION_EXPRESSION_VALUE, countByProductionCodeValue);
this.logger.info("Count is {}", eventCount);
// Appended to the ADD_TO_AGGREGATION_ATTRIBUTE_VALUE for identification in the expression
// attribute names/values. There could be more than one product code to aggregate
String updateStatement = String.format("ADD %s %s",
QUANTITY_EXPRESSION_NAME,
ADD_TO_AGGREGATION_EXPRESSION_VALUE);
updateStatements.add(updateStatement);
return Update.builder()
.tableName(this.tableConfig.getTableName())
.key(compositeKey)
.updateExpression(String.join(",", updateStatements))
.expressionAttributeNames(expressionAttributeNames)
.expressionAttributeValues(expressionAttributeValues)
.build();
}