Package com.amazonaws.services.dynamodb.model

Examples of com.amazonaws.services.dynamodb.model.QueryResult


    public <T> QueryResultPage<T> queryPage(Class<T> clazz, DynamoDBQueryExpression queryExpression, DynamoDBMapperConfig config) {
        config = mergeConfig(config);

        QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config);

        QueryResult scanResult = db.query(applyUserAgent(queryRequest));
        QueryResultPage<T> result = new QueryResultPage<T>();
        result.setResults(marshallIntoObjects(clazz, scanResult.getItems()));
        result.setLastEvaluatedKey(scanResult.getLastEvaluatedKey());

        return result;
    }
View Full Code Here


        QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config);
        queryRequest.setCount(true);

        // Count queries can also be truncated for large datasets
        int count = 0;
        QueryResult queryResult = null;
        do {
            queryResult = db.query(applyUserAgent(queryRequest));
            count += queryResult.getCount();
            queryRequest.setExclusiveStartKey(queryResult.getLastEvaluatedKey());
        } while (queryResult.getLastEvaluatedKey() != null);

        return count;
    }
View Full Code Here

    public <T> PaginatedQueryList<T> query(Class<T> clazz, DynamoDBQueryExpression queryExpression, DynamoDBMapperConfig config) {
        config = mergeConfig(config);

        QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config);

        QueryResult queryResult = db.query(applyUserAgent(queryRequest));
        return new PaginatedQueryList<T>(this, clazz, db, queryRequest, queryResult);
    }
View Full Code Here

        QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config);
        queryRequest.setCount(true);

        // Count queries can also be truncated for large datasets
        int count = 0;
        QueryResult queryResult = null;
        do {
            queryResult = db.query(applyUserAgent(queryRequest));
            count += queryResult.getCount();
            queryRequest.setExclusiveStartKey(queryResult.getLastEvaluatedKey());
        } while (queryResult.getLastEvaluatedKey() != null);

        return count;
    }
View Full Code Here

    public <T> PaginatedQueryList<T> query(Class<T> clazz, DynamoDBQueryExpression queryExpression, DynamoDBMapperConfig config) {
        config = mergeConfig(config);

        QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config);

        QueryResult queryResult = db.query(applyUserAgent(queryRequest));
        return new PaginatedQueryList<T>(this, clazz, db, queryRequest, queryResult);
    }
View Full Code Here

    public <T> QueryResultPage<T> queryPage(Class<T> clazz, DynamoDBQueryExpression queryExpression, DynamoDBMapperConfig config) {
        config = mergeConfig(config);

        QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config);

        QueryResult scanResult = db.query(applyUserAgent(queryRequest));
        QueryResultPage<T> result = new QueryResultPage<T>();
        result.setResults(marshallIntoObjects(clazz, scanResult.getItems()));
        result.setLastEvaluatedKey(scanResult.getLastEvaluatedKey());
       
        return result;
    }
View Full Code Here

        QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config);
        queryRequest.setCount(true);

        // Count queries can also be truncated for large datasets
        int count = 0;
        QueryResult queryResult = null;
        do {
            queryResult = db.query(applyUserAgent(queryRequest));
            count += queryResult.getCount();
            queryRequest.setExclusiveStartKey(queryResult.getLastEvaluatedKey());
        } while (queryResult.getLastEvaluatedKey() != null);

        return count;
    }
View Full Code Here

    }

        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;
  }
View Full Code Here

  }

  public com.amazonaws.services.dynamodbv2.model.QueryResult queryV2(com.amazonaws.services.dynamodbv2.model.QueryRequest v2Request) {
        Table table = this.tables.get(v2Request.getTableName());
        QueryRequest request = AlternatorDBApiVersion2Mapper.MapV2QueryRequestToV1(v2Request, table);
        QueryResult result = query(request);
        return AlternatorDBApiVersion2Mapper.MapV1QueryResultToV2(result, table);
  }
View Full Code Here

        inProcessClient.save(PERSISTENCE_PATH);
        createNewInProcessClient().restore(PERSISTENCE_PATH);

        AttributeValue hashKey = new AttributeValue().withS("1");
        QueryRequest request = new QueryRequest(tableName, hashKey);
        QueryResult result = getClient().query(request);
        Assert.assertNotNull(result.getItems());
        Assert.assertNotSame(result.getItems().size(), 0);
        Map<String, AttributeValue> row = result.getItems().get(0);
        assertEquals(row.get("id"), hashKey);
        assertEquals(row.get("count").getN(), "100");
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodb.model.QueryResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.