* The parameters for running the scan.
* @return The count of matching items, without returning any of the actual
* item data.
*/
public int count(Class<?> clazz, DynamoDBScanExpression scanExpression) {
ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression);
scanRequest.setCount(true);
// Count scans can also be truncated for large datasets
int count = 0;
ScanResult scanResult = null;
do {
scanResult = db.scan(applyUserAgent(scanRequest));
count += scanResult.getCount();
scanRequest.setExclusiveStartKey(scanResult.getLastEvaluatedKey());
} while (scanResult.getLastEvaluatedKey() != null);
return count;
}