#29 Need a way to reference parent from a given ParseTreeNode

closed
nobody
None
5
2012-10-08
2012-04-06
Xavier Cho
No

I suppose we need a way to reference the parent node from a given ParseTreeNode. For example, when you implement a drill down feature which requires to examine if an argument to a function call such as Union or Hierarchize represents a descendent member of the target member for the operation, then if it's true modifiy the parent CallNode as needed.

It's much hard to implement without any way to reference to the parent node in ParseTreeNode API.

Discussion

  • Julian Hyde
    Julian Hyde
    2012-04-06

    I agree it's harder to use the API when there are no parent links. But I deliberately created the API this way, for 2 reasons:

    1. A node can have multiple parents. E.g. you can create the literal constant 0 and use it in several places in your parse tree. If there were backlinks to parents, a DAG such as this would not be allowed.

    2. It is easier to modify parse trees, because there are fewer links to hook up.

    If you want to know the parent keep a stack. You might find it useful to create an implementation of org.olap4j.mdx.ParseTreeVisitor that keeps that stack automatically.

    Because the design is as I intended, I am changing this to a feature request and closing with status "rejected".