-
Notifications
You must be signed in to change notification settings - Fork 985
DRILL-6071: Limit batch size for flatten operator #1091
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
Closed
Closed
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -93,8 +93,18 @@ public static class ColumnSize { | |
|
|
||
| public final int elementCount; | ||
|
|
||
| /** | ||
| * Size of the top level value vector. For map and repeated list, | ||
| * this is just size of offset vector. | ||
| */ | ||
| public int dataSize; | ||
|
|
||
| /** | ||
| * Total size of the column includes the sum total of memory for all | ||
| * value vectors representing the column. | ||
| */ | ||
| public int netSize; | ||
|
|
||
| /** | ||
| * The estimated, average number of elements per parent value. | ||
| * Always 1 for a non-repeated type. For a repeated type, | ||
|
|
@@ -131,9 +141,15 @@ public ColumnSize(ValueVector v, String prefix) { | |
| break; | ||
| default: | ||
| dataSize = v.getPayloadByteCount(valueCount); | ||
| stdSize = TypeHelper.getSize(metadata.getType()) * elementCount; | ||
| try { | ||
| stdSize = TypeHelper.getSize(metadata.getType()) * elementCount; | ||
| } catch (Exception e) { | ||
| // For unsupported types, just set stdSize to 0. | ||
| stdSize = 0; | ||
| } | ||
| } | ||
| estSize = safeDivide(dataSize, valueCount); | ||
| netSize = v.getPayloadByteCount(valueCount); | ||
| } | ||
|
|
||
| @SuppressWarnings("resource") | ||
|
|
@@ -154,8 +170,14 @@ private int buildRepeated(ValueVector v) { | |
| return childCount; | ||
| } | ||
|
|
||
| @SuppressWarnings("resource") | ||
| private void buildList(ValueVector v) { | ||
| @SuppressWarnings("resource") | ||
| // complex ListVector cannot be casted to RepeatedListVector. | ||
| // check the mode. | ||
| if (v.getField().getDataMode() != DataMode.REPEATED) { | ||
| dataSize = v.getPayloadByteCount(valueCount); | ||
| return; | ||
| } | ||
| UInt4Vector offsetVector = ((RepeatedListVector) v).getOffsetVector(); | ||
| dataSize = offsetVector.getPayloadByteCount(valueCount); | ||
| } | ||
|
|
@@ -232,6 +254,10 @@ else if (width > 0) { | |
| } | ||
| } | ||
|
|
||
| public static ColumnSize getColumn(ValueVector v, String prefix) { | ||
| return new ColumnSize(v, prefix); | ||
| } | ||
|
|
||
| public static final int MAX_VECTOR_SIZE = ValueVector.MAX_BUFFER_SIZE; // 16 MiB | ||
|
|
||
| private List<ColumnSize> columnSizes = new ArrayList<>(); | ||
|
|
@@ -380,14 +406,18 @@ private void measureColumn(ValueVector v, String prefix) { | |
| // vectors do consume space, so visit columns recursively. | ||
|
|
||
| switch (v.getField().getType().getMinorType()) { | ||
| case MAP: | ||
| expandMap((AbstractMapVector) v, prefix + v.getField().getName() + "."); | ||
| break; | ||
| case LIST: | ||
| expandList((RepeatedListVector) v, prefix + v.getField().getName() + "."); | ||
| break; | ||
| default: | ||
| v.collectLedgers(ledgers); | ||
| case MAP: | ||
| expandMap((AbstractMapVector) v, prefix + v.getField().getName() + "."); | ||
| break; | ||
| case LIST: | ||
|
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. Here, check mode. If mode is REPEATED, this is a RepeatedListVector and should go down one path. Otherwise, it is a ListVector (possible list of unions) and should go down another path. |
||
| // complex ListVector cannot be casted to RepeatedListVector. | ||
| // do not expand the list if it is not repeated mode. | ||
| if (v.getField().getDataMode() == DataMode.REPEATED) { | ||
| expandList((RepeatedListVector) v, prefix + v.getField().getName() + "."); | ||
| } | ||
| break; | ||
| default: | ||
| v.collectLedgers(ledgers); | ||
| } | ||
|
|
||
| netRowWidth += colSize.estSize; | ||
|
|
||
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.
The memory manager is an excellent idea. But, it is private. This means we are passing up one of the key benefits of this kind of manager: the ability to unit test it separately without needing actual memory or batches. (See the external sort for an example.)
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.
Memory manager actually requires incoming batch. All the tests in testOutputBatch are exercising this code. I went down the path of writing tests just for memory manager. But, they are redundant and doing the same thing I am doing with the other tests. Also, did not see much point in validating output row count, since we are interested in batch size more than row count. Please let me know if you feel otherwise and I can include those tests as well.