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 List<MaterializedView> getMaterializedViews(String project) { List<Map<String, AttributeValue>> items = dynamoDBClient.scan(new ScanRequest() .withTableName(tableConfig.getTableName()) .withFilterExpression("#P = :pValue AND begins_with(type_table_name, :prefix)") .withExpressionAttributeNames(of("#P", "project")) .withExpressionAttributeValues(of( ":pValue", new AttributeValue(project), ":prefix", new AttributeValue("materialized_")))).getItems(); return items.stream() .map(item -> JsonHelper.read(item.get("value").getS(), MaterializedView.class)) .collect(Collectors.toList()); }
private static void findProductsForPriceLessThanZero() { Map<String, AttributeValue> expressionAttributeValues = new HashMap<String, AttributeValue>(); expressionAttributeValues.put(":pr", new AttributeValue().withN("100")); ScanRequest scanRequest = new ScanRequest() .withTableName(tableName) .withFilterExpression("Price < :pr") .withExpressionAttributeValues(expressionAttributeValues) .withProjectionExpression("Id, Title, ProductCategory, Price"); ScanResult result = client.scan(scanRequest); System.out.println("Scan of " + tableName + " for items with a price less than 100."); for (Map<String, AttributeValue> item : result.getItems()) { System.out.println(""); printItem(item); } }
@Override public KeyIterator getKeys(final SliceQuery query, final StoreTransaction txh) throws BackendException { log.debug("Entering getKeys table:{} query:{} txh:{}", getTableName(), encodeForLog(query), txh); final Expression filterExpression = new FilterExpressionBuilder().rangeKey() .range(query) .build(); final ScanRequest scanRequest = super.createScanRequest() .withFilterExpression(filterExpression.getConditionExpression()) .withExpressionAttributeValues(filterExpression.getAttributeValues()); final Scanner scanner; final ScanContextInterpreter interpreter; if (client.isEnableParallelScan()) { scanner = client.getDelegate().getParallelScanCompletionService(scanRequest); interpreter = new MultiRowParallelScanInterpreter(this, query); } else { scanner = new SequentialScanner(client.getDelegate(), scanRequest); interpreter = new MultiRowSequentialScanInterpreter(this, query); } final KeyIterator result = new ScanBackedKeyIterator(scanner, interpreter); log.debug("Exiting getKeys table:{} query:{} txh:{} returning:{}", getTableName(), encodeForLog(query), txh, result); return result; }
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); } }
public static ScanRequest copyScanRequest(final ScanRequest request) { return new ScanRequest().withAttributesToGet(request.getAttributesToGet()) .withScanFilter(request.getScanFilter()) .withConditionalOperator(request.getConditionalOperator()) .withExclusiveStartKey(request.getExclusiveStartKey()) .withExpressionAttributeNames(request.getExpressionAttributeNames()) .withExpressionAttributeValues(cloneItem(request.getExpressionAttributeValues())) .withFilterExpression(request.getFilterExpression()) .withIndexName(request.getIndexName()).withLimit(request.getLimit()) .withProjectionExpression(request.getProjectionExpression()) .withReturnConsumedCapacity(request.getReturnConsumedCapacity()) .withScanFilter(request.getScanFilter()).withSelect(request.getSelect()) .withTableName(request.getTableName()).withTotalSegments(request.getTotalSegments()) .withSegment(request.getSegment()); }