Example usage for com.amazonaws.services.dynamodbv2.document TableKeysAndAttributes addPrimaryKey

List of usage examples for com.amazonaws.services.dynamodbv2.document TableKeysAndAttributes addPrimaryKey

Introduction

In this page you can find the example usage for com.amazonaws.services.dynamodbv2.document TableKeysAndAttributes addPrimaryKey.

Prototype

public TableKeysAndAttributes addPrimaryKey(PrimaryKey primaryKey) 

Source Link

Document

Adds a primary key to be included in the batch get-item operation.

Usage

From source file:com.clicktravel.infrastructure.persistence.aws.dynamodb.DynamoDocumentStoreTemplate.java

License:Apache License

private <T extends Item> List<T> executeQuery(final KeySetQuery query, final Class<T> itemClass) {
    final ItemConfiguration itemConfiguration = getItemConfiguration(itemClass);
    final String tableName = databaseSchemaHolder.schemaName() + "." + itemConfiguration.tableName();
    // max 100 keys per fetch
    final List<List<ItemId>> split_ids = split(new ArrayList<ItemId>(query.itemIds()), 100);
    final List<T> fetchedItems = new ArrayList<T>();
    for (final List<ItemId> ids : split_ids) {
        final TableKeysAndAttributes keys = new TableKeysAndAttributes(tableName);
        for (final ItemId id : ids) {
            keys.addPrimaryKey(getPrimaryKey(id, itemConfiguration));
        }/* w  w w. j  av  a  2 s.  c o  m*/
        processBatchRead(dynamoDBClient.batchGetItem(keys), fetchedItems, tableName, itemClass);
    }
    return fetchedItems;
}