/** * 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; }
protected void setLastLowLevelResult(ScanOutcome lowLevelResult) { super.setLastLowLevelResult(lowLevelResult); ScanResult result = lowLevelResult.getScanResult(); accumulateStats(result.getConsumedCapacity(), result.getCount(), result.getScannedCount()); } }
if (other.getLastEvaluatedKey() != null && other.getLastEvaluatedKey().equals(this.getLastEvaluatedKey()) == false) return false; if (other.getConsumedCapacity() == null ^ this.getConsumedCapacity() == null) return false; if (other.getConsumedCapacity() != null && other.getConsumedCapacity().equals(this.getConsumedCapacity()) == false) return false; return true;
@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; }
/** * 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; }
&& other.getLastEvaluatedKey().equals(this.getLastEvaluatedKey()) == false) return false; if (other.getConsumedCapacity() == null ^ this.getConsumedCapacity() == null) return false; if (other.getConsumedCapacity() != null && other.getConsumedCapacity().equals(this.getConsumedCapacity()) == false) return false; return true;
/** * 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; }
@SuppressFBWarnings(value = "IT_NO_SUCH_ELEMENT", justification = "https://github.com/awslabs/dynamodb-janusgraph-storage-backend/issues/222") @Override public ScanResult next() { final Scan backoff = new Scan(request, delegate, lastConsumedCapacity); ScanResult result = null; try { result = backoff.runWithBackoff(); //this will be non-null or runWithBackoff throws } catch (BackendException e) { throw new BackendRuntimeException(e); } if (result.getConsumedCapacity() != null) { lastConsumedCapacity = result.getConsumedCapacity().getCapacityUnits().intValue(); } if (result.getLastEvaluatedKey() != null && !result.getLastEvaluatedKey().isEmpty()) { hasNext = true; request.setExclusiveStartKey(result.getLastEvaluatedKey()); } else { hasNext = false; } return result; }
protected void setLastLowLevelResult(ScanOutcome lowLevelResult) { super.setLastLowLevelResult(lowLevelResult); ScanResult result = lowLevelResult.getScanResult(); accumulateStats(result.getConsumedCapacity(), result.getCount(), result.getScannedCount()); } }
if (other.getLastEvaluatedKey() != null && other.getLastEvaluatedKey().equals(this.getLastEvaluatedKey()) == false) return false; if (other.getConsumedCapacity() == null ^ this.getConsumedCapacity() == null) return false; if (other.getConsumedCapacity() != null && other.getConsumedCapacity().equals(this.getConsumedCapacity()) == false) return false; return true;
@Override protected PageResults<Map<String, AttributeValue>> fetchPage(RequestLimit lim) { // Read from DynamoDB RetryResult<ScanResult> retryResult = context.getClient().scanTable(tableName, null, segment, context.getSplit().getTotalSegments(), lastEvaluatedKey, lim.items, context.getReporter()); ScanResult result = retryResult.result; int retries = retryResult.retries; double consumedCapacityUnits = 0.0; if (result.getConsumedCapacity() != null) { consumedCapacityUnits = result.getConsumedCapacity().getCapacityUnits(); } return new PageResults<>(result.getItems(), result.getLastEvaluatedKey(), consumedCapacityUnits, retries); } }
@Override protected PageResults<Map<String, AttributeValue>> fetchPage(RequestLimit lim) { // Read from DynamoDB RetryResult<ScanResult> retryResult = context.getClient().scanTable(tableName, null, segment, context.getSplit().getTotalSegments(), lastEvaluatedKey, lim.items, context.getReporter()); ScanResult result = retryResult.result; int retries = retryResult.retries; double consumedCapacityUnits = 0.0; if (result.getConsumedCapacity() != null) { consumedCapacityUnits = result.getConsumedCapacity().getCapacityUnits(); } return new PageResults<>(result.getItems(), result.getLastEvaluatedKey(), consumedCapacityUnits, retries); } }
logger.debug("readPage() CC: {}", result.getConsumedCapacity());
@Override public SegmentedScanResult call() { ScanResult result = null; result = runWithBackoff(); final ConsumedCapacity cc = result.getConsumedCapacity(); if (cc != null && cc.getCapacityUnits() != null) { lastConsumedCapacity = result.getConsumedCapacity() .getCapacityUnits().intValue(); } else if (result.getScannedCount() != null && result.getCount() != null) { final boolean isConsistent = request.getConsistentRead(); int itemSize = isConsistent ? BootstrapConstants.STRONGLY_CONSISTENT_READ_ITEM_SIZE : BootstrapConstants.EVENTUALLY_CONSISTENT_READ_ITEM_SIZE; lastConsumedCapacity = (result.getScannedCount() / (int) Math.max(1.0, result.getCount())) * (ItemSizeCalculator.calculateScanResultSizeInBytes(result) / itemSize); } if (result.getLastEvaluatedKey() != null && !result.getLastEvaluatedKey().isEmpty()) { hasNext = true; request.setExclusiveStartKey(result.getLastEvaluatedKey()); } else { hasNext = false; } if (lastConsumedCapacity > 0) { rateLimiter.acquire(lastConsumedCapacity); } return new SegmentedScanResult(result, request.getSegment()); }
public ScanResult scan(final ScanRequest request, final int permitsToConsume) throws BackendException { setUserAgent(request); ScanResult result; timedReadThrottle(SCAN, request.getTableName(), permitsToConsume); final Timer.Context apiTimerContext = getTimerContext(SCAN, request.getTableName()); try { result = client.scan(request); } catch (Exception e) { throw processDynamoDbApiException(e, SCAN, request.getTableName()); } finally { apiTimerContext.stop(); } meterConsumedCapacity(SCAN, result.getConsumedCapacity()); measureItemCount(SCAN, request.getTableName(), result.getCount()); return result; }
@Override public int count(final Credentials credentials, final String table, final Map<String, Condition> conditions) { final AmazonDynamoDB aws = credentials.aws(); try { final ScanRequest request = new ScanRequest() .withTableName(table) .withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL) .withScanFilter(conditions) .withSelect(Select.COUNT) .withLimit(Integer.MAX_VALUE); final long start = System.currentTimeMillis(); final ScanResult result = aws.scan(request); final int count = result.getCount(); Logger.info( this, // @checkstyle LineLength (1 line) "#total(): COUNT=%d in '%s' using %s, %s, in %[ms]s", count, request.getTableName(), request.getFilterExpression(), new PrintableConsumedCapacity( result.getConsumedCapacity() ).print(), System.currentTimeMillis() - start ); return count; } finally { aws.shutdown(); } }
@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; }