nastra commented on code in PR #14800: URL: https://github.com/apache/iceberg/pull/14800#discussion_r2792743755
########## arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedDeltaLengthByteArrayValuesReader.java: ########## @@ -0,0 +1,202 @@ +/* + * 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.function.IntUnaryOperator; +import org.apache.arrow.vector.BaseVariableWidthVector; +import org.apache.arrow.vector.FieldVector; +import org.apache.parquet.bytes.ByteBufferInputStream; +import org.apache.parquet.column.values.ValuesReader; +import org.apache.parquet.io.ParquetDecodingException; +import org.apache.parquet.io.api.Binary; + +/** + * A {@link VectorizedValuesReader} implementation for the encoding type DELTA_LENGTH_BYTE_ARRAY. + * This is adapted from Spark's VectorizedDeltaLengthByteArrayReader. + * + * @see <a + * href="https://github.com/apache/parquet-format/blob/master/Encodings.md#delta-length-byte-array-delta_length_byte_array--6"> + * Parquet format encodings: DELTA_LENGTH_BYTE_ARRAY</a> + */ +public class VectorizedDeltaLengthByteArrayValuesReader extends ValuesReader + implements VectorizedValuesReader { + + private final VectorizedDeltaEncodedValuesReader lengthReader; + + private ByteBufferInputStream in; + private int[] lengths; + private ByteBuffer byteBuffer; + private int currentIndex; + + VectorizedDeltaLengthByteArrayValuesReader() { + lengthReader = new VectorizedDeltaEncodedValuesReader(); + } + + @Override + public void initFromPage(int valueCount, ByteBufferInputStream inputStream) throws IOException { + lengthReader.initFromPage(valueCount, inputStream); + // actual number of elements in the page may be less than the passed valueCount here due to + // nulls + lengths = lengthReader.readIntegers(lengthReader.getTotalValueCount(), 0); + + in = inputStream.remainingStream(); + currentIndex = 0; Review Comment: why not init have `private int currentIndex = 0` instead of setting it to 0 here? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
