}
String hashKeyValue = getKeyValue(request.getHashKeyValue());
List<String> attributesToGet = request.getAttributesToGet();
QueryResult queryResult = new QueryResult();
List<Map<String, AttributeValue>> list = new ArrayList<Map<String, AttributeValue>>();
KeySchema keySchema = table.getKeySchema();
KeySchemaElement rangeKeyElement = keySchema.getRangeKeyElement();
ItemRangeGroup rangeGroup = table.getItemRangeGroup(hashKeyValue);
if (rangeGroup != null) {
for (Map<String, AttributeValue> item : rangeGroup.getItems(rangeKeyElement, request.getRangeKeyCondition())) {
if (request.getScanIndexForward() == null || request.getScanIndexForward() == true) {
// The default value is true (forward).
// If ScanIndexForward is not specified, the results are returned in ascending order.
list.add(getItemWithAttributesToGet(item, attributesToGet));
} else {
list.add(0, getItemWithAttributesToGet(item, attributesToGet));
}
}
}
if (request.getLimit() != null && request.getLimit() > 0) {
while (list.size() > request.getLimit()) {
list.remove((int) request.getLimit());
}
}
queryResult.setItems(list);
queryResult.setCount(list.size());
queryResult.setConsumedCapacityUnits(0.5);
// DynamoDBMapper implements paged query continuations if we return a LastEvaluatedKey value.
// Leave this value null to indicate we are returning the full result set.
queryResult.setLastEvaluatedKey(null); // new Key(request.getHashKeyValue()));
return queryResult;
}