@Override public GetItemOutcome getItemOutcome(KeyAttribute... primaryKeyComponents) { return doLoadItem(new GetItemSpec() .withPrimaryKey(primaryKeyComponents)); }
private GetItemOutcome doLoadItem(GetItemSpec spec) { String tableName = getTable().getTableName(); // Set up the key attributes GetItemRequest req = spec.getRequest() .withTableName(tableName) .withKey(InternalUtils.toAttributeValueMap(spec.getKeyComponents())) .withExpressionAttributeNames(spec.getNameMap()); GetItemResult result = getClient().getItem(req); return new GetItemOutcome(result); }
@Override public GetItemOutcome getItemOutcome(PrimaryKey primaryKey, String projectionExpression, Map<String, String> nameMap) { return doLoadItem(new GetItemSpec() .withPrimaryKey(primaryKey) .withProjectionExpression(projectionExpression) .withNameMap(nameMap)); }
/** * Get a consistent view of an item. * @param path path to look up in the database * @param path entry * @return the result * @throws IOException failure */ @Retries.RetryTranslated private Item getConsistentItem(final Path path) throws IOException { PrimaryKey key = pathToKey(path); final GetItemSpec spec = new GetItemSpec() .withPrimaryKey(key) .withConsistentRead(true); // strictly consistent read return readOp.retry("get", path.toString(), true, () -> table.getItem(spec)); }
public Student getStudent(String id) throws JsonParseException, JsonMappingException, IOException { Table t = db.getTable(studentTableName); GetItemSpec gio = new GetItemSpec() .withPrimaryKey("id", id); Item item = t.getItem(gio); Student student = mapper.readValue(StringEscapeUtils.unescapeJson(item.getJSON("payload").substring(1)), Student.class); return student; }
/** * When a projection expression is specified, the corresponding name-map can * optionally be specified via { {@link #withNameMap(Map)}. (Note * attributes-to-get must not be specified if a projection expression has * been specified.) */ public GetItemSpec withProjectionExpression(String projectionExpression) { getRequest().setProjectionExpression(projectionExpression); return this; }
@Override public GetItemOutcome getItemOutcome(PrimaryKey primaryKey, String projectionExpression, Map<String, String> nameMap) { return doLoadItem(new GetItemSpec() .withPrimaryKey(primaryKey) .withProjectionExpression(projectionExpression) .withNameMap(nameMap)); }
public static void retrieveItem(String threadId, String replyDateTime) throws IOException { Table table = dynamoDB.getTable(tableName); GetItemSpec spec = new GetItemSpec() .withPrimaryKey("Id", threadId, "ReplyDateTime", replyDateTime) .withConsistentRead(true); Item item = table.getItem(spec); // Uncompress the reply message and print String uncompressed = uncompressString(ByteBuffer.wrap(item.getBinary("ExtendedMessage"))); System.out.println("Reply message:\n" + " Id: " + item.getString("Id") + "\n" + " ReplyDateTime: " + item.getString("ReplyDateTime") + "\n" + " PostedBy: " + item.getString("PostedBy") + "\n" + " Message: " + item.getString("Message") + "\n" + " ExtendedMessage (uncompressed): " + uncompressed + "\n"); }
public GetItemSpec withAttributesToGet(String ... attrNames) { if (attrNames == null) getRequest().setAttributesToGet(null); else getRequest().setAttributesToGet(Arrays.asList(attrNames)); return this; }
@Override public GetItemOutcome getItemOutcome(PrimaryKey primaryKey) { return doLoadItem(new GetItemSpec() .withPrimaryKey(primaryKey)); }
private GetItemOutcome doLoadItem(GetItemSpec spec) { String tableName = getTable().getTableName(); // Set up the key attributes GetItemRequest req = spec.getRequest() .withTableName(tableName) .withKey(InternalUtils.toAttributeValueMap(spec.getKeyComponents())) .withExpressionAttributeNames(spec.getNameMap()); GetItemResult result = getClient().getItem(req); return new GetItemOutcome(result); }
public GetItemSpec withConsistentRead(boolean consistentRead) { getRequest().setConsistentRead(consistentRead); return this; }
@Override public GetItemOutcome getItemOutcome(PrimaryKey primaryKey) { return doLoadItem(new GetItemSpec() .withPrimaryKey(primaryKey)); }
public GetItemSpec withReturnConsumedCapacity(ReturnConsumedCapacity capacity) { getRequest().setReturnConsumedCapacity(capacity); return this; }
@Override public GetItemOutcome getItemOutcome(KeyAttribute... primaryKeyComponents) { return doLoadItem(new GetItemSpec() .withPrimaryKey(primaryKeyComponents)); }
public String getProjectionExpression() { return getRequest().getProjectionExpression(); }
/** * Returns the DynamoDB get item spec for the specified key. * * @param key The key. * * @return The get item spec. */ GetItemSpec resolveGetItemSpec(final Object key) { if (applyRangeKey) { return new GetItemSpec().withPrimaryKey( itemTransformer.getHashKeyAttributeName(), resolveHashKey(key), rangeKeyName, rangeKeyValue); } return new GetItemSpec().withPrimaryKey( itemTransformer.getHashKeyAttributeName(), resolveHashKey(key)); }
public Boolean isConsistentRead() { return getRequest().isConsistentRead(); }
public List<String> getAttributesToGet() { return getRequest().getAttributesToGet(); }
public String getReturnConsumedCapacity() { return getRequest().getReturnConsumedCapacity(); }