-
Notifications
You must be signed in to change notification settings - Fork 94
fix: DH-22265: increment Kafka column index for complex spec #7887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
devinrsmith
merged 5 commits into
deephaven:main
from
devinrsmith:dh-22265-index-chunks-correctly
Apr 13, 2026
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a74a338
fix: DH-22265: increment Kafka column index for complex spec
devinrsmith f3d4389
safety checks
devinrsmith cf130f0
remove extraneous line
devinrsmith 545e1b9
review response
devinrsmith 5dc6e69
remove warning logging
devinrsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -336,6 +336,45 @@ protected abstract KeyOrValueIngestData getIngestData( | |
| protected abstract KeyOrValueProcessor getProcessor( | ||
| TableDefinition tableDef, | ||
| KeyOrValueIngestData data); | ||
|
|
||
| private KeyOrValueIngestData ingestDataAndIncrement( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe: |
||
| KeyOrValue keyOrValue, | ||
| SchemaRegistryClient schemaRegistryClient, | ||
| Map<String, ?> configs, | ||
| MutableInt nextColumnIndexMut, | ||
| List<ColumnDefinition<?>> columnDefinitionsOut) { | ||
|
devinrsmith marked this conversation as resolved.
Outdated
|
||
| final int ixPre = nextColumnIndexMut.get(); | ||
| final int sizePre = columnDefinitionsOut.size(); | ||
| // It's unfortunate we have to do this; but the getIngestData signature and design of KeyOrValueSpec | ||
| // would need a breaking change to improve in these regards. | ||
| final KeyOrValueIngestData ingestData = getIngestData(keyOrValue, schemaRegistryClient, configs, | ||
| nextColumnIndexMut, columnDefinitionsOut); | ||
| final int addedIx = nextColumnIndexMut.get() - ixPre; | ||
| final int addedColumns = columnDefinitionsOut.size() - sizePre; | ||
| if (ingestData == null) { | ||
| // ignore case (or, possible a complex impl that chooses to return null when it's empty): | ||
|
devinrsmith marked this conversation as resolved.
Outdated
|
||
| // expecting no modifications | ||
| if (addedIx != 0 || addedColumns != 0) { | ||
| throw new IllegalStateException( | ||
| "KeyOrValueSpec getIngestData is modifying out-variables without returning ingest data"); | ||
| } | ||
| } else if (ingestData.isSimple()) { | ||
| // simple case: | ||
| // expecting exactly one increment and one column | ||
| if (addedIx != 1 || addedColumns != 1) { | ||
| throw new IllegalStateException( | ||
| "Simple KeyOrValueSpec getIngestData is not adding exactly one index or one column"); | ||
|
devinrsmith marked this conversation as resolved.
Outdated
|
||
| } | ||
| } else { | ||
| // complex case: | ||
| // expecting no increments - we'll increase the index based on any columns that were added | ||
| if (addedIx != 0) { | ||
| throw new IllegalStateException("Complex KeyOrValueSpec getIngestData is mutating the index"); | ||
| } | ||
| nextColumnIndexMut.getAndAdd(addedColumns); | ||
| } | ||
| return ingestData; | ||
| } | ||
| } | ||
|
|
||
| private static final KeyOrValueSpec FROM_PROPERTIES = new SimpleConsume(null, null); | ||
|
|
@@ -1273,10 +1312,10 @@ private static ConsumeStruct getConsumeStruct( | |
| cc.setColumnIndex.setColumnIndex(publisherParametersBuilder, nextColumnIndex.getAndIncrement()); | ||
| }); | ||
|
|
||
| final KeyOrValueIngestData keyIngestData = keySpec.getIngestData(KeyOrValue.KEY, | ||
| schemaRegistryClient, configs, nextColumnIndex, columnDefinitions); | ||
| final KeyOrValueIngestData valueIngestData = valueSpec.getIngestData(KeyOrValue.VALUE, | ||
| schemaRegistryClient, configs, nextColumnIndex, columnDefinitions); | ||
| final KeyOrValueIngestData keyIngestData = keySpec.ingestDataAndIncrement( | ||
| KeyOrValue.KEY, schemaRegistryClient, configs, nextColumnIndex, columnDefinitions); | ||
| final KeyOrValueIngestData valueIngestData = valueSpec.ingestDataAndIncrement( | ||
| KeyOrValue.VALUE, schemaRegistryClient, configs, nextColumnIndex, columnDefinitions); | ||
|
devinrsmith marked this conversation as resolved.
Outdated
|
||
|
|
||
| final TableDefinition tableDefinition = TableDefinition.of(columnDefinitions); | ||
| publisherParametersBuilder.setTableDefinition(tableDefinition); | ||
|
|
@@ -1670,6 +1709,10 @@ public static class KeyOrValueIngestData { | |
| public int simpleColumnIndex = NULL_COLUMN_INDEX; | ||
| public Function<Object, Object> toObjectChunkMapper = Function.identity(); | ||
| public Object extra; | ||
|
|
||
| private boolean isSimple() { | ||
| return simpleColumnIndex != NULL_COLUMN_INDEX; | ||
| } | ||
| } | ||
|
|
||
| private interface SetColumnIndex { | ||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.