public GetItemSpec() { super(new GetItemRequest()); }
/** * Simplified method form for invoking the GetItem operation. * * @see #getItemAsync(GetItemRequest) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key)); }
/** * Simplified method form for invoking the GetItem operation with an AsyncHandler. * * @see #getItemAsync(GetItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key, com.amazonaws.handlers.AsyncHandler<GetItemRequest, GetItemResult> asyncHandler) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key), asyncHandler); }
/** * Simplified method form for invoking the GetItem operation. * * @see #getItemAsync(GetItemRequest) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key)); }
/** * Simplified method form for invoking the GetItem operation with an AsyncHandler. * * @see #getItemAsync(GetItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key, com.amazonaws.handlers.AsyncHandler<GetItemRequest, GetItemResult> asyncHandler) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key), asyncHandler); }
@Override public GetItemResult getItem(String tableName, java.util.Map<String, AttributeValue> key) { return getItem(new GetItemRequest().withTableName(tableName).withKey(key)); }
@Override public GetItemResult getItem(String tableName, java.util.Map<String, AttributeValue> key) { return getItem(new GetItemRequest().withTableName(tableName).withKey(key)); }
/** * Simplified method form for invoking the GetItem operation. * * @see #getItemAsync(GetItemRequest) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key).withConsistentRead(consistentRead)); }
/** * Simplified method form for invoking the GetItem operation. * * @see #getItemAsync(GetItemRequest) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key).withConsistentRead(consistentRead)); }
/** * Simplified method form for invoking the GetItem operation with an AsyncHandler. * * @see #getItemAsync(GetItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead, com.amazonaws.handlers.AsyncHandler<GetItemRequest, GetItemResult> asyncHandler) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key).withConsistentRead(consistentRead), asyncHandler); }
/** * Simplified method form for invoking the GetItem operation with an AsyncHandler. * * @see #getItemAsync(GetItemRequest, com.amazonaws.handlers.AsyncHandler) */ @Override public java.util.concurrent.Future<GetItemResult> getItemAsync(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead, com.amazonaws.handlers.AsyncHandler<GetItemRequest, GetItemResult> asyncHandler) { return getItemAsync(new GetItemRequest().withTableName(tableName).withKey(key).withConsistentRead(consistentRead), asyncHandler); }
@Override public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("readkey: " + key + " from table: " + table); } GetItemRequest req = new GetItemRequest(table, createPrimaryKey(key)); req.setAttributesToGet(fields); req.setConsistentRead(consistentRead); GetItemResult res; try { res = dynamoDB.getItem(req); } catch (AmazonServiceException ex) { LOGGER.error(ex); return Status.ERROR; } catch (AmazonClientException ex) { LOGGER.error(ex); return CLIENT_ERROR; } if (null != res.getItem()) { result.putAll(extractResult(res.getItem())); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Result: " + res.toString()); } } return Status.OK; }
@Override public GetItemResult getItem(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { return getItem(new GetItemRequest().withTableName(tableName).withKey(key).withConsistentRead(consistentRead)); }
@Override public GetItemResult getItem(String tableName, java.util.Map<String, AttributeValue> key, Boolean consistentRead) { return getItem(new GetItemRequest().withTableName(tableName).withKey(key).withConsistentRead(consistentRead)); }
GetItemRequest greq = new GetItemRequest(table, createPrimaryKey(startkey)); greq.setAttributesToGet(fields);
@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; }
@Override public Optional<Map<String, Object>> getAttributes(RequestEnvelope envelope) throws PersistenceException { String partitionKey = partitionKeyGenerator.apply(envelope); GetItemRequest request = new GetItemRequest() .withTableName(tableName) .withKey(Collections.singletonMap(partitionKeyName, new AttributeValue().withS(partitionKey))) .withConsistentRead(true); Map<String, AttributeValue> result = null; try { result = dynamoDb.getItem(request).getItem(); } catch (ResourceNotFoundException e) { throw new PersistenceException(String.format("Table %s does not exist or is in the process of being created", tableName), e); } catch (AmazonDynamoDBException e) { throw new PersistenceException("Failed to retrieve attributes from DynamoDB", e); } if (result != null && result.containsKey(attributesKeyName)) { Map<String, Object> attributes = ItemUtils.toSimpleMapValue(result.get(attributesKeyName).getM()); return Optional.of(attributes); } return Optional.empty(); }
@Override public <T> T getConfig(String project, String configName, Class<T> clazz) { Map<String, AttributeValue> item = dynamoDBClient.getItem(new GetItemRequest() .withTableName(tableConfig.getTableName()) .withKey(new SimpleImmutableEntry<>("project", new AttributeValue(project)), new SimpleImmutableEntry<>("id", new AttributeValue(configName))) .withAttributesToGet("value") .withConsistentRead(true)).getItem(); if (item == null) { return null; } String value = item.get("value").getS(); return value == null ? null : JsonHelper.read(value, clazz); }
@Override public MaterializedView getMaterializedView(String project, String tableName) { Map<String, AttributeValue> item = dynamoDBClient.getItem(new GetItemRequest().withTableName(tableConfig.getTableName()) .withAttributesToGet("value") .withKey(of( "project", new AttributeValue(project), "type_table_name", new AttributeValue("materialized_" + tableName)))).getItem(); if (item == null) { throw new NotExistsException("Materialized view"); } return JsonHelper.read(item.get("value").getS(), MaterializedView.class); }
private Document getItem(Key key, GetItemOperationConfig config) { final GetItemRequest request = new GetItemRequest(tableName, key); if (config != null) { request.setConsistentRead(config.isConsistentRead()); if (config.getAttributesToGet() != null && config.getAttributesToGet().size() > 0) { request.setAttributesToGet(config.getAttributesToGet()); } } Table.appendDynamoDBDocumentUserAgentString(request); final GetItemResult response = this.client.getItem(request); final Map<String, AttributeValue> item = response.getItem(); if (item == null || item.size() == 0) { return null; } final Document returnDocument = fromAttributeMap(item); returnDocument.commit(); return returnDocument; }