spark git commit: [SPARK-10371][SQL][FOLLOW-UP] fix code style
Repository: spark Updated Branches: refs/heads/branch-1.6 7de8abd6f -> 0d637571d [SPARK-10371][SQL][FOLLOW-UP] fix code style Author: Wenchen FanCloses #9627 from cloud-fan/follow. (cherry picked from commit 1510c527b4f5ee0953ae42313ef9e16d2f5864c4) Signed-off-by: Yin Huai Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/0d637571 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/0d637571 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/0d637571 Branch: refs/heads/branch-1.6 Commit: 0d637571d7705dca3ac63d8bf57224290223c0ff Parents: 7de8abd Author: Wenchen Fan Authored: Wed Nov 11 09:33:07 2015 -0800 Committer: Yin Huai Committed: Wed Nov 11 09:34:08 2015 -0800 -- .../expressions/EquivalentExpressions.scala | 22 +--- .../sql/catalyst/expressions/Expression.scala | 21 +-- .../expressions/codegen/CodeGenerator.scala | 20 +- 3 files changed, 30 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/spark/blob/0d637571/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala -- diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala index e7380d2..f83df49 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala @@ -29,29 +29,27 @@ class EquivalentExpressions { * Wrapper around an Expression that provides semantic equality. */ case class Expr(e: Expression) { -val hash = e.semanticHash() override def equals(o: Any): Boolean = o match { case other: Expr => e.semanticEquals(other.e) case _ => false } -override def hashCode: Int = hash +override val hashCode: Int = e.semanticHash() } // For each expression, the set of equivalent expressions. - private val equivalenceMap: mutable.HashMap[Expr, mutable.MutableList[Expression]] = - new mutable.HashMap[Expr, mutable.MutableList[Expression]] + private val equivalenceMap = mutable.HashMap.empty[Expr, mutable.MutableList[Expression]] /** * Adds each expression to this data structure, grouping them with existing equivalent * expressions. Non-recursive. - * Returns if there was already a matching expression. + * Returns true if there was already a matching expression. */ def addExpr(expr: Expression): Boolean = { if (expr.deterministic) { val e: Expr = Expr(expr) val f = equivalenceMap.get(e) if (f.isDefined) { -f.get.+= (expr) +f.get += expr true } else { equivalenceMap.put(e, mutable.MutableList(expr)) @@ -63,19 +61,19 @@ class EquivalentExpressions { } /** - * Adds the expression to this datastructure recursively. Stops if a matching expression + * Adds the expression to this data structure recursively. Stops if a matching expression * is found. That is, if `expr` has already been added, its children are not added. * If ignoreLeaf is true, leaf nodes are ignored. */ def addExprTree(root: Expression, ignoreLeaf: Boolean = true): Unit = { val skip = root.isInstanceOf[LeafExpression] && ignoreLeaf -if (!skip && root.deterministic && !addExpr(root)) { - root.children.foreach(addExprTree(_, ignoreLeaf)) +if (!skip && !addExpr(root)) { + root.children.foreach(addExprTree(_, ignoreLeaf)) } } /** - * Returns all fo the expression trees that are equivalent to `e`. Returns + * Returns all of the expression trees that are equivalent to `e`. Returns * an empty collection if there are none. */ def getEquivalentExprs(e: Expression): Seq[Expression] = { @@ -90,8 +88,8 @@ class EquivalentExpressions { } /** - * Returns the state of the datastructure as a string. If all is false, skips sets of equivalent - * expressions with cardinality 1. + * Returns the state of the data structure as a string. If `all` is false, skips sets of + * equivalent expressions with cardinality 1. */ def debugString(all: Boolean = false): String = { val sb: mutable.StringBuilder = new StringBuilder() http://git-wip-us.apache.org/repos/asf/spark/blob/0d637571/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala -- diff --git
spark git commit: [SPARK-10371][SQL][FOLLOW-UP] fix code style
Repository: spark Updated Branches: refs/heads/master 1bc41125e -> 1510c527b [SPARK-10371][SQL][FOLLOW-UP] fix code style Author: Wenchen FanCloses #9627 from cloud-fan/follow. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/1510c527 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/1510c527 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/1510c527 Branch: refs/heads/master Commit: 1510c527b4f5ee0953ae42313ef9e16d2f5864c4 Parents: 1bc4112 Author: Wenchen Fan Authored: Wed Nov 11 09:33:07 2015 -0800 Committer: Yin Huai Committed: Wed Nov 11 09:33:41 2015 -0800 -- .../expressions/EquivalentExpressions.scala | 22 +--- .../sql/catalyst/expressions/Expression.scala | 21 +-- .../expressions/codegen/CodeGenerator.scala | 20 +- 3 files changed, 30 insertions(+), 33 deletions(-) -- http://git-wip-us.apache.org/repos/asf/spark/blob/1510c527/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala -- diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala index e7380d2..f83df49 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala @@ -29,29 +29,27 @@ class EquivalentExpressions { * Wrapper around an Expression that provides semantic equality. */ case class Expr(e: Expression) { -val hash = e.semanticHash() override def equals(o: Any): Boolean = o match { case other: Expr => e.semanticEquals(other.e) case _ => false } -override def hashCode: Int = hash +override val hashCode: Int = e.semanticHash() } // For each expression, the set of equivalent expressions. - private val equivalenceMap: mutable.HashMap[Expr, mutable.MutableList[Expression]] = - new mutable.HashMap[Expr, mutable.MutableList[Expression]] + private val equivalenceMap = mutable.HashMap.empty[Expr, mutable.MutableList[Expression]] /** * Adds each expression to this data structure, grouping them with existing equivalent * expressions. Non-recursive. - * Returns if there was already a matching expression. + * Returns true if there was already a matching expression. */ def addExpr(expr: Expression): Boolean = { if (expr.deterministic) { val e: Expr = Expr(expr) val f = equivalenceMap.get(e) if (f.isDefined) { -f.get.+= (expr) +f.get += expr true } else { equivalenceMap.put(e, mutable.MutableList(expr)) @@ -63,19 +61,19 @@ class EquivalentExpressions { } /** - * Adds the expression to this datastructure recursively. Stops if a matching expression + * Adds the expression to this data structure recursively. Stops if a matching expression * is found. That is, if `expr` has already been added, its children are not added. * If ignoreLeaf is true, leaf nodes are ignored. */ def addExprTree(root: Expression, ignoreLeaf: Boolean = true): Unit = { val skip = root.isInstanceOf[LeafExpression] && ignoreLeaf -if (!skip && root.deterministic && !addExpr(root)) { - root.children.foreach(addExprTree(_, ignoreLeaf)) +if (!skip && !addExpr(root)) { + root.children.foreach(addExprTree(_, ignoreLeaf)) } } /** - * Returns all fo the expression trees that are equivalent to `e`. Returns + * Returns all of the expression trees that are equivalent to `e`. Returns * an empty collection if there are none. */ def getEquivalentExprs(e: Expression): Seq[Expression] = { @@ -90,8 +88,8 @@ class EquivalentExpressions { } /** - * Returns the state of the datastructure as a string. If all is false, skips sets of equivalent - * expressions with cardinality 1. + * Returns the state of the data structure as a string. If `all` is false, skips sets of + * equivalent expressions with cardinality 1. */ def debugString(all: Boolean = false): String = { val sb: mutable.StringBuilder = new StringBuilder() http://git-wip-us.apache.org/repos/asf/spark/blob/1510c527/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala -- diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/Expression.scala