@Override public Integer getMaxResultSize() { return spec.getMaxResultSize(); }
@Override public boolean hasNextPage() { if (lastEvaluatedKey == null) return false; Integer max = spec.getMaxResultSize(); if (max == null) return true; return nextRequestLimit(max.intValue()) > 0; }
@Override public Page<Item, ScanOutcome> nextPage() { if (lastEvaluatedKey == null) { throw new NoSuchElementException("No more pages"); } final Integer max = spec.getMaxResultSize(); if (max != null) { int nextLimit = nextRequestLimit(max.intValue()); if (nextLimit == 0) throw new NoSuchElementException("No more pages"); request.setLimit(nextLimit); } request.setExclusiveStartKey(lastEvaluatedKey); // fire off request to the server side ScanResult result = client.scan(request); final int nextIndex = index + this.size(); return new ScanPage(client, spec, request, nextIndex, new ScanOutcome(result)); } }
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(); } }
@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 Integer getMaxResultSize() { return spec.getMaxResultSize(); }
@Override public boolean hasNextPage() { if (lastEvaluatedKey == null) return false; Integer max = spec.getMaxResultSize(); if (max == null) return true; return nextRequestLimit(max.intValue()) > 0; }
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(); } }
@Override public Page<Item, ScanOutcome> nextPage() { if (lastEvaluatedKey == null) { throw new NoSuchElementException("No more pages"); } final Integer max = spec.getMaxResultSize(); if (max != null) { int nextLimit = nextRequestLimit(max.intValue()); if (nextLimit == 0) throw new NoSuchElementException("No more pages"); request.setLimit(nextLimit); } request.setExclusiveStartKey(lastEvaluatedKey); // fire off request to the server side ScanResult result = client.scan(request); final int nextIndex = index + this.size(); return new ScanPage(client, spec, request, nextIndex, new ScanOutcome(result)); } }
@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); }