Package

org.opencypher.okapi

trees

Permalink

package trees

Visibility
  1. Public
  2. All

Type Members

  1. abstract class AbstractTreeNode[T <: AbstractTreeNode[T]] extends TreeNode[T]

    Permalink

    Class that implements the children and withNewChildren methods using reflection when implementing TreeNode with a case class or case object.

    Class that implements the children and withNewChildren methods using reflection when implementing TreeNode with a case class or case object.

    Requirements: All child nodes need to be individual constructor parameters and their order in children is their order in the constructor. Every constructor parameter of type T is assumed to be a child node.

    This class caches values that are expensive to recompute.

    The constructor can also contain a list of children, but there are constraints:

    • A list of children cannot be empty, because the current design relies on testing the type of an element.
    • If any children are contained in a list at all, then all list elements need to be children. This allows to only check the type of the first element.
    • There can be at most one list of children and there can be no normal child constructor parameters that appear after the list of children. This allows to call withNewChildren with a different number of children than the original node had and vary the length of the list to accommodate.
  2. case class BottomUp[T <: TreeNode[T]](rule: PartialFunction[T, T])(implicit evidence$3: ClassTag[T]) extends TreeRewriter[T, T] with Product with Serializable

    Permalink

    Applies the given partial function starting from the leafs of this tree.

  3. case class InvalidConstructorArgument(message: String, originalException: Option[Exception] = None) extends RuntimeException with Product with Serializable

    Permalink
  4. case class TopDown[T <: TreeNode[T]](rule: PartialFunction[T, T])(implicit evidence$4: ClassTag[T]) extends TreeRewriter[T, T] with Product with Serializable

    Permalink

    Applies the given partial function starting from the root of this tree.

    Applies the given partial function starting from the root of this tree.

    Note

    Note the applied rule cannot insert new parent nodes.

  5. abstract class TreeNode[T <: TreeNode[T]] extends Product with Traversable[T]

    Permalink

    This is the basic tree node class.

    This is the basic tree node class. Usually it makes more sense to use AbstractTreeNode, which uses reflection to generate the children and withNewChildren field/method. Our benchmarks show that manually implementing them can result in a speedup of a factor of ~3 for tree rewrites, so in performance critical places it might make sense to extend TreeNode instead.

    This class uses array operations instead of Scala collections, both for improved performance as well as to save stack frames during recursion, which allows it to operate on trees that are several thousand nodes high.

  6. abstract class TreeRewriter[I <: TreeNode[I], O <: TreeNode[O]] extends AnyRef

    Permalink

Value Members

  1. object AbstractTreeNode

    Permalink

    Caches an instance of the copy method per case class type.

Ungrouped