Skip to content

Commit

Permalink
[Fix] Fix SeaTunnelRow::getBytesSize not support map interface (#5990)
Browse files Browse the repository at this point in the history
Hisoka-X authored Dec 11, 2023
1 parent d4a323e commit 1184a11
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -269,6 +269,15 @@ private int getBytesForValue(Object v) {
}
return rowSize;
default:
if (v instanceof Map) {
int mapSize = 0;
for (Map.Entry<?, ?> entry : ((Map<?, ?>) v).entrySet()) {
mapSize +=
getBytesForValue(entry.getKey())
+ getBytesForValue(entry.getValue());
}
return mapSize;
}
throw new UnsupportedOperationException("Unsupported type: " + clazz);
}
}
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
import org.junit.jupiter.api.Test;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -96,4 +97,11 @@ void testWithLinkHashMap() {
SeaTunnelRow row = new SeaTunnelRow(new Object[] {map});
Assertions.assertEquals(8, row.getBytesSize());
}

@Test
void testWithMapInterface() {
Map<String, String> map = Collections.singletonMap("key", "value");
SeaTunnelRow row = new SeaTunnelRow(new Object[] {map});
Assertions.assertEquals(8, row.getBytesSize());
}
}

0 comments on commit 1184a11

Please sign in to comment.