Refine search
/** * Gets the global secondary index. * @param indexName The index name. * @return The global secondary index or null. */ public GlobalSecondaryIndex globalSecondaryIndex(final String indexName) { if (!globalSecondaryIndexes.containsKey(indexName)) { return null; } final GlobalSecondaryIndex gsi = globalSecondaryIndexes.get(indexName); final GlobalSecondaryIndex copy = new GlobalSecondaryIndex().withIndexName(gsi.getIndexName()); copy.withProjection(new Projection().withProjectionType(gsi.getProjection().getProjectionType())); for (final KeySchemaElement key : gsi.getKeySchema()) { copy.withKeySchema(new KeySchemaElement(key.getAttributeName(), key.getKeyType())); } return copy; }
@Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getProjectionType() == null) ? 0 : getProjectionType().hashCode()); hashCode = prime * hashCode + ((getNonKeyAttributes() == null) ? 0 : getNonKeyAttributes().hashCode()); return hashCode; }
public Projection unmarshall(JsonUnmarshallerContext context) throws Exception { Projection projection = new Projection(); if (context.testExpression("ProjectionType", targetDepth)) { context.nextToken(); projection.setProjectionType(context.getUnmarshaller(String.class).unmarshall(context)); projection.setNonKeyAttributes(new ListUnmarshaller<String>(context.getUnmarshaller(String.class)).unmarshall(context));
public Map<String,LocalSecondaryIndex> localSecondaryIndexes() { final Map<String,LocalSecondaryIndex> map = new LinkedHashMap<String,LocalSecondaryIndex>(); for (final DynamoDBMapperFieldModel<T,Object> field : fields.values()) { for (final String indexName : field.localSecondaryIndexNames()) { final LocalSecondaryIndex lsi = new LocalSecondaryIndex().withIndexName(indexName); if (map.put(indexName, lsi) != null) { throw new DynamoDBMappingException( targetType.getSimpleName() + "[" + field.name() + "]; must not duplicate LSI " + indexName ); } lsi.withProjection(new Projection().withProjectionType(KEYS_ONLY)); lsi.withKeySchema(new KeySchemaElement(keys.get(HASH).name(), HASH)); lsi.withKeySchema(new KeySchemaElement(field.name(), RANGE)); } } if (map.isEmpty()) { return Collections.<String,LocalSecondaryIndex>emptyMap(); } return Collections.unmodifiableMap(map); }
keySchema.add(new KeySchemaElement() .withAttributeName(hashKeyName) .withKeyType(KeyType.HASH)); .withTableName(tableName) .withKeySchema(keySchema) .withProvisionedThroughput( new ProvisionedThroughput() .withReadCapacityUnits(readCapacityUnits) .withWriteCapacityUnits(writeCapacityUnits)); new KeySchemaElement().withAttributeName(hashKeyName).withKeyType(KeyType.HASH), new KeySchemaElement() .withAttributeName("PostedBy") .withKeyType(KeyType.RANGE)) .withProjection(new Projection() .withProjectionType(ProjectionType.KEYS_ONLY)));
keySchema.add(new KeySchemaElement().withAttributeName("videoid").withKeyType(KeyType.HASH)); keySchema.add(new KeySchemaElement().withAttributeName("category").withKeyType(KeyType.RANGE)); ProvisionedThroughput ptIndex = new ProvisionedThroughput().withReadCapacityUnits(150L) .withWriteCapacityUnits(150L); .withKeySchema(new KeySchemaElement().withAttributeName("category").withKeyType(KeyType.HASH), new KeySchemaElement().withAttributeName("videoid").withKeyType(KeyType.RANGE)) .withProjection(new Projection().withProjectionType(ProjectionType.ALL)); new ProvisionedThroughput().withReadCapacityUnits(100L).withWriteCapacityUnits(100L)) .withGlobalSecondaryIndexes(videoCategoryGsi);
/** * Get projection JSON element. * @param json JSON input * @return Projection */ private Projection projection(final JsonObject json) { final JsonObject projn = json.getJsonObject("Projection"); final Projection projection = new Projection() .withProjectionType(projn.getString("ProjectionType")); final Collection<String> nonkeyattrs = new LinkedList<String>(); if (projn.containsKey("NonKeyAttributes")) { for (final JsonValue nonkey : projn.getJsonArray("NonKeyAttributes")) { final JsonString nonKeyName = (JsonString) nonkey; nonkeyattrs.add(nonKeyName.getString()); } projection.setNonKeyAttributes(nonkeyattrs); } return projection; }
private boolean performCreate(DynamoDBEntityInformation<T, ID> entityInformation) throws TableNeverTransitionedToStateException, InterruptedException { Class<T> domainType = entityInformation.getJavaType(); CreateTableRequest ctr = mapper.generateCreateTableRequest(domainType); LOGGER.trace("Creating table {} for entity {}", ctr.getTableName(), domainType); ctr.setProvisionedThroughput(pt); if (ctr.getGlobalSecondaryIndexes() != null) { ctr.getGlobalSecondaryIndexes().forEach(gsi -> { gsi.setProjection(new Projection().withProjectionType(gsiProjectionType)); gsi.setProvisionedThroughput(pt); }); } boolean result = TableUtils.createTableIfNotExists(amazonDynamoDB, ctr); if (result) { TableUtils.waitUntilActive(amazonDynamoDB, ctr.getTableName()); LOGGER.debug("Created table {} for entity {}", ctr.getTableName(), domainType); } return result; }
withProjectionType(projectionType);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof CreateGlobalSecondaryIndexAction == false) return false; CreateGlobalSecondaryIndexAction other = (CreateGlobalSecondaryIndexAction) obj; if (other.getIndexName() == null ^ this.getIndexName() == null) return false; if (other.getIndexName() != null && other.getIndexName().equals(this.getIndexName()) == false) return false; if (other.getKeySchema() == null ^ this.getKeySchema() == null) return false; if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false) return false; if (other.getProjection() == null ^ this.getProjection() == null) return false; if (other.getProjection() != null && other.getProjection().equals(this.getProjection()) == false) return false; if (other.getProvisionedThroughput() == null ^ this.getProvisionedThroughput() == null) return false; if (other.getProvisionedThroughput() != null && other.getProvisionedThroughput().equals(this.getProvisionedThroughput()) == false) return false; return true; }
/** * <p> * Represents the non-key attribute names which will be projected into the index. * </p> * <p> * For local secondary indexes, the total count of <code>NonKeyAttributes</code> summed across all of the local * secondary indexes, must not exceed 20. If you project the same attribute into two different indexes, this counts * as two distinct attributes when determining the total. * </p> * * @param nonKeyAttributes * Represents the non-key attribute names which will be projected into the index.</p> * <p> * For local secondary indexes, the total count of <code>NonKeyAttributes</code> summed across all of the * local secondary indexes, must not exceed 20. If you project the same attribute into two different indexes, * this counts as two distinct attributes when determining the total. * @return Returns a reference to this object so that method calls can be chained together. */ public Projection withNonKeyAttributes(java.util.Collection<String> nonKeyAttributes) { setNonKeyAttributes(nonKeyAttributes); return this; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof LocalSecondaryIndex == false) return false; LocalSecondaryIndex other = (LocalSecondaryIndex) obj; if (other.getIndexName() == null ^ this.getIndexName() == null) return false; if (other.getIndexName() != null && other.getIndexName().equals(this.getIndexName()) == false) return false; if (other.getKeySchema() == null ^ this.getKeySchema() == null) return false; if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false) return false; if (other.getProjection() == null ^ this.getProjection() == null) return false; if (other.getProjection() != null && other.getProjection().equals(this.getProjection()) == false) return false; return true; }
if (getNonKeyAttributes() == null) { this.nonKeyAttributes = new java.util.ArrayList<String>(nonKeyAttributes.length);
.withTableName(tableName) .withProvisionedThroughput( new ProvisionedThroughput() .withReadCapacityUnits((long)1) .withWriteCapacityUnits((long) 1)); tableKeySchema.add(new KeySchemaElement() .withAttributeName("CustomerId") .withKeyType(KeyType.HASH)); tableKeySchema.add(new KeySchemaElement() .withAttributeName("OrderId") Projection projection = new Projection() .withProjectionType(ProjectionType.INCLUDE); ArrayList<String> nonKeyAttributes = new ArrayList<String>(); nonKeyAttributes.add("ProductCategory"); nonKeyAttributes.add("ProductName"); projection.setNonKeyAttributes(nonKeyAttributes); projection = new Projection().withProjectionType(ProjectionType.ALL);
public Map<String,GlobalSecondaryIndex> globalSecondaryIndexes() { final Map<String,GlobalSecondaryIndex> map = new LinkedHashMap<String,GlobalSecondaryIndex>(); for (final DynamoDBMapperFieldModel<T,Object> field : fields.values()) { for (final String indexName : field.globalSecondaryIndexNames(HASH)) { final GlobalSecondaryIndex gsi = new GlobalSecondaryIndex().withIndexName(indexName); if (map.put(indexName, gsi) != null) { throw new DynamoDBMappingException( targetType.getSimpleName() + "[" + field.name() + "]; must not duplicate GSI " + indexName ); } gsi.withProjection(new Projection().withProjectionType(KEYS_ONLY)); gsi.withKeySchema(new KeySchemaElement(field.name(), HASH)); } } for (final DynamoDBMapperFieldModel<T,Object> field : fields.values()) { for (final String indexName : field.globalSecondaryIndexNames(RANGE)) { final GlobalSecondaryIndex gsi = map.get(indexName); if (gsi == null) { throw new DynamoDBMappingException( targetType.getSimpleName() + "[" + field.name() + "]; no HASH key for GSI " + indexName ); } gsi.withKeySchema(new KeySchemaElement(field.name(), RANGE)); } } if (map.isEmpty()) { return Collections.<String,GlobalSecondaryIndex>emptyMap(); } return Collections.unmodifiableMap(map); }
withProjectionType(projectionType);
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof GlobalSecondaryIndexInfo == false) return false; GlobalSecondaryIndexInfo other = (GlobalSecondaryIndexInfo) obj; if (other.getIndexName() == null ^ this.getIndexName() == null) return false; if (other.getIndexName() != null && other.getIndexName().equals(this.getIndexName()) == false) return false; if (other.getKeySchema() == null ^ this.getKeySchema() == null) return false; if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false) return false; if (other.getProjection() == null ^ this.getProjection() == null) return false; if (other.getProjection() != null && other.getProjection().equals(this.getProjection()) == false) return false; if (other.getProvisionedThroughput() == null ^ this.getProvisionedThroughput() == null) return false; if (other.getProvisionedThroughput() != null && other.getProvisionedThroughput().equals(this.getProvisionedThroughput()) == false) return false; return true; }
setNonKeyAttributes(new java.util.ArrayList<String>(nonKeyAttributes.length));
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof LocalSecondaryIndexInfo == false) return false; LocalSecondaryIndexInfo other = (LocalSecondaryIndexInfo) obj; if (other.getIndexName() == null ^ this.getIndexName() == null) return false; if (other.getIndexName() != null && other.getIndexName().equals(this.getIndexName()) == false) return false; if (other.getKeySchema() == null ^ this.getKeySchema() == null) return false; if (other.getKeySchema() != null && other.getKeySchema().equals(this.getKeySchema()) == false) return false; if (other.getProjection() == null ^ this.getProjection() == null) return false; if (other.getProjection() != null && other.getProjection().equals(this.getProjection()) == false) return false; return true; }
final List<String> nonKeyAttributes = globalSecondaryIndex.getProjection().getNonKeyAttributes(); for (final String attributeName : nonKeyAttributes) { addColumnFromNonKeyAttribute(globalSecondaryIndex.getIndexName(), table, attributeName); final List<String> nonKeyAttributes = localSecondaryIndex.getProjection().getNonKeyAttributes(); for (final String attributeName : nonKeyAttributes) { addColumnFromNonKeyAttribute(localSecondaryIndex.getIndexName(), table, attributeName);