for (Item item: itemsToPut) { writeRequests.add(new WriteRequest() .withPutRequest(new PutRequest() .withItem(toAttributeValues(item))));
toParameters(attributeValues, clazz, tableName, config); requestItems.add(tableName, new WriteRequest(new PutRequest(transformAttributes(parameters))));
public PutRequest unmarshall(JsonUnmarshallerContext context) throws Exception { PutRequest putRequest = new PutRequest(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) { return null; } while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("Item", targetDepth)) { context.nextToken(); putRequest.setItem(new MapUnmarshaller<String, AttributeValue>(context.getUnmarshaller(String.class), AttributeValueJsonUnmarshaller .getInstance()).unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return putRequest; }
@Override public List<Object> batchCreate(RequestContext context, List<User> users) { List<WriteRequest> collect = users.stream() .map(user -> new WriteRequest(new PutRequest(generatePutRequest(context.project, user.id, user.properties)))) .collect(Collectors.toList()); dynamoDBClient.batchWriteItem(new BatchWriteItemRequest().withRequestItems(ImmutableMap.of(context.project, collect))); return null; }
new PutRequest().withItem( transformAttributes(parameters))));
public PutRequest unmarshall(JsonUnmarshallerContext context) throws Exception { AwsJsonReader reader = context.getReader(); if (!reader.isContainer()) { reader.skipValue(); return null; } PutRequest putRequest = new PutRequest(); reader.beginObject(); while (reader.hasNext()) { String name = reader.nextName(); if (name.equals("Item")) { putRequest.setItem(new MapUnmarshaller<AttributeValue>( AttributeValueJsonUnmarshaller.getInstance() ) .unmarshall(context)); } else { reader.skipValue(); } } reader.endObject(); return putRequest; }
private List<WriteRequest> generateWriteRequests(List<String> keys) { return keys.stream() .map(key -> ImmutableMap.of(partitionKeyName, new AttributeValue(key), ATTRIBUTE_NAME, new AttributeValue(this.dataGenerator.getRandomValue()))) .map(item -> new PutRequest().withItem(item)) .map(put -> new WriteRequest().withPutRequest(put)) .collect(Collectors.toList()); }
public PutPointRequest(GeoPoint geoPoint, AttributeValue rangeKeyValue) { putItemRequest = new PutItemRequest(); putItemRequest.setItem(new HashMap<String, AttributeValue>()); putRequest = new PutRequest(); putRequest.setItem(new HashMap<String, AttributeValue>()); this.geoPoint = geoPoint; this.rangeKeyValue = rangeKeyValue; }
writeBatchList = writeBatchMap.get(tableName); writeBatchList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(item))); writeBatchMapSizeBytes += itemSizeBytes;
writeBatchList = writeBatchMap.get(tableName); writeBatchList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(item))); writeBatchMapSizeBytes += itemSizeBytes;
@Override public List<Map<String, AttributeValue>> emit(final UnmodifiableBuffer<Map<String, AttributeValue>> buffer) throws IOException { // Map of WriteRequests to records for reference Map<WriteRequest, Map<String, AttributeValue>> requestMap = new HashMap<WriteRequest, Map<String, AttributeValue>>(); List<Map<String, AttributeValue>> unproc = new ArrayList<Map<String, AttributeValue>>(); // Build a batch request with a record list List<WriteRequest> rList = new ArrayList<WriteRequest>(); List<Map<String, AttributeValue>> resultList; // Amazon DynamoDB only allows one operation per item in a bulk insertion (no duplicate items) Set<Map<String, AttributeValue>> uniqueItems = uniqueItems(buffer.getRecords()); for (Map<String, AttributeValue> item : uniqueItems) { WriteRequest wr = new WriteRequest().withPutRequest(new PutRequest().withItem(item)); // add to the map requestMap.put(wr, item); // add to the list of requests rList.add(wr); // Max of sixteen not to exceed maximum request size if (rList.size() == 16) { resultList = performBatchRequest(rList, requestMap); unproc.addAll(resultList); rList.clear(); } } resultList = performBatchRequest(rList, requestMap); unproc.addAll(resultList); LOG.info("Successfully emitted " + (buffer.getRecords().size() - unproc.size()) + " records into DynamoDB."); return unproc; }
@Override public List<Map<String, AttributeValue>> emit(final UnmodifiableBuffer<Map<String, AttributeValue>> buffer) throws IOException { // Map of WriteRequests to records for reference Map<WriteRequest, Map<String, AttributeValue>> requestMap = new HashMap<WriteRequest, Map<String, AttributeValue>>(); List<Map<String, AttributeValue>> unproc = new ArrayList<Map<String, AttributeValue>>(); // Build a batch request with a record list List<WriteRequest> rList = new ArrayList<WriteRequest>(); List<Map<String, AttributeValue>> resultList; // Amazon DynamoDB only allows one operation per item in a bulk insertion (no duplicate items) Set<Map<String, AttributeValue>> uniqueItems = uniqueItems(buffer.getRecords()); for (Map<String, AttributeValue> item : uniqueItems) { WriteRequest wr = new WriteRequest().withPutRequest(new PutRequest().withItem(item)); // add to the map requestMap.put(wr, item); // add to the list of requests rList.add(wr); // Max of sixteen not to exceed maximum request size if (rList.size() == 16) { resultList = performBatchRequest(rList, requestMap); unproc.addAll(resultList); rList.clear(); } } resultList = performBatchRequest(rList, requestMap); unproc.addAll(resultList); LOG.info("Successfully emitted " + (buffer.getRecords().size() - unproc.size()) + " records into DynamoDB."); return unproc; }
int i = 0; while (it.hasNext()) { PutRequest put = new PutRequest(it.next()); writeRequests.add(new WriteRequest(put));
Map<String, AttributeValue> row = toRow(object, null); setRowKey(getKeyForAppid(object.getId(), appid), row); reqs.add(new WriteRequest().withPutRequest(new PutRequest().withItem(row))); j++;
Map<String, AttributeValue> row = toRow(object, null); setRowKey(object.getId(), row); reqs.add(new WriteRequest().withPutRequest(new PutRequest().withItem(row))); j++;
Map<String, AttributeValue> row = toRow(object, null); setRowKey(getKeyForAppid(object.getId(), appid), row); reqs.add(new WriteRequest().withPutRequest(new PutRequest().withItem(row))); j++;
forumList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(forumItem))); requestItems.put("Forum", forumList); threadList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(threadItem)));
for (Item item: itemsToPut) { writeRequests.add(new WriteRequest() .withPutRequest(new PutRequest() .withItem(toAttributeValues(item))));
if(value.length == 0) value = EMPTY_VALUE; item.put("value", new AttributeValue().withB(ByteBuffer.wrap(value))); list.add(new WriteRequest().withPutRequest(new PutRequest(item)));
public PutRequest unmarshall(JsonUnmarshallerContext context) throws Exception { PutRequest putRequest = new PutRequest(); int originalDepth = context.getCurrentDepth(); String currentParentElement = context.getCurrentParentElement(); int targetDepth = originalDepth + 1; JsonToken token = context.getCurrentToken(); if (token == null) token = context.nextToken(); if (token == VALUE_NULL) { return null; } while (true) { if (token == null) break; if (token == FIELD_NAME || token == START_OBJECT) { if (context.testExpression("Item", targetDepth)) { context.nextToken(); putRequest.setItem(new MapUnmarshaller<String, AttributeValue>(context.getUnmarshaller(String.class), AttributeValueJsonUnmarshaller .getInstance()).unmarshall(context)); } } else if (token == END_ARRAY || token == END_OBJECT) { if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) { if (context.getCurrentDepth() <= originalDepth) break; } } token = context.nextToken(); } return putRequest; }