String getTableName() { return parallelScanRequests.get(0).getTableName(); }
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 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 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 + ((getAttributesToGet() == null) ? 0 : getAttributesToGet().hashCode()); hashCode = prime * hashCode + ((getLimit() == null) ? 0 : getLimit().hashCode()); hashCode = prime * hashCode + ((getSelect() == null) ? 0 : getSelect().hashCode()); hashCode = prime * hashCode + ((getScanFilter() == null) ? 0 : getScanFilter().hashCode()); hashCode = prime * hashCode + ((getConditionalOperator() == null) ? 0 : getConditionalOperator().hashCode()); hashCode = prime * hashCode + ((getExclusiveStartKey() == null) ? 0 : getExclusiveStartKey().hashCode()); hashCode = prime * hashCode + ((getReturnConsumedCapacity() == null) ? 0 : getReturnConsumedCapacity().hashCode()); hashCode = prime * hashCode + ((getTotalSegments() == null) ? 0 : getTotalSegments().hashCode()); hashCode = prime * hashCode + ((getSegment() == null) ? 0 : getSegment().hashCode()); hashCode = prime * hashCode + ((getProjectionExpression() == null) ? 0 : getProjectionExpression().hashCode()); hashCode = prime * hashCode + ((getFilterExpression() == null) ? 0 : getFilterExpression().hashCode()); hashCode = prime * hashCode + ((getExpressionAttributeNames() == null) ? 0 : getExpressionAttributeNames().hashCode()); hashCode = prime * hashCode + ((getExpressionAttributeValues() == null) ? 0 : getExpressionAttributeValues().hashCode()); hashCode = prime * hashCode + ((getConsistentRead() == null) ? 0 : getConsistentRead().hashCode()); return hashCode; }
@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)); }
return false; ScanRequest other = (ScanRequest) 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)
String getTableName() { return parallelScanRequests.get(0).getTableName(); }
/** * Marshall the given parameter object. */ public void marshall(ScanRequest scanRequest, ProtocolMarshaller protocolMarshaller) { if (scanRequest == null) { throw new SdkClientException("Invalid argument passed to marshall(...)"); } try { protocolMarshaller.marshall(scanRequest.getTableName(), TABLENAME_BINDING); protocolMarshaller.marshall(scanRequest.getIndexName(), INDEXNAME_BINDING); protocolMarshaller.marshall(scanRequest.getAttributesToGet(), ATTRIBUTESTOGET_BINDING); protocolMarshaller.marshall(scanRequest.getLimit(), LIMIT_BINDING); protocolMarshaller.marshall(scanRequest.getSelect(), SELECT_BINDING); protocolMarshaller.marshall(scanRequest.getScanFilter(), SCANFILTER_BINDING); protocolMarshaller.marshall(scanRequest.getConditionalOperator(), CONDITIONALOPERATOR_BINDING); protocolMarshaller.marshall(scanRequest.getExclusiveStartKey(), EXCLUSIVESTARTKEY_BINDING); protocolMarshaller.marshall(scanRequest.getReturnConsumedCapacity(), RETURNCONSUMEDCAPACITY_BINDING); protocolMarshaller.marshall(scanRequest.getTotalSegments(), TOTALSEGMENTS_BINDING); protocolMarshaller.marshall(scanRequest.getSegment(), SEGMENT_BINDING); protocolMarshaller.marshall(scanRequest.getProjectionExpression(), PROJECTIONEXPRESSION_BINDING); protocolMarshaller.marshall(scanRequest.getFilterExpression(), FILTEREXPRESSION_BINDING); protocolMarshaller.marshall(scanRequest.getExpressionAttributeNames(), EXPRESSIONATTRIBUTENAMES_BINDING); protocolMarshaller.marshall(scanRequest.getExpressionAttributeValues(), EXPRESSIONATTRIBUTEVALUES_BINDING); protocolMarshaller.marshall(scanRequest.getConsistentRead(), CONSISTENTREAD_BINDING); } catch (Exception e) { throw new SdkClientException("Unable to marshall request to JSON: " + e.getMessage(), e); } }
@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; }
scanResult.getItems(), clazz, scanRequest.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
@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)); } }
@Override protected String getTableName() { return request.getTableName(); }
ScanRequest other = (ScanRequest) 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)
/** * 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; }
jsonWriter.beginObject(); if (scanRequest.getTableName() != null) { String tableName = scanRequest.getTableName(); jsonWriter.name("TableName"); jsonWriter.value(tableName);
@Test public void testCreateScanRequestFromExpression() { DynamoDBScanExpression se = new DynamoDBScanExpression(); se.setConditionalOperator("lt"); Map<String, AttributeValue> esk = new HashMap<String, AttributeValue>(); se.setExclusiveStartKey(esk); Map<String, String> ean = new HashMap<String, String>(); se.setExpressionAttributeNames(ean); Map<String, AttributeValue> eav = new HashMap<String, AttributeValue>(); se.setExpressionAttributeValues(eav); se.setFilterExpression("testFilter"); se.setLimit(5); Map<String, Condition> filter = new HashMap<String, Condition>(); se.setScanFilter(filter); se.setSegment(2); se.setTotalSegments(10); ScanRequest sr = mapper.createScanRequestFromExpression(MockTwoValuePlusVersionClass.class, se, config); assertEquals(sr.getConditionalOperator(), "lt"); assertEquals(sr.getTableName(), "aws-android-sdk-dynamodbmapper-test"); assertEquals(sr.getExclusiveStartKey(), esk); assertEquals(sr.getExpressionAttributeNames(), ean); assertEquals(sr.getExpressionAttributeValues(), eav); assertEquals(sr.getFilterExpression(), "testFilter"); assertEquals(sr.getLimit().intValue(), 5); assertEquals(sr.getScanFilter(), filter); assertEquals(sr.getSegment().intValue(), 2); assertEquals(sr.getTotalSegments().intValue(), 10); }
assertEquals(sr1.getTableName(), "aws-android-sdk-dynamodbmapper-test"); assertNull(sr1.getExclusiveStartKey()); assertEquals(sr1.getExpressionAttributeNames(), ean); assertEquals(sr2.getTableName(), "aws-android-sdk-dynamodbmapper-test"); assertNull(sr2.getExclusiveStartKey()); assertEquals(sr2.getExpressionAttributeNames(), ean);
public SequentialScanner(final DynamoDbDelegate dynamoDbDelegate, final ScanRequest request) { this.dynamoDbDelegate = dynamoDbDelegate; Preconditions.checkArgument(request.getExclusiveStartKey() == null || request.getExclusiveStartKey().isEmpty(), "A scan worker should start with a fresh ScanRequest"); this.request = DynamoDbDelegate.copyScanRequest(request); this.lastConsumedCapacity = dynamoDbDelegate.estimateCapacityUnits(DynamoDbDelegate.SCAN, request.getTableName()); this.currentFuture = dynamoDbDelegate.scanAsync(request, lastConsumedCapacity); }