-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Backport "Parquet dynamic batch size" #13350 #13393
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| import com.google.common.collect.ImmutableList; | ||
| import com.google.common.collect.Range; | ||
| import com.google.common.primitives.Shorts; | ||
| import io.airlift.units.DataSize; | ||
| import org.apache.hadoop.hive.common.type.HiveDecimal; | ||
| import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector; | ||
| import org.apache.hadoop.hive.serde2.objectinspector.primitive.JavaHiveDecimalObjectInspector; | ||
|
|
@@ -1492,6 +1493,43 @@ private void setParquetLogging() | |
| Logger.getLogger("parquet.hadoop.ColumnChunkPageWriteStore").setLevel(Level.WARNING); | ||
| } | ||
|
|
||
| @Test | ||
| public void testStructMaxReadBytes() | ||
| throws Exception | ||
| { | ||
| DataSize maxReadBlockSize = new DataSize(1_000, DataSize.Unit.BYTE); | ||
| List<List> structValues = createTestStructs( | ||
| Collections.nCopies(500, String.join("", Collections.nCopies(33, "test"))), | ||
| Collections.nCopies(500, String.join("", Collections.nCopies(1, "test")))); | ||
| List<String> structFieldNames = asList("a", "b"); | ||
| Type structType = RowType.from(asList(field("a", VARCHAR), field("b", VARCHAR))); | ||
|
|
||
| tester.testMaxReadBytes( | ||
| getStandardStructObjectInspector(structFieldNames, asList(javaStringObjectInspector, javaStringObjectInspector)), | ||
| structValues, | ||
| structValues, | ||
| structType, | ||
| maxReadBlockSize); | ||
| } | ||
|
|
||
| @Test | ||
| public void testArrayMaxReadBytes() | ||
| throws Exception | ||
| { | ||
| DataSize maxReadBlockSize = new DataSize(1_000, DataSize.Unit.BYTE); | ||
| Iterable<List<Integer>> values = createFixedTestArrays(limit(cycle(asList(1, null, 3, 5, null, null, null, 7, 11, null, 13, 17)), 30_000)); | ||
| tester.testMaxReadBytes(getStandardListObjectInspector(javaIntObjectInspector), values, values, new ArrayType(INTEGER), maxReadBlockSize); | ||
| } | ||
|
|
||
| @Test | ||
| public void testMapMaxReadBytes() | ||
| throws Exception | ||
| { | ||
| DataSize maxReadBlockSize = new DataSize(1_000, DataSize.Unit.BYTE); | ||
| Iterable<Map<String, Long>> values = createFixedTestMaps(Collections.nCopies(5_000, String.join("", Collections.nCopies(33, "test"))), longsBetween(0, 5_000)); | ||
| tester.testMaxReadBytes(getStandardMapObjectInspector(javaStringObjectInspector, javaLongObjectInspector), values, values, mapType(VARCHAR, BIGINT), maxReadBlockSize); | ||
| } | ||
|
|
||
| private static <T> Iterable<T> repeatEach(int n, Iterable<T> iterable) | ||
| { | ||
| return () -> new AbstractIterator<T>() | ||
|
|
@@ -1611,6 +1649,48 @@ private <T> Iterable<List<T>> createNullableTestArrays(Iterable<T> values) | |
| return insertNullEvery(ThreadLocalRandom.current().nextInt(2, 5), createTestArrays(values)); | ||
| } | ||
|
|
||
| private <T> List<List<T>> createFixedTestArrays(Iterable<T> values) | ||
|
||
| { | ||
| List<List<T>> arrays = new ArrayList<>(); | ||
| Iterator<T> valuesIter = values.iterator(); | ||
| List<T> array = new ArrayList<>(); | ||
| int count = 1; | ||
| while (valuesIter.hasNext()) { | ||
| if (count % 10 == 0) { | ||
| arrays.add(array); | ||
| array = new ArrayList<>(); | ||
| } | ||
| if (count % 20 == 0) { | ||
| arrays.add(Collections.emptyList()); | ||
| } | ||
| array.add(valuesIter.next()); | ||
| ++count; | ||
| } | ||
| return arrays; | ||
| } | ||
|
|
||
| private <K, V> Iterable<Map<K, V>> createFixedTestMaps(Iterable<K> keys, Iterable<V> values) | ||
| { | ||
| List<Map<K, V>> maps = new ArrayList<>(); | ||
| Iterator<K> keysIterator = keys.iterator(); | ||
| Iterator<V> valuesIterator = values.iterator(); | ||
| Map<K, V> map = new HashMap<>(); | ||
| int count = 1; | ||
| while (keysIterator.hasNext() && valuesIterator.hasNext()) { | ||
| if (count % 5 == 0) { | ||
| maps.add(map); | ||
| map = new HashMap<>(); | ||
| } | ||
| if (count % 10 == 0) { | ||
| maps.add(Collections.emptyMap()); | ||
| } | ||
| map.put(keysIterator.next(), valuesIterator.next()); | ||
| ++count; | ||
| } | ||
| return maps; | ||
| } | ||
|
|
||
|
|
||
| private <K, V> Iterable<Map<K, V>> createTestMaps(Iterable<K> keys, Iterable<V> values) | ||
| { | ||
| List<Map<K, V>> maps = new ArrayList<>(); | ||
|
|
@@ -1635,6 +1715,7 @@ private <K, V> Iterable<Map<K, V>> createNullableTestMaps(Iterable<K> keys, Iter | |
| return insertNullEvery(ThreadLocalRandom.current().nextInt(2, 5), createTestMaps(keys, values)); | ||
| } | ||
|
|
||
|
|
||
| private static Byte intToByte(Integer input) | ||
| { | ||
| if (input == null) { | ||
|
|
||
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.
any reason remove these constants? were added for schema verification
might trigger compile errors
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.
@zhenxiao : Will make sure Travis is green in #13473 before merge :)