This is an automated email from the ASF dual-hosted git repository.
hongze pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 1fd19a563 [VL] Following #5889, correct / simplify the table indenting
algorithm (#5917)
1fd19a563 is described below
commit 1fd19a563b7ce1e2b0a0cb5a79a4044e743d3ab0
Author: Hongze Zhang <[email protected]>
AuthorDate: Thu May 30 11:00:06 2024 +0800
[VL] Following #5889, correct / simplify the table indenting algorithm
(#5917)
---
.../gluten/integration/action/Parameterized.scala | 2 +-
.../apache/gluten/integration/action/TableRender.scala | 10 ++++++----
.../gluten/integration/action/TableRenderTest.scala | 18 ++++++++++++++++++
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git
a/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/Parameterized.scala
b/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/Parameterized.scala
index 799b7632e..8f5bc0946 100644
---
a/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/Parameterized.scala
+++
b/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/Parameterized.scala
@@ -227,7 +227,7 @@ case class TestResultLines(
metricNames: Seq[String],
lines: Iterable[TestResultLine]) {
def print(): Unit = {
- val fields = ListBuffer[String]("Query ID", "Succeed")
+ val fields = ListBuffer[String]("Query ID", "Succeeded")
dimNames.foreach(dimName => fields.append(dimName))
metricNames.foreach(metricName => fields.append(metricName))
fields.append("Row Count")
diff --git
a/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/TableRender.scala
b/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/TableRender.scala
index b25a5db93..4cded2848 100644
---
a/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/TableRender.scala
+++
b/tools/gluten-it/common/src/main/scala/org/apache/gluten/integration/action/TableRender.scala
@@ -116,12 +116,14 @@ object TableRender {
def updateWidth(field: Field, lowerBound: Int): Unit = {
field match {
case branch @ Field.Branch(name, children) =>
- val childLowerBound =
- Math.ceil((lowerBound max name.length + 2).toDouble /
children.size.toDouble).toInt
- children.foreach(child => updateWidth(child, childLowerBound))
+ val leafLowerBound =
+ Math
+ .ceil((lowerBound max name.length + 2).toDouble /
branch.leafs.size.toDouble)
+ .toInt
+ children.foreach(child => updateWidth(child, leafLowerBound *
child.leafs.size))
val childrenWidth =
children.map(child =>
widthMap(System.identityHashCode(child))).sum
- val width = childLowerBound * children.size max childrenWidth +
children.size - 1
+ val width = childrenWidth + children.size - 1
val hash = System.identityHashCode(branch)
widthMap += hash -> width
case leaf @ Field.Leaf(name) =>
diff --git
a/tools/gluten-it/common/src/test/java/org/apache/gluten/integration/action/TableRenderTest.scala
b/tools/gluten-it/common/src/test/java/org/apache/gluten/integration/action/TableRenderTest.scala
index 87ad23f36..ce7b0974c 100644
---
a/tools/gluten-it/common/src/test/java/org/apache/gluten/integration/action/TableRenderTest.scala
+++
b/tools/gluten-it/common/src/test/java/org/apache/gluten/integration/action/TableRenderTest.scala
@@ -82,10 +82,28 @@ object TableRenderTest {
Console.out.println()
}
+ def case4(): Unit = {
+ val render: TableRender[Seq[String]] = TableRender.create(
+ Branch(
+ "ABBBBBBBBBBBBBBBBBBBBBBBBBBBBC",
+ List(Branch("AB", List(Leaf("A"), Leaf("B"))), Leaf("C"))),
+ Branch("DE", List(Leaf("D"), Leaf("E"))))(new RowParser[Seq[String]] {
+ override def parse(rowFactory: FieldAppender.RowAppender, row:
Seq[String]): Unit = {
+ val inc = rowFactory.incremental()
+ row.foreach(ceil => inc.next().write(ceil))
+ }
+ })
+
+ render.appendRow(List("aaaa", "b", "cccccc", "d", "eeeee"))
+ render.print(Console.out)
+ Console.out.println()
+ }
+
def main(args: Array[String]): Unit = {
case0()
case1()
case2()
case3()
+ case4()
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]