Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug : Batch write using spark report items greater than 400KB #150

Open
maxmithun opened this issue Jul 27, 2021 · 0 comments
Open

Bug : Batch write using spark report items greater than 400KB #150

maxmithun opened this issue Jul 27, 2021 · 0 comments

Comments

@maxmithun
Copy link

maxmithun commented Jul 27, 2021

This method is defined as static so that mulitple tasks running in an executor will update the itemSize sharing the same variable. which incorrectly update and exceeds the size

static int getItemSizeBytes(Map<String, AttributeValue> item) {
   try {
     int itemSize = 0;
     for (Entry<String, AttributeValue> entry : item.entrySet()) {
       itemSize += entry.getKey() != null ? entry.getKey().getBytes(CHARACTER_ENCODING).length : 0;
       itemSize += entry.getValue() != null ? getAttributeSizeBytes(entry.getValue()) : 0;
     }
     return itemSize;
   } catch (UnsupportedEncodingException e) {
     throw new RuntimeException(e);
   }
 }

static int getItemSizeBytes(Map<String, AttributeValue> item) {

Called from method putBatch

int itemSizeBytes = DynamoDBUtil.getItemSizeBytes(item);

https://github.com/awslabs/emr-dynamodb-connector/blob/master/emr-dynamodb-hadoop/src/main/java/org/apache/hadoop/dynamodb/DynamoDBClient.java#L204

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant