boolean detect(Object record) {
            if (lastRecordSize == -1 || sampling()) {
                lastRecordSize = ObjectSizeCalculator.getObjectSize(record);
            }
            totalSize += lastRecordSize;
            return totalSize > this.batchSizeBytes;
        }
Tool to detect if to flush out the existing buffer.
Sampling the record to compute the size with 0.01 percentage.
inlong-sort/sort-flink/sort-flink-v1.15/sort-connectors/hudi/src/main/java/org/apache/inlong/sort/hudi/sink/StreamWriteFunction.java