Example usage for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient scan

List of usage examples for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient scan

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2 AmazonDynamoDBClient scan.

Prototype

@Override
public ScanResult scan(ScanRequest request) 

Source Link

Document

The Scan operation returns one or more items and item attributes by accessing every item in a table or a secondary index.

Usage

From source file:awslabs.lab51.SolutionCode.java

License:Open Source License

@Override
public List<Map<String, AttributeValue>> getImageItems(AmazonDynamoDBClient dynamoDbClient) {
    try {//w  w w .ja v a  2 s.c om
        String tableName = System.getProperty("SESSIONTABLE");
        String keyPrefix = System.getProperty("PARAM3");

        ScanRequest scanRequest = new ScanRequest(tableName).withSelect("ALL_ATTRIBUTES");

        if (!keyPrefix.isEmpty()) {
            Map<String, Condition> scanFilter = new HashMap<String, Condition>();
            scanFilter.put("Key", new Condition().withAttributeValueList(new AttributeValue().withS(keyPrefix))
                    .withComparisonOperator("BEGINS_WITH"));
            scanRequest.withScanFilter(scanFilter);
        }

        return dynamoDbClient.scan(scanRequest).getItems();
    } catch (Exception ex) {
        labController.logMessageToPage("getImageItems Error: " + ex.getMessage() + ":" + ex.getStackTrace());
        return null;
    }
}