Class HistoricalNodeTree<N extends HistoricalNode>
java.lang.Object
com.inductiveautomation.ignition.common.PathTree<QualifiedPath, N>
com.inductiveautomation.historian.gateway.api.query.HistoricalNodeTree<N>
- Type Parameters:
N- the node type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
RetirementAwareNodeTree
A
PathTree of HistoricalNodes keyed by QualifiedPath, with recursive
removal that also removes parent nodes left without children.
Thread-safe: one ReadWriteLockExecutor guards every tree operation, with reads taking
a read hold, mutations a write hold, and nested same-thread holds running inline. The
*Unlocked variants let a caller batch several operations under one hold and assert that it holds
the lock.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class PathTree
PathTree.TreeNode -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbrowse(QualifiedPath path) Essentially an alias for getChildren(path), though wraps the results in a list.final voidclear()Clears the entire tree.final voidCALLER MUST HOLD WRITE LOCK.final NcomputeIfAbsent(QualifiedPath path, Function<QualifiedPath, N> supplier) final NcomputeIfAbsentUnlocked(QualifiedPath path, Function<QualifiedPath, N> supplier) CALLER MUST HOLD WRITE LOCK.protected final PathTree<QualifiedPath, N>.TreeNodefindNode(QualifiedPath path, boolean create) Locates the node at the given path.protected final PathTree<QualifiedPath, N>.TreeNodefindNode(QualifiedPath path, boolean create, Object[] valueArray) protected final PathTree<QualifiedPath, N>.TreeNodefindNodeUnlocked(QualifiedPath path, boolean create) CALLER MUST HOLD WRITE OR READ LOCK.protected final PathTree<QualifiedPath, N>.TreeNodefindNodeUnlocked(QualifiedPath path, boolean create, Object[] valueArray) CALLER MUST HOLD WRITE OR READ LOCK.final Nget(QualifiedPath path) Returns the value at the given path.final <R extends N>
Collection<R> Returns all nested children under a given path using breadth-first search.getBranches(QualifiedPath path) Returns the keys for the branches beneath the given point.getBranches(QualifiedPath path, boolean foldersOnly) Returns the keys for the branches beneath the given point.final @Nullable NgetByCanonicalKey(String canonicalKey) Returns the node for a canonical lowercased qualified-path string in O(1), ornullif none.final <R extends N>
Collection<R> getChildren(QualifiedPath path) Returns the children under a given path.protected final PathTree<QualifiedPath, N>.@NonNull TreeNodegetRoot()final NgetUnlocked(QualifiedPath path) CALLER MUST HOLD WRITE OR READ LOCK.final Object[]getValuesOfPath(QualifiedPath path) Returns all of the node values from the tree nodes along the specified path.protected final PathTree<QualifiedPath, N>.TreeNodeinstantiateNode(PathTree<QualifiedPath, N>.TreeNode parent, QualifiedPath path, int pos) Instantiates a TreeNode under the parent, for the given path position of the path.booleanWhether the current thread holds the node-tree read lock.booleanWhether the current thread holds the node-tree write lock.final booleanput(QualifiedPath path, N value) Inserts the value at the given path.final booleanputUnlocked(QualifiedPath path, N value) CALLER MUST HOLD WRITE LOCK.voidfinal voidCALLER MUST HOLD WRITE LOCK.final Nremove(QualifiedPath path) Removes the given path, and returns the value that was associated with the path, if applicable.final @Nullable NremoveIfEmpty(QualifiedPath path) Removes and returns the value, and if there are no children, removes the node from the tree.final @Nullable NCALLER MUST HOLD WRITE LOCK.final NremoveUnlocked(QualifiedPath path) CALLER MUST HOLD WRITE LOCK.final intsize()Calculates the size of this tag tree.<E extends Exception>
voidwithReadLock(CheckedRunnable<E> action) <T, E extends Exception>
TwithReadLock(CheckedSupplier<T, E> action) <E extends Exception>
voidwithWriteLock(CheckedRunnable<E> action) <T, E extends Exception>
TwithWriteLock(CheckedSupplier<T, E> action) Methods inherited from class PathTree
initializeRoot, isCaseSensitive, setCaseSensitive
-
Field Details
-
rwLockExecutor
-
-
Constructor Details
-
HistoricalNodeTree
-
-
Method Details
-
recursiveRemoveWithParent
-
recursiveRemoveWithParentUnlocked
CALLER MUST HOLD WRITE LOCK. -
findNode
Description copied from class:PathTreeLocates the node at the given path. Will insert nodes as necessary, if create is true. Otherwise will return null if the path doesn't exist.- Overrides:
findNodein classPathTree<QualifiedPath, N extends HistoricalNode>
-
findNodeUnlocked
protected final PathTree<QualifiedPath, N>.TreeNode findNodeUnlocked(QualifiedPath path, boolean create) CALLER MUST HOLD WRITE OR READ LOCK. -
findNode
protected final PathTree<QualifiedPath, N>.TreeNode findNode(QualifiedPath path, boolean create, Object[] valueArray) - Overrides:
findNodein classPathTree<QualifiedPath, N extends HistoricalNode>
-
findNodeUnlocked
protected final PathTree<QualifiedPath, N>.TreeNode findNodeUnlocked(QualifiedPath path, boolean create, Object[] valueArray) CALLER MUST HOLD WRITE OR READ LOCK. -
getValuesOfPath
Description copied from class:PathTreeReturns all of the node values from the tree nodes along the specified path. The return length will be the path length + 1 (the root/null value), even if the node doesn't exist. Any tree node that doesn't exist or doesn't have a value will have a null entry.- Overrides:
getValuesOfPathin classPathTree<QualifiedPath, N extends HistoricalNode>- Parameters:
path- the path to locate- Returns:
- an array whose bounds are equal to path.getPathLength()+1. Index 0 is the null/root value. Each array element represents the value at a given location in the tree, and will be null if the node does not exist.
-
clear
public final void clear()Description copied from class:PathTreeClears the entire tree.- Overrides:
clearin classPathTree<QualifiedPath, N extends HistoricalNode>
-
clearUnlocked
public final void clearUnlocked()CALLER MUST HOLD WRITE LOCK. -
removeIfEmpty
Description copied from class:PathTreeRemoves and returns the value, and if there are no children, removes the node from the tree. *- Overrides:
removeIfEmptyin classPathTree<QualifiedPath, N extends HistoricalNode>
-
removeIfEmptyUnlocked
CALLER MUST HOLD WRITE LOCK. -
remove
Description copied from class:PathTreeRemoves the given path, and returns the value that was associated with the path, if applicable.- Overrides:
removein classPathTree<QualifiedPath, N extends HistoricalNode>
-
removeUnlocked
CALLER MUST HOLD WRITE LOCK. -
computeIfAbsent
- Overrides:
computeIfAbsentin classPathTree<QualifiedPath, N extends HistoricalNode>
-
computeIfAbsentUnlocked
CALLER MUST HOLD WRITE LOCK. -
get
Description copied from class:PathTreeReturns the value at the given path. If the path is null, the root value is returned.- Overrides:
getin classPathTree<QualifiedPath, N extends HistoricalNode>
-
getUnlocked
CALLER MUST HOLD WRITE OR READ LOCK. -
getByCanonicalKey
Returns the node for a canonical lowercased qualified-path string in O(1), ornullif none. Reads are lock-free, so this suits hot-path lookups by a caller that already holds the key (aNormalizedPathBundle.lowercaseKey()); tree walks still take the lock.- Parameters:
canonicalKey-PathFolding.canonical(path.toString())of the adapted, normalizedQualifiedPath, derived as inAbstractDefinitionResolver.normalizePath
-
put
Description copied from class:PathTreeInserts the value at the given path. Returns whether or not the insertion was successful. Intermediary nodes will be created implicitly, and subclasses can customize their values by overriding instantiateNode.- Overrides:
putin classPathTree<QualifiedPath, N extends HistoricalNode>
-
putUnlocked
CALLER MUST HOLD WRITE LOCK. -
getBranches
Description copied from class:PathTreeReturns the keys for the branches beneath the given point. Returns empty list if the point is not found, or there are no branches. If foldersOnly is true, will only return children that have null leaf values.- Overrides:
getBranchesin classPathTree<QualifiedPath, N extends HistoricalNode>
-
getBranches
Description copied from class:PathTreeReturns the keys for the branches beneath the given point. Returns empty list if the point is not found, or there are no branches.- Overrides:
getBranchesin classPathTree<QualifiedPath, N extends HistoricalNode>
-
getAllNestedChildren
Description copied from class:PathTreeReturns all nested children under a given path using breadth-first search.- Overrides:
getAllNestedChildrenin classPathTree<QualifiedPath, N extends HistoricalNode>
-
getChildren
Description copied from class:PathTreeReturns the children under a given path. Used for browsing. Will never return null, just an empty collection if there are no children or the path doesn't exist. Does not return nested children.- Overrides:
getChildrenin classPathTree<QualifiedPath, N extends HistoricalNode>
-
browse
Description copied from class:PathTreeEssentially an alias for getChildren(path), though wraps the results in a list.- Overrides:
browsein classPathTree<QualifiedPath, N extends HistoricalNode>
-
size
public final int size()Description copied from class:PathTreeCalculates the size of this tag tree. Note that this is not thread safe and is not efficient!- Overrides:
sizein classPathTree<QualifiedPath, N extends HistoricalNode>
-
getRoot
- Overrides:
getRootin classPathTree<QualifiedPath, N extends HistoricalNode>
-
instantiateNode
protected final PathTree<QualifiedPath, N>.TreeNode instantiateNode(PathTree<QualifiedPath, N>.TreeNode parent, QualifiedPath path, int pos) Description copied from class:PathTreeInstantiates a TreeNode under the parent, for the given path position of the path. Subclasses can override this method to provide custom node types, and to create default values for implicit nodes.- Overrides:
instantiateNodein classPathTree<QualifiedPath, N extends HistoricalNode>- Parameters:
parent- the parent nodepath- the complete path of the ultimate node being createdpos- the position in the path that the node is being created for- Returns:
- the new node
-
isWriteLockedByCurrentThread
public boolean isWriteLockedByCurrentThread()Whether the current thread holds the node-tree write lock. -
isReadLockedByCurrentThread
public boolean isReadLockedByCurrentThread()Whether the current thread holds the node-tree read lock. -
withReadLock
- Throws:
E
-
withReadLock
- Throws:
E
-
withWriteLock
- Throws:
E
-
withWriteLock
- Throws:
E
-