vbhanuchander-lang commented on code in PR #17645: URL: https://github.com/apache/iceberg/pull/17645#discussion_r3787866987
########## arrow/src/test/java/org/apache/iceberg/arrow/vectorized/TestVariableWidthInitialCapacity.java: ########## @@ -0,0 +1,107 @@ +/* + * 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; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.arrow.memory.BufferAllocator; +import org.apache.arrow.memory.RootAllocator; +import org.apache.arrow.vector.FixedSizeBinaryVector; +import org.apache.arrow.vector.VarCharVector; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +/** + * Pins the Arrow sizing contract that {@code VectorizedArrowReader} relies on when it allocates + * variable-width vectors. + * + * <p>{@code setInitialCapacity(int)} takes a <em>value count</em>, not a byte count, and sizes the + * data buffer at Arrow's default of 8 bytes per value. Passing {@code batchSize * averageWidth} to + * it therefore reserves offsets for {@code averageWidth} times too many values. The density + * overload, {@code setInitialCapacity(int, double)}, expresses what the reader actually means. + */ +public class TestVariableWidthInitialCapacity { + + private static final int BATCH_SIZE = 5000; + private static final int AVERAGE_WIDTH = 10; + + private BufferAllocator allocator; + + @BeforeEach + public void before() { + this.allocator = new RootAllocator(Long.MAX_VALUE); + } + + @AfterEach + public void after() { + allocator.close(); + } + + @Test + public void testDensityOverloadReservesOneSlotPerRow() { Review Comment: Done — the new tests are `variableWidthVectorsHoldOneBatchOfValues()` and `fixedWidthVectorsHoldOneBatchOfValues()`, no `test` prefix. Thanks for the pointer to the convention. -- 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]
