Travesing/Querying through the namsepace #1116
fatihalgan
started this conversation in
General
Replies: 1 comment
-
No, nothing like that. Perhaps you should be storing NodeIds instead of cobbling together paths; these can be retrieved in constant time from the NodeManager, which is basically just a map. Or store them in some other manner that allows a more efficient lookup. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I was wondering what is the correct way of using the namespace API to locate a node in the namespace. Currently, I am forced to hold a reference to the root level UAFolderNode (or nodes) inside the namespace and use a treeilike recursion based technique similar to the following;
public Tuple2<String, UaFolderNode> getChildFolderFromRoot(String path, UaFolderNode root) {
String[] paths = path.split("/");
Optional maybeChild = getChildFolder(path, root, true);
String[] newPaths = new String[paths.length - 1];
//if path is same as root itself
if(newPaths.length == 0 && path.equals(root.getBrowseName().getName())) {
return new Tuple2<String, UaFolderNode>(path, root);
}
for (int i = 1; i < paths.length; i++) {
newPaths[i - 1] = paths[i];
}
if (newPaths.length > 1) {
String newPath = String.join("/", newPaths);
return getChildFolderFromRoot(newPath, maybeChild.get());
} else {
return new Tuple2<String, UaFolderNode>(newPaths[0], maybeChild.get());
}
}
I wonder if there is a more proper way to search and retrieve a reference to a UaFolderNode (or any other node) instance just via specifying a path, like a query API against the namespace without holding a reference to the root node.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions