/** * Returns a non-null list of the returned items; can be empty. */ public List<Item> getItems() { return InternalUtils.toItemList(result.getItems()); }
private List<T> marshalParallelScanResultsIntoObjects(List<ScanResult> scanResults) { List<T> allItems = new LinkedList<T>(); for (ScanResult scanResult : scanResults) { if (null != scanResult) { allItems.addAll(mapper.marshallIntoObjects( mapper.toParameters( scanResult.getItems(), clazz, parallelScanTask.getTableName(), config))); } } return allItems; } }
/** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. * * @return A string representation of this object. * * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getItems() != null) sb.append("Items: ").append(getItems()).append(","); if (getCount() != null) sb.append("Count: ").append(getCount()).append(","); if (getScannedCount() != null) sb.append("ScannedCount: ").append(getScannedCount()).append(","); if (getLastEvaluatedKey() != null) sb.append("LastEvaluatedKey: ").append(getLastEvaluatedKey()).append(","); if (getConsumedCapacity() != null) sb.append("ConsumedCapacity: ").append(getConsumedCapacity()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getItems() == null) ? 0 : getItems().hashCode()); hashCode = prime * hashCode + ((getCount() == null) ? 0 : getCount().hashCode()); hashCode = prime * hashCode + ((getScannedCount() == null) ? 0 : getScannedCount().hashCode()); hashCode = prime * hashCode + ((getLastEvaluatedKey() == null) ? 0 : getLastEvaluatedKey().hashCode()); hashCode = prime * hashCode + ((getConsumedCapacity() == null) ? 0 : getConsumedCapacity().hashCode()); return hashCode; }
public ScanPage( AmazonDynamoDB client, ScanSpec spec, ScanRequest request, int index, ScanOutcome outcome) { super(Collections.unmodifiableList( toItemList(outcome.getScanResult().getItems())), outcome); this.client = client; this.spec = spec; this.request = request; this.index = index; final Integer max = spec.getMaxResultSize(); final ScanResult result = outcome.getScanResult(); final List<?> ilist = result.getItems(); final int size = ilist == null ? 0 : ilist.size(); if (max != null && (index + size) > max) { this.lastEvaluatedKey = null; } else { this.lastEvaluatedKey = result.getLastEvaluatedKey(); } }
public PaginatedScanList( DynamoDBMapper mapper, Class<T> clazz, AmazonDynamoDB dynamo, ScanRequest scanRequest, ScanResult scanResult, PaginationLoadingStrategy paginationLoadingStrategy, DynamoDBMapperConfig config ) { super(mapper, clazz, dynamo, paginationLoadingStrategy); this.scanRequest = scanRequest; this.scanResult = scanResult; this.config = config; allResults.addAll(mapper.marshallIntoObjects( mapper.toParameters( scanResult.getItems(), clazz, scanRequest.getTableName(), config))); // If the results should be eagerly loaded at once if (paginationLoadingStrategy == PaginationLoadingStrategy.EAGER_LOADING) { loadAllResults(); } }
@Override protected synchronized List<T> fetchNextPage() { scanRequest.setExclusiveStartKey(scanResult.getLastEvaluatedKey()); scanResult = dynamo.scan(DynamoDBMapper.applyUserAgent(scanRequest)); return mapper.marshallIntoObjects(mapper.toParameters( scanResult.getItems(), clazz, scanRequest.getTableName(), config)); }
for (Map<String, AttributeValue> items : res.getItems()) { result.add(extractResult(items));
@Override public <T> ScanResultPage<T> scanPage(Class<T> clazz, DynamoDBScanExpression scanExpression, DynamoDBMapperConfig config) { config = mergeConfig(config); ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression, config); ScanResult scanResult = db.scan(applyUserAgent(scanRequest)); ScanResultPage<T> result = new ScanResultPage<T>(); List<AttributeTransformer.Parameters<T>> parameters = toParameters(scanResult.getItems(), clazz, scanRequest.getTableName(), config); result.setResults(marshallIntoObjects(parameters)); result.setLastEvaluatedKey(scanResult.getLastEvaluatedKey()); result.setCount(scanResult.getCount()); result.setScannedCount(scanResult.getScannedCount()); result.setConsumedCapacity(scanResult.getConsumedCapacity()); return result; }
/** * <p> * An array of item attributes that match the scan criteria. Each element in * this array consists of an attribute name and the value for that * attribute. * </p> * <p> * Returns a reference to this object so that method calls can be chained * together. * * @param items <p> * An array of item attributes that match the scan criteria. Each * element in this array consists of an attribute name and the * value for that attribute. * </p> * @return A reference to this updated object so that method calls can be * chained together. */ public ScanResult withItems(java.util.Map<String, AttributeValue>... items) { if (getItems() == null) { this.items = new java.util.ArrayList<java.util.Map<String, AttributeValue>>( items.length); } for (java.util.Map<String, AttributeValue> value : items) { this.items.add(value); } return this; }
private List<T> marshalParallelScanResultsIntoObjects(List<ScanResult> scanResults) { final List<T> allItems = new LinkedList<T>(); for (final ScanResult scanResult : scanResults) { if (null != scanResult) { allItems.addAll(mapper.marshallIntoObjects( mapper.toParameters( scanResult.getItems(), clazz, parallelScanTask.getTableName(), config))); } } return allItems; } }
@Override public Set<String> getProjects() { return dynamoDBClient.scan(new ScanRequest().withTableName(tableConfig.getTableName()) .withAttributesToGet("project")).getItems().stream() .map(e -> e.get("project").getS()) .collect(Collectors.toSet()); }
/** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getItems() != null) sb.append("Items: " + getItems() + ","); if (getCount() != null) sb.append("Count: " + getCount() + ","); if (getScannedCount() != null) sb.append("ScannedCount: " + getScannedCount() + ","); if (getLastEvaluatedKey() != null) sb.append("LastEvaluatedKey: " + getLastEvaluatedKey() + ","); if (getConsumedCapacity() != null) sb.append("ConsumedCapacity: " + getConsumedCapacity()); sb.append("}"); return sb.toString(); }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getItems() == null) ? 0 : getItems().hashCode()); hashCode = prime * hashCode + ((getCount() == null) ? 0 : getCount().hashCode()); hashCode = prime * hashCode + ((getScannedCount() == null) ? 0 : getScannedCount().hashCode()); hashCode = prime * hashCode + ((getLastEvaluatedKey() == null) ? 0 : getLastEvaluatedKey().hashCode()); hashCode = prime * hashCode + ((getConsumedCapacity() == null) ? 0 : getConsumedCapacity().hashCode()); return hashCode; }
@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()); }
scanResult.getItems(), clazz, scanRequest.getTableName(),
@Override protected synchronized List<T> fetchNextPage() { scanRequest.setExclusiveStartKey(scanResult.getLastEvaluatedKey()); scanResult = dynamo.scan(DynamoDBMapper.applyUserAgent(scanRequest)); return mapper.marshallIntoObjects(mapper.toParameters( scanResult.getItems(), clazz, scanRequest.getTableName(), config)); } }
/** * Scans through an Amazon DynamoDB table and returns a single page of * matching results. The table to scan is determined by looking at the * annotations on the specified class, which declares where to store the * object data in AWS DynamoDB, and the scan expression parameter allows the * caller to filter results and control how the scan 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 Amazon DynamoDB. * @param scanExpression Details on how to run the scan, including any * filters to apply to limit results. * @param config The configuration to use for this scan, which overrides the * default provided at object construction. * @return a single page of matching results. */ public <T> ScanResultPage<T> scanPage(Class<T> clazz, DynamoDBScanExpression scanExpression, DynamoDBMapperConfig config) { config = mergeConfig(config); final ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression, config); final ScanResult scanResult = db.scan(applyUserAgent(scanRequest)); final ScanResultPage<T> result = new ScanResultPage<T>(); final List<AttributeTransformer.Parameters<T>> parameters = toParameters(scanResult.getItems(), clazz, scanRequest.getTableName(), config); result.setResults(marshallIntoObjects(parameters)); result.setLastEvaluatedKey(scanResult.getLastEvaluatedKey()); return result; }