nastra commented on code in PR #15373: URL: https://github.com/apache/iceberg/pull/15373#discussion_r2835939509
########## arrow/src/main/java/org/apache/iceberg/arrow/vectorized/parquet/VectorizedByteStreamSplitValuesReader.java: ########## @@ -0,0 +1,113 @@ +/* + * 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.io.UncheckedIOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import org.apache.arrow.vector.FieldVector; +import org.apache.parquet.bytes.ByteBufferInputStream; +import org.apache.parquet.column.values.ValuesReader; + +/** + * A {@link VectorizedValuesReader} implementation for the encoding type BYTE_STREAM_SPLIT. This is + * adapted from Parquet's ByteStreamSplitValuesReader. + * + * @see <a + * href="https://parquet.apache.org/docs/file-format/data-pages/encodings/#byte-stream-split-byte_stream_split--9"> + * Parquet format encodings: BYTE_STREAM_SPLIT</a> + */ +public class VectorizedByteStreamSplitValuesReader extends ValuesReader + implements VectorizedValuesReader { + + private int totalBytesInStream; + private ByteBufferInputStream in; + private ByteBuffer decodedDataStream; + + public VectorizedByteStreamSplitValuesReader() {} + + @Override + public void initFromPage(int ignoredValueCount, ByteBufferInputStream inputStream) + throws IOException { + totalBytesInStream = inputStream.available(); + this.in = inputStream; + } + + @Override + public float readFloat() { + ensureDecoded(FLOAT_SIZE); + return decodedDataStream.getFloat(); + } + + @Override + public double readDouble() { Review Comment: After looking at the Parquet implementation, I don't think it's going to add significant complexity so I would prefer to add the other types in this PR. The other reason for having it in this PR is that we would still have a gap if those types are being encoded and we'd have to fix it anyway but I'd like to add everything into the same release -- 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]
