我有一个带有哈希和范围复杂键的表。
我可以使用GetItem
AWS SDK for Java 查询项目。如果GetItem
没有找到对象,则返回 null,或者将项目作为Map<String, AttributeValue>
.
我正在寻找最快的方法来检查对象是否确实存在
我在想可能提供.withAttributesToGet
诸如:
GetItemResult result = dbClient.getItem(new GetItemRequest().
withTableName(TABLE_NAME).
withKey(new Key(new AttributeValue().withS(hashKey),
new AttributeValue().withS(rangeKey))).
withAttributesToGet(new ArrayList<String>()));
Map<String, AttributeValue> item = result.getItem();
return (item != null);
另一个优化是不使用 SDK JSON 解析器,自己解析响应来快速检查项目是否返回。
谢谢