/** * Adds a hash-only primary key to be included in the batch get-item * operation. * * @param hashKeyName name of the hash key attribute name * @param hashKeyValue name of the hash key value * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashOnlyPrimaryKey( String hashKeyName, Object hashKeyValue) { this.addPrimaryKey(new PrimaryKey(hashKeyName, hashKeyValue)); return this; }
/** * Adds a primary key to be included in the batch get-item operation. A * primary key could consist of either a hash-key or both a * hash-key and a range-key depending on the schema of the table. */ public TableKeysAndAttributes addPrimaryKey(PrimaryKey primaryKey) { if (primaryKey != null) { if (primaryKeys == null) primaryKeys = new ArrayList<PrimaryKey>(); checkConsistency(primaryKey); this.primaryKeys.add(primaryKey); } return this; }
for (TableKeysAndAttributes tableKeysAndAttributes: tableKeysAndAttributesCol) { final Set<String> attrNames = tableKeysAndAttributes.getAttributeNames(); final List<PrimaryKey> pks = tableKeysAndAttributes.getPrimaryKeys(); final List<Map<String,AttributeValue>> keys = new ArrayList<Map<String,AttributeValue>>(pks.size()); for (PrimaryKey pk: pks) final KeysAndAttributes keysAndAttrs = new KeysAndAttributes() .withAttributesToGet(attrNames) .withConsistentRead(tableKeysAndAttributes.isConsistentRead()) .withKeys(keys) .withProjectionExpression(tableKeysAndAttributes.getProjectionExpression()) .withExpressionAttributeNames(tableKeysAndAttributes.getNameMap()) requestItems.put(tableKeysAndAttributes.getTableName(), keysAndAttrs);
TableKeysAndAttributes tableKeysAndAttributes = new TableKeysAndAttributes(table); tableKeysAndAttributes.addHashOnlyPrimaryKey(hashKeyName, hashKeyValue); } else { tableKeysAndAttributes.addHashAndRangePrimaryKey(hashKeyName, hashKeyValue, rangeKeyName, rangeKeyValue);
TableKeysAndAttributes forumTableKeysAndAttributes = new TableKeysAndAttributes(forumTableName); forumTableKeysAndAttributes.addHashOnlyPrimaryKeys("Name", "Amazon S3", "Amazon DynamoDB"); TableKeysAndAttributes threadTableKeysAndAttributes = new TableKeysAndAttributes(threadTableName); threadTableKeysAndAttributes.addHashAndRangePrimaryKeys("ForumName", "Subject", "Amazon DynamoDB","DynamoDB Thread 1", "Amazon DynamoDB","DynamoDB Thread 2",
TableKeysAndAttributes tableKeysAndAttributes = new TableKeysAndAttributes(table); tableKeysAndAttributes.addHashOnlyPrimaryKey(hashKeyName, hashKeyValue); } else { tableKeysAndAttributes.addHashAndRangePrimaryKey(hashKeyName, hashKeyValue, rangeKeyName, rangeKeyValue);
for (TableKeysAndAttributes tableKeysAndAttributes: tableKeysAndAttributesCol) { final Set<String> attrNames = tableKeysAndAttributes.getAttributeNames(); final List<PrimaryKey> pks = tableKeysAndAttributes.getPrimaryKeys(); final List<Map<String,AttributeValue>> keys = new ArrayList<Map<String,AttributeValue>>(pks.size()); for (PrimaryKey pk: pks) final KeysAndAttributes keysAndAttrs = new KeysAndAttributes() .withAttributesToGet(attrNames) .withConsistentRead(tableKeysAndAttributes.isConsistentRead()) .withKeys(keys) .withProjectionExpression(tableKeysAndAttributes.getProjectionExpression()) .withExpressionAttributeNames(tableKeysAndAttributes.getNameMap()) requestItems.put(tableKeysAndAttributes.getTableName(), keysAndAttrs);
/** * Adds multiple hash-only primary keys to be included in the batch get-item * operation. * * @param hashKeyName name of the hash key attribute name * @param hashKeyValues multiple hash key values * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashOnlyPrimaryKeys(String hashKeyName, Object ... hashKeyValues) { for (Object hashKeyValue: hashKeyValues) { this.addPrimaryKey(new PrimaryKey(hashKeyName, hashKeyValue)); } return this; }
/** * Adds a primary key to be included in the batch get-item operation. A * primary key could consist of either a hash-key or both a * hash-key and a range-key depending on the schema of the table. */ public TableKeysAndAttributes addPrimaryKey(PrimaryKey primaryKey) { if (primaryKey != null) { if (primaryKeys == null) primaryKeys = new ArrayList<PrimaryKey>(); checkConsistency(primaryKey); this.primaryKeys.add(primaryKey); } return this; }
/** * Adds a primary key (that consists of a hash-key and a range-key) to be * included in the batch get-item operation. * * @param hashKeyName hash key attribute name * @param hashKeyValue hash key value * @param rangeKeyName range key attribute name * @param rangeKeyValue range key value * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashAndRangePrimaryKey( String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue) { this.addPrimaryKey( new PrimaryKey() .addComponent(hashKeyName, hashKeyValue) .addComponent(rangeKeyName, rangeKeyValue)); return this; }
Object hashKeyValue = alternatingHashRangeKeyValues[i]; Object rangeKeyValue = alternatingHashRangeKeyValues[i+1]; this.addPrimaryKey( new PrimaryKey() .addComponent(hashKeyName, hashKeyValue)
/** * Adds a hash-only primary key to be included in the batch get-item * operation. * * @param hashKeyName name of the hash key attribute name * @param hashKeyValue name of the hash key value * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashOnlyPrimaryKey( String hashKeyName, Object hashKeyValue) { this.addPrimaryKey(new PrimaryKey(hashKeyName, hashKeyValue)); return this; }
/** * Adds multiple hash-only primary keys to be included in the batch get-item * operation. * * @param hashKeyName name of the hash key attribute name * @param hashKeyValues multiple hash key values * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashOnlyPrimaryKeys(String hashKeyName, Object ... hashKeyValues) { for (Object hashKeyValue: hashKeyValues) { this.addPrimaryKey(new PrimaryKey(hashKeyName, hashKeyValue)); } return this; }
Object hashKeyValue = alternatingHashRangeKeyValues[i]; Object rangeKeyValue = alternatingHashRangeKeyValues[i+1]; this.addPrimaryKey( new PrimaryKey() .addComponent(hashKeyName, hashKeyValue)
/** * Adds a primary key (that consists of a hash-key and a range-key) to be * included in the batch get-item operation. * * @param hashKeyName hash key attribute name * @param hashKeyValue hash key value * @param rangeKeyName range key attribute name * @param rangeKeyValue range key value * @return the current instance for method chaining purposes */ public TableKeysAndAttributes addHashAndRangePrimaryKey( String hashKeyName, Object hashKeyValue, String rangeKeyName, Object rangeKeyValue) { this.addPrimaryKey( new PrimaryKey() .addComponent(hashKeyName, hashKeyValue) .addComponent(rangeKeyName, rangeKeyValue)); return this; }