@@ -43,7 +43,7 @@ case class SplitEvaluation(
4343 partialEvaluations : Seq [NamedExpression ])
4444
4545/**
46- * An [[AggregateExpression ]] that can be partially computed without seeing all relevent tuples.
46+ * An [[AggregateExpression ]] that can be partially computed without seeing all relevant tuples.
4747 * These partial evaluations can then be combined to compute the actual answer.
4848 */
4949abstract class PartialAggregate extends AggregateExpression {
@@ -63,28 +63,28 @@ abstract class AggregateFunction
6363 extends AggregateExpression with Serializable with trees.LeafNode [Expression ] {
6464 self : Product =>
6565
66- type EvaluatedType = Any
66+ override type EvaluatedType = Any
6767
6868 /** Base should return the generic aggregate expression that this function is computing */
6969 val base : AggregateExpression
70- def references = base.references
71- def nullable = base.nullable
72- def dataType = base.dataType
70+ override def references = base.references
71+ override def nullable = base.nullable
72+ override def dataType = base.dataType
7373
7474 def update (input : Row ): Unit
7575 override def eval (input : Row ): Any
7676
7777 // Do we really need this?
78- def newInstance = makeCopy(productIterator.map { case a : AnyRef => a }.toArray)
78+ override def newInstance = makeCopy(productIterator.map { case a : AnyRef => a }.toArray)
7979}
8080
8181case class Count (child : Expression ) extends PartialAggregate with trees.UnaryNode [Expression ] {
82- def references = child.references
83- def nullable = false
84- def dataType = IntegerType
82+ override def references = child.references
83+ override def nullable = false
84+ override def dataType = IntegerType
8585 override def toString = s " COUNT( $child) "
8686
87- def asPartial : SplitEvaluation = {
87+ override def asPartial : SplitEvaluation = {
8888 val partialCount = Alias (Count (child), " PartialCount" )()
8989 SplitEvaluation (Sum (partialCount.toAttribute), partialCount :: Nil )
9090 }
@@ -93,18 +93,18 @@ case class Count(child: Expression) extends PartialAggregate with trees.UnaryNod
9393}
9494
9595case class CountDistinct (expressions : Seq [Expression ]) extends AggregateExpression {
96- def children = expressions
97- def references = expressions.flatMap(_.references).toSet
98- def nullable = false
99- def dataType = IntegerType
96+ override def children = expressions
97+ override def references = expressions.flatMap(_.references).toSet
98+ override def nullable = false
99+ override def dataType = IntegerType
100100 override def toString = s " COUNT(DISTINCT ${expressions.mkString(" ," )}}) "
101101 override def newInstance = new CountDistinctFunction (expressions, this )
102102}
103103
104104case class Average (child : Expression ) extends PartialAggregate with trees.UnaryNode [Expression ] {
105- def references = child.references
106- def nullable = false
107- def dataType = DoubleType
105+ override def references = child.references
106+ override def nullable = false
107+ override def dataType = DoubleType
108108 override def toString = s " AVG( $child) "
109109
110110 override def asPartial : SplitEvaluation = {
@@ -122,9 +122,9 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN
122122}
123123
124124case class Sum (child : Expression ) extends PartialAggregate with trees.UnaryNode [Expression ] {
125- def references = child.references
126- def nullable = false
127- def dataType = child.dataType
125+ override def references = child.references
126+ override def nullable = false
127+ override def dataType = child.dataType
128128 override def toString = s " SUM( $child) "
129129
130130 override def asPartial : SplitEvaluation = {
@@ -140,18 +140,18 @@ case class Sum(child: Expression) extends PartialAggregate with trees.UnaryNode[
140140case class SumDistinct (child : Expression )
141141 extends AggregateExpression with trees.UnaryNode [Expression ] {
142142
143- def references = child.references
144- def nullable = false
145- def dataType = child.dataType
143+ override def references = child.references
144+ override def nullable = false
145+ override def dataType = child.dataType
146146 override def toString = s " SUM(DISTINCT $child) "
147147
148148 override def newInstance = new SumDistinctFunction (child, this )
149149}
150150
151151case class First (child : Expression ) extends PartialAggregate with trees.UnaryNode [Expression ] {
152- def references = child.references
153- def nullable = child.nullable
154- def dataType = child.dataType
152+ override def references = child.references
153+ override def nullable = child.nullable
154+ override def dataType = child.dataType
155155 override def toString = s " FIRST( $child) "
156156
157157 override def asPartial : SplitEvaluation = {
@@ -172,14 +172,12 @@ case class AverageFunction(expr: Expression, base: AggregateExpression)
172172 private val sum = MutableLiteral (Cast (Literal (0 ), expr.dataType).eval(EmptyRow ))
173173 private val sumAsDouble = Cast (sum, DoubleType )
174174
175-
176-
177175 private val addFunction = Add (sum, expr)
178176
179177 override def eval (input : Row ): Any =
180178 sumAsDouble.eval(EmptyRow ).asInstanceOf [Double ] / count.toDouble
181179
182- def update (input : Row ): Unit = {
180+ override def update (input : Row ): Unit = {
183181 count += 1
184182 sum.update(addFunction, input)
185183 }
@@ -190,7 +188,7 @@ case class CountFunction(expr: Expression, base: AggregateExpression) extends Ag
190188
191189 var count : Int = _
192190
193- def update (input : Row ): Unit = {
191+ override def update (input : Row ): Unit = {
194192 val evaluatedExpr = expr.map(_.eval(input))
195193 if (evaluatedExpr.map(_ != null ).reduceLeft(_ || _)) {
196194 count += 1
@@ -207,7 +205,7 @@ case class SumFunction(expr: Expression, base: AggregateExpression) extends Aggr
207205
208206 private val addFunction = Add (sum, expr)
209207
210- def update (input : Row ): Unit = {
208+ override def update (input : Row ): Unit = {
211209 sum.update(addFunction, input)
212210 }
213211
@@ -219,9 +217,9 @@ case class SumDistinctFunction(expr: Expression, base: AggregateExpression)
219217
220218 def this () = this (null , null ) // Required for serialization.
221219
222- val seen = new scala.collection.mutable.HashSet [Any ]()
220+ private val seen = new scala.collection.mutable.HashSet [Any ]()
223221
224- def update (input : Row ): Unit = {
222+ override def update (input : Row ): Unit = {
225223 val evaluatedExpr = expr.eval(input)
226224 if (evaluatedExpr != null ) {
227225 seen += evaluatedExpr
@@ -239,7 +237,7 @@ case class CountDistinctFunction(expr: Seq[Expression], base: AggregateExpressio
239237
240238 val seen = new scala.collection.mutable.HashSet [Any ]()
241239
242- def update (input : Row ): Unit = {
240+ override def update (input : Row ): Unit = {
243241 val evaluatedExpr = expr.map(_.eval(input))
244242 if (evaluatedExpr.map(_ != null ).reduceLeft(_ && _)) {
245243 seen += evaluatedExpr
@@ -254,7 +252,7 @@ case class FirstFunction(expr: Expression, base: AggregateExpression) extends Ag
254252
255253 var result : Any = null
256254
257- def update (input : Row ): Unit = {
255+ override def update (input : Row ): Unit = {
258256 if (result == null ) {
259257 result = expr.eval(input)
260258 }
0 commit comments