public ScanCollection(AmazonDynamoDB client, ScanSpec spec) { this.client = client; this.spec = spec; Map<String, AttributeValue> startKey = spec.getRequest() .getExclusiveStartKey(); this.startKey = startKey == null ? null : new LinkedHashMap<String, AttributeValue>(startKey); }
if (getConditionalOperator() != null) sb.append("ConditionalOperator: ").append(getConditionalOperator()).append(","); if (getExclusiveStartKey() != null) sb.append("ExclusiveStartKey: ").append(getExclusiveStartKey()).append(","); if (getReturnConsumedCapacity() != null) sb.append("ReturnConsumedCapacity: ").append(getReturnConsumedCapacity()).append(",");
@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; }
if (other.getConditionalOperator() != null && other.getConditionalOperator().equals(this.getConditionalOperator()) == false) return false; if (other.getExclusiveStartKey() == null ^ this.getExclusiveStartKey() == null) return false; if (other.getExclusiveStartKey() != null && other.getExclusiveStartKey().equals(this.getExclusiveStartKey()) == false) return false; if (other.getReturnConsumedCapacity() == null ^ this.getReturnConsumedCapacity() == null)
/** * 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); } }
if (getConditionalOperator() != null) sb.append("ConditionalOperator: " + getConditionalOperator() + ","); if (getExclusiveStartKey() != null) sb.append("ExclusiveStartKey: " + getExclusiveStartKey() + ","); if (getReturnConsumedCapacity() != null) sb.append("ReturnConsumedCapacity: " + getReturnConsumedCapacity() + ",");
+ ((getConditionalOperator() == null) ? 0 : getConditionalOperator().hashCode()); hashCode = prime * hashCode + ((getExclusiveStartKey() == null) ? 0 : getExclusiveStartKey().hashCode()); hashCode = prime
@Test public void scanNextPageOfSegmentWithoutExclusiveStartKey() { EasyMock.reset(mockClient); ScanRequest scan1 = new ScanRequest().withTableName(TABLE); List<ScanRequest> list = new ArrayList<ScanRequest>(); list.add(scan1); Map<String, AttributeValue> lastEvaluatedKey = new HashMap<String, AttributeValue>(); lastEvaluatedKey.put("TestPrimaryKey", new AttributeValue().withS("Test1")); ScanResult result = new ScanResult().withLastEvaluatedKey(lastEvaluatedKey); ParallelScanTask testTask = new ParallelScanTask(mockClient, list); EasyMock.expect(mockClient.scan(scan1)).andReturn(result); EasyMock.replay(mockClient); testTask.scanNextPageOfSegment(0, false); EasyMock.verify(mockClient); EasyMock.reset(mockClient); Capture<ScanRequest> captureArgument = new Capture<ScanRequest>(); ScanResult mockResult = EasyMock.createMock(ScanResult.class); EasyMock.expect(mockResult.getLastEvaluatedKey()).andReturn(null).anyTimes(); EasyMock.expect(mockClient.scan(EasyMock.capture(captureArgument))).andReturn( mockResult); EasyMock.replay(mockClient, mockResult); testTask.scanNextPageOfSegment(0, false); EasyMock.verify(mockClient); assertNull(captureArgument.getValue().getExclusiveStartKey()); }
@Test public void scanNextPageOfSegmentWithExclusiveStartKey() { EasyMock.reset(mockClient); ScanRequest scan1 = new ScanRequest().withTableName(TABLE); List<ScanRequest> list = new ArrayList<ScanRequest>(); list.add(scan1); Map<String, AttributeValue> lastEvaluatedKey = new HashMap<String, AttributeValue>(); lastEvaluatedKey.put("TestPrimaryKey", new AttributeValue().withS("Test1")); ScanResult result = new ScanResult().withLastEvaluatedKey(lastEvaluatedKey); ParallelScanTask testTask = new ParallelScanTask(mockClient, list); EasyMock.expect(mockClient.scan(scan1)).andReturn(result); EasyMock.replay(mockClient); testTask.scanNextPageOfSegment(0, false); EasyMock.verify(mockClient); EasyMock.reset(mockClient); Capture<ScanRequest> captureArgument = new Capture<ScanRequest>(); ScanResult mockResult = EasyMock.createMock(ScanResult.class); EasyMock.expect(mockResult.getLastEvaluatedKey()).andReturn(null).anyTimes(); EasyMock.expect(mockClient.scan(EasyMock.capture(captureArgument))).andReturn(mockResult); EasyMock.replay(mockClient, mockResult); testTask.scanNextPageOfSegment(0, true); EasyMock.verify(mockClient); assertEquals( captureArgument.getValue().getExclusiveStartKey().get("TestPrimaryKey").getS(), "Test1"); }
public boolean isFirstResult() { return scanRequest.getExclusiveStartKey() == null || scanRequest.getExclusiveStartKey().isEmpty(); } }
/** Test on using predefined map entry setter to provide map parameter. */ @Test public void testPredefinedMapEntryMethod() { ScanRequest scanRequest = new ScanRequest() .addExclusiveStartKeyEntry("hash-key", new AttributeValue().withS("1")) .addExclusiveStartKeyEntry("range-key", new AttributeValue().withS("2")); Map<String, AttributeValue> item = scanRequest.getExclusiveStartKey(); assertEquals(2, item.size()); assertEquals("1", item.get("hash-key").getS()); assertEquals("2", item.get("range-key").getS()); }
&& other.getConditionalOperator().equals(this.getConditionalOperator()) == false) return false; if (other.getExclusiveStartKey() == null ^ this.getExclusiveStartKey() == null) return false; if (other.getExclusiveStartKey() != null && other.getExclusiveStartKey().equals(this.getExclusiveStartKey()) == false) return false; if (other.getReturnConsumedCapacity() == null ^ this.getReturnConsumedCapacity() == null)
public ScanCollection(AmazonDynamoDB client, ScanSpec spec) { this.client = client; this.spec = spec; Map<String, AttributeValue> startKey = spec.getRequest() .getExclusiveStartKey(); this.startKey = startKey == null ? null : new LinkedHashMap<String, AttributeValue>(startKey); }
jsonWriter.value(conditionalOperator); if (scanRequest.getExclusiveStartKey() != null) { java.util.Map<String, AttributeValue> exclusiveStartKey = scanRequest .getExclusiveStartKey(); jsonWriter.name("ExclusiveStartKey"); jsonWriter.beginObject();
@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); }
assertNull(sr1.getExclusiveStartKey()); assertEquals(sr1.getExpressionAttributeNames(), ean); assertEquals(sr1.getExpressionAttributeValues(), eav); assertNull(sr2.getExclusiveStartKey()); assertEquals(sr2.getExpressionAttributeNames(), ean); assertEquals(sr2.getExpressionAttributeValues(), eav);
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); }
@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; }
/** * 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); } }
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()); }