Sindhu
Sindhu

Reputation: 2582

Set limits in DyanmoDb batchWriteItem

Is there any way we can set threshold limits for batchWriteItem in dynamoDb : if TableWriteItems has reached 25 items limit ,insert data (this can be done by checking size of tableWriteItems ,but what if we never received 25 items from backend for a significant time )

What I am looking here is :-> if TableWriteItems has reached either of these three conditions : timeLimit , itemSizeLimit or dataSizeLimit ,insert one batch in dynamoDb

TableWriteItems testTableWriteItems = new TableWriteItems("TestTable");
            for (int i = 1; i <= 25; i++) {

                PrimaryKey primaryKey = new PrimaryKey();
                primaryKey.addComponent("testId", testId.toString());
                primaryKey.addComponent("testName", "testbatch"+i);
                Item item = new Item().withPrimaryKey(primaryKey);

                testTableWriteItems.addItemToPut(item);

            }



            BatchWriteItemOutcome outcome = dynamoDB.batchWriteItem(testTableWriteItems);

Upvotes: 0

Views: 209

Answers (1)

Alexander Patrikalakis
Alexander Patrikalakis

Reputation: 5205

The DynamoDB Import-Export Tool has a sample solution for batching items up in groups of 25 items. You could expand that using the Item sizing method in the DynamoDB Storage Backend for Titan to implement the size limit. Finally, you would need a second thread to stroke the work queue and fire BatchWriteItem requests if the queue size does not change for a while.

Upvotes: 1

Related Questions