gpt4 book ai didi

java - DynamoDB - JAVA - 使用低级 API 的 BatchWrite

转载 作者:行者123 更新时间:2023-12-02 02:43:29 25 4
gpt4 key购买 nike

我想知道我们是否可以使用 DynamoDB for java 的低级 API 执行批量写入/更新。

提前致谢!

最佳答案

是的。像这样的事情:

Map<String, List<WriteRequest>> writeRequestItems = new HashMap<String, List<WriteRequest>>();
Map<String, AttributeValue> userItem1 = new HashMap<String, AttributeValue>();
userItem1.put("userId", new AttributeValue().withS("1"));
userItem1.put("name", new AttributeValue().withS("Alex"));
Map<String, AttributeValue> userItem2 = new HashMap<String,AttributeValue>();
userItem2.put("userId", new AttributeValue().withS("2"));
userItem2.put("name", new AttributeValue().withS("Jonh"));
List<WriteRequest> userList = new ArrayList<WriteRequest>();
userList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(userItem1)));
userList.add(new WriteRequest().withPutRequest(new PutRequest().withItem(userItem2)));
writeRequestItems.put("User", userList);
BatchWriteItemRequest batchWriteItemRequest = new BatchWriteItemRequest(writeRequestItems);
BatchWriteItemResult batchWriteItemResult = dynamoDBClient.batchWriteItem(batchWriteItemRequest);

关于java - DynamoDB - JAVA - 使用低级 API 的 BatchWrite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45046749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com