From 96b9772a7d5edad4192228266361e8e80f26ae33 Mon Sep 17 00:00:00 2001 From: Vibhatha Abeykoon Date: Tue, 6 Aug 2024 06:32:46 +0530 Subject: [PATCH] fix: typo --- .../vector/complex/LargeListViewVector.java | 22 +++++----- .../impl/UnionLargeListViewReader.java | 6 ++- .../org/apache/arrow/vector/types/Types.java | 3 +- .../arrow/vector/TestLargeListViewVector.java | 44 +++++++++---------- 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java index c02f5d3949b36..aad70c5477c0b 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/LargeListViewVector.java @@ -148,11 +148,11 @@ public void setInitialCapacity(int numRecords) { * * @param numRecords value count * @param density density of LargeListViewVector. Density is the average size of a list per - * position in the ListViewVector. For example, a density value of 10 implies each position in - * the list vector has a list of 10 values. A density value of 0.1 implies out of 10 positions - * in the list vector, 1 position has a list of size 1, and the remaining positions are null - * (no lists) or empty lists. This helps in tightly controlling the memory we provision for - * inner data vector. + * position in the LargeListViewVector. For example, a density value of 10 implies each + * position in the list vector has a list of 10 values. A density value of 0.1 implies out of + * 10 positions in the list vector, 1 position has a list of size 1, and the remaining + * positions are null (no lists) or empty lists. This helps in tightly controlling the memory + * we provision for inner data vector. */ @Override public void setInitialCapacity(int numRecords, double density) { @@ -362,19 +362,19 @@ public TransferPair getTransferPair(Field field, BufferAllocator allocator) { @Override public TransferPair getTransferPair(String ref, BufferAllocator allocator, CallBack callBack) { throw new UnsupportedOperationException( - "LargeListVector does not support getTransferPair(String, BufferAllocator, CallBack) yet"); + "LargeListViewVector does not support getTransferPair(String, BufferAllocator, CallBack) yet"); } @Override public TransferPair getTransferPair(Field field, BufferAllocator allocator, CallBack callBack) { throw new UnsupportedOperationException( - "LargeListVector does not support getTransferPair(Field, BufferAllocator, CallBack) yet"); + "LargeListViewVector does not support getTransferPair(Field, BufferAllocator, CallBack) yet"); } @Override public TransferPair makeTransferPair(ValueVector target) { throw new UnsupportedOperationException( - "LargeListVector does not support makeTransferPair(ValueVector) yet"); + "LargeListViewVector does not support makeTransferPair(ValueVector) yet"); } @Override @@ -798,7 +798,7 @@ public void setValueCount(int valueCount) { */ Preconditions.checkArgument( childValueCount <= Integer.MAX_VALUE || childValueCount >= Integer.MIN_VALUE, - "LargeListVector doesn't yet support 64-bit allocations: %s", + "LargeListViewVector doesn't yet support 64-bit allocations: %s", childValueCount); vector.setValueCount((int) childValueCount); } @@ -841,7 +841,7 @@ public int getValueCount() { } /** - * Get the density of this ListVector. + * Get the density of this LargeListViewVector. * * @return density */ @@ -853,7 +853,7 @@ public double getDensity() { return totalListSize / valueCount; } - /** Validating ListViewVector creation based on the specification guideline. */ + /** Validating LargeListViewVector creation based on the specification guideline. */ @Override public void validate() { for (int i = 0; i < valueCount; i++) { diff --git a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/UnionLargeListViewReader.java b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/UnionLargeListViewReader.java index 3e1a070e5ab5b..4bcd028de300d 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/UnionLargeListViewReader.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/complex/impl/UnionLargeListViewReader.java @@ -16,6 +16,8 @@ */ package org.apache.arrow.vector.complex.impl; +import static org.apache.arrow.memory.util.LargeMemoryUtil.checkedCastToInt; + import org.apache.arrow.vector.ValueVector; import org.apache.arrow.vector.complex.BaseLargeRepeatedValueViewVector; import org.apache.arrow.vector.complex.LargeListViewVector; @@ -33,7 +35,7 @@ public class UnionLargeListViewReader extends AbstractFieldReader { private int size; /** - * Constructor for UnionListViewReader. + * Constructor for UnionLargeListViewReader. * * @param vector the vector to read from */ @@ -105,7 +107,7 @@ public boolean next() { // And, size keeps track of the elements count in the list, so to make sure we traverse // the full list, we need to check if the currentOffset is less than the currentOffset + size if (currentOffset < currentOffset + size) { - data.getReader().setPosition(currentOffset++); + data.getReader().setPosition(checkedCastToInt(currentOffset++)); return true; } else { return false; diff --git a/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java b/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java index 39f1625975776..6b2c56de01c40 100644 --- a/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java +++ b/java/vector/src/main/java/org/apache/arrow/vector/types/Types.java @@ -112,6 +112,7 @@ import org.apache.arrow.vector.complex.impl.UInt2WriterImpl; import org.apache.arrow.vector.complex.impl.UInt4WriterImpl; import org.apache.arrow.vector.complex.impl.UInt8WriterImpl; +import org.apache.arrow.vector.complex.impl.UnionLargeListViewWriter; import org.apache.arrow.vector.complex.impl.UnionLargeListWriter; import org.apache.arrow.vector.complex.impl.UnionListWriter; import org.apache.arrow.vector.complex.impl.UnionWriter; @@ -657,7 +658,7 @@ public FieldVector getNewVector( @Override public FieldWriter getNewFieldWriter(ValueVector vector) { - return new UnionLargeListWriter((LargeListVector) vector); + return new UnionLargeListViewWriter((LargeListViewVector) vector); } }, FIXED_SIZE_LIST(null) { diff --git a/java/vector/src/test/java/org/apache/arrow/vector/TestLargeListViewVector.java b/java/vector/src/test/java/org/apache/arrow/vector/TestLargeListViewVector.java index 9f39fb85dc39f..563ac811c4fdb 100644 --- a/java/vector/src/test/java/org/apache/arrow/vector/TestLargeListViewVector.java +++ b/java/vector/src/test/java/org/apache/arrow/vector/TestLargeListViewVector.java @@ -26,9 +26,7 @@ import org.apache.arrow.memory.ArrowBuf; import org.apache.arrow.memory.BufferAllocator; import org.apache.arrow.vector.complex.BaseLargeRepeatedValueViewVector; -import org.apache.arrow.vector.complex.LargeListVector; import org.apache.arrow.vector.complex.LargeListViewVector; -import org.apache.arrow.vector.complex.ListViewVector; import org.apache.arrow.vector.complex.impl.UnionLargeListViewWriter; import org.apache.arrow.vector.types.Types.MinorType; import org.apache.arrow.vector.types.pojo.ArrowType; @@ -287,7 +285,7 @@ public void testNestedLargeListViewVector() throws Exception { assertEquals(2, largeListViewVector.getValueCount()); - /* get listVector value at index 0 -- the value itself is a listvector */ + /* get largeListViewVector value at index 0 -- the value itself is a largeListViewVector */ Object result = largeListViewVector.getObject(0); ArrayList> resultSet = (ArrayList>) result; ArrayList list; @@ -307,7 +305,7 @@ public void testNestedLargeListViewVector() throws Exception { assertEquals(Long.valueOf(150), list.get(2)); assertEquals(Long.valueOf(175), list.get(3)); - /* get listVector value at index 1 -- the value itself is a listvector */ + /* get largeListViewVector value at index 1 -- the value itself is a largeListViewVector */ result = largeListViewVector.getObject(1); resultSet = (ArrayList>) result; @@ -335,7 +333,7 @@ public void testNestedLargeListViewVector() throws Exception { /* check underlying offsets */ final ArrowBuf offsetBuffer = largeListViewVector.getOffsetBuffer(); - /* listVector has 2 lists at index 0 and 3 lists at index 1 */ + /* largeListViewVector has 2 lists at index 0 and 3 lists at index 1 */ assertEquals(0, offsetBuffer.getLong(0 * LargeListViewVector.OFFSET_WIDTH)); assertEquals(2, offsetBuffer.getLong(1 * LargeListViewVector.OFFSET_WIDTH)); } @@ -346,27 +344,27 @@ public void testNestedLargeListViewVector1() { try (LargeListViewVector largeListViewVector = LargeListViewVector.empty("sourceVector", allocator)) { - MinorType listViewType = MinorType.LISTVIEW; + MinorType listViewType = MinorType.LARGELISTVIEW; MinorType scalarType = MinorType.BIGINT; largeListViewVector.addOrGetVector(FieldType.nullable(listViewType.getType())); - ListViewVector innerList1 = (ListViewVector) largeListViewVector.getDataVector(); + LargeListViewVector innerList1 = (LargeListViewVector) largeListViewVector.getDataVector(); innerList1.addOrGetVector(FieldType.nullable(listViewType.getType())); - ListViewVector innerList2 = (ListViewVector) innerList1.getDataVector(); + LargeListViewVector innerList2 = (LargeListViewVector) innerList1.getDataVector(); innerList2.addOrGetVector(FieldType.nullable(listViewType.getType())); - ListViewVector innerList3 = (ListViewVector) innerList2.getDataVector(); + LargeListViewVector innerList3 = (LargeListViewVector) innerList2.getDataVector(); innerList3.addOrGetVector(FieldType.nullable(listViewType.getType())); - ListViewVector innerList4 = (ListViewVector) innerList3.getDataVector(); + LargeListViewVector innerList4 = (LargeListViewVector) innerList3.getDataVector(); innerList4.addOrGetVector(FieldType.nullable(listViewType.getType())); - ListViewVector innerList5 = (ListViewVector) innerList4.getDataVector(); + LargeListViewVector innerList5 = (LargeListViewVector) innerList4.getDataVector(); innerList5.addOrGetVector(FieldType.nullable(listViewType.getType())); - ListViewVector innerList6 = (ListViewVector) innerList5.getDataVector(); + LargeListViewVector innerList6 = (LargeListViewVector) innerList5.getDataVector(); innerList6.addOrGetVector(FieldType.nullable(scalarType.getType())); largeListViewVector.setInitialCapacity(128); @@ -420,7 +418,7 @@ public void testNestedLargeListViewVector2() throws Exception { assertEquals(2, largeListViewVector.getValueCount()); - /* get listVector value at index 0 -- the value itself is a listvector */ + /* get largeListViewVector value at index 0 -- the value itself is a largeListViewVector */ Object result = largeListViewVector.getObject(0); ArrayList> resultSet = (ArrayList>) result; ArrayList list; @@ -438,7 +436,7 @@ public void testNestedLargeListViewVector2() throws Exception { assertEquals(Long.valueOf(75), list.get(0)); assertEquals(Long.valueOf(125), list.get(1)); - /* get listVector value at index 1 -- the value itself is a listvector */ + /* get largeListViewVector value at index 1 -- the value itself is a largeListViewVector */ result = largeListViewVector.getObject(1); resultSet = (ArrayList>) result; @@ -462,7 +460,7 @@ public void testNestedLargeListViewVector2() throws Exception { /* check underlying offsets */ final ArrowBuf offsetBuffer = largeListViewVector.getOffsetBuffer(); - /* listVector has 2 lists at index 0 and 3 lists at index 1 */ + /* largeListViewVector has 2 lists at index 0 and 3 lists at index 1 */ assertEquals(0, offsetBuffer.getLong(0 * LargeListViewVector.OFFSET_WIDTH)); assertEquals(2, offsetBuffer.getLong(1 * LargeListViewVector.OFFSET_WIDTH)); } @@ -492,7 +490,7 @@ public void testGetBufferAddress() throws Exception { largeListViewVector.setValueCount(2); - /* check listVector contents */ + /* check largeListViewVector contents */ Object result = largeListViewVector.getObject(0); ArrayList resultSet = (ArrayList) result; assertEquals(3, resultSet.size()); @@ -532,7 +530,7 @@ public void testGetBufferAddress() throws Exception { /* * Setting up the buffers directly needs to be validated with the base method used in - * the ListVector class where we use the approach of startListView(), + * the LargeListViewVector class where we use the approach of startListView(), * write to the child vector and endListView(). *

* To support this, we have to consider the following scenarios; @@ -543,7 +541,7 @@ public void testGetBufferAddress() throws Exception { */ /* Setting up buffers directly would require the following steps to be taken - * 0. Allocate buffers in listViewVector by calling `allocateNew` method. + * 0. Allocate buffers in largeListViewVector by calling `allocateNew` method. * 1. Initialize the child vector using `initializeChildrenFromFields` method. * 2. Set values in the child vector. * 3. Set validity, offset and size buffers using `setValidity`, @@ -719,7 +717,7 @@ public void testBasicLargeListViewSetNested() { assertEquals(2, largeListViewVector.getValueCount()); - /* get listViewVector value at index 0 -- the value itself is a listViewVector */ + /* get largeListViewVector value at index 0 -- the value itself is a largeListViewVector */ Object result = largeListViewVector.getObject(0); ArrayList> resultSet = (ArrayList>) result; ArrayList list; @@ -739,7 +737,7 @@ public void testBasicLargeListViewSetNested() { assertEquals(Long.valueOf(150), list.get(2)); assertEquals(Long.valueOf(175), list.get(3)); - /* get listViewVector value at index 1 -- the value itself is a listViewVector */ + /* get largeListViewVector value at index 1 -- the value itself is a largeListViewVector */ result = largeListViewVector.getObject(1); resultSet = (ArrayList>) result; @@ -900,11 +898,11 @@ public void testConsistentChildName() throws Exception { try (LargeListViewVector largeListViewVector = LargeListViewVector.empty("sourceVector", allocator)) { String emptyListStr = largeListViewVector.getField().toString(); - assertTrue(emptyListStr.contains(LargeListVector.DATA_VECTOR_NAME)); + assertTrue(emptyListStr.contains(LargeListViewVector.DATA_VECTOR_NAME)); largeListViewVector.addOrGetVector(FieldType.nullable(MinorType.INT.getType())); String emptyVectorStr = largeListViewVector.getField().toString(); - assertTrue(emptyVectorStr.contains(LargeListVector.DATA_VECTOR_NAME)); + assertTrue(emptyVectorStr.contains(LargeListViewVector.DATA_VECTOR_NAME)); } } @@ -1105,7 +1103,7 @@ public void testIsEmpty() { public void testTotalCapacity() { final FieldType type = FieldType.nullable(MinorType.INT.getType()); try (final LargeListViewVector vector = - new LargeListViewVector("largelist", allocator, type, null)) { + new LargeListViewVector("largelistview", allocator, type, null)) { // Force the child vector to be allocated based on the type // (this is a bad API: we have to track and repeat the type twice) vector.addOrGetVector(type);