jbewing commented on code in PR #15373: URL: https://github.com/apache/iceberg/pull/15373#discussion_r2835259813
########## 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: Mind if I get to that in a follow up? I noted this in the PR description: > This in particular revives https://github.com/apache/iceberg/pull/14852 which implements BYTE_STREAM_SPLIT vectorized read support for float/double data types (which are the defaults for the parquet v2 writer. Additional data types are supported like int, long, and fixed length byte array, but support for those is forthcoming in this PR although not crazy to add). But the int, long, and fixed length binary array support are supported in the parquet v2 spec, but they were adopted for this encoding a bit later (see [PARQUET-2414](https://issues.apache.org/jira/browse/PARQUET-2414)). It also remains the case that BYTE_STREAM_SPLIT is the default encoding used for floating point types, however, not for int, long, or fixed length byte array at this point (so the writer intentionally has to opt in even if they're on parquet v2). All to say: you're totally right, but I'd like to punt to a follow up as just supporting float + double gets us in the door for parquet v2 support -- 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]
