-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
PARQUET-869: Configurable record counts for block size checks #470
Open
rdblue
wants to merge
2
commits into
apache:master
Choose a base branch
from
rdblue:PARQUET-869-configurable-row-group-min-max-record-check
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
/* | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
|
@@ -45,8 +45,11 @@ public class ParquetProperties { | |
public static final boolean DEFAULT_IS_DICTIONARY_ENABLED = true; | ||
public static final WriterVersion DEFAULT_WRITER_VERSION = WriterVersion.PARQUET_1_0; | ||
public static final boolean DEFAULT_ESTIMATE_ROW_COUNT_FOR_PAGE_SIZE_CHECK = true; | ||
public static final int DEFAULT_MINIMUM_RECORD_COUNT_FOR_CHECK = 100; | ||
public static final int DEFAULT_MAXIMUM_RECORD_COUNT_FOR_CHECK = 10000; | ||
public static final boolean DEFAULT_ESTIMATE_ROW_COUNT_FOR_ROW_GROUP_SIZE_CHECK = true; | ||
public static final int DEFAULT_MINIMUM_RECORD_COUNT_FOR_PAGE_SIZE_CHECK = 100; | ||
public static final int DEFAULT_MAXIMUM_RECORD_COUNT_FOR_PAGE_SIZE_CHECK = 10000; | ||
public static final int DEFAULT_MINIMUM_RECORD_COUNT_FOR_ROW_GROUP_SIZE_CHECK = 100; | ||
public static final int DEFAULT_MAXIMUM_RECORD_COUNT_FOR_ROW_GROUP_SIZE_CHECK = 10000; | ||
|
||
public static final ValuesWriterFactory DEFAULT_VALUES_WRITER_FACTORY = new DefaultValuesWriterFactory(); | ||
|
||
|
@@ -80,12 +83,15 @@ public static WriterVersion fromString(String name) { | |
private final boolean enableDictionary; | ||
private final int minRowCountForPageSizeCheck; | ||
private final int maxRowCountForPageSizeCheck; | ||
private final boolean estimateNextSizeCheck; | ||
private final int minRowCountForRowGroupSizeCheck; | ||
private final int maxRowCountForRowGroupSizeCheck; | ||
private final boolean estimateNextPageSizeCheck; | ||
private final boolean estimateNextRowGroupSizeCheck; | ||
private final ByteBufferAllocator allocator; | ||
private final ValuesWriterFactory valuesWriterFactory; | ||
|
||
private ParquetProperties(WriterVersion writerVersion, int pageSize, int dictPageSize, boolean enableDict, int minRowCountForPageSizeCheck, | ||
int maxRowCountForPageSizeCheck, boolean estimateNextSizeCheck, ByteBufferAllocator allocator, | ||
int maxRowCountForPageSizeCheck, int minRowCountForRowGroupSizeCheck, int maxRowCountForRowGroupSizeCheck, boolean estimateNextPageSizeCheck, boolean estimateNextRowGroupSizeCheck, ByteBufferAllocator allocator, | ||
ValuesWriterFactory writerFactory) { | ||
this.pageSizeThreshold = pageSize; | ||
this.initialSlabSize = CapacityByteArrayOutputStream | ||
|
@@ -95,7 +101,10 @@ private ParquetProperties(WriterVersion writerVersion, int pageSize, int dictPag | |
this.enableDictionary = enableDict; | ||
this.minRowCountForPageSizeCheck = minRowCountForPageSizeCheck; | ||
this.maxRowCountForPageSizeCheck = maxRowCountForPageSizeCheck; | ||
this.estimateNextSizeCheck = estimateNextSizeCheck; | ||
this.minRowCountForRowGroupSizeCheck = minRowCountForRowGroupSizeCheck; | ||
this.maxRowCountForRowGroupSizeCheck = maxRowCountForRowGroupSizeCheck; | ||
this.estimateNextPageSizeCheck = estimateNextPageSizeCheck; | ||
this.estimateNextRowGroupSizeCheck = estimateNextRowGroupSizeCheck; | ||
this.allocator = allocator; | ||
|
||
this.valuesWriterFactory = writerFactory; | ||
|
@@ -179,12 +188,24 @@ public int getMaxRowCountForPageSizeCheck() { | |
return maxRowCountForPageSizeCheck; | ||
} | ||
|
||
public int getMinRowCountForRowGroupSizeCheck() { | ||
return minRowCountForRowGroupSizeCheck; | ||
} | ||
|
||
public int getMaxRowCountForRowGroupSizeCheck() { | ||
return maxRowCountForRowGroupSizeCheck; | ||
} | ||
|
||
public ValuesWriterFactory getValuesWriterFactory() { | ||
return valuesWriterFactory; | ||
} | ||
|
||
public boolean estimateNextSizeCheck() { | ||
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. I suggest deprecating instead of removing. |
||
return estimateNextSizeCheck; | ||
public boolean estimateNextPageSizeCheck() { | ||
return estimateNextPageSizeCheck; | ||
} | ||
|
||
public boolean estimateNextRowGroupSizeCheck() { | ||
return estimateNextRowGroupSizeCheck; | ||
} | ||
|
||
public static Builder builder() { | ||
|
@@ -200,9 +221,12 @@ public static class Builder { | |
private int dictPageSize = DEFAULT_DICTIONARY_PAGE_SIZE; | ||
private boolean enableDict = DEFAULT_IS_DICTIONARY_ENABLED; | ||
private WriterVersion writerVersion = DEFAULT_WRITER_VERSION; | ||
private int minRowCountForPageSizeCheck = DEFAULT_MINIMUM_RECORD_COUNT_FOR_CHECK; | ||
private int maxRowCountForPageSizeCheck = DEFAULT_MAXIMUM_RECORD_COUNT_FOR_CHECK; | ||
private boolean estimateNextSizeCheck = DEFAULT_ESTIMATE_ROW_COUNT_FOR_PAGE_SIZE_CHECK; | ||
private int minRowCountForPageSizeCheck = DEFAULT_MINIMUM_RECORD_COUNT_FOR_PAGE_SIZE_CHECK; | ||
private int maxRowCountForPageSizeCheck = DEFAULT_MAXIMUM_RECORD_COUNT_FOR_PAGE_SIZE_CHECK; | ||
private boolean estimateNextPageSizeCheck = DEFAULT_ESTIMATE_ROW_COUNT_FOR_PAGE_SIZE_CHECK; | ||
private int minRowCountForRowGroupSizeCheck = DEFAULT_MINIMUM_RECORD_COUNT_FOR_ROW_GROUP_SIZE_CHECK; | ||
private int maxRowCountForRowGroupSizeCheck = DEFAULT_MAXIMUM_RECORD_COUNT_FOR_ROW_GROUP_SIZE_CHECK; | ||
private boolean estimateNextRowGroupSizeCheck = DEFAULT_ESTIMATE_ROW_COUNT_FOR_ROW_GROUP_SIZE_CHECK; | ||
private ByteBufferAllocator allocator = new HeapByteBufferAllocator(); | ||
private ValuesWriterFactory valuesWriterFactory = DEFAULT_VALUES_WRITER_FACTORY; | ||
|
||
|
@@ -215,7 +239,10 @@ private Builder(ParquetProperties toCopy) { | |
this.writerVersion = toCopy.writerVersion; | ||
this.minRowCountForPageSizeCheck = toCopy.minRowCountForPageSizeCheck; | ||
this.maxRowCountForPageSizeCheck = toCopy.maxRowCountForPageSizeCheck; | ||
this.estimateNextSizeCheck = toCopy.estimateNextSizeCheck; | ||
this.estimateNextPageSizeCheck = toCopy.estimateNextPageSizeCheck; | ||
this.minRowCountForRowGroupSizeCheck = toCopy.minRowCountForRowGroupSizeCheck; | ||
this.maxRowCountForRowGroupSizeCheck = toCopy.maxRowCountForRowGroupSizeCheck; | ||
this.estimateNextRowGroupSizeCheck = toCopy.estimateNextRowGroupSizeCheck; | ||
this.allocator = toCopy.allocator; | ||
} | ||
|
||
|
@@ -281,9 +308,28 @@ public Builder withMaxRowCountForPageSizeCheck(int max) { | |
return this; | ||
} | ||
|
||
public Builder withMinRowCountForRowGroupSizeCheck(int min) { | ||
Preconditions.checkArgument(min > 0, | ||
"Invalid row count for block size check (negative): %s", min); | ||
this.minRowCountForRowGroupSizeCheck = min; | ||
return this; | ||
} | ||
|
||
public Builder withMaxRowCountForRowGroupSizeCheck(int max) { | ||
Preconditions.checkArgument(max > 0, | ||
"Invalid row count for block size check (negative): %s", max); | ||
this.maxRowCountForRowGroupSizeCheck = max; | ||
return this; | ||
} | ||
|
||
// Do not attempt to predict next size check. Prevents issues with rows that vary significantly in size. | ||
public Builder estimateRowCountForPageSizeCheck(boolean estimateNextSizeCheck) { | ||
this.estimateNextSizeCheck = estimateNextSizeCheck; | ||
this.estimateNextPageSizeCheck = estimateNextSizeCheck; | ||
return this; | ||
} | ||
|
||
public Builder estimateRowCountForRowGroupSizeCheck(boolean estimateRowGroupSizeCheck) { | ||
this.estimateNextRowGroupSizeCheck = estimateRowGroupSizeCheck; | ||
return this; | ||
} | ||
|
||
|
@@ -303,7 +349,9 @@ public ParquetProperties build() { | |
ParquetProperties properties = | ||
new ParquetProperties(writerVersion, pageSize, dictPageSize, | ||
enableDict, minRowCountForPageSizeCheck, maxRowCountForPageSizeCheck, | ||
estimateNextSizeCheck, allocator, valuesWriterFactory); | ||
minRowCountForRowGroupSizeCheck, maxRowCountForRowGroupSizeCheck, | ||
estimateNextPageSizeCheck, estimateNextRowGroupSizeCheck, | ||
allocator, valuesWriterFactory); | ||
// we pass a constructed but uninitialized factory to ParquetProperties above as currently | ||
// creation of ValuesWriters is invoked from within ParquetProperties. In the future | ||
// we'd like to decouple that and won't need to pass an object to properties and then pass the | ||
|
This file contains 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 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 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 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
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.
Not sure if anyone would use such constants but it is a braking change to remove them. It might be a good idea to deprecate them instead and use the new ones internally.