Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19230#discussion_r138806043
--- Diff:
sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/ColumnVector.java
---
@@ -99,73 +100,18 @@ public ArrayData copy() {
@Override
public Object[] array() {
DataType dt = data.dataType();
+ Function<Integer, Object> getAtMethod = (Function<Integer, Object>)
i -> get(i, dt);
Object[] list = new Object[length];
-
- if (dt instanceof BooleanType) {
- for (int i = 0; i < length; i++) {
- if (!data.isNullAt(offset + i)) {
- list[i] = data.getBoolean(offset + i);
- }
- }
- } else if (dt instanceof ByteType) {
- for (int i = 0; i < length; i++) {
- if (!data.isNullAt(offset + i)) {
- list[i] = data.getByte(offset + i);
- }
- }
- } else if (dt instanceof ShortType) {
- for (int i = 0; i < length; i++) {
- if (!data.isNullAt(offset + i)) {
- list[i] = data.getShort(offset + i);
- }
- }
- } else if (dt instanceof IntegerType) {
- for (int i = 0; i < length; i++) {
- if (!data.isNullAt(offset + i)) {
- list[i] = data.getInt(offset + i);
- }
- }
- } else if (dt instanceof FloatType) {
- for (int i = 0; i < length; i++) {
- if (!data.isNullAt(offset + i)) {
- list[i] = data.getFloat(offset + i);
- }
- }
- } else if (dt instanceof DoubleType) {
+ try {
for (int i = 0; i < length; i++) {
if (!data.isNullAt(offset + i)) {
- list[i] = data.getDouble(offset + i);
+ list[i] = getAtMethod.call(i);
--- End diff --
can we just call `get(i + offset, dt)`? The `getAtMethod` seems not very
useful, as we still need to go through the if-else branches in `get` everytime.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]