You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/03/09 04:53:05 UTC

[GitHub] [spark] LuciferYang opened a new pull request #35781: [SPARK-38460][SQL] Clean up duplicate codes in `get` method of `ColumnarBatchRow/ColumnarRow/MutableColumnarRow`

LuciferYang opened a new pull request #35781:
URL: https://github.com/apache/spark/pull/35781


   ### What changes were proposed in this pull request?
   The logic of the `ColumnarBatchRow.get` is very similar to `ColumnarRow.get` and `MutableColumnarRow.get`.
   
   This PR is changed to make the above 3 methods call `SpecializedGettersReader.read` to clean up duplicate codes.
   
   The `SpecializedGettersReader.read` is also used by `UnsafeArrayData.get`, `UnsafeRow.get` and `ColumnarArray.get` in Spark code.
   
   ### Why are the changes needed?
   Clean up duplicate codes.
   
   
   ### Does this PR introduce _any_ user-facing change?
   No.
   
   
   ### How was this patch tested?
   Pass GA


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] LuciferYang commented on a change in pull request #35781: [SPARK-38460][SQL] Clean up duplicate codes in `get` method of `ColumnarBatchRow/ColumnarRow/MutableColumnarRow`

Posted by GitBox <gi...@apache.org>.
LuciferYang commented on a change in pull request #35781:
URL: https://github.com/apache/spark/pull/35781#discussion_r822285489



##########
File path: sql/catalyst/src/main/java/org/apache/spark/sql/vectorized/ColumnarBatchRow.java
##########
@@ -145,40 +146,7 @@ public ColumnarMap getMap(int ordinal) {
 
   @Override
   public Object get(int ordinal, DataType dataType) {
-    if (dataType instanceof BooleanType) {
-      return getBoolean(ordinal);
-    } else if (dataType instanceof ByteType) {
-      return getByte(ordinal);
-    } else if (dataType instanceof ShortType) {
-      return getShort(ordinal);
-    } else if (dataType instanceof IntegerType || dataType instanceof YearMonthIntervalType) {
-      return getInt(ordinal);
-    } else if (dataType instanceof LongType || dataType instanceof DayTimeIntervalType) {
-      return getLong(ordinal);
-    } else if (dataType instanceof FloatType) {
-      return getFloat(ordinal);
-    } else if (dataType instanceof DoubleType) {
-      return getDouble(ordinal);
-    } else if (dataType instanceof StringType) {
-      return getUTF8String(ordinal);
-    } else if (dataType instanceof BinaryType) {
-      return getBinary(ordinal);
-    } else if (dataType instanceof DecimalType) {
-      DecimalType t = (DecimalType) dataType;
-      return getDecimal(ordinal, t.precision(), t.scale());
-    } else if (dataType instanceof DateType) {
-      return getInt(ordinal);
-    } else if (dataType instanceof TimestampType) {
-      return getLong(ordinal);
-    } else if (dataType instanceof ArrayType) {
-      return getArray(ordinal);
-    } else if (dataType instanceof StructType) {
-      return getStruct(ordinal, ((StructType)dataType).fields().length);
-    } else if (dataType instanceof MapType) {
-      return getMap(ordinal);
-    } else {
-      throw new UnsupportedOperationException("Datatype not supported " + dataType);
-    }
+    return SpecializedGettersReader.read(this, ordinal, dataType, false, false);

Review comment:
       https://github.com/apache/spark/blob/b8c03eeb15a22895d3ab55b931b468ad012a28d4/sql/catalyst/src/main/java/org/apache/spark/sql/catalyst/expressions/SpecializedGettersReader.java#L25-L97




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org