com.amazonaws.services.dynamodbv2.model.QueryRequest Java Examples
The following examples show how to use
com.amazonaws.services.dynamodbv2.model.QueryRequest.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LowLevelQuery.java From aws-dynamodb-examples with Apache License 2.0 | 8 votes |
private static void findRepliesForAThread(String forumName, String threadSubject) { String replyId = forumName + "#" + threadSubject; Condition hashKeyCondition = new Condition() .withComparisonOperator(ComparisonOperator.EQ) .withAttributeValueList(new AttributeValue().withS(replyId)); Map<String, Condition> keyConditions = new HashMap<String, Condition>(); keyConditions.put("Id", hashKeyCondition); QueryRequest queryRequest = new QueryRequest() .withTableName(tableName) .withKeyConditions(keyConditions); QueryResult result = client.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); } }
Example #2
Source File: DynamoDBClient.java From emr-dynamodb-connector with Apache License 2.0 | 6 votes |
public RetryResult<QueryResult> queryTable( String tableName, DynamoDBQueryFilter dynamoDBQueryFilter, Map<String, AttributeValue> exclusiveStartKey, long limit, Reporter reporter) { final QueryRequest queryRequest = new QueryRequest() .withTableName(tableName) .withExclusiveStartKey(exclusiveStartKey) .withKeyConditions(dynamoDBQueryFilter.getKeyConditions()) .withLimit(Ints.checkedCast(limit)) .withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL); RetryResult<QueryResult> retryResult = getRetryDriver().runWithRetry( new Callable<QueryResult>() { @Override public QueryResult call() { log.debug("Executing DynamoDB query: " + queryRequest); return dynamoDB.query(queryRequest); } }, reporter, PrintCounter.DynamoDBReadThrottle); return retryResult; }
Example #3
Source File: DynamoDBEntityWithHashAndRangeKeyCriteria.java From spring-data-dynamodb with Apache License 2.0 | 6 votes |
protected Query<Long> buildFinderCountQuery(DynamoDBOperations dynamoDBOperations,boolean pageQuery) { if (isApplicableForQuery()) { if (isApplicableForGlobalSecondaryIndex()) { String tableName = dynamoDBOperations.getOverriddenTableName(entityInformation.getDynamoDBTableName()); QueryRequest queryRequest = buildQueryRequest(tableName, getGlobalSecondaryIndexName(), getHashKeyAttributeName(), getRangeKeyAttributeName(), this.getRangeKeyPropertyName(), getHashKeyConditions(), getRangeKeyConditions()); return new QueryRequestCountQuery<T>(dynamoDBOperations,entityInformation.getJavaType(), queryRequest); } else { DynamoDBQueryExpression<T> queryExpression = buildQueryExpression(); return new QueryExpressionCountQuery<T>(dynamoDBOperations, entityInformation.getJavaType(), queryExpression); } } else { return new ScanExpressionCountQuery<T>(dynamoDBOperations, clazz, buildScanExpression(),pageQuery); } }
Example #4
Source File: LowLevelQuery.java From aws-dynamodb-examples with Apache License 2.0 | 6 votes |
private static void findRepliesForAThreadSpecifyOptionalLimit(String forumName, String threadSubject) { Map<String, AttributeValue> lastEvaluatedKey = null; do { QueryRequest queryRequest = new QueryRequest() .withTableName(tableName) .withKeyConditions(makeReplyKeyConditions(forumName, threadSubject)) .withLimit(1) .withExclusiveStartKey(lastEvaluatedKey); QueryResult result = client.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); } lastEvaluatedKey = result.getLastEvaluatedKey(); } while (lastEvaluatedKey != null); }
Example #5
Source File: GeoDataManager.java From dynamodb-geo with Apache License 2.0 | 6 votes |
public void run() { QueryRequest queryRequest = DynamoDBUtil.copyQueryRequest(geoQueryRequest.getQueryRequest()); long hashKey = S2Manager.generateHashKey(range.getRangeMin(), config.getHashKeyLength()); List<QueryResult> queryResults = dynamoDBManager.queryGeohash(queryRequest, hashKey, range); for (QueryResult queryResult : queryResults) { if (isInterrupted()) { return; } // getQueryResults() returns a synchronized list. geoQueryResult.getQueryResults().add(queryResult); List<Map<String, AttributeValue>> filteredQueryResult = filter(queryResult.getItems(), geoQueryRequest); // getItem() returns a synchronized list. geoQueryResult.getItem().addAll(filteredQueryResult); } }
Example #6
Source File: LowLevelQuery.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
private static void findRepliesPostedWithinTimePeriod(String forumName, String threadSubject) { long startDateMilli = (new Date()).getTime() - (15L * 24L * 60L * 60L * 1000L); long endDateMilli = (new Date()).getTime() - (5L * 24L * 60L * 60L * 1000L); java.text.SimpleDateFormat df = new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); String startDate = df.format(startDateMilli); String endDate = df.format(endDateMilli); Condition sortKeyCondition = new Condition().withComparisonOperator(ComparisonOperator.BETWEEN.toString()) .withAttributeValueList(new AttributeValue().withS(startDate), new AttributeValue().withS(endDate)); Map<String, Condition> keyConditions = makeReplyKeyConditions(forumName, threadSubject); keyConditions.put("ReplyDateTime", sortKeyCondition); QueryRequest queryRequest = new QueryRequest().withTableName(tableName).withKeyConditions(keyConditions) .withProjectionExpression("Message, ReplyDateTime, PostedBy"); QueryResult result = client.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); } }
Example #7
Source File: LowLevelQuery.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
private static void findRepliesInLast15DaysWithConfig(String forumName, String threadSubject) { long twoWeeksAgoMilli = (new Date()).getTime() - (15L * 24L * 60L * 60L * 1000L); Date twoWeeksAgo = new Date(); twoWeeksAgo.setTime(twoWeeksAgoMilli); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); String twoWeeksAgoStr = df.format(twoWeeksAgo); Condition sortKeyCondition = new Condition().withComparisonOperator(ComparisonOperator.GT.toString()) .withAttributeValueList(new AttributeValue().withS(twoWeeksAgoStr)); Map<String, Condition> keyConditions = makeReplyKeyConditions(forumName, threadSubject); keyConditions.put("ReplyDateTime", sortKeyCondition); QueryRequest queryRequest = new QueryRequest().withTableName(tableName).withKeyConditions(keyConditions) .withProjectionExpression("Message, ReplyDateTime, PostedBy"); QueryResult result = client.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); } }
Example #8
Source File: DynamoDbDelegate.java From dynamodb-janusgraph-storage-backend with Apache License 2.0 | 6 votes |
public QueryResult query(final QueryRequest request, final int permitsToConsume) throws BackendException { setUserAgent(request); QueryResult result; timedReadThrottle(QUERY, request.getTableName(), permitsToConsume); final Timer.Context apiTimerContext = getTimerContext(QUERY, request.getTableName()); try { result = client.query(request); } catch (Exception e) { throw processDynamoDbApiException(e, QUERY, request.getTableName()); } finally { apiTimerContext.stop(); } meterConsumedCapacity(QUERY, result.getConsumedCapacity()); measureItemCount(QUERY, request.getTableName(), result.getCount()); return result; }
Example #9
Source File: LowLevelQuery.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
private static void findRepliesForAThread(String forumName, String threadSubject) { String replyId = forumName + "#" + threadSubject; Condition partitionKeyCondition = new Condition().withComparisonOperator(ComparisonOperator.EQ) .withAttributeValueList(new AttributeValue().withS(replyId)); Map<String, Condition> keyConditions = new HashMap<String, Condition>(); keyConditions.put("Id", partitionKeyCondition); QueryRequest queryRequest = new QueryRequest().withTableName(tableName).withKeyConditions(keyConditions); QueryResult result = client.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); } }
Example #10
Source File: MapperQueryExpressionCryptoTest.java From aws-dynamodb-encryption-java with Apache License 2.0 | 6 votes |
private static <T> QueryRequest testCreateQueryRequestFromExpression( Class<T> clazz, DynamoDBQueryExpression<T> queryExpression, String expectedErrorMessage) { try { QueryRequest request = (QueryRequest) testedMethod.invoke(mapper, clazz, queryExpression, DynamoDBMapperConfig.DEFAULT); if (expectedErrorMessage != null) { fail("Exception containing messsage (" + expectedErrorMessage + ") is expected."); } return request; } catch (InvocationTargetException ite) { if (expectedErrorMessage != null) { assertTrue("Exception message [" + ite.getCause().getMessage() + "] does not contain " + "the expected message [" + expectedErrorMessage + "].", ite.getCause().getMessage().contains(expectedErrorMessage)); } else { ite.getCause().printStackTrace(); fail("Internal error when calling createQueryRequestFromExpressio method"); } } catch (Exception e) { fail(e.getMessage()); } return null; }
Example #11
Source File: LowLevelQuery.java From aws-dynamodb-examples with Apache License 2.0 | 6 votes |
private static void findRepliesInLast15DaysWithConfig(String forumName, String threadSubject) { long twoWeeksAgoMilli = (new Date()).getTime() - (15L*24L*60L*60L*1000L); Date twoWeeksAgo = new Date(); twoWeeksAgo.setTime(twoWeeksAgoMilli); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); String twoWeeksAgoStr = df.format(twoWeeksAgo); Condition rangeKeyCondition = new Condition() .withComparisonOperator(ComparisonOperator.GT.toString()) .withAttributeValueList(new AttributeValue().withS(twoWeeksAgoStr)); Map<String, Condition> keyConditions = makeReplyKeyConditions(forumName, threadSubject); keyConditions.put("ReplyDateTime", rangeKeyCondition); QueryRequest queryRequest = new QueryRequest().withTableName(tableName) .withKeyConditions(keyConditions) .withProjectionExpression("Message, ReplyDateTime, PostedBy"); QueryResult result = client.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); } }
Example #12
Source File: GenericDynamoDBTest.java From strongbox with Apache License 2.0 | 6 votes |
@Test public void testDeleteSecretMaliciousResults() { QueryRequest request = constructQueryRequest(SECRET_NAME); // Result contains entries that do no match the filter in the request (i.e. items for secret2). So it should be // considered malicious. QueryResult maliciousResult = constructQueryResult(true); when(mockDynamoDBClient.query(request)).thenReturn(maliciousResult); // Call the delete secret method. boolean consideredMalicious = false; try { dynamoDB.delete(new SecretIdentifier(SECRET_NAME)); } catch (PotentiallyMaliciousDataException e) { consideredMalicious = true; } assertTrue(consideredMalicious); // Verify nothing was actually deleted because the malicious check failed. verify(mockDynamoDBClient, times(1)).query(request); verify(mockDynamoDBClient, never()).deleteItem(tableName, constructKey(SECRET_NAME, 1)); verify(mockDynamoDBClient, never()).deleteItem(tableName, constructKey(SECRET_NAME, 2)); verify(mockDynamoDBClient, never()).deleteItem(tableName, constructKey(SECRET2_NAME, 1)); }
Example #13
Source File: DynamoDBEntityWithHashAndRangeKeyCriteria.java From spring-data-dynamodb with Apache License 2.0 | 6 votes |
protected Query<T> buildFinderQuery(DynamoDBOperations dynamoDBOperations) { if (isApplicableForQuery()) { if (isApplicableForGlobalSecondaryIndex()) { String tableName = dynamoDBOperations.getOverriddenTableName(entityInformation.getDynamoDBTableName()); QueryRequest queryRequest = buildQueryRequest(tableName, getGlobalSecondaryIndexName(), getHashKeyAttributeName(), getRangeKeyAttributeName(), this.getRangeKeyPropertyName(), getHashKeyConditions(), getRangeKeyConditions()); return new MultipleEntityQueryRequestQuery<T>(dynamoDBOperations,entityInformation.getJavaType(), queryRequest); } else { DynamoDBQueryExpression<T> queryExpression = buildQueryExpression(); return new MultipleEntityQueryExpressionQuery<T>(dynamoDBOperations, entityInformation.getJavaType(), queryExpression); } } else { return new MultipleEntityScanExpressionQuery<T>(dynamoDBOperations, clazz, buildScanExpression()); } }
Example #14
Source File: DynamoDBReader.java From geowave with Apache License 2.0 | 6 votes |
private List<QueryRequest> addQueryRanges( final String tableName, final SinglePartitionQueryRanges r, short[] adapterIds, final InternalAdapterStore adapterStore) { final List<QueryRequest> retVal = new ArrayList<>(); final byte[] partitionKey = DynamoDBUtils.getDynamoDBSafePartitionKey(r.getPartitionKey()); if (((adapterIds == null) || (adapterIds.length == 0)) && (adapterStore != null)) { adapterIds = adapterStore.getAdapterIds(); } for (final Short adapterId : adapterIds) { final Collection<ByteArrayRange> sortKeyRanges = r.getSortKeyRanges(); if ((sortKeyRanges != null) && !sortKeyRanges.isEmpty()) { sortKeyRanges.forEach( (sortKeyRange -> retVal.add( getQuery(tableName, partitionKey, sortKeyRange, adapterId)))); } else { retVal.add(getQuery(tableName, partitionKey, null, adapterId)); } } return retVal; }
Example #15
Source File: LowLevelQuery.java From aws-dynamodb-examples with Apache License 2.0 | 6 votes |
private static void findRepliesUsingAFilterExpression(String forumName, String threadSubject) { Map<String, Condition> keyConditions = makeReplyKeyConditions(forumName, threadSubject); Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>(); expressionAttributeValues.put(":val", new AttributeValue().withS("User B")); QueryRequest queryRequest = new QueryRequest() .withTableName(tableName) .withKeyConditions(keyConditions) .withFilterExpression("PostedBy = :val") .withExpressionAttributeValues(expressionAttributeValues) .withProjectionExpression("Message, ReplyDateTime, PostedBy"); QueryResult result = client.query(queryRequest); for (Map<String, AttributeValue> item : result.getItems()) { printItem(item); } }
Example #16
Source File: MetaStore.java From aws-dynamodb-encryption-java with Apache License 2.0 | 6 votes |
@Override public long getMaxVersion(final String materialName) { final List<Map<String, AttributeValue>> items = ddb.query( new QueryRequest() .withTableName(tableName) .withConsistentRead(Boolean.TRUE) .withKeyConditions( Collections.singletonMap( DEFAULT_HASH_KEY, new Condition().withComparisonOperator( ComparisonOperator.EQ).withAttributeValueList( new AttributeValue().withS(materialName)))) .withLimit(1).withScanIndexForward(false) .withAttributesToGet(DEFAULT_RANGE_KEY)).getItems(); if (items.isEmpty()) { return -1L; } else { return Long.parseLong(items.get(0).get(DEFAULT_RANGE_KEY).getN()); } }
Example #17
Source File: DynamoDBService2.java From Doradus with Apache License 2.0 | 5 votes |
@Override public List<DColumn> getColumns(String storeName, String rowKey, String startColumn, String endColumn, int count) { Timer t = new Timer(); String key = storeName + "_" + rowKey; HashMap<String,Condition> keyConditions = new HashMap<String,Condition>(); keyConditions.put("key", new Condition() .withComparisonOperator(ComparisonOperator.EQ) .withAttributeValueList(new AttributeValue().withS(key))); if(startColumn != null && endColumn != null) { keyConditions.put("column", new Condition() .withComparisonOperator(ComparisonOperator.BETWEEN) .withAttributeValueList(new AttributeValue().withS(startColumn), new AttributeValue(endColumn))); } else if(startColumn != null) { keyConditions.put("column", new Condition() .withComparisonOperator(ComparisonOperator.GE) .withAttributeValueList(new AttributeValue().withS(startColumn))); } else if(endColumn != null) { keyConditions.put("column", new Condition() .withComparisonOperator(ComparisonOperator.LT) .withAttributeValueList(new AttributeValue().withS(endColumn))); } QueryRequest request = new QueryRequest() .withTableName(getTenant().getName()) .withLimit(Math.min(100, count)) .withKeyConditions(keyConditions); QueryResult result = m_client.query(request); List<DColumn> list = fromItems(result.getItems()); m_logger.debug("get columns range for {} in {}", getTenant().getName(), t); return list; }
Example #18
Source File: TransactionManagerDBFacadeIntegrationTest.java From dynamodb-transactions with Apache License 2.0 | 5 votes |
private void testQueryContainsItem( final TransactionManagerDynamoDBFacade facade, final Map<String, AttributeValue> item, final boolean filterAttributes) { QueryRequest queryRequest = createQueryRequest(filterAttributes); QueryResult queryResult = facade.query(queryRequest); assertEquals(1, queryResult.getItems().size()); assertContainsNoTransactionAttributes(queryResult.getItems().get(0)); assertEquals(item, queryResult.getItems().get(0)); }
Example #19
Source File: MapperQueryExpressionCryptoTest.java From aws-dynamodb-encryption-java with Apache License 2.0 | 5 votes |
@Test public void testHashOnlyQueryOnHashRangeTable() { // Primary hash only query on a Hash+Range table QueryRequest queryRequest = testCreateQueryRequestFromExpression( LSIRangeKeyTestClass.class, new DynamoDBQueryExpression<LSIRangeKeyTestClass>() .withHashKeyValues(new LSIRangeKeyTestClass("foo", null))); assertTrue(queryRequest.getKeyConditions().size() == 1); assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertNull(queryRequest.getIndexName()); // Hash+Range query on a LSI queryRequest = testCreateQueryRequestFromExpression( LSIRangeKeyTestClass.class, new DynamoDBQueryExpression<LSIRangeKeyTestClass>() .withHashKeyValues(new LSIRangeKeyTestClass("foo", null)) .withRangeKeyCondition("lsiRangeKey", RANGE_KEY_CONDITION) .withIndexName("LSI")); assertTrue(queryRequest.getKeyConditions().size() == 2); assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertTrue(queryRequest.getKeyConditions().containsKey("lsiRangeKey")); assertEquals("LSI", queryRequest.getIndexName()); // Hash-only query on a LSI queryRequest = testCreateQueryRequestFromExpression( LSIRangeKeyTestClass.class, new DynamoDBQueryExpression<LSIRangeKeyTestClass>() .withHashKeyValues(new LSIRangeKeyTestClass("foo", null)) .withIndexName("LSI")); assertTrue(queryRequest.getKeyConditions().size() == 1); assertTrue(queryRequest.getKeyConditions().containsKey("primaryHashKey")); assertEquals("LSI", queryRequest.getIndexName()); }
Example #20
Source File: DynamoDBTemplate.java From spring-data-dynamodb with Apache License 2.0 | 5 votes |
@Override public <T> PaginatedQueryList<T> query(Class<T> clazz, QueryRequest queryRequest) { QueryResult queryResult = amazonDynamoDB.query(queryRequest); return new PaginatedQueryList<T>(dynamoDBMapper, clazz, amazonDynamoDB, queryRequest, queryResult, dynamoDBMapperConfig.getPaginationLoadingStrategy(), dynamoDBMapperConfig); }
Example #21
Source File: GenericDynamoDBTest.java From strongbox with Apache License 2.0 | 5 votes |
@Test public void testDeleteSecret() { QueryRequest request = constructQueryRequest(SECRET_NAME); QueryResult result = constructQueryResult(false); when(mockDynamoDBClient.query(request)).thenReturn(result); // Call the delete secret method. dynamoDB.delete(new SecretIdentifier(SECRET_NAME)); // Verify only the entries matching the correct secret were deleted. verify(mockDynamoDBClient, times(1)).query(request); verify(mockDynamoDBClient, times(1)).deleteItem(tableName, constructKey(SECRET_NAME, 1)); verify(mockDynamoDBClient, times(1)).deleteItem(tableName, constructKey(SECRET_NAME, 2)); verify(mockDynamoDBClient, never()).deleteItem(tableName, constructKey(SECRET2_NAME, 1)); }
Example #22
Source File: GenericDynamoDBTest.java From strongbox with Apache License 2.0 | 5 votes |
private static QueryRequest constructQueryRequest(String secretName) { Map<String, String> expressionAttributeNames = new HashMap<>(); expressionAttributeNames.put("#1", KEY_ATTRIBUTE_NAME.toString()); Map<String, AttributeValue> expressionAttributeValues = new HashMap<>(); expressionAttributeValues.put(":a", new AttributeValue().withS(secretName)); QueryRequest request = new QueryRequest() .withTableName(tableName) .withConsistentRead(true) .withKeyConditionExpression("#1 = :a") .withExpressionAttributeNames(expressionAttributeNames) .withExpressionAttributeValues(expressionAttributeValues); return request; }
Example #23
Source File: DynamoDBEntityWithHashKeyOnlyCriteria.java From spring-data-dynamodb with Apache License 2.0 | 5 votes |
protected Query<T> buildFinderQuery(DynamoDBOperations dynamoDBOperations) { if (isApplicableForGlobalSecondaryIndex()) { List<Condition> hashKeyConditions = getHashKeyConditions(); QueryRequest queryRequest = buildQueryRequest(dynamoDBOperations.getOverriddenTableName(entityInformation.getDynamoDBTableName()), getGlobalSecondaryIndexName(), getHashKeyAttributeName(), null, null, hashKeyConditions, null); return new MultipleEntityQueryRequestQuery<T>(dynamoDBOperations,entityInformation.getJavaType(), queryRequest); } else { return new MultipleEntityScanExpressionQuery<T>(dynamoDBOperations, clazz, buildScanExpression()); } }
Example #24
Source File: DynamoDBMetadataDeleter.java From geowave with Apache License 2.0 | 5 votes |
@Override public boolean delete(final MetadataQuery metadata) { // the nature of metadata deleter is that primary ID is always // well-defined and it is deleting a single entry at a time final String tableName = operations.getMetadataTableName(metadataType); final QueryRequest queryRequest = new QueryRequest(tableName); if (metadata.hasSecondaryId()) { queryRequest.withFilterExpression( DynamoDBOperations.METADATA_SECONDARY_ID_KEY + " = :secVal").addExpressionAttributeValuesEntry( ":secVal", new AttributeValue().withB(ByteBuffer.wrap(metadata.getSecondaryId()))); } queryRequest.withKeyConditionExpression( DynamoDBOperations.METADATA_PRIMARY_ID_KEY + " = :priVal").addExpressionAttributeValuesEntry( ":priVal", new AttributeValue().withB(ByteBuffer.wrap(metadata.getPrimaryId()))); final QueryResult queryResult = operations.getClient().query(queryRequest); for (final Map<String, AttributeValue> entry : queryResult.getItems()) { final Map<String, AttributeValue> key = new HashMap<>(); key.put( DynamoDBOperations.METADATA_PRIMARY_ID_KEY, entry.get(DynamoDBOperations.METADATA_PRIMARY_ID_KEY)); key.put( DynamoDBOperations.METADATA_TIMESTAMP_KEY, entry.get(DynamoDBOperations.METADATA_TIMESTAMP_KEY)); operations.getClient().deleteItem(tableName, key); } return true; }
Example #25
Source File: DynamoDBReader.java From geowave with Apache License 2.0 | 5 votes |
protected void initScanner() { final String tableName = operations.getQualifiedTableName(readerParams.getIndex().getName()); // if ((readerParams.getLimit() != null) && (readerParams.getLimit() > // 0)) { // TODO: we should do something here // } final List<QueryRequest> requests = new ArrayList<>(); final Collection<SinglePartitionQueryRanges> ranges = readerParams.getQueryRanges().getPartitionQueryRanges(); if ((ranges != null) && !ranges.isEmpty()) { ranges.forEach( (queryRequest -> requests.addAll( addQueryRanges( tableName, queryRequest, readerParams.getAdapterIds(), readerParams.getInternalAdapterStore())))); } // else if ((readerParams.getAdapterIds() != null) && // !readerParams.getAdapterIds().isEmpty()) { // //TODO this isn't going to work because there aren't partition keys // being passed along // requests.addAll( // getAdapterOnlyQueryRequests( // tableName, // readerParams.getAdapterIds())); // } startRead( requests, tableName, DataStoreUtils.isMergingIteratorRequired(readerParams, visibilityEnabled), readerParams.getMaxResolutionSubsamplingPerDimension() == null); }
Example #26
Source File: DynamoDBUtil.java From dynamodb-geo with Apache License 2.0 | 5 votes |
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; }
Example #27
Source File: AbstractDynamoDBQueryCriteria.java From spring-data-dynamodb with Apache License 2.0 | 5 votes |
protected void applySortIfSpecified(QueryRequest queryRequest, List<String> permittedPropertyNames) { if (permittedPropertyNames.size() > 2) { throw new UnsupportedOperationException("Can only sort by at most a single global hash and range key"); } if (sort != null) { boolean sortAlreadySet = false; for (Order order : sort) { if (permittedPropertyNames.contains(order.getProperty())) { if (sortAlreadySet) { throw new UnsupportedOperationException("Sorting by multiple attributes not possible"); } if (queryRequest.getKeyConditions().size() > 1 && !hasIndexHashKeyEqualCondition()) { throw new UnsupportedOperationException( "Sorting for global index queries with criteria on both hash and range not possible"); } queryRequest.setScanIndexForward(order.getDirection().equals(Direction.ASC)); sortAlreadySet = true; } else { throw new UnsupportedOperationException("Sorting only possible by " + permittedPropertyNames + " for the criteria specified"); } } } }
Example #28
Source File: LazyPaginatedQuery.java From geowave with Apache License 2.0 | 5 votes |
public LazyPaginatedQuery( final QueryResult currentResult, final QueryRequest request, final AmazonDynamoDBAsync dynamoDBClient) { this.currentResult = currentResult; this.request = request; this.dynamoDBClient = dynamoDBClient; }
Example #29
Source File: TransactionManagerDBFacadeIntegrationTest.java From dynamodb-transactions with Apache License 2.0 | 5 votes |
private QueryRequest createQueryRequest(final boolean filterAttributes) { Condition hashKeyCondition = new Condition() .withComparisonOperator(ComparisonOperator.EQ) .withAttributeValueList(key0.get(ID_ATTRIBUTE)); QueryRequest request = new QueryRequest() .withTableName(INTEG_HASH_TABLE_NAME) .withKeyConditions(Collections.singletonMap(ID_ATTRIBUTE, hashKeyCondition)); if (filterAttributes) { request.setAttributesToGet(attributesToGet); } return request; }
Example #30
Source File: DynamoDBEntityWithHashKeyOnlyCriteria.java From spring-data-dynamodb with Apache License 2.0 | 5 votes |
protected Query<Long> buildFinderCountQuery(DynamoDBOperations dynamoDBOperations,boolean pageQuery) { if (isApplicableForGlobalSecondaryIndex()) { List<Condition> hashKeyConditions = getHashKeyConditions(); QueryRequest queryRequest = buildQueryRequest(dynamoDBOperations.getOverriddenTableName(entityInformation.getDynamoDBTableName()), getGlobalSecondaryIndexName(), getHashKeyAttributeName(), null, null, hashKeyConditions, null); return new QueryRequestCountQuery<T>(dynamoDBOperations, entityInformation.getJavaType(), queryRequest); } else { return new ScanExpressionCountQuery<T>(dynamoDBOperations, clazz, buildScanExpression(),pageQuery); } }