FelixYBW commented on code in PR #13280: URL: https://github.com/apache/gluten/pull/13280#discussion_r4345549801
########## gluten-arrow/src/main/java/org/apache/gluten/vectorized/RefCountedArrowColumnVector.java: ########## @@ -0,0 +1,77 @@ +/* + * 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.gluten.vectorized; + +import org.apache.arrow.vector.ValueVector; +import org.apache.spark.sql.vectorized.ArrowColumnVector; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * Spark's {@link ArrowColumnVector} with a reference count, used by Gluten's Java Arrow batches + * (see {@link org.apache.gluten.columnarbatch.ColumnarBatches}). The count starts at 1; {@link + * #retain()} increments it and {@link #close()} decrements it. The Arrow vector is released when + * the count reaches 0. + * + * <p>Reading goes through Spark's accessors. To write, fill the Arrow vectors (e.g. with Spark's + * {@code ArrowWriter}) and wrap them, see {@link ArrowColumnVectors}. + */ +public final class RefCountedArrowColumnVector extends ArrowColumnVector { Review Comment: Since Spark 3.3 ColumnarBatch is no longer final, so the reference count can move to the batch level. But one thing the follow-up needs to handle: some operators (ColumnarArrowEvalPythonExec, partial project/generate) build batches from columns borrowed from other batches and rely on per-column reference counts today. A batch-level count would need the composed batch to retain its parent batches instead. -- 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]
