/** * <p> * The maximum number of items to evaluate (not necessarily the number of matching items). If DynamoDB processes the * number of items up to the limit while processing the results, it stops the operation and returns the matching * values up to that point, and a key in <code>LastEvaluatedKey</code> to apply in a subsequent operation, so that * you can pick up where you left off. Also, if the processed data set size exceeds 1 MB before DynamoDB reaches * this limit, it stops the operation and returns the matching values up to the limit, and a key in * <code>LastEvaluatedKey</code> to apply in a subsequent operation to continue the operation. For more information, * see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html">Query and * Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>. * </p> * * @param limit * The maximum number of items to evaluate (not necessarily the number of matching items). If DynamoDB * processes the number of items up to the limit while processing the results, it stops the operation and * returns the matching values up to that point, and a key in <code>LastEvaluatedKey</code> to apply in a * subsequent operation, so that you can pick up where you left off. Also, if the processed data set size * exceeds 1 MB before DynamoDB reaches this limit, it stops the operation and returns the matching values up * to the limit, and a key in <code>LastEvaluatedKey</code> to apply in a subsequent operation to continue * the operation. For more information, see <a * href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html">Query and * Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>. * @return Returns a reference to this object so that method calls can be chained together. */ public QueryRequest withLimit(Integer limit) { setLimit(limit); return this; }
@Override public Page<Item,QueryOutcome> nextPage() { if (lastEvaluatedKey == null) { throw new NoSuchElementException("No more pages"); } final Integer max = spec.getMaxResultSize(); if (max != null) { int nextLimit = nextRequestLimit(max.intValue()); if (nextLimit == 0) throw new NoSuchElementException("No more pages"); request.setLimit(nextLimit); } request.setExclusiveStartKey(lastEvaluatedKey); QueryResult result = client.query(request); final int nextIndex = index + this.size(); return new QueryPage(client, spec, request, nextIndex, new QueryOutcome(result)); } }
@Override public Page<Item, QueryOutcome> firstPage() { QueryRequest request = spec.getRequest(); request.setExclusiveStartKey(startKey); request.setLimit(InternalUtils.minimum( spec.getMaxResultSize(), spec.getMaxPageSize())); QueryResult result = client.query(request); QueryOutcome outcome = new QueryOutcome(result); setLastLowLevelResult(outcome); return new QueryPage(client, spec, request, 0, outcome); }
QueryWithLimitWorker(final DynamoDbDelegate delegate, final QueryRequest request, final StaticBuffer titanKey, final int limit) { super(delegate, request, titanKey); this.limit = limit; request.setLimit(limit); }
/** * <p> * The maximum number of items to evaluate (not necessarily the number of matching items). If DynamoDB processes the * number of items up to the limit while processing the results, it stops the operation and returns the matching * values up to that point, and a key in <code>LastEvaluatedKey</code> to apply in a subsequent operation, so that * you can pick up where you left off. Also, if the processed data set size exceeds 1 MB before DynamoDB reaches * this limit, it stops the operation and returns the matching values up to the limit, and a key in * <code>LastEvaluatedKey</code> to apply in a subsequent operation to continue the operation. For more information, * see <a href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html">Query and * Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>. * </p> * * @param limit * The maximum number of items to evaluate (not necessarily the number of matching items). If DynamoDB * processes the number of items up to the limit while processing the results, it stops the operation and * returns the matching values up to that point, and a key in <code>LastEvaluatedKey</code> to apply in a * subsequent operation, so that you can pick up where you left off. Also, if the processed data set size * exceeds 1 MB before DynamoDB reaches this limit, it stops the operation and returns the matching values up * to the limit, and a key in <code>LastEvaluatedKey</code> to apply in a subsequent operation to continue * the operation. For more information, see <a * href="http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html">Query and * Scan</a> in the <i>Amazon DynamoDB Developer Guide</i>. * @return Returns a reference to this object so that method calls can be chained together. */ public QueryRequest withLimit(Integer limit) { setLimit(limit); return this; }
QueryRequest projectQuery = new QueryRequest("project"); projectQuery.setLimit(Integer.MAX_VALUE); QueryResponse projectResponse = restApi.query(projectQuery); QueryRequest typeDefQuery = new QueryRequest("typedefinition"); typeDefQuery.setQueryFilter(new QueryFilter("Name", "=", "Portfolio Item")); QueryResponse typeDefResponse = restApi.query(typeDefQuery); JsonObject piTypeDef = typeDefResponse.getResults().get(0).getAsJsonObject(); for(JsonElement projectResult : projectResponse.getResults()) { JsonObject project = projectResult.getAsJsonObject(); System.out.println("Project: " + project.get("Name").getAsString()); //Begin hackery (note we're not handling multiple pages- // if you have more than 200 custom attributes you'll have to page String scopedAttributeDefUrl = "/project/" + project.get("ObjectID").getAsLong() + "/typedefinition/" + piTypeDef.get("ObjectID").getAsLong() + "/scopedattributedefinition" + "?fetch=Hidden,Required,Name&query=" + URLEncoder.encode("(Custom = true)", "utf-8"); String attributes = restApi.getClient().doGet(scopedAttributeDefUrl); QueryResponse attributeResponse = new QueryResponse(attributes); //End hackery for(JsonElement customAttributeResult : attributeResponse.getResults()) { JsonObject customAttribute = customAttributeResult.getAsJsonObject(); System.out.print("\tAttribute: " + customAttribute.get("Name").getAsString()); System.out.print(", Hidden: " + customAttribute.get("Hidden").getAsBoolean()); System.out.println(", Required: " + customAttribute.get("Required").getAsBoolean()); } System.out.println(); }
QueryRequest ustore = new QueryRequest("hierarchicalrequirement"); ustore.setLimit(Integer.MAX_VALUE); ustore.setFetch(new Fetch("FormattedID","Name","Parent","Feature","Blocked","PlanEstimate","ScheduleState","Release","Iteration","Owner","Project")); ustore.setQueryFilter(new QueryFilter("Feature.Name","=",feature.getName())); QueryResponse usResp = restApi.query(ustore);
private <T> QueryRequest createQueryRequestFromExpression(Class<T> clazz, DynamoDBQueryExpression<T> queryExpression, DynamoDBMapperConfig config) { final QueryRequest queryRequest = new QueryRequest(); queryRequest.setConsistentRead(queryExpression.isConsistentRead()); queryRequest.setTableName(getTableName(clazz, queryExpression.getHashKeyValues(), config)); queryRequest.setIndexName(queryExpression.getIndexName()); final ItemConverter converter = getConverter(config); // Hash key (primary or index) conditions final Map<String, Condition> hashKeyConditions = getHashKeyEqualsConditions( converter, queryExpression.getHashKeyValues()); // Range key (primary or index) conditions final Map<String, Condition> rangeKeyConditions = queryExpression.getRangeKeyConditions(); processKeyConditions(clazz, queryRequest, hashKeyConditions, rangeKeyConditions); queryRequest.setScanIndexForward(queryExpression.isScanIndexForward()); queryRequest.setLimit(queryExpression.getLimit()); queryRequest.setExclusiveStartKey(queryExpression.getExclusiveStartKey()); queryRequest.setQueryFilter(queryExpression.getQueryFilter()); queryRequest.setConditionalOperator(queryExpression.getConditionalOperator()); queryRequest.setRequestMetricCollector(config.getRequestMetricCollector()); queryRequest.setFilterExpression(queryExpression.getFilterExpression()); queryRequest.setExpressionAttributeNames(queryExpression .getExpressionAttributeNames()); queryRequest.setExpressionAttributeValues(queryExpression .getExpressionAttributeValues()); return applyUserAgent(queryRequest); }
@Override public QueryResultWrapper next() throws BackendException { final QueryResultWrapper wrapper = super.next(); final int returnedCount = getReturnedCount(); // If we already have reached the limit for this query, we can stop making new requests if (returnedCount >= limit) { markComplete(); } else { // Make sure we don't ask DynamoDB for more results than we care about final int maxRemainingRecords = limit - returnedCount; Preconditions.checkState(maxRemainingRecords > 0); getRequest().setLimit(maxRemainingRecords); } return wrapper; }
try { restApi = new RallyRestApi( new URI(host), username, password); restApi.setApplicationName(applicationName); QueryRequest defectRequest = new QueryRequest("Defect"); defectRequest.setProject(projectRef); defectRequest.setFetch(new Fetch(new String[] {"Name", "FormattedID","State", "Priority", "Severity", "Requirement"})); defectRequest.setLimit(1000); defectRequest.setScopedDown(false); defectRequest.setScopedUp(false); defectRequest.setQueryFilter(new QueryFilter("Requirement", "=", storyRef)); QueryResponse defectQueryResponse = restApi.query(defectRequest); for (int i=0; i<defectQueryResponse.getResults().size();i++){ JsonObject defectJsonObject = defectQueryResponse.getResults().get(i).getAsJsonObject(); System.out.println("Name: " + defectJsonObject.get("Name") + " State: " + defectJsonObject.get("State") + " Priority: " + defectJsonObject.get("Priority") + " FormattedID: " + defectJsonObject.get("Requirement")); } } finally { if (restApi != null) { restApi.close(); } }
restApi.setApplicationName(applicationName); storyRequest.setFetch(new Fetch(new String[] {"Name", "FormattedID", "Tags", "Children"})); storyRequest.setLimit(1000); storyRequest.setScopedDown(false); storyRequest.setScopedUp(false);
storyRequest.setLimit(1000); storyRequest.setScopedDown(false); storyRequest.setScopedUp(false);
@Override public Page<Item,QueryOutcome> nextPage() { if (lastEvaluatedKey == null) { throw new NoSuchElementException("No more pages"); } final Integer max = spec.getMaxResultSize(); if (max != null) { int nextLimit = nextRequestLimit(max.intValue()); if (nextLimit == 0) throw new NoSuchElementException("No more pages"); request.setLimit(nextLimit); } request.setExclusiveStartKey(lastEvaluatedKey); QueryResult result = client.query(request); final int nextIndex = index + this.size(); return new QueryPage(client, spec, request, nextIndex, new QueryOutcome(result)); } }
QueryRequest storyRequest = new QueryRequest("HierarchicalRequirement"); storyRequest.setFetch(new Fetch("Name","Owner","UserName","PlanEstimate","Discussion","ConversationPost","Text")); storyRequest.setLimit(1000); storyRequest.setScopedDown(false); storyRequest.setScopedUp(false);
storyRequest.setLimit(1000); storyRequest.setScopedDown(false); storyRequest.setScopedUp(false);
RallyRestApi restApi = new RallyRestApi(new URI("https://rally.rallydev.com/"), "_apogjlfdkjglfjlksr23rfdlj"); String wsapiVersion = "v2.0"; String workspaceRef = "/workspace/01245"; String projectRef = "/project/6757552"; if(restApi!=null){ restApi.setWsapiVersion(wsapiVersion); QueryRequest queryRequest = new QueryRequest("TestFolders"); queryRequest.setFetch(new Fetch(new String[] { "Name","FormattedID","TestFolder"})); queryRequest.setWorkspace(workspaceRef); queryRequest.setProject(projectRef); queryRequest.setScopedDown(true); queryRequest.setLimit(Integer.MAX_VALUE); queryRequest.setPageSize(Integer.MAX_VALUE); QueryResponse queryResponse = null; JsonArray jsonarr = new JsonArray(); queryResponse = restApi.query(queryRequest); int responseTotalResultsCount = queryResponse.getTotalResultCount(); jsonarr.addAll(queryResponse.getResults()); int jsonArrSize = jsonarr.size(); for (int i=0; i<queryResponse.getResults().size();i++){ JsonObject testCaseJsonObject = queryResponse.getResults().get(i).getAsJsonObject(); System.out.println(testCaseJsonObject.getAsJsonObject().get("FormattedID")+": "+testCaseJsonObject.getAsJsonObject().get("Name")); } }
storyRequest.setLimit(1000); storyRequest.setScopedDown(true); storyRequest.setScopedUp(false);
public QueryWorker buildQueryWorker(final StaticBuffer hashKey, final SliceQuery query) { final QueryRequest request = createQueryRequest(hashKey, query); // Only enforce a limit when Titan tells us to if (query.hasLimit()) { final int limit = query.getLimit(); request.setLimit(limit); return new QueryWithLimitWorker(client.getDelegate(), request, hashKey, limit); } return new QueryWorker(client.getDelegate(), request, hashKey); }
@Override public Page<Item, QueryOutcome> firstPage() { QueryRequest request = spec.getRequest(); request.setExclusiveStartKey(startKey); request.setLimit(InternalUtils.minimum( spec.getMaxResultSize(), spec.getMaxPageSize())); QueryResult result = client.query(request); QueryOutcome outcome = new QueryOutcome(result); setLastLowLevelResult(outcome); return new QueryPage(client, spec, request, 0, outcome); }
queryRequest.setLimit(Integer.MAX_VALUE);