Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
marmbrus committed Apr 3, 2014
1 parent a2d90ba commit b4a6887
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class Projection(expressions: Seq[Expression]) extends (Row => Row) {

protected val exprArray = expressions.toArray
def apply(input: Row): Row = {
val outputArray = new Array[Any](exprArray.size)
val outputArray = new Array[Any](exprArray.length)
var i = 0
while (i < exprArray.size) {
while (i < exprArray.length) {
outputArray(i) = exprArray(i).apply(input)
i += 1
}
Expand All @@ -57,7 +57,7 @@ case class MutableProjection(expressions: Seq[Expression]) extends (Row => Row)

def apply(input: Row): Row = {
var i = 0
while (i < exprArray.size) {
while (i < exprArray.length) {
mutableRow(i) = exprArray(i).apply(input)
i += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class AggregateExpression extends Expression {
* Creates a new instance that can be used to compute this aggregate expression for a group
* of input rows/
*/
def newInstance: AggregateFunction
def newInstance(): AggregateFunction
}

/**
Expand Down Expand Up @@ -75,7 +75,7 @@ abstract class AggregateFunction
override def apply(input: Row): Any

// Do we really need this?
def newInstance = makeCopy(productIterator.map { case a: AnyRef => a }.toArray)
def newInstance() = makeCopy(productIterator.map { case a: AnyRef => a }.toArray)
}

case class Count(child: Expression) extends PartialAggregate with trees.UnaryNode[Expression] {
Expand All @@ -89,7 +89,7 @@ case class Count(child: Expression) extends PartialAggregate with trees.UnaryNod
SplitEvaluation(Sum(partialCount.toAttribute), partialCount :: Nil)
}

override def newInstance = new CountFunction(child, this)
override def newInstance()= new CountFunction(child, this)
}

case class CountDistinct(expressions: Seq[Expression]) extends AggregateExpression {
Expand All @@ -98,7 +98,7 @@ case class CountDistinct(expressions: Seq[Expression]) extends AggregateExpressi
def nullable = false
def dataType = IntegerType
override def toString = s"COUNT(DISTINCT ${expressions.mkString(",")}})"
override def newInstance = new CountDistinctFunction(expressions, this)
override def newInstance()= new CountDistinctFunction(expressions, this)
}

case class Average(child: Expression) extends PartialAggregate with trees.UnaryNode[Expression] {
Expand All @@ -118,7 +118,7 @@ case class Average(child: Expression) extends PartialAggregate with trees.UnaryN
partialCount :: partialSum :: Nil)
}

override def newInstance = new AverageFunction(child, this)
override def newInstance()= new AverageFunction(child, this)
}

case class Sum(child: Expression) extends PartialAggregate with trees.UnaryNode[Expression] {
Expand All @@ -134,7 +134,7 @@ case class Sum(child: Expression) extends PartialAggregate with trees.UnaryNode[
partialSum :: Nil)
}

override def newInstance = new SumFunction(child, this)
override def newInstance()= new SumFunction(child, this)
}

case class SumDistinct(child: Expression)
Expand All @@ -145,7 +145,7 @@ case class SumDistinct(child: Expression)
def dataType = child.dataType
override def toString = s"SUM(DISTINCT $child)"

override def newInstance = new SumDistinctFunction(child, this)
override def newInstance()= new SumDistinctFunction(child, this)
}

case class First(child: Expression) extends PartialAggregate with trees.UnaryNode[Expression] {
Expand All @@ -160,7 +160,7 @@ case class First(child: Expression) extends PartialAggregate with trees.UnaryNod
First(partialFirst.toAttribute),
partialFirst :: Nil)
}
override def newInstance = new FirstFunction(child, this)
override def newInstance()= new FirstFunction(child, this)
}

case class AverageFunction(expr: Expression, base: AggregateExpression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ case class Aggregate(

// Creates a new aggregate buffer for a group.
def newAggregateBuffer(): Array[AggregateFunction] = {
val buffer = new Array[AggregateFunction](computedAggregates.size)
val buffer = new Array[AggregateFunction](computedAggregates.length)
var i = 0
while(i < computedAggregates.size) {
buffer(i) = computedAggregates(i).aggregate.newInstance
while (i < computedAggregates.length) {
buffer(i) = computedAggregates(i).aggregate.newInstance()
i += 1
}
buffer
Expand Down Expand Up @@ -122,16 +122,16 @@ case class Aggregate(
while (iter.hasNext) {
currentRow = iter.next()
var i = 0
while (i < buffer.size) {
while (i < buffer.length) {
buffer(i).update(currentRow)
i += 1
}
}
val resultProjection = new Projection(resultExpressions, computedSchema)
val aggregateResults = new GenericMutableRow(computedAggregates.size)
val aggregateResults = new GenericMutableRow(computedAggregates.length)

var i = 0
while (i < buffer.size) {
while (i < buffer.length) {
aggregateResults(i) = buffer(i).apply(EmptyRow)
i += 1
}
Expand All @@ -154,15 +154,15 @@ case class Aggregate(
}

var i = 0
while (i < currentBuffer.size) {
while (i < currentBuffer.length) {
currentBuffer(i).update(currentRow)
i += 1
}
}

new Iterator[Row] {
private[this] val hashTableIter = hashTable.entrySet().iterator()
private[this] val aggregateResults = new GenericMutableRow(computedAggregates.size)
private[this] val aggregateResults = new GenericMutableRow(computedAggregates.length)
private[this] val resultProjection =
new MutableProjection(resultExpressions, computedSchema ++ namedGroups.map(_._2))
private[this] val joinedRow = new JoinedRow
Expand All @@ -175,7 +175,7 @@ case class Aggregate(
val currentBuffer = currentEntry.getValue

var i = 0
while (i < currentBuffer.size) {
while (i < currentBuffer.length) {
aggregateResults(i) = currentBuffer(i).apply(EmptyRow)
i += 1
}
Expand Down

0 comments on commit b4a6887

Please sign in to comment.