Skip to content

Commit a61ba71

Browse files
committed
address comments
1 parent d4267b7 commit a61ba71

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ private void throwUnsupportedException(int requiredCapacity, Throwable cause) {
522522
* After writing array elements to the child column vector, call this method to set the offset and
523523
* length of the written array.
524524
*/
525-
public void arrayWriteEnd(int rowId, int offset, int length) {
525+
public void putArrayOffsetAndLength(int rowId, int offset, int length) {
526526
putInt(2 * rowId, offset);
527527
putInt(2 * rowId + 1, length);
528528
}
@@ -563,7 +563,7 @@ public final Array getArray(int rowId) {
563563
*/
564564
public int putByteArray(int rowId, byte[] value, int offset, int length) {
565565
int result = arrayData().appendBytes(length, value, offset);
566-
arrayWriteEnd(rowId, result, length);
566+
putArrayOffsetAndLength(rowId, result, length);
567567
return result;
568568
}
569569

@@ -829,13 +829,13 @@ public final int appendDoubles(int length, double[] src, int offset) {
829829
public final int appendByteArray(byte[] value, int offset, int length) {
830830
int copiedOffset = arrayData().appendBytes(length, value, offset);
831831
reserve(elementsAppended + 1);
832-
arrayWriteEnd(elementsAppended, copiedOffset, length);
832+
putArrayOffsetAndLength(elementsAppended, copiedOffset, length);
833833
return elementsAppended++;
834834
}
835835

836836
public final int appendArray(int length) {
837837
reserve(elementsAppended + 1);
838-
arrayWriteEnd(elementsAppended, arrayData().elementsAppended, length);
838+
putArrayOffsetAndLength(elementsAppended, arrayData().elementsAppended, length);
839839
return elementsAppended++;
840840
}
841841

sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OffHeapColumnVector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ public final class OffHeapColumnVector extends ColumnVector {
3434
// The data stored in these two allocations need to maintain binary compatible. We can
3535
// directly pass this buffer to external components.
3636
private long nulls;
37+
// The actually data of this column vector will be store here. If it's an array column vector,
38+
// we will store the offsets and lengths here, and store the element data in child column vector.
3739
private long data;
3840

3941
protected OffHeapColumnVector(int capacity, DataType type) {

sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OnHeapColumnVector.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public final class OnHeapColumnVector extends ColumnVector {
4242
// Array for each type. Only 1 is populated for any type.
4343
private byte[] byteData;
4444
private short[] shortData;
45+
// This is not used used to store data for int column vector, but also can store offsets and
46+
// lengths for array column vector.
4547
private int[] intData;
4648
private long[] longData;
4749
private float[] floatData;

sql/core/src/test/scala/org/apache/spark/sql/execution/vectorized/ColumnarBatchSuite.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ class ColumnarBatchSuite extends SparkFunSuite {
631631
assert(column.arrayData().elementsAppended == 17)
632632

633633
// Put the same "ll" at offset. This should not allocate more memory in the column.
634-
column.arrayWriteEnd(idx, offset, 2)
634+
column.putArrayOffsetAndLength(idx, offset, 2)
635635
reference += "ll"
636636
idx += 1
637637
assert(column.arrayData().elementsAppended == 17)
@@ -667,10 +667,10 @@ class ColumnarBatchSuite extends SparkFunSuite {
667667
}
668668

669669
// Populate it with arrays [0], [1, 2], [], [3, 4, 5]
670-
column.arrayWriteEnd(0, 0, 1)
671-
column.arrayWriteEnd(1, 1, 2)
672-
column.arrayWriteEnd(2, 2, 0)
673-
column.arrayWriteEnd(3, 3, 3)
670+
column.putArrayOffsetAndLength(0, 0, 1)
671+
column.putArrayOffsetAndLength(1, 1, 2)
672+
column.putArrayOffsetAndLength(2, 2, 0)
673+
column.putArrayOffsetAndLength(3, 3, 3)
674674

675675
val a1 = ColumnVectorUtils.toPrimitiveJavaArray(column.getArray(0)).asInstanceOf[Array[Int]]
676676
val a2 = ColumnVectorUtils.toPrimitiveJavaArray(column.getArray(1)).asInstanceOf[Array[Int]]
@@ -703,7 +703,7 @@ class ColumnarBatchSuite extends SparkFunSuite {
703703
data.reserve(array.length)
704704
assert(data.capacity == array.length * 2)
705705
data.putInts(0, array.length, array, 0)
706-
column.arrayWriteEnd(0, 0, array.length)
706+
column.putArrayOffsetAndLength(0, 0, array.length)
707707
assert(ColumnVectorUtils.toPrimitiveJavaArray(column.getArray(0)).asInstanceOf[Array[Int]]
708708
=== array)
709709
}}

0 commit comments

Comments
 (0)