@Override public ItemCollection<ScanOutcome> scan(String filterExpression, String projectionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doScan(new ScanSpec() .withFilterExpression(filterExpression) .withProjectionExpression(projectionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
protected ItemCollection<ScanOutcome> doScan(ScanSpec spec) { // set the table name String tableName = getTable().getTableName(); ScanRequest req = spec.getRequest().withTableName(tableName); // set up the start key, if any Collection<KeyAttribute> startKey = spec.getExclusiveStartKey(); if (startKey != null) req.setExclusiveStartKey(InternalUtils.toAttributeValueMap(startKey)); // scan filters; Collection<ScanFilter> filters = spec.getScanFilters(); if (filters != null) { req.setScanFilter(InternalUtils.toAttributeConditionMap(filters)); } // set up the value map, if any (when expression API is used) final Map<String,AttributeValue> attrValMap = InternalUtils.fromSimpleMap(spec.getValueMap()); // set up expressions, if any req.withExpressionAttributeNames(spec.getNameMap()) .withExpressionAttributeValues(attrValMap) ; return new ScanCollection(getClient(), spec); } }
@Override public Page<Item, ScanOutcome> firstPage() { ScanRequest request = spec.getRequest(); request.setExclusiveStartKey(startKey); request.setLimit(InternalUtils.minimum( spec.getMaxResultSize(), spec.getMaxPageSize())); ScanResult result = client.scan(request); ScanOutcome outcome = new ScanOutcome(result); setLastLowLevelResult(outcome); return new ScanPage(client, spec, request, 0, outcome); }
@Override public ItemCollection<ScanOutcome> scan(ScanFilter... scanFilters) { return doScan(new ScanSpec() .withScanFilters(scanFilters)); }
ScanSpec spec = new ScanSpec() .withMaxResultSize(itemLimit) .withTotalSegments(totalSegments) .withSegment(segment);
ScanSpec scanSpec = new ScanSpec() .withFilterExpression("#idname in (:val1, :val2, :val3)") .withNameMap(ImmutableMap.of("#idname", "ID")) .withValueMap(ImmutableMap.of(":val1", "123", ":val2", "456", ":val23", "789")); ItemCollection<ScanOutcome> = table.scan(scanSpec);
private int nextRequestLimit(int max) { int nextIndex = index + this.size(); return InternalUtils.minimum( max - nextIndex, spec.getMaxPageSize()); }
@Override public ItemCollection<ScanOutcome> scan(ScanFilter... scanFilters) { return doScan(new ScanSpec() .withScanFilters(scanFilters)); }
ValueMap values = new ValueMap().withString( ":p_status", "READY" ).withString( ":p_prefix", prefix ); NameMap names = new NameMap().with( "#status_name", "status" ).with( "#path_name", CDynamoDbCommon.RANGE_KEY_NAME ); scanSpec = new ScanSpec() .withFilterExpression( UAwsBasic.DATABASE_JSON_DEFINITION_NAME + ".#status_name = :p_status AND contains( #path_name , :p_prefix)" ) .withNameMap( names ).withValueMap( values ) .withMaxResultSize( 10 ).withExclusiveStartKey( CDynamoDbCommon.PRIMARY_KEY_NAME, primaryLast, CDynamoDbCommon.RANGE_KEY_NAME, hashLast );
private int nextRequestLimit(int max) { int nextIndex = index + this.size(); return InternalUtils.minimum( max - nextIndex, spec.getMaxPageSize()); }
@Override public ItemCollection<ScanOutcome> scan(String filterExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doScan(new ScanSpec() .withFilterExpression(filterExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
protected ItemCollection<ScanOutcome> doScan(ScanSpec spec) { // set the table name String tableName = getTable().getTableName(); ScanRequest req = spec.getRequest().withTableName(tableName); // set up the start key, if any Collection<KeyAttribute> startKey = spec.getExclusiveStartKey(); if (startKey != null) req.setExclusiveStartKey(InternalUtils.toAttributeValueMap(startKey)); // scan filters; Collection<ScanFilter> filters = spec.getScanFilters(); if (filters != null) { req.setScanFilter(InternalUtils.toAttributeConditionMap(filters)); } // set up the value map, if any (when expression API is used) final Map<String,AttributeValue> attrValMap = InternalUtils.fromSimpleMap(spec.getValueMap()); // set up expressions, if any req.withExpressionAttributeNames(spec.getNameMap()) .withExpressionAttributeValues(attrValMap) ; return new ScanCollection(getClient(), spec); } }
/** * Returns the result of a request to get all items from the specified * DynamoDB table. * * @param table The DynamoDB table. * * @return The iterable item collection. */ ItemCollection<?> getAllItems(final Table table) { if (applyRangeKey) { RangeKeyCondition c = new RangeKeyCondition(rangeKeyName).eq(rangeKeyValue); return table.getIndex(getRangeKeyGSIName()).query(new QuerySpec().withRangeKeyCondition(c)); } return table.scan(new ScanSpec()); }
@Override public Page<Item, ScanOutcome> firstPage() { ScanRequest request = spec.getRequest(); request.setExclusiveStartKey(startKey); request.setLimit(InternalUtils.minimum( spec.getMaxResultSize(), spec.getMaxPageSize())); ScanResult result = client.scan(request); ScanOutcome outcome = new ScanOutcome(result); setLastLowLevelResult(outcome); return new ScanPage(client, spec, request, 0, outcome); }
@Beta public ItemCollection<ScanOutcome> scan(ScanExpressionSpec scanExpressions) { return scanDelegate.scan(new ScanSpec() .withProjectionExpression(scanExpressions.getProjectionExpression()) .withFilterExpression(scanExpressions.getFilterExpression()) .withNameMap(scanExpressions.getNameMap()) .withValueMap(scanExpressions.getValueMap())); }
/** * Convenient method to specify expressions (and the associated name map and * value map) via {@link ScanExpressionSpec}. */ @Beta public ScanSpec withExpressionSpec(ScanExpressionSpec xspec) { return withFilterExpression(xspec.getFilterExpression()) .withProjectionExpression(xspec.getProjectionExpression()) .withNameMap(xspec.getNameMap()) .withValueMap(xspec.getValueMap()) ; } }
@Override public ItemCollection<ScanOutcome> scan(String filterExpression, String projectionExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doScan(new ScanSpec() .withFilterExpression(filterExpression) .withProjectionExpression(projectionExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Override public ItemCollection<ScanOutcome> scan(String filterExpression, Map<String, String> nameMap, Map<String, Object> valueMap) { return doScan(new ScanSpec() .withFilterExpression(filterExpression) .withNameMap(nameMap) .withValueMap(valueMap)); }
@Beta public ItemCollection<ScanOutcome> scan(ScanExpressionSpec scanExpressions) { return scanDelegate.scan(new ScanSpec() .withProjectionExpression(scanExpressions.getProjectionExpression()) .withFilterExpression(scanExpressions.getFilterExpression()) .withNameMap(scanExpressions.getNameMap()) .withValueMap(scanExpressions.getValueMap())); }
/** * Convenient method to specify expressions (and the associated name map and * value map) via {@link ScanExpressionSpec}. */ @Beta public ScanSpec withExpressionSpec(ScanExpressionSpec xspec) { return withFilterExpression(xspec.getFilterExpression()) .withProjectionExpression(xspec.getProjectionExpression()) .withNameMap(xspec.getNameMap()) .withValueMap(xspec.getValueMap()) ; } }