Package com.amazonaws.services.dynamodbv2.model

Examples of com.amazonaws.services.dynamodbv2.model.ScanResult


        ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression, config);
        scanRequest.setSelect(Select.COUNT);

        // Count scans can also be truncated for large datasets
        int count = 0;
        ScanResult scanResult = null;
        do {
            scanResult = db.scan(applyUserAgent(scanRequest));
            count += scanResult.getCount();
            scanRequest.setExclusiveStartKey(scanResult.getLastEvaluatedKey());
        } while (scanResult.getLastEvaluatedKey() != null);

        return count;
    }
View Full Code Here


        Map<String, AttributeValue> lastKeysEvaluated = null;
        do {
            ScanRequest scanRequest = new ScanRequest()
                    .withTableName(table)
                    .withExclusiveStartKey(lastKeysEvaluated);
            ScanResult result = dbClient.scan(scanRequest);
            for (Map<String, AttributeValue> item : result.getItems()) {
                String keyVal = item.get(keyAttributeName.get()).getS();

                //Need to deal with the fact that these attributes might not exist
                DeploymentContext.ContextKey contextKey = item.containsKey(contextKeyAttributeName.get()) ? DeploymentContext.ContextKey.valueOf(item.get(contextKeyAttributeName.get()).getS()) : null;
                String contextVal = item.containsKey(contextValueAttributeName.get()) ? item.get(contextValueAttributeName.get()).getS() : null;
                String key = keyVal + ";" + contextKey + ";" + contextVal;
                propertyMap.put(key,
                        new PropertyWithDeploymentContext(
                                contextKey,
                                contextVal,
                                keyVal,
                                item.get(valueAttributeName.get()).getS()
                        ));
            }
            lastKeysEvaluated = result.getLastEvaluatedKey();
        } while (lastKeysEvaluated != null);
        return propertyMap;
    }
View Full Code Here

        Map<String, AttributeValue> lastKeysEvaluated = null;
        do {
            ScanRequest scanRequest = new ScanRequest()
                    .withTableName(table)
                    .withExclusiveStartKey(lastKeysEvaluated);
            ScanResult result = dbClient.scan(scanRequest);
            for (Map<String, AttributeValue> item : result.getItems()) {
                propertyMap.put(item.get(keyAttributeName.get()).getS(), item.get(valueAttributeName.get()).getS());
            }
            lastKeysEvaluated = result.getLastEvaluatedKey();
        } while (lastKeysEvaluated != null);
        return propertyMap;
    }
View Full Code Here

    public <T> PaginatedScanList<T> scan(Class<T> clazz, DynamoDBScanExpression scanExpression, DynamoDBMapperConfig config) {
        config = mergeConfig(config);

        ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression, config);

        ScanResult scanResult = db.scan(applyUserAgent(scanRequest));
        return new PaginatedScanList<T>(this, clazz, db, scanRequest, scanResult, config.getPaginationLoadingStrategy(), config);
    }
View Full Code Here

    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, config);

        result.setResults(marshallIntoObjects(parameters));
        result.setLastEvaluatedKey(scanResult.getLastEvaluatedKey());

        return result;
    }
View Full Code Here

        ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression, config);
        scanRequest.setSelect(Select.COUNT);

        // Count scans can also be truncated for large datasets
        int count = 0;
        ScanResult scanResult = null;
        do {
            scanResult = db.scan(applyUserAgent(scanRequest));
            count += scanResult.getCount();
            scanRequest.setExclusiveStartKey(scanResult.getLastEvaluatedKey());
        } while (scanResult.getLastEvaluatedKey() != null);

        return count;
    }
View Full Code Here

      /**
       * Get the ScanResult from cache if the segment scan has finished.
       */
      else if (currentSegmentState == SegmentScanState.HasNextPage
          || currentSegmentState == SegmentScanState.SegmentScanCompleted) {
        ScanResult scanResult = segmentScanResults.get(segment);
        scanResults.add(scanResult);
      }
      else if (currentSegmentState == SegmentScanState.Waiting
          || currentSegmentState == SegmentScanState.Scanning){
        throw new AmazonClientException("Should never see a 'Scanning' or 'Waiting' state when marshalling parallel scan results.");
View Full Code Here

  }
 
  private ScanResult scanNextPageOfSegment(int currentSegment, boolean checkLastEvaluatedKey) {
    ScanRequest segmentScanRequest = parallelScanRequests.get(currentSegment);
    if (checkLastEvaluatedKey) {
      ScanResult lastScanResult = segmentScanResults.get(currentSegment);
      segmentScanRequest.setExclusiveStartKey(lastScanResult.getLastEvaluatedKey());
    } else {
      segmentScanRequest.setExclusiveStartKey(null);
    }
    ScanResult scanResult = dynamo.scan(mapper.applyUserAgent(segmentScanRequest));
   
    /**
     * Cache the scan result in segmentScanResults.
     * We should never try to get these scan results by calling get() on the cached future tasks.
     */
    segmentScanResults.set(currentSegment, scanResult);
   
    /**
     * Update the state and notify any waiting thread.
     */
    synchronized(segmentScanStates) {
      if (null == scanResult.getLastEvaluatedKey())
        segmentScanStates.set(currentSegment, SegmentScanState.SegmentScanCompleted);
      else
        segmentScanStates.set(currentSegment, SegmentScanState.HasNextPage);
      segmentScanStates.notifyAll();
    }
View Full Code Here

            Condition condition = new Condition()
                .withComparisonOperator(ComparisonOperator.GT.toString())
                .withAttributeValueList(new AttributeValue().withN("1985"));
            scanFilter.put("year", condition);
            ScanRequest scanRequest = new ScanRequest(tableName).withScanFilter(scanFilter);
            ScanResult scanResult = dynamoDB.scan(scanRequest);
            System.out.println("Result: " + scanResult);

        } catch (AmazonServiceException ase) {
            System.out.println("Caught an AmazonServiceException, which means your request made it "
                    + "to AWS, but was rejected with an error response for some reason.");
View Full Code Here

    public <T> PaginatedScanList<T> scan(Class<T> clazz, DynamoDBScanExpression scanExpression, DynamoDBMapperConfig config) {
        config = mergeConfig(config);

        ScanRequest scanRequest = createScanRequestFromExpression(clazz, scanExpression, config);

        ScanResult scanResult = db.scan(applyUserAgent(scanRequest));
        return new PaginatedScanList<T>(this, clazz, db, scanRequest, scanResult, config.getPaginationLoadingStrategy(), config);
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.model.ScanResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.