Node¶
interface Node
An element in an abstract tree.
It is not expected that users of this library have to deal with this type directly.
Trees¶
Trees are expected to be built bottom-up: a node is always built before its parents. Once a node has been accepted by a parent, it is simplified then freezes (becomes forever immutable). The same node may be added to multiple parent nodes.
This scheme ensures that trees are always fully simplified: we are always building a single node at a time, and all its children are guaranteed to already be immutable and simplified themselves.
There are two main categories of nodes:
-
Nodes that represent some data by themselves.
-
Nodes that group other nodes into a single larger node.
The former category implements this interface, whereas the latter implements CompoundNode.
Implementations¶
The two main implementations of this interface are:
-
BsonNodeis mainly used for operators in queries -
Valueis mainly used for operators and their results in aggregations
Inheritors¶
Functions¶
freeze¶
@LowLevelApi
abstract fun freeze()
Makes this node immutable.
After this method has been called, the expression can never be modified again. This ensures that nodes cannot change after they have been used within other nodes.
To learn more about this process, see Node.
Thread-safety
Instances of <strong>Node</strong> are not thread-safe before <strong>freeze</strong> has been called.
Once the freeze function has returned, then the node must be immutable and thread-safe.