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 0a41a81e18d582f621cb78f6dc08f586789be964 Author: Pierre Laporte <pie...@pingtimeout.fr> AuthorDate: Tue May 13 18:29:42 2025 +0200 Compute the children nodes of a given ordinal in the n-ary 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 326ef6d..2dcc4b8 100644 --- a/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala +++ b/benchmarks/src/gatling/scala/org/apache/polaris/benchmarks/NAryTreeBuilder.scala @@ -47,6 +47,23 @@ case class NAryTreeBuilder(nsWidth: Int, nsDepth: Int) { pathToRoot(parent, ordinal :: acc) } + /** + * Computes the ordinals of all child nodes for a given node. + * + * @param ordinal the ordinal of the parent node + * @return a list of ordinals representing the child nodes + */ + def childrenOf(ordinal: Int): List[Int] = { + if (depthOf(ordinal) >= nsDepth - 1) { + // Node is a leaf, has no children + List.empty + } else { + // For a node with ordinal p, its children have ordinals: p*nsWidth + 1, p*nsWidth + 2, ..., p*nsWidth + nsWidth + val firstChild = ordinal * nsWidth + 1 + (firstChild until firstChild + nsWidth).toList + } + } + /** * Calculates the depth of a node in the n-ary tree based on its ordinal. *