refactor(io): extract shared Arrow writer base for Lance and Vortex#19254
Draft
yihua wants to merge 1 commit into
Draft
refactor(io): extract shared Arrow writer base for Lance and Vortex#19254yihua wants to merge 1 commit into
yihua wants to merge 1 commit into
Conversation
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the issue this Pull Request addresses
The Lance and Vortex base writers duplicate ~85-90% of their structure (Arrow buffering, dual flush triggers, allocator lifecycle, bloom filter support, empty-file close handling): 362 and 345 lines that must be maintained in lockstep. This PR extracts the shared boilerplate so the next Arrow-native format only implements its FFI-specific hooks. Writer-side only; reader-side extraction is a follow-up.
Summary and Changelog
HoodieBaseArrowWriter(org.apache.hudi.io.arrow, hudi-hadoop-common, ungated): owns the Arrow child-allocator lifecycle,VectorSchemaRootmanagement, row buffering, the dual flush trigger (row-count batch size or byte watermark), bloom-filter and min/max key support,getDataSize, empty-file-on-close handling, and close ordering with exception suppression. Imports only Arrow and Hudi types (nodev.vortex, no Lance native types), so it compiles on the Java 8 target.HoodieBaseLanceWritershrinks 362 to 161 lines andHoodieBaseVortexWriter345 to 184, each keeping only format-specific hooks (Lance native writer calls; Vortex C Data Interface export and the dedicated native allocator with its tolerated one-time schema-export retention). The Vortex writer stays in the JDK-17-gated source root.initializeFormatWriter,writeBatch,closeFormatWriter,getFormatName,isFormatWriterInitialized, plus optionalfinalizeFooterMetadata(Lance footer),closeFormatResources, andcloseAfterAllocator(Vortex native allocator).addFooterMetadata,getWrittenRecordCount,getDataSizeare intact, the Spark/Flink subclasses are unmodified, and the reflectiveHoodieSparkVortexWriter.newWriterfactory contract is untouched.Impact
Behavior-preserving deduplication of the Arrow writer path. Validated: Lance tests (TestLanceDataSource 61, TestHoodieSparkLanceWriter 23, TestHoodieSparkLanceReader 16) and the Vortex round-trip (2) all pass on JDK 17; the Java 11 Spark chain and Flink client compile; checkstyle clean.
Risk Level
medium: touches the write path of two formats, mitigated by the full Lance and Vortex test runs above and an adversarial equivalence review of flush triggers, close ordering, and allocator lifecycle.
Documentation Update
none
Contributor's checklist