This is an automated email from the ASF dual-hosted git repository.

pingtimeout pushed a commit to branch benchmarks-ppc
in repository https://gitbox.apache.org/repos/asf/polaris-tools.git

commit 4c9b6531e8b347a3d84f976e397d0fd14f93750f
Author: Pierre Laporte <pie...@pingtimeout.fr>
AuthorDate: Wed May 14 14:33:06 2025 +0200

    Compute the sibling nodes of a given ordinal in the tree
---
 .../org/apache/polaris/benchmarks/NAryTreeBuilder.scala | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git 
a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala
 
b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala
index 2dcc4b8..5be05bc 100644
--- 
a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala
+++ 
b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala
@@ -117,4 +117,21 @@ case class NAryTreeBuilder(nsWidth: Int, nsDepth: Int) {
     val lastLevel = nsDepth - 1
     math.pow(nsWidth, lastLevel).toInt
   }
+
+  /**
+   * Computes the ordinals of all sibling nodes for a given node.
+   *
+   * @param ordinal the ordinal of the node
+   * @return a list of ordinals representing the sibling nodes (excluding the 
node itself)
+   */
+  def siblingsOf(ordinal: Int): List[Int] =
+    if (ordinal == 0) {
+      // Root node has no siblings
+      List.empty
+    } else {
+      // Get parent ordinal
+      val parent = (ordinal - 1) / nsWidth
+      // Get all children of parent (siblings including self) and exclude self
+      childrenOf(parent).filter(_ != ordinal)
+    }
 }

Reply via email to