Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

I was using below option
BatchGetItemSpec batchGetItemSpec = new BatchGetItemSpec();
BatchGetItemRequest batchGetItemRequest = new BatchGetItemRequest();
QuerySpec querySpec = new QuerySpec();

        Map<String, KeysAndAttributes> requestItem = new HashMap<>();

        Map<String, AttributeValue> attributeValueMap = new HashMap<>();
         for (GetScoopService.GeneratedKeys key: keys) {
             attributeValueMap.put("pk",new AttributeValue(getPartitionKey(key)));

         }
        requestItem.put(sskTableName,new KeysAndAttributes().withKeys(attributeValueMap));

        batchGetItemRequest.setRequestItems(requestItem);

But here " attributeValueMap.put("pk",new AttributeValue(getPartitionKey(key)));" I m adding this in map so its overriding everything one single item is requested. I need to reqeust a single table against a PK for different PK values in batch query. PLease share some java samples

You must be logged in to vote

Replies: 1 comment

Comment options

So keys in KeysAndAttributes takes a Collection: new KeysAndAttributes().withKeys(<Collection>)

It'd look something like this (based on your sample code):

        for (GetScoopService.GeneratedKeys key: keys) {
            listOfKeys.add(Map.of("pk", new AttributeValue(getPartitionKey(key))));
        }

        requestItem.put(tableName, new KeysAndAttributes().withKeys(listOfKeys));
        batchGetItemRequest.setRequestItems(requestItem);
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.