-
Notifications
You must be signed in to change notification settings - Fork 3k
Add support for DELTA_LENGTH_BYTE_ARRAY Parquet encoding #13709
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
Show all changes
44 commits
Select commit
Hold shift + click to select a range
a69ec52
rebase
eric-maynard 0bba5ef
lint
eric-maynard 9ecc2be
some changes per comments
eric-maynard 3cd2819
Merge branch 'main' of ssh://github.com-oss/apache/iceberg into parqu…
eric-maynard 8d186fe
javadoc
eric-maynard 5ce8913
lint
eric-maynard 9fe0bba
create class
eric-maynard 6cecf96
remove clash
eric-maynard 2ce2590
Merge branch 'parquet-v2-refactor' of ssh://github.com-oss/eric-mayna…
eric-maynard 3aed168
refactoring
eric-maynard 98d1c5c
clean up
eric-maynard b72e338
wire up
eric-maynard b76cc47
tweak header
eric-maynard ec07775
check in
eric-maynard c79a77c
resolve conflicts
eric-maynard 1969466
debugging
eric-maynard d2b173b
debugging
eric-maynard 1f219e5
debugging commit
eric-maynard 21c11d8
move code
eric-maynard e4bc23f
switch back to floats
eric-maynard a88af2e
clean a bit
eric-maynard c375e99
semistable
eric-maynard f8cfbb2
polish
eric-maynard 9d27297
stable:
eric-maynard d75f85e
spotless; polish
eric-maynard 03f6395
spotless
eric-maynard c39570d
fix lints
eric-maynard 1ac89a9
initial impl
eric-maynard ddeadf7
convinced I need to use a golden file
eric-maynard dc75fc4
resolve conflicts
eric-maynard f86b93c
resolve more conflicts
eric-maynard 5117f9f
license
eric-maynard c7e5a68
revert
eric-maynard db99901
spotless
eric-maynard 4528490
lint
eric-maynard fa3806d
Merge branch 'main' of ssh://github.com-oss/apache/iceberg into DELTA…
eric-maynard 679390e
add golden file
eric-maynard 6f5eeee
spotless
eric-maynard 9f27974
spotless
eric-maynard b8173d6
change value
eric-maynard 4d86a46
resolve conflicts
eric-maynard 9954a43
spotless
eric-maynard 29e59c5
change readBinary path
eric-maynard dbfd7bb
lint
eric-maynard 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
181 changes: 181 additions & 0 deletions
181
...g/apache/iceberg/arrow/vectorized/parquet/VectorizedDeltaLengthByteArrayValuesReader.java
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 |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| /* | ||
| * 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 | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.iceberg.arrow.vectorized.parquet; | ||
|
|
||
| import java.io.EOFException; | ||
| import java.io.IOException; | ||
| import java.nio.ByteBuffer; | ||
| import java.util.UUID; | ||
| import java.util.function.IntUnaryOperator; | ||
| import org.apache.arrow.vector.FieldVector; | ||
| import org.apache.arrow.vector.IntVector; | ||
| import org.apache.iceberg.arrow.ArrowAllocation; | ||
| import org.apache.iceberg.io.CloseableGroup; | ||
| import org.apache.parquet.bytes.ByteBufferInputStream; | ||
| import org.apache.parquet.io.ParquetDecodingException; | ||
| import org.apache.parquet.io.api.Binary; | ||
|
|
||
| public class VectorizedDeltaLengthByteArrayValuesReader | ||
| implements VectorizedValuesReader, AutoCloseable { | ||
|
|
||
| private final VectorizedDeltaEncodedValuesReader lengthReader; | ||
| private final CloseableGroup closeables; | ||
|
|
||
| private ByteBufferInputStream in; | ||
| private IntVector lengthsVector; | ||
| private ByteBuffer byteBuffer; | ||
|
|
||
| VectorizedDeltaLengthByteArrayValuesReader() { | ||
| lengthReader = new VectorizedDeltaEncodedValuesReader(); | ||
| closeables = new CloseableGroup(); | ||
| } | ||
|
|
||
| @Override | ||
| public void initFromPage(int valueCount, ByteBufferInputStream inputStream) throws IOException { | ||
| lengthsVector = new IntVector("length-" + UUID.randomUUID(), ArrowAllocation.rootAllocator()); | ||
| closeables.addCloseable(lengthsVector); | ||
| lengthReader.initFromPage(valueCount, inputStream); | ||
| lengthReader.readIntegers(lengthReader.getTotalValueCount(), lengthsVector, 0); | ||
| this.in = inputStream.remainingStream(); | ||
| } | ||
|
|
||
| @Override | ||
| public Binary readBinary(int len) { | ||
| readValues(1, null, 0, x -> len, (f, i, v) -> byteBuffer = v); | ||
| return Binary.fromReusedByteBuffer(byteBuffer); | ||
| } | ||
|
|
||
| @Override | ||
| public void readBinary(int total, FieldVector vec, int rowId, boolean setArrowValidityVector) { | ||
| readValues( | ||
| total, | ||
| vec, | ||
| rowId, | ||
| x -> lengthsVector.get(x), | ||
| (f, i, v) -> f.getDataBuffer().setBytes(i, v)); | ||
| } | ||
|
|
||
| @SuppressWarnings("UnusedVariable") | ||
| private void readValues( | ||
| int total, | ||
| FieldVector vec, | ||
| int rowId, | ||
| IntUnaryOperator getLength, | ||
| BinaryOutputWriter outputWriter) { | ||
| ByteBuffer buffer; | ||
| for (int i = 0; i < total; i++) { | ||
| int length = getLength.applyAsInt(rowId + i); | ||
| try { | ||
| if (length <= 0) { | ||
| throw new IllegalStateException("Invalid length: " + length); | ||
| } | ||
| buffer = in.slice(length); | ||
| } catch (EOFException e) { | ||
| throw new ParquetDecodingException("Failed to read " + length + " bytes"); | ||
| } | ||
| outputWriter.write(vec, rowId + i, buffer); | ||
| } | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public boolean readBoolean() { | ||
| throw new UnsupportedOperationException("readBoolean is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public byte readByte() { | ||
| throw new UnsupportedOperationException("readByte is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public short readShort() { | ||
| throw new UnsupportedOperationException("readShort is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public int readInteger() { | ||
| throw new UnsupportedOperationException("readInteger is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public long readLong() { | ||
| throw new UnsupportedOperationException("readLong is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public float readFloat() { | ||
| throw new UnsupportedOperationException("readFloat is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public double readDouble() { | ||
| throw new UnsupportedOperationException("readDouble is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public void readIntegers(int total, FieldVector vec, int rowId) { | ||
| throw new UnsupportedOperationException("readIntegers is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public void readLongs(int total, FieldVector vec, int rowId) { | ||
| throw new UnsupportedOperationException("readLongs is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public void readFloats(int total, FieldVector vec, int rowId) { | ||
| throw new UnsupportedOperationException("readFloats is not supported"); | ||
| } | ||
|
|
||
| /** DELTA_LENGTH_BYTE_ARRAY only supports BINARY */ | ||
| @Override | ||
| public void readDoubles(int total, FieldVector vec, int rowId) { | ||
| throw new UnsupportedOperationException("readDoubles is not supported"); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() throws Exception { | ||
| closeables.close(); | ||
| } | ||
|
|
||
| /** A functional interface to write binary values into a FieldVector */ | ||
| @FunctionalInterface | ||
| interface BinaryOutputWriter { | ||
|
|
||
| /** | ||
| * A functional interface that can be used to write a binary value to a specified row in a | ||
| * FieldVector | ||
| * | ||
| * @param vec a FieldVector to write the value into | ||
| * @param index The offset to write to | ||
| * @param val value to write | ||
| */ | ||
| void write(FieldVector vec, long index, ByteBuffer val); | ||
| } | ||
| } | ||
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
Binary file added
BIN
+9.5 KB
spark/v4.0/spark/src/test/resources/encodings/DELTA_LENGTH_BYTE_ARRAY/binary.parquet
Binary file not shown.
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.
Uh oh!
There was an error while loading. Please reload this page.