siddharthteotia commented on code in PR #18638: URL: https://github.com/apache/pinot/pull/18638#discussion_r3429418941
########## pinot-plugins/pinot-input-format/pinot-arrow/src/main/java/org/apache/pinot/plugin/inputformat/arrow/ArrowAccumulators.java: ########## @@ -0,0 +1,184 @@ +/** + * 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.pinot.plugin.inputformat.arrow; + +import com.google.common.base.Preconditions; +import java.io.IOException; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Set; +import javax.annotation.Nullable; +import org.apache.arrow.memory.BufferAllocator; +import org.apache.arrow.vector.FieldVector; +import org.apache.arrow.vector.VectorSchemaRoot; +import org.apache.arrow.vector.ipc.ArrowReader; +import org.apache.arrow.vector.util.VectorAppender; +import org.apache.pinot.spi.data.FieldSpec; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.data.readers.ColumnReader; + + +/** + * Package-private helper shared by {@link ArrowColumnReaderFactory} and + * {@link InMemoryArrowColumnReaderFactory}: walks every record batch in an {@link ArrowReader}, + * concatenates each wanted column's values into a per-column accumulator {@link FieldVector} via + * Arrow's {@link VectorAppender}, and produces one {@link ArrowColumnReader} per accumulator. + * + * <p>Accumulator vectors are allocated against the caller-supplied {@link BufferAllocator}. The + * caller (factory) owns and closes them via {@link Result#getAccumulators()}; this helper does + * not retain references. + */ +final class ArrowAccumulators { + + private ArrowAccumulators() { + } + + static Result populate(ArrowReader reader, BufferAllocator allocator, Schema targetSchema, Review Comment: Yes this pattern is better. Thanks for addressing -- 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]
