StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTableName() != null) sb.append("TableName: ").append(getTableName()).append(","); if (getIndexName() != null) sb.append("IndexName: ").append(getIndexName()).append(",");
public PaginatedQueryList( DynamoDBMapper mapper, Class<T> clazz, AmazonDynamoDB dynamo, QueryRequest queryRequest, QueryResult queryResult, PaginationLoadingStrategy paginationLoadingStrategy, DynamoDBMapperConfig config ) { super(mapper, clazz, dynamo, paginationLoadingStrategy); this.queryRequest = queryRequest; this.queryResult = queryResult; this.config = config; allResults.addAll(mapper.marshallIntoObjects( mapper.toParameters( queryResult.getItems(), clazz, queryRequest.getTableName(), config))); // If the results should be eagerly loaded at once if (paginationLoadingStrategy == PaginationLoadingStrategy.EAGER_LOADING) { loadAllResults(); } }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getIndexName() == null) ? 0 : getIndexName().hashCode()); hashCode = prime * hashCode + ((getSelect() == null) ? 0 : getSelect().hashCode()); hashCode = prime * hashCode + ((getAttributesToGet() == null) ? 0 : getAttributesToGet().hashCode()); hashCode = prime * hashCode + ((getLimit() == null) ? 0 : getLimit().hashCode()); hashCode = prime * hashCode + ((getConsistentRead() == null) ? 0 : getConsistentRead().hashCode()); hashCode = prime * hashCode + ((getKeyConditions() == null) ? 0 : getKeyConditions().hashCode()); hashCode = prime * hashCode + ((getQueryFilter() == null) ? 0 : getQueryFilter().hashCode()); hashCode = prime * hashCode + ((getConditionalOperator() == null) ? 0 : getConditionalOperator().hashCode()); hashCode = prime * hashCode + ((getScanIndexForward() == null) ? 0 : getScanIndexForward().hashCode()); hashCode = prime * hashCode + ((getExclusiveStartKey() == null) ? 0 : getExclusiveStartKey().hashCode()); hashCode = prime * hashCode + ((getReturnConsumedCapacity() == null) ? 0 : getReturnConsumedCapacity().hashCode()); hashCode = prime * hashCode + ((getProjectionExpression() == null) ? 0 : getProjectionExpression().hashCode()); hashCode = prime * hashCode + ((getFilterExpression() == null) ? 0 : getFilterExpression().hashCode()); hashCode = prime * hashCode + ((getKeyConditionExpression() == null) ? 0 : getKeyConditionExpression().hashCode()); hashCode = prime * hashCode + ((getExpressionAttributeNames() == null) ? 0 : getExpressionAttributeNames().hashCode()); hashCode = prime * hashCode + ((getExpressionAttributeValues() == null) ? 0 : getExpressionAttributeValues().hashCode()); return hashCode; }
@Override protected synchronized List<T> fetchNextPage() { queryRequest.setExclusiveStartKey(queryResult.getLastEvaluatedKey()); queryResult = dynamo.query(DynamoDBMapper.applyUserAgent(queryRequest)); return mapper.marshallIntoObjects(mapper.toParameters( queryResult.getItems(), clazz, queryRequest.getTableName(), config)); } }
return false; QueryRequest other = (QueryRequest) obj; if (other.getTableName() == null ^ this.getTableName() == null) return false; if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false; if (other.getIndexName() == null ^ this.getIndexName() == null)
@Override public <T> QueryResultPage<T> queryPage(Class<T> clazz, DynamoDBQueryExpression<T> queryExpression, DynamoDBMapperConfig config) { config = mergeConfig(config); QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config); QueryResult queryResult = db.query(applyUserAgent(queryRequest)); QueryResultPage<T> result = new QueryResultPage<T>(); List<AttributeTransformer.Parameters<T>> parameters = toParameters(queryResult.getItems(), clazz, queryRequest.getTableName(), config); result.setResults(marshallIntoObjects(parameters)); result.setLastEvaluatedKey(queryResult.getLastEvaluatedKey()); result.setCount(queryResult.getCount()); result.setScannedCount(queryResult.getScannedCount()); result.setConsumedCapacity(queryResult.getConsumedCapacity()); return result; }
/** * Marshall the given parameter object. */ public void marshall(QueryRequest queryRequest, ProtocolMarshaller protocolMarshaller) { if (queryRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(queryRequest.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(queryRequest.getIndexName(), INDEXNAME_BINDING); protocolMarshaller.marshall(queryRequest.getSelect(), SELECT_BINDING); protocolMarshaller.marshall(queryRequest.getAttributesToGet(), ATTRIBUTESTOGET_BINDING); protocolMarshaller.marshall(queryRequest.getLimit(), LIMIT_BINDING); protocolMarshaller.marshall(queryRequest.getConsistentRead(), CONSISTENTREAD_BINDING); protocolMarshaller.marshall(queryRequest.getKeyConditions(), KEYCONDITIONS_BINDING); protocolMarshaller.marshall(queryRequest.getQueryFilter(), QUERYFILTER_BINDING); protocolMarshaller.marshall(queryRequest.getConditionalOperator(), CONDITIONALOPERATOR_BINDING); protocolMarshaller.marshall(queryRequest.getScanIndexForward(), SCANINDEXFORWARD_BINDING); protocolMarshaller.marshall(queryRequest.getExclusiveStartKey(), EXCLUSIVESTARTKEY_BINDING); protocolMarshaller.marshall(queryRequest.getReturnConsumedCapacity(), RETURNCONSUMEDCAPACITY_BINDING); protocolMarshaller.marshall(queryRequest.getProjectionExpression(), PROJECTIONEXPRESSION_BINDING); protocolMarshaller.marshall(queryRequest.getFilterExpression(), FILTEREXPRESSION_BINDING); protocolMarshaller.marshall(queryRequest.getKeyConditionExpression(), KEYCONDITIONEXPRESSION_BINDING); protocolMarshaller.marshall(queryRequest.getExpressionAttributeNames(), EXPRESSIONATTRIBUTENAMES_BINDING); protocolMarshaller.marshall(queryRequest.getExpressionAttributeValues(), EXPRESSIONATTRIBUTEVALUES_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
queryResult.getItems(), clazz, queryRequest.getTableName(), config)));
StringBuilder sb = new StringBuilder(); sb.append("{"); if (getTableName() != null) sb.append("TableName: " + getTableName() + ","); if (getIndexName() != null) sb.append("IndexName: " + getIndexName() + ",");
int hashCode = 1; hashCode = prime * hashCode + ((getTableName() == null) ? 0 : getTableName().hashCode()); hashCode = prime * hashCode + ((getIndexName() == null) ? 0 : getIndexName().hashCode()); hashCode = prime * hashCode + ((getSelect() == null) ? 0 : getSelect().hashCode());
@Override protected synchronized List<T> fetchNextPage() { queryRequest.setExclusiveStartKey(queryResult.getLastEvaluatedKey()); queryResult = dynamo.query(DynamoDBMapper.applyUserAgent(queryRequest)); return mapper.marshallIntoObjects(mapper.toParameters( queryResult.getItems(), clazz, queryRequest.getTableName(), config)); } }
@Override protected String getTableName() { return request.getTableName(); }
QueryWorker(final DynamoDbDelegate delegate, final QueryRequest request, final StaticBuffer titanKey) { super(delegate, DynamoDbDelegate.QUERY, request.getTableName()); this.request = request; this.titanKey = titanKey; this.returnedCount = 0; this.scannedCount = 0; this.finalItemList = new ArrayList<>(); this.permitsToConsume = 1; this.totalCapacityUnits = 0.0; }
QueryRequest other = (QueryRequest) obj; if (other.getTableName() == null ^ this.getTableName() == null) return false; if (other.getTableName() != null && other.getTableName().equals(this.getTableName()) == false) return false; if (other.getIndexName() == null ^ this.getIndexName() == null)
/** * Queries an Amazon DynamoDB table and returns a single page of matching * results. The table to query is determined by looking at the annotations * on the specified class, which declares where to store the object data in * Amazon DynamoDB, and the query expression parameter allows the caller to * filter results and control how the query is executed. * * @param <T> The type of the objects being returned. * @param clazz The class annotated with DynamoDB annotations describing how * to store the object data in AWS DynamoDB. * @param queryExpression Details on how to run the query, including any * conditions on the key values * @param config The configuration to use for this query, which overrides * the default provided at object construction. * @return a single page of matching results */ public <T> QueryResultPage<T> queryPage(Class<T> clazz, DynamoDBQueryExpression<T> queryExpression, DynamoDBMapperConfig config) { config = mergeConfig(config); final QueryRequest queryRequest = createQueryRequestFromExpression(clazz, queryExpression, config); final QueryResult scanResult = db.query(applyUserAgent(queryRequest)); final QueryResultPage<T> result = new QueryResultPage<T>(); final List<AttributeTransformer.Parameters<T>> parameters = toParameters(scanResult.getItems(), clazz, queryRequest.getTableName(), config); result.setResults(marshallIntoObjects(parameters)); result.setLastEvaluatedKey(scanResult.getLastEvaluatedKey()); return result; }
jsonWriter.beginObject(); if (queryRequest.getTableName() != null) { String tableName = queryRequest.getTableName(); jsonWriter.name("TableName"); jsonWriter.value(tableName);
@Override protected synchronized List<T> fetchNextPage() { queryRequest.setExclusiveStartKey(queryResult.getLastEvaluatedKey()); queryResult = dynamo.query(DynamoDBMapper.applyUserAgent(queryRequest)); return mapper.marshallIntoObjects(mapper.toParameters( queryResult.getItems(), clazz, queryRequest.getTableName(), config)); } }
@Override public QueryResult query(QueryRequest request) throws AmazonServiceException, AmazonClientException { Collection<String> attributesToGet = addSpecialAttributes(request.getAttributesToGet()); request.setAttributesToGet(attributesToGet); QueryResult result = txManager.getClient().query(request); List<Map<String, AttributeValue>> items = handleItems(result.getItems(), request.getTableName(), request.getAttributesToGet()); result.setItems(items); return result; }
@Override protected QueryResultWrapper getMergedPages() { final QueryResult mergedDynamoResult = new QueryResult().withItems(getFinalItemList()) .withCount(returnedCount) .withScannedCount(scannedCount) .withConsumedCapacity(new ConsumedCapacity() .withTableName(request.getTableName()) .withCapacityUnits(totalCapacityUnits)); return new QueryResultWrapper(titanKey, mergedDynamoResult); } }
public static QueryRequest copyQueryRequest(QueryRequest queryRequest) { QueryRequest copiedQueryRequest = new QueryRequest().withAttributesToGet(queryRequest.getAttributesToGet()) .withConsistentRead(queryRequest.getConsistentRead()) .withExclusiveStartKey(queryRequest.getExclusiveStartKey()).withIndexName(queryRequest.getIndexName()) .withKeyConditions(queryRequest.getKeyConditions()).withLimit(queryRequest.getLimit()) .withReturnConsumedCapacity(queryRequest.getReturnConsumedCapacity()) .withScanIndexForward(queryRequest.getScanIndexForward()).withSelect(queryRequest.getSelect()) .withTableName(queryRequest.getTableName()); return copiedQueryRequest; } }