From 8fcef0fd31b3b96d71073c14bded900cb29ef827 Mon Sep 17 00:00:00 2001 From: Wenchen Fan Date: Wed, 13 Sep 2023 15:54:46 +0800 Subject: [PATCH] avoid repeated if checks --- .../execution/vectorized/OffHeapColumnVector.java | 12 ++++++------ .../sql/execution/vectorized/OnHeapColumnVector.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OffHeapColumnVector.java b/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OffHeapColumnVector.java index 9cb1b1f0b5e3c..2bb0b02d4c9c4 100644 --- a/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OffHeapColumnVector.java +++ b/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OffHeapColumnVector.java @@ -218,7 +218,7 @@ public byte[] getBytes(int rowId, int count) { Platform.copyMemory(null, data + rowId, array, Platform.BYTE_ARRAY_OFFSET, count); } else { for (int i = 0; i < count; i++) { - array[i] = getByte(rowId + i); + array[i] = (byte) dictionary.decodeToInt(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -279,7 +279,7 @@ public short[] getShorts(int rowId, int count) { Platform.copyMemory(null, data + rowId * 2L, array, Platform.SHORT_ARRAY_OFFSET, count * 2L); } else { for (int i = 0; i < count; i++) { - array[i] = getShort(rowId + i); + array[i] = (short) dictionary.decodeToInt(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -345,7 +345,7 @@ public int[] getInts(int rowId, int count) { Platform.copyMemory(null, data + rowId * 4L, array, Platform.INT_ARRAY_OFFSET, count * 4L); } else { for (int i = 0; i < count; i++) { - array[i] = getInt(rowId + i); + array[i] = dictionary.decodeToInt(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -423,7 +423,7 @@ public long[] getLongs(int rowId, int count) { Platform.copyMemory(null, data + rowId * 8L, array, Platform.LONG_ARRAY_OFFSET, count * 8L); } else { for (int i = 0; i < count; i++) { - array[i] = getLong(rowId + i); + array[i] = dictionary.decodeToLong(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -487,7 +487,7 @@ public float[] getFloats(int rowId, int count) { Platform.copyMemory(null, data + rowId * 4L, array, Platform.FLOAT_ARRAY_OFFSET, count * 4L); } else { for (int i = 0; i < count; i++) { - array[i] = getFloat(rowId + i); + array[i] = dictionary.decodeToFloat(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -553,7 +553,7 @@ public double[] getDoubles(int rowId, int count) { count * 8L); } else { for (int i = 0; i < count; i++) { - array[i] = getDouble(rowId + i); + array[i] = dictionary.decodeToDouble(dictionaryIds.getDictId(rowId + i)); } } return array; diff --git a/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OnHeapColumnVector.java b/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OnHeapColumnVector.java index be590bb9ac726..2bf2b8d08fcea 100644 --- a/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OnHeapColumnVector.java +++ b/sql/core/src/main/java/org/apache/spark/sql/execution/vectorized/OnHeapColumnVector.java @@ -216,7 +216,7 @@ public byte[] getBytes(int rowId, int count) { System.arraycopy(byteData, rowId, array, 0, count); } else { for (int i = 0; i < count; i++) { - array[i] = getByte(rowId + i); + array[i] = (byte) dictionary.decodeToInt(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -276,7 +276,7 @@ public short[] getShorts(int rowId, int count) { System.arraycopy(shortData, rowId, array, 0, count); } else { for (int i = 0; i < count; i++) { - array[i] = getShort(rowId + i); + array[i] = (short) dictionary.decodeToInt(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -337,7 +337,7 @@ public int[] getInts(int rowId, int count) { System.arraycopy(intData, rowId, array, 0, count); } else { for (int i = 0; i < count; i++) { - array[i] = getInt(rowId + i); + array[i] = dictionary.decodeToInt(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -409,7 +409,7 @@ public long[] getLongs(int rowId, int count) { System.arraycopy(longData, rowId, array, 0, count); } else { for (int i = 0; i < count; i++) { - array[i] = getLong(rowId + i); + array[i] = dictionary.decodeToLong(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -466,7 +466,7 @@ public float[] getFloats(int rowId, int count) { System.arraycopy(floatData, rowId, array, 0, count); } else { for (int i = 0; i < count; i++) { - array[i] = getFloat(rowId + i); + array[i] = dictionary.decodeToFloat(dictionaryIds.getDictId(rowId + i)); } } return array; @@ -525,7 +525,7 @@ public double[] getDoubles(int rowId, int count) { System.arraycopy(doubleData, rowId, array, 0, count); } else { for (int i = 0; i < count; i++) { - array[i] = getDouble(rowId + i); + array[i] = dictionary.decodeToDouble(dictionaryIds.getDictId(rowId + i)); } } return array;