in emr-dynamodb-hadoop/src/main/java/org/apache/hadoop/dynamodb/DynamoDBUtil.java [166:197]
private static int getAttributeSizeBytes(AttributeValue att) throws UnsupportedEncodingException {
int byteSize = 0;
if (att.getN() != null) {
byteSize += att.getN().getBytes(CHARACTER_ENCODING).length;
} else if (att.getS() != null) {
byteSize += att.getS().getBytes(CHARACTER_ENCODING).length;
} else if (att.getB() != null) {
byteSize += att.getB().array().length;
} else if (att.getNS() != null) {
for (String number : att.getNS()) {
byteSize += number.getBytes(CHARACTER_ENCODING).length;
}
} else if (att.getSS() != null) {
for (String string : att.getSS()) {
byteSize += string.getBytes(CHARACTER_ENCODING).length;
}
} else if (att.getBS() != null) {
for (ByteBuffer byteBuffer : att.getBS()) {
byteSize += byteBuffer.array().length;
}
} else if (att.getM() != null) {
for (Entry<String, AttributeValue> entry : att.getM().entrySet()) {
byteSize += getAttributeSizeBytes(entry.getValue())
+ entry.getKey().getBytes(CHARACTER_ENCODING).length;
}
} else if (att.getL() != null) {
for (AttributeValue entry : att.getL()) {
byteSize += getAttributeSizeBytes(entry);
}
}
return byteSize;
}