Github user kiszk commented on a diff in the pull request:
https://github.com/apache/spark/pull/18014#discussion_r118622945
--- Diff:
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OnHeapColumnVector.java
---
@@ -386,6 +425,35 @@ public void putArray(int rowId, int offset, int
length) {
}
@Override
+ public void putArray(int rowId, Object src, int srcOffset, int
dstOffset, int numElements) {
+ DataType et = type;
+ reserve(dstOffset + numElements);
+ if (et == DataTypes.BooleanType || et == DataTypes.ByteType) {
+ Platform.copyMemory(
+ src, srcOffset, byteData, Platform.BYTE_ARRAY_OFFSET + dstOffset,
numElements);
+ } else if (et == DataTypes.BooleanType || et == DataTypes.ByteType) {
+ Platform.copyMemory(
+ src, srcOffset, shortData, Platform.SHORT_ARRAY_OFFSET + dstOffset
* 2, numElements * 2);
+ } else if (et == DataTypes.IntegerType || et == DataTypes.DateType ||
+ DecimalType.is32BitDecimalType(type)) {
+ Platform.copyMemory(
+ src, srcOffset, intData, Platform.INT_ARRAY_OFFSET + dstOffset *
4, numElements * 4);
+ } else if (type instanceof LongType || type instanceof TimestampType ||
+ DecimalType.is64BitDecimalType(type)) {
+ Platform.copyMemory(
+ src, srcOffset, longData, Platform.LONG_ARRAY_OFFSET + dstOffset *
8, numElements * 8);
+ } else if (et == DataTypes.FloatType) {
+ Platform.copyMemory(
+ src, srcOffset, floatData, Platform.FLOAT_ARRAY_OFFSET + dstOffset
* 4, numElements * 4);
+ } else if (et == DataTypes.DoubleType) {
+ Platform.copyMemory(
+ src, srcOffset, doubleData, Platform.DOUBLE_ARRAY_OFFSET +
dstOffset * 8, numElements * 8);
+ } else {
+ throw new RuntimeException("Unhandled " + type);
--- End diff --
IIUC, `UnsafeArrayData` put all of the elements together in a contiguous
memory region even when it is a nested array.
On the other hand, current `ColumnVector` puts elements for each dimension
in different `ColumnVector.childColumns[0]`. Thus, multiple bulk copies are
required.
If there is an array `Array(Array(1), Array(2))`, in `ColumnVector`,
`Array(1)` and `Array(2)` are stored into different `intData` in
`ColumnVector.childColumns[0]`.
Am I correct?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]