public List<T> scan() { DynamoDBScanExpression scanExpression = new DynamoDBScanExpression() .withExclusiveStartKey(null) .withLimit(LIMIT); PaginatedScanList<T> resutlList = getDynamoDbMapper().scan(entityClass, scanExpression); List<T> sortedResults = new ArrayList<T>(resutlList); Collections.sort(sortedResults); return sortedResults; }
/** * Builds scan query expression using a hash attribute value where to start * @param pHashAttrValueHash attribute value where to start scanning */ public void buildScanExpression(AttributeValue pHashAttrValue){ DynamoDBScanExpression newScanExpression = new DynamoDBScanExpression(); // TODO right now we only support scanning using the key, but we should support other types of scans newScanExpression.addFilterCondition(getKeySchema().getHashKeyElement().getAttributeName(), buildKeyScanCondition()); dynamoDBExpression = newScanExpression; }
/** * Executes a query after building a DynamoDB specific query based on the received one */ @Override public Result<K, T> execute(Query<K, T> query) { DynamoDBQuery<K, T> dynamoDBQuery = buildDynamoDBQuery(query); DynamoDBMapper mapper = new DynamoDBMapper(dynamoDBClient); List<T> objList = null; if (DynamoDBQuery.getType().equals(DynamoDBQuery.RANGE_QUERY)) objList = mapper.query(persistentClass, (DynamoDBQueryExpression)dynamoDBQuery.getQueryExpression()); if (DynamoDBQuery.getType().equals(DynamoDBQuery.SCAN_QUERY)) objList = mapper.scan(persistentClass, (DynamoDBScanExpression)dynamoDBQuery.getQueryExpression()); return new DynamoDBResult<K, T>(this, query, objList); }