【发布时间】:2012-03-20 18:10:10
【问题描述】:
我有一个带有哈希和范围复杂键的表。
我可以使用 AWS SDK for Java 中的 GetItem 查询项目。
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解析器,自己解析响应,快速检查item是否返回。
谢谢
【问题讨论】:
-
“最快”是什么意思?这里的实际瓶颈是什么?
标签: java amazon-web-services amazon-dynamodb