Skip to content

Commit 2cae095

Browse files
Combine the Aggregate Expression & Function
1 parent 230e70f commit 2cae095

File tree

5 files changed

+346
-307
lines changed

5 files changed

+346
-307
lines changed

mllib/src/main/scala/org/apache/spark/mllib/linalg/Vectors.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,12 @@ private[spark] class VectorUDT extends UserDefinedType[Vector] {
109109
val row = new GenericMutableRow(4)
110110
obj match {
111111
case sv: SparseVector =>
112-
row.setByte(0, 0)
112+
row.setByte(0, 0.toByte)
113113
row.setInt(1, sv.size)
114114
row.update(2, sv.indices.toSeq)
115115
row.update(3, sv.values.toSeq)
116116
case dv: DenseVector =>
117-
row.setByte(0, 1)
117+
row.setByte(0, 1.toByte)
118118
row.setNullAt(1)
119119
row.setNullAt(2)
120120
row.update(3, dv.values.toSeq)

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Row.scala

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ object Row {
5353
*/
5454
trait Row extends Seq[Any] with Serializable {
5555
def apply(i: Int): Any
56-
5756
def isNullAt(i: Int): Boolean
5857

5958
def getInt(i: Int): Int
@@ -80,6 +79,18 @@ trait Row extends Seq[Any] with Serializable {
8079
}
8180
false
8281
}
82+
83+
final def apply(bound: BoundReference): Any = apply(bound.ordinal)
84+
final def isNullAt(bound: BoundReference): Boolean = isNullAt(bound.ordinal)
85+
final def getInt(bound: BoundReference): Int = getInt(bound.ordinal)
86+
final def getLong(bound: BoundReference): Long = getLong(bound.ordinal)
87+
final def getDouble(bound: BoundReference): Double = getDouble(bound.ordinal)
88+
final def getBoolean(bound: BoundReference): Boolean = getBoolean(bound.ordinal)
89+
final def getShort(bound: BoundReference): Short = getShort(bound.ordinal)
90+
final def getByte(bound: BoundReference): Byte = getByte(bound.ordinal)
91+
final def getFloat(bound: BoundReference): Float = getFloat(bound.ordinal)
92+
final def getString(bound: BoundReference): String = getString(bound.ordinal)
93+
final def getAs[T](bound: BoundReference): T = getAs[T](bound.ordinal)
8394
}
8495

8596
/**
@@ -90,7 +101,6 @@ trait MutableRow extends Row {
90101
def setNullAt(i: Int): Unit
91102

92103
def update(ordinal: Int, value: Any)
93-
94104
def setInt(ordinal: Int, value: Int)
95105
def setLong(ordinal: Int, value: Long)
96106
def setDouble(ordinal: Int, value: Double)
@@ -99,6 +109,16 @@ trait MutableRow extends Row {
99109
def setByte(ordinal: Int, value: Byte)
100110
def setFloat(ordinal: Int, value: Float)
101111
def setString(ordinal: Int, value: String)
112+
113+
final def update(bound: BoundReference, value: Any) { update(bound.ordinal, value) }
114+
final def setInt(bound: BoundReference, value: Int) { setInt(bound.ordinal, value) }
115+
final def setLong(bound: BoundReference, value: Long) { setLong(bound.ordinal, value) }
116+
final def setDouble(bound: BoundReference, value: Double) { setDouble(bound.ordinal, value) }
117+
final def setBoolean(bound: BoundReference, value: Boolean) { setBoolean(bound.ordinal, value) }
118+
final def setShort(bound: BoundReference, value: Short) { setShort(bound.ordinal, value) }
119+
final def setByte(bound: BoundReference, value: Byte) { setByte(bound.ordinal, value) }
120+
final def setFloat(bound: BoundReference, value: Float) { setFloat(bound.ordinal, value) }
121+
final def setString(bound: BoundReference, value: String) { setString(bound.ordinal, value) }
102122
}
103123

104124
/**

0 commit comments

Comments
 (0)