Use vector cursors when possible in MSQ#18305
Merged
gianm merged 11 commits intoapache:masterfrom Jul 31, 2025
Merged
Conversation
gianm
reviewed
Jul 29, 2025
| { | ||
| if (hasMultipleValues) { | ||
| Object object = getObject(); | ||
| ArrayList arrayList = (ArrayList) object; |
Contributor
There was a problem hiding this comment.
This is brittle, it assumes that the underlying object is always going to be an ArrayList. At least use plain List. You should also handle the case here where the underlying object is null or String. I think this can happen with some underlying selectors.
Contributor
Author
There was a problem hiding this comment.
Added branches for these cases. I haven't been able to find a test case that that returns a string here, so I haven't added one yet.
| { | ||
| Object object = getObject(); | ||
| if (hasMultipleValues) { | ||
| ArrayList arrayList = (ArrayList) object; |
Contributor
There was a problem hiding this comment.
Same as getRow, you should handle null, String, and List for the underlying objects.
gianm
approved these changes
Jul 31, 2025
gianm
added a commit
to gianm/druid
that referenced
this pull request
Aug 5, 2025
Follow-up to apache#18305. Fixes a bug where calling ShimCursor's makeDimensionSelector on a non-string type would throw an error. Now, it has behavior similar to QueryableIndexCursor: - Uses ValueTypes.makeNumericWrappingDimensionSelector on numeric types, casting the numbers to strings. - Returns a nil selector for array and complex types. The new tests verify selector compatibility more extensively.
cryptoe
pushed a commit
that referenced
this pull request
Aug 6, 2025
Follow-up to #18305. Fixes a bug where calling ShimCursor's makeDimensionSelector on a non-string type would throw an error. Now, it has behavior similar to QueryableIndexCursor: - Uses ValueTypes.makeNumericWrappingDimensionSelector on numeric types, casting the numbers to strings. - Returns a nil selector for array and complex types. The new tests verify selector compatibility more extensively.
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.
Add a "shim" cursor implementation, which is an adapter from Cursor to Vector Cursor. This allows vector cursors to be used as normal cursors, by simply reading a vector of values and stepping through it as the cursor advances.
Shim cursors have been used in MSQ
ScanQueryFrameProcessorto use vector cursors when possible.Also does some minor refactoring around
MSQTestBase, to make MSQ tests actually use the modules registered by thegetCoreModule()call in the test framework.Main changes
ShimCursorto adaptVectorCursorto theCursorinterface. (processing/src/main/java/org/apache/druid/segment/shim/ShimCursor.java)ShimColumnSelectorFactoryto create appropriate cursors. (processing/src/main/java/org/apache/druid/segment/shim/ShimColumnSelectorFactory.java)ShimMultiValueDimensionSelectorfor multi-value dimension vector selectors. (processing/src/main/java/org/apache/druid/segment/shim/ShimMultiValueDimensionSelector.java)ShimNumericColumnValueSelectorfor numeric vector selectors. (processing/src/main/java/org/apache/druid/segment/shim/ShimNumericColumnValueSelector.java)ShimObjectColumnValueSelectorfor object vector selectors. (processing/src/main/java/org/apache/druid/segment/shim/ShimObjectColumnValueSelector.java)This PR has: