hailin0 commented on code in PR #5502:
URL: https://github.com/apache/seatunnel/pull/5502#discussion_r1327200132


##########
seatunnel-api/src/main/java/org/apache/seatunnel/api/table/type/SeaTunnelRow.java:
##########
@@ -97,6 +100,180 @@ public boolean isNullAt(int pos) {
         return this.fields[pos] == null;
     }
 
+    public int getBytesSize(SeaTunnelRowType rowType) {
+        if (size == 0) {
+            int s = 0;
+            for (int i = 0; i < fields.length; i++) {
+                s += getBytesForValue(fields[i], rowType.getFieldType(i));
+            }
+            size = s;
+        }
+        return size;
+    }
+
+    /** faster version of {@link #getBytesSize(SeaTunnelRowType)}. */
+    private int getBytesForValue(Object v, SeaTunnelDataType<?> dataType) {
+        if (v == null) {
+            return 0;
+        }
+        SqlType sqlType = dataType.getSqlType();
+        switch (sqlType) {
+            case STRING:
+                return ((String) v).length();

Review Comment:
   +1
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to