-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Unnest functionality for Druid #13268
Changes from 4 commits
4e686a8
f354dd7
f9ac767
9f98b12
31612fc
035c423
6a9b0d7
ba55890
7333da5
90073f6
f6fc1aa
bbc66f5
e146ebb
bb22a92
1908242
3de1161
d1a884a
401a9b2
bce6ffe
240afe2
9821c53
b7ab781
5fd3dd7
576dbcc
e56b0b2
bb66e59
8f71b81
e312f91
0e3ede4
edff9cd
321536f
5e8c38a
2ecf23b
81b674a
bd467dc
30c2897
44c9955
5659760
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,31 @@ | |
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
|
||
/** | ||
* The cursor to help unnest MVDs without dictionary encoding. | ||
* Consider a segment has 2 rows | ||
* ['a', 'b', 'c'] | ||
* ['d', 'e'] | ||
* | ||
* The baseCursor points to the row ['a', 'b', 'c'] | ||
* while the unnestCursor with each call of advance() moves over individual elements. | ||
* | ||
* unnestCursor.advance() -> 'a' | ||
* unnestCursor.advance() -> 'b' | ||
* unnestCursor.advance() -> 'c' | ||
* unnestCursor.advance() -> 'd' (advances base cursor first) | ||
* unnestCursor.advance() -> 'e' | ||
* | ||
* | ||
* The allowSet if available helps skip over elements which are not in the allowList by moving the cursor to | ||
* the next available match. | ||
* | ||
* The index reference points to the index of each row that the unnest cursor is accessing through currentVal | ||
* The index ranges from 0 to the size of the list in each row which is held in the unnestListForCurrentRow | ||
* | ||
* The needInitialization flag sets up the initial values of unnestListForCurrentRow at the beginning of the segment | ||
* | ||
*/ | ||
public class ColumnarValueUnnestCursor implements Cursor | ||
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. can you add some javadocs here about this class? 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. Added javadocs 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. super nitpick, but why not just call this thing what it is doing, e.g. |
||
{ | ||
private final Cursor baseCursor; | ||
|
@@ -69,7 +94,11 @@ public ColumnSelectorFactory getColumnSelectorFactory() | |
@Override | ||
public DimensionSelector makeDimensionSelector(DimensionSpec dimensionSpec) | ||
{ | ||
throw new UnsupportedOperationException("Dimension selector not applicable for column value selector"); | ||
if (!outputName.equals(dimensionSpec.getDimension())) { | ||
return baseColumSelectorFactory.makeDimensionSelector(dimensionSpec); | ||
} | ||
throw new UnsupportedOperationException( | ||
"Dimension selector not applicable for column value selector for column " + outputName); | ||
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. More design nits:
|
||
} | ||
|
||
@Override | ||
|
@@ -203,6 +232,11 @@ public void reset() | |
baseCursor.reset(); | ||
} | ||
|
||
/** | ||
* This method populates the objects when the base cursor moves to the next row | ||
* | ||
* @param firstRun flag to populate one time object references to hold values for unnest cursor | ||
*/ | ||
private void getNextRow(boolean firstRun) | ||
{ | ||
currentVal = this.columnValueSelector.getObject(); | ||
|
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.
this isn't specific to multi-value dimensions, since this also handles
ARRAY
typed selectors