List of usage examples for com.amazonaws.services.dynamodbv2.model ProjectionType INCLUDE
ProjectionType INCLUDE
To view the source code for com.amazonaws.services.dynamodbv2.model ProjectionType INCLUDE.
Click Source Link
From source file:io.venable.amazonaws.dynamo.table.builder.ProjectionBuilderImpl.java
License:Apache License
@Override public T attributes(Collection<String> names) { projection.setProjectionType(ProjectionType.INCLUDE); projection.setNonKeyAttributes(names); return parent; }
From source file:jp.classmethod.aws.dynamodb.DynamoDbRepository.java
License:Open Source License
/** * Creates a GSI configuration object/*from w w w.jav a 2s .c o m*/ * * @param name name of the index object to create * @param hashKey hash key of the index * @param rangeKey range key of the index * @param nonKeyAttributes determines the projection type and top level projected attributes. * if null, ALL attributes are projected. if an empty list, KEYS_ONLY are projected. * if the list has elements, only the elements INCLUDED in the list are projected * @return a description of a global secondary index that can be used to create a table. */ protected static GlobalSecondaryIndex createGlobalSecondaryIndex(String name, String hashKey, String rangeKey, List<String> nonKeyAttributes) { Preconditions.checkArgument(false == Strings.isNullOrEmpty(hashKey)); final KeySchemaElement hks = new KeySchemaElement(hashKey, KeyType.HASH); final Projection projection; if (nonKeyAttributes == null) { projection = new Projection().withProjectionType(ProjectionType.ALL); } else if (nonKeyAttributes.isEmpty()) { projection = new Projection().withProjectionType(ProjectionType.KEYS_ONLY); } else { projection = new Projection().withProjectionType(ProjectionType.INCLUDE) .withNonKeyAttributes(nonKeyAttributes); } final GlobalSecondaryIndex result = new GlobalSecondaryIndex().withIndexName(name) .withProjection(projection); if (Strings.isNullOrEmpty(rangeKey)) { result.withKeySchema(hks); } else { result.withKeySchema(hks, new KeySchemaElement(rangeKey, KeyType.RANGE)); } return result; }