Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/7626#discussion_r35368464
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/InternalRow.scala ---
@@ -25,48 +25,133 @@ import org.apache.spark.unsafe.types.UTF8String
* An abstract class for row used internal in Spark SQL, which only
contain the columns as
* internal types.
*/
-abstract class InternalRow extends Row {
+abstract class InternalRow {
- def getUTF8String(i: Int): UTF8String = getAs[UTF8String](i)
+ def numFields: Int
- def getBinary(i: Int): Array[Byte] = getAs[Array[Byte]](i)
+ def get(i: Int): Any
- // This is only use for test
- override def getString(i: Int): String = getAs[UTF8String](i).toString
-
- // These expensive API should not be used internally.
- final override def getDecimal(i: Int): java.math.BigDecimal =
- throw new UnsupportedOperationException
- final override def getDate(i: Int): java.sql.Date =
- throw new UnsupportedOperationException
- final override def getTimestamp(i: Int): java.sql.Timestamp =
- throw new UnsupportedOperationException
- final override def getSeq[T](i: Int): Seq[T] = throw new
UnsupportedOperationException
- final override def getList[T](i: Int): java.util.List[T] = throw new
UnsupportedOperationException
- final override def getMap[K, V](i: Int): scala.collection.Map[K, V] =
- throw new UnsupportedOperationException
- final override def getJavaMap[K, V](i: Int): java.util.Map[K, V] =
- throw new UnsupportedOperationException
- final override def getStruct(i: Int): Row = throw new
UnsupportedOperationException
- final override def getAs[T](fieldName: String): T = throw new
UnsupportedOperationException
- final override def getValuesMap[T](fieldNames: Seq[String]): Map[String,
T] =
- throw new UnsupportedOperationException
-
- // A default implementation to change the return type
- override def copy(): InternalRow = this
+ // TODO: Remove this.
+ def apply(i: Int): Any = get(i)
+
+ def getAs[T](i: Int): T = get(i).asInstanceOf[T]
+
+ def isNullAt(i: Int): Boolean = get(i) == null
+
+ def getBoolean(i: Int): Boolean = getAs[Boolean](i)
+
+ def getByte(i: Int): Byte = getAs[Byte](i)
+
+ def getShort(i: Int): Short = getAs[Short](i)
+
+ def getInt(i: Int): Int = getAs[Int](i)
+
+ def getLong(i: Int): Long = getAs[Long](i)
+
+ def getFloat(i: Int): Float = getAs[Float](i)
+
+ def getDouble(i: Int): Double = getAs[Double](i)
+
+ override def toString: String = s"[${this.mkString(",")}]"
/**
- * Returns true if we can check equality for these 2 rows.
- * Equality check between external row and internal row is not allowed.
- * Here we do this check to prevent call `equals` on internal row with
external row.
+ * Make a copy of the current [[Row]] object.
--- End diff --
InternalRow
---
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]