ハッシュと範囲の複雑なキーを持つテーブルがあります。AWS SDK for Java
を使用してアイテムをクエリできます。オブジェクトが見つからない場合は null を返します。アイテムは として返されGetItem
ます。
オブジェクトが存在するかどう
かを確認するための最速のアプローチを探しています。GetItem
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);
もう 1 つの最適化は、SDK JSON パーサーを使用せずに自分で応答を解析して、アイテムが返されたかどうかをすばやく確認することです。
ありがとう