/** * Set the hash and range key attributes of the item. * <p> * For a hash-only table, you only need to provide the hash attribute. For a hash-and-range table, you must provide * both. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param hashKey * a map entry including the name and value of the primary hash key. * @param rangeKey * a map entry including the name and value of the primary range key, or null if it is a hash-only table. */ public GetItemRequest withKey(java.util.Map.Entry<String, AttributeValue> hashKey, java.util.Map.Entry<String, AttributeValue> rangeKey) throws IllegalArgumentException { setKey(hashKey, rangeKey); return this; }
/** * <p> * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item to * retrieve. * </p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only * need to provide a value for the partition key. For a composite primary key, you must provide values for both the * partition key and the sort key. * </p> * * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. * @return Returns a reference to this object so that method calls can be chained together. */ public GetItemRequest withKey(java.util.Map<String, AttributeValue> key) { setKey(key); return this; }
/** * Set the hash and range key attributes of the item. * <p> * For a hash-only table, you only need to provide the hash attribute. For a hash-and-range table, you must provide * both. * * @param hashKey * a map entry including the name and value of the primary hash key. * @param rangeKey * a map entry including the name and value of the primary range key, or null if it is a hash-only table. */ public void setKey(java.util.Map.Entry<String, AttributeValue> hashKey, java.util.Map.Entry<String, AttributeValue> rangeKey) throws IllegalArgumentException { java.util.HashMap<String, AttributeValue> key = new java.util.HashMap<String, AttributeValue>(); if (hashKey != null) { key.put(hashKey.getKey(), hashKey.getValue()); } else { throw new IllegalArgumentException("hashKey must be non-null object."); } if (rangeKey != null) { key.put(rangeKey.getKey(), rangeKey.getValue()); } setKey(key); }
/** * Constructs a new GetItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table containing the requested item. * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. */ public GetItemRequest(String tableName, java.util.Map<String, AttributeValue> key) { setTableName(tableName); setKey(key); }
/** * Constructs a new GetItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table containing the requested item. * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. * @param consistentRead * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly * consistent reads; otherwise, the operation uses eventually consistent reads. */ public GetItemRequest(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { setTableName(tableName); setKey(key); setConsistentRead(consistentRead); }
@Override public <T extends Object> T load(T keyObject, DynamoDBMapperConfig config) { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) keyObject.getClass(); config = mergeConfig(config); final DynamoDBMapperTableModel<T> model = getTableModel(clazz, config); String tableName = getTableName(clazz, keyObject, config); GetItemRequest rq = new GetItemRequest() .withRequestMetricCollector(config.getRequestMetricCollector()); Map<String, AttributeValue> key = model.convertKey(keyObject); rq.setKey(key); rq.setTableName(tableName); rq.setConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT); GetItemResult item = db.getItem(applyUserAgent(rq)); Map<String, AttributeValue> itemAttributes = item.getItem(); if ( itemAttributes == null ) { return null; } T object = privateMarshallIntoObject( toParameters(itemAttributes, clazz, tableName, config)); return object; }
/** * Constructs a new GetItemRequest object. Callers should use the setter or * fluent setter (with...) methods to initialize any additional object * members. * * @param tableName <p> * The name of the table containing the requested item. * </p> * @param key <p> * A map of attribute names to <code>AttributeValue</code> * objects, representing the primary key of the item to retrieve. * </p> * <p> * For the primary key, you must provide all of the attributes. * For example, with a simple primary key, you only need to * provide a value for the partition key. For a composite primary * key, you must provide values for both the partition key and * the sort key. * </p> */ public GetItemRequest(String tableName, java.util.Map<String, AttributeValue> key) { setTableName(tableName); setKey(key); }
Boolean consistentRead) { setTableName(tableName); setKey(key); setConsistentRead(consistentRead);
GetItemRequest getItemRequest = new GetItemRequest(); getItemRequest.setTableName(tableName); getItemRequest.setKey(key); return getItem(getItemRequest);
GetItemRequest getItemRequest = new GetItemRequest(); getItemRequest.setTableName(tableName); getItemRequest.setKey(key); getItemRequest.setConsistentRead(consistentRead); return getItem(getItemRequest);
/** * Set the hash and range key attributes of the item. * <p> * For a hash-only table, you only need to provide the hash attribute. For a hash-and-range table, you must provide * both. * <p> * Returns a reference to this object so that method calls can be chained together. * * @param hashKey * a map entry including the name and value of the primary hash key. * @param rangeKey * a map entry including the name and value of the primary range key, or null if it is a hash-only table. */ public GetItemRequest withKey(java.util.Map.Entry<String, AttributeValue> hashKey, java.util.Map.Entry<String, AttributeValue> rangeKey) throws IllegalArgumentException { setKey(hashKey, rangeKey); return this; }
/** * <p> * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item to * retrieve. * </p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you only * need to provide a value for the partition key. For a composite primary key, you must provide values for both the * partition key and the sort key. * </p> * * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. * @return Returns a reference to this object so that method calls can be chained together. */ public GetItemRequest withKey(java.util.Map<String, AttributeValue> key) { setKey(key); return this; }
rq.setKey(key); rq.setTableName(tableName); rq.setConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT);
public GetPointRequest(GeoPoint geoPoint, AttributeValue rangeKeyValue) { getItemRequest = new GetItemRequest(); getItemRequest.setKey(new HashMap<String, AttributeValue>()); this.geoPoint = geoPoint; this.rangeKeyValue = rangeKeyValue; }
/** * Constructs a new GetItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table containing the requested item. * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. */ public GetItemRequest(String tableName, java.util.Map<String, AttributeValue> key) { setTableName(tableName); setKey(key); }
/** * Set the hash and range key attributes of the item. * <p> * For a hash-only table, you only need to provide the hash attribute. For a hash-and-range table, you must provide * both. * * @param hashKey * a map entry including the name and value of the primary hash key. * @param rangeKey * a map entry including the name and value of the primary range key, or null if it is a hash-only table. */ public void setKey(java.util.Map.Entry<String, AttributeValue> hashKey, java.util.Map.Entry<String, AttributeValue> rangeKey) throws IllegalArgumentException { java.util.HashMap<String, AttributeValue> key = new java.util.HashMap<String, AttributeValue>(); if (hashKey != null) { key.put(hashKey.getKey(), hashKey.getValue()); } else { throw new IllegalArgumentException("hashKey must be non-null object."); } if (rangeKey != null) { key.put(rangeKey.getKey(), rangeKey.getValue()); } setKey(key); }
/** * Constructs a new GetItemRequest object. Callers should use the setter or fluent setter (with...) methods to * initialize any additional object members. * * @param tableName * The name of the table containing the requested item. * @param key * A map of attribute names to <code>AttributeValue</code> objects, representing the primary key of the item * to retrieve.</p> * <p> * For the primary key, you must provide all of the attributes. For example, with a simple primary key, you * only need to provide a value for the partition key. For a composite primary key, you must provide values * for both the partition key and the sort key. * @param consistentRead * Determines the read consistency model: If set to <code>true</code>, then the operation uses strongly * consistent reads; otherwise, the operation uses eventually consistent reads. */ public GetItemRequest(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { setTableName(tableName); setKey(key); setConsistentRead(consistentRead); }
/** * Makes a GetItemRequest for a given attribute. * @param attr Attribute name * @return GetItemRequest */ private GetItemRequest makeItemRequestFor(final String attr) { final GetItemRequest request = new GetItemRequest(); request.setTableName(this.name); request.setAttributesToGet(Collections.singletonList(attr)); request.setKey(this.attributes.only(this.keys)); request.setReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL); request.setConsistentRead(true); return request; }
/** * Makes a GetItemRequest for a given attribute. * @param attr Attribute name * @return GetItemRequest */ private GetItemRequest makeItemRequestFor(final String attr) { final GetItemRequest request = new GetItemRequest(); request.setTableName(this.name); request.setAttributesToGet(Collections.singletonList(attr)); request.setKey(this.attributes.only(this.keys)); request.setReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL); request.setConsistentRead(true); return request; }
@Override public <T extends Object> T load(T keyObject, DynamoDBMapperConfig config) { @SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) keyObject.getClass(); config = mergeConfig(config); final DynamoDBMapperTableModel<T> model = getTableModel(clazz, config); String tableName = getTableName(clazz, keyObject, config); GetItemRequest rq = new GetItemRequest() .withRequestMetricCollector(config.getRequestMetricCollector()); Map<String, AttributeValue> key = model.convertKey(keyObject); rq.setKey(key); rq.setTableName(tableName); rq.setConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT); GetItemResult item = db.getItem(applyUserAgent(rq)); Map<String, AttributeValue> itemAttributes = item.getItem(); if ( itemAttributes == null ) { return null; } T object = privateMarshallIntoObject( toParameters(itemAttributes, clazz, tableName, config)); return object; }