-
Notifications
You must be signed in to change notification settings - Fork 3.8k
add hasNulls to ColumnCapabilities, ColumnAnalysis #10219
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f1c5b2d
add isNullable to ColumnCapabilities, ColumnAnalysis
clintropolis 69e772e
better builder
clintropolis 1126f15
fix segment metadata queries in integration tests
clintropolis 1dddd40
Merge remote-tracking branch 'upstream/master' into column-nullable
clintropolis 0455c2f
adjustments
clintropolis 5d89085
cleanup
clintropolis 9087a73
fix spotbugs
clintropolis 82ff3e4
treat unknown as true in segmentmetadata
clintropolis bdd6b07
rename to hasNulls, add docs
clintropolis 09d452b
fixup
clintropolis 336dbbb
test the dim indexer selector isNull fix for numeric columns
clintropolis b8c1145
fixes
clintropolis 2a21abb
oof
clintropolis 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
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
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
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
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 |
|---|---|---|
|
|
@@ -100,6 +100,11 @@ public Map<String, ColumnAnalysis> analyze(Segment segment) | |
|
|
||
| Map<String, ColumnAnalysis> columns = new TreeMap<>(); | ||
|
|
||
| Function<String, ColumnCapabilities> adapterCapabilitesFn = | ||
| storageAdapter instanceof IncrementalIndexStorageAdapter | ||
| ? ((IncrementalIndexStorageAdapter) storageAdapter)::getSnapshotColumnCapabilities | ||
| : storageAdapter::getColumnCapabilities; | ||
|
|
||
| for (String columnName : columnNames) { | ||
| final ColumnHolder columnHolder = index == null ? null : index.getColumnHolder(columnName); | ||
| final ColumnCapabilities capabilities; | ||
|
|
@@ -108,11 +113,7 @@ public Map<String, ColumnAnalysis> analyze(Segment segment) | |
| } else { | ||
| // this can be removed if we get to the point where IncrementalIndexStorageAdapter.getColumnCapabilities | ||
| // accurately reports the capabilities | ||
| if (storageAdapter instanceof IncrementalIndexStorageAdapter) { | ||
| capabilities = ((IncrementalIndexStorageAdapter) storageAdapter).getSnapshotColumnCapabilities(columnName); | ||
| } else { | ||
| capabilities = storageAdapter.getColumnCapabilities(columnName); | ||
| } | ||
| capabilities = adapterCapabilitesFn.apply(columnName); | ||
| } | ||
|
|
||
| final ColumnAnalysis analysis; | ||
|
|
@@ -146,7 +147,7 @@ public Map<String, ColumnAnalysis> analyze(Segment segment) | |
| } | ||
|
|
||
| // Add time column too | ||
| ColumnCapabilities timeCapabilities = storageAdapter.getColumnCapabilities(ColumnHolder.TIME_COLUMN_NAME); | ||
| ColumnCapabilities timeCapabilities = adapterCapabilitesFn.apply(ColumnHolder.TIME_COLUMN_NAME); | ||
| if (timeCapabilities == null) { | ||
| timeCapabilities = ColumnCapabilitiesImpl.createSimpleNumericColumnCapabilities(ValueType.LONG); | ||
| } | ||
|
|
@@ -192,6 +193,7 @@ private ColumnAnalysis analyzeNumericColumn( | |
| return new ColumnAnalysis( | ||
| capabilities.getType().name(), | ||
| capabilities.hasMultipleValues().isTrue(), | ||
| capabilities.hasNulls().isMaybeTrue(), // if we don't know for sure, then we should plan to check for nulls | ||
|
Contributor
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. This comment doesn't make a lot of sense in the context of SegmentAnalyzer. It shouldn't "know" what the fields are being used for, so it shouldn't "know" they're going to be used to check for nulls somewhere higher up the chain. Maybe a better thing to do would be:
|
||
| size, | ||
| null, | ||
| null, | ||
|
|
@@ -242,6 +244,7 @@ private ColumnAnalysis analyzeStringColumn( | |
| return new ColumnAnalysis( | ||
| capabilities.getType().name(), | ||
| capabilities.hasMultipleValues().isTrue(), | ||
| capabilities.hasNulls().isMaybeTrue(), // if we don't know for sure, then we should plan to check for nulls | ||
| size, | ||
| analyzingCardinality() ? cardinality : 0, | ||
| min, | ||
|
|
@@ -319,6 +322,7 @@ public Long accumulate(Long accumulated, Cursor cursor) | |
| return new ColumnAnalysis( | ||
| capabilities.getType().name(), | ||
| capabilities.hasMultipleValues().isTrue(), | ||
| capabilities.hasNulls().isMaybeTrue(), // if we don't know for sure, then we should plan to check for nulls | ||
| size, | ||
| cardinality, | ||
| min, | ||
|
|
@@ -335,6 +339,7 @@ private ColumnAnalysis analyzeComplexColumn( | |
| { | ||
| try (final ComplexColumn complexColumn = columnHolder != null ? (ComplexColumn) columnHolder.getColumn() : null) { | ||
| final boolean hasMultipleValues = capabilities != null && capabilities.hasMultipleValues().isTrue(); | ||
| final boolean hasNulls = capabilities != null && capabilities.hasNulls().isMaybeTrue(); | ||
| long size = 0; | ||
|
|
||
| if (analyzingSize() && complexColumn != null) { | ||
|
|
@@ -345,7 +350,7 @@ private ColumnAnalysis analyzeComplexColumn( | |
|
|
||
| final Function<Object, Long> inputSizeFn = serde.inputSizeFn(); | ||
| if (inputSizeFn == null) { | ||
| return new ColumnAnalysis(typeName, hasMultipleValues, 0, null, null, null, null); | ||
| return new ColumnAnalysis(typeName, hasMultipleValues, hasNulls, 0, null, null, null, null); | ||
| } | ||
|
|
||
| final int length = complexColumn.getLength(); | ||
|
|
@@ -357,6 +362,7 @@ private ColumnAnalysis analyzeComplexColumn( | |
| return new ColumnAnalysis( | ||
| typeName, | ||
| hasMultipleValues, | ||
| hasNulls, | ||
| size, | ||
| null, | ||
| null, | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize you just copied this code from somewhere else, but is there a way we can do this without
instanceof? Maybe a new method on StorageAdapter with some nice javadocs? This code is pretty brittle otherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh, I think introduced the ugly
instanceofin the first place in a previous PR to fix a different bug. I have a plan to not need this, since it is only necessary for incremental index adapter, so I hope this code is rather temporary but the changes are too big to be part of this patch.I would rather not introduce a new method to storage adapter specifically for incremental index adapter, and would prefer to address it when I eliminate the need for it, if that is cool with you. If you disagree and feel strongly about it though, I can introduce a temporary method for it now, and just remove it in the follow-up.