我有一个带有散列和范围复杂键的表。
我可以使用查询项目 GetItem
来自AWS SDK for Java。
该 GetItem
如果找不到对象,则返回null,或者将项目作为a返回 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解析器并自己解析响应以快速检查项目是否已返回。
谢谢