String tableName = getTable().getTableName();
QueryRequest req = spec.getRequest().withTableName(tableName);
// hash key
final KeyAttribute hashKey = spec.getHashKey();
req.addKeyConditionsEntry(hashKey.getName(),
new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(InternalUtils.toAttributeValue(hashKey.getValue()))
);
// range key condition
RangeKeyCondition rangeKeyCond = spec.getRangeKeyCondition();
if (rangeKeyCond != null) {
KeyConditions keyCond = rangeKeyCond.getKeyCondition();
if (keyCond == null)
throw new IllegalArgumentException("key condition not specified in range key condition");
Object[] values = rangeKeyCond.getValues();
if (values == null)
throw new IllegalArgumentException("key condition values not specified in range key condition");
req.addKeyConditionsEntry(rangeKeyCond.getAttrName(),
new Condition()
.withComparisonOperator(keyCond.toComparisonOperator())
.withAttributeValueList(InternalUtils.toAttributeValues(values))
);
}
// query filters;