tree
The Deephaven tree
method creates a tree table from a source table given an ID column name and parent column name.
Syntax
resultNoOrphans = source.tree(idColumn, parentColumn)
resultWithOrphans = TreeTable.promoteOrphans(source, idColumn, parentColumn).tree(idColumn, parentColumn)
Parameters
Parameter | Type | Description |
---|---|---|
idColumn> | String | The name of the ID column. |
parentColumn | String | The name of the parent column. |
Methods
Static
The TreeTable
interface has the following static methods:
promoteOrphans(Table, String, String)
- Adapt a source table to be used for a tree to ensure that the result will have no orphaned nodes.
Instance
The following methods can be called on an instance of TreeTable
:
getIdentifierColumn
- Get the name of the identifier column used to create the tree table.getNodeDefinition
- Get the TableDefinition that should be exposed to node table consumers.getParentIdentifierColumn
- Get the name of the parent identifier column used to create the tree table.makeNodeOperationsRecorder
- Create aTreeNodeOperationsRecorder
, which records node-level operations when capturing snapshots.withFilters(filters...)
- Create a newTreeTable
with the specifiedFilters
applied.withNodeFilterColumns(ColumnNames...)
- Create a newTreeTable
with the specifiedColumnNames...
designated for node-level filtering.withNodeOperations(nodeOperations)
- Create a newTreeTable
that will apply the recorded operations to nodes when gathering snapshots.
Returns
A tree table.
Examples
The following example creates a tree table from a static table.
source = emptyTable(100).updateView("ID = i", "Parent = i == 0 ? NULL_INT : (int)(i / 4)")
result = source.tree("ID", "Parent")
- result
- source
The following example creates a tree table from a real-time table.
t1 = emptyTable(10_000).updateView("ID = i", "Parent = i == 0 ? NULL_INT : (int)(i / 10)")
t2 = timeTable("PT00:00:00.01").updateView("I = i % 10_000").lastBy("I")
source = t1.join(t2, "ID = I")
result = source.tree("ID", "Parent")
The following example contains orphan nodes. Two tree tables are created. The first omits orphan nodes, while the second promotes them such that they appear in the tree table.
import io.deephaven.engine.table.hierarchical.TreeTable
source = emptyTable(100).updateView("ID = i + 2", "Parent = i == 0 ? NULL_INT : i % 100")
resultNoOrphans = source.tree("ID", "Parent")
resultWithOrphans = TreeTable.promoteOrphans(source, "ID", "Parent").tree("ID", "Parent")
- resultNoOrphans
- resultWithOrphans
- source