Kafka Connect: Split route field path once instead of per record#16655
Open
wombatu-kun wants to merge 1 commit into
Open
Kafka Connect: Split route field path once instead of per record#16655wombatu-kun wants to merge 1 commit into
wombatu-kun wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
When routing by a field (static routing with
iceberg.tables.route-field, or dynamic routing),SinkWriterextracted the route value for every record viaRecordUtils.extractFromRecordValue(value, routeField), which re-parsed the dotted field path withSplitter.on('.').splitToList(routeField)on each call. The route field is fixed for the connector's lifetime, so this re-parse is pure per-record overhead.This splits the path once in the
SinkWriterconstructor and adds aRecordUtils.extractFromRecordValue(Object, List<String>)overload that takes the already-split path; the existingStringoverload now delegates to it, so other callers are unchanged. Behavior is identical.A throwaway A/B microbench over the whole
extractFromRecordValuemethod (2M iterations x 9 trials, median; baseline = currentStringoverload that splits per call, optimized =Listoverload with the path split once) showed:keydata.id.keykeydata.id.keyThat is roughly 47 ns saved per record for a single-segment route field and ~120-130 ns for a three-segment path, paid once per record on the routing path. The numbers are indicative wall-clock from a microbench, not JMH.
Existing
TestSinkWriterandTestRecordUtilscover both routing modes and the extraction overloads.