Repository navigation
Conversation
…ation Serialize the five metadata fields directly as StringData and retain the deserialized values. Preserve the wire format for data and index rows, and skip the absent payload when copying an index-only row.
| stringDataSerializer.serialize(StringData.fromString(record.getOperationType()), target); | ||
| stringDataSerializer.serialize(record.recordKey(), target); | ||
| stringDataSerializer.serialize(record.partitionPath(), target); | ||
| stringDataSerializer.serialize(record.fileId(), target); |
There was a problem hiding this comment.
setFileId(null) now causes StringDataSerializer.serialize to throw NullPointerException during shuffle. I ran the same call against the base and it round-tripped as the four-character string "null" via String.valueOf. Could we preserve that behavior by normalizing the Java string inputs in the constructors and setters, and add a round-trip test that passes an actual Java null? The current compatibility test starts with the string literal.
| * For serialization/deserialization {@code HoodieFlinkInternalRowTypeInfo} and {@link HoodieFlinkInternalRowSerializer} are used | ||
| * to optimize serialization/deserialization costs. | ||
| */ | ||
| @Getter |
There was a problem hiding this comment.
Could we make the five raw StringData getters package-private? On Flink 1.20.1, starting with the key "key", row.recordKey().toBytes()[0] = 'x' changes the bytes used by this serializer. row.getRecordKey() still returns "key", while deserializing that same row yields "xey". This lets the partitioner and the downstream operator see different keys. The serializer can access package-private getters directly.
| } | ||
| return record; | ||
| RowData rowData = rowDataSerializer.deserialize(source); | ||
| return new HoodieFlinkInternalRow(false, recordKey, partition, fileId, instantTime, operationType, rowData); |
There was a problem hiding this comment.
Keeping all five deserialized fields increases the live heap of the record-index minibatch. On Flink 1.20.1/JDK 17, JOL measured 516,992 bytes reachable from a list of 1,000 freshly deserialized rows on the base and 1,044,976 bytes on this commit (one INT payload, distinct keys, one partition, and three empty metadata fields per row). Even an empty field retains its own byte array and Flink memory-segment objects until the batch is flushed. Could we share an empty StringData for zero-length metadata and remeasure the buffered batch alongside the allocation benchmark?
| this(recordKey, partitionPath, "", "", "", false, rowData); | ||
| } | ||
|
|
||
| public HoodieFlinkInternalRow(String recordKey, String partitionPath, String operationType, RowData rowData) { |
There was a problem hiding this comment.
Could we keep this four-argument constructor and the existing getRowData() getter? A caller compiled against the base throws NoSuchMethodError for each when run against this commit. Keeping both signatures preserves binary compatibility and lets the existing sink and test callers stay as they are. The serializer optimization only needs direct access to the five metadata fields.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21050 +/- ##
============================================
- Coverage 81.06% 80.32% -0.75%
+ Complexity 37278 36923 -355
============================================
Files 2608 2608
Lines 150876 150895 +19
Branches 18931 18936 +5
============================================
- Hits 122302 121199 -1103
- Misses 20063 21224 +1161
+ Partials 8511 8472 -39
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Describe the issue this Pull Request addresses
Closes #21049
HoodieFlinkInternalRowalready stores its five metadata fields as FlinkStringData. During upsert shuffle, the serializer converts each field through a JavaStringon both write and read. These conversions allocate extra objects for every row.Summary and Changelog
StringDatavalues directly and retain the values returned by Flink's deserializer. This preserves the existing wire format for both data rows and index-only rows.serializer.copy(indexRecord)throwing aNullPointerException. The copy now preserves the metadata fields and skips the absentRowDatapayload.Stringgetters for metadata, migrate payload access fromgetRowData()torowData(), and remove the four-argument data-row constructor used only by repository tests.Impact
A single-threaded benchmark on Flink 1.20.1 and JDK 17.0.19 deserialized a row, read all five metadata fields through their Java
Stringgetters, and serialized it again. Each implementation ran in six fresh JVMs using the same 125-byte row.These figures measure the serializer loop. Both implementations produced identical bytes.
Risk Level
Low. The main risks are changing the shuffle wire format or retaining bytes from a reusable input buffer. Tests compare the serialized output with independently constructed legacy bytes and overwrite the input buffer before checking the restored row. All five tests in
TestHoodieFlinkInternalRowSerializerpassed on Flink 1.20.1.External code that directly uses
getRowData()or the removed constructor onHoodieFlinkInternalRowmust migrate and recompile.Documentation Update
none
Contributor's checklist