LionWeb-io / lionweb-repository

Reference implementation of LionWeb repository
Apache License 2.0
2 stars 1 forks source link

Consider adding operation to retrieve all descendants of a given type #92

Open ftomassetti opened 2 months ago

ftomassetti commented 2 months ago

One operation that is currently expensive to do is to retrieve all the descendants of a given type (or, similary, given a list of nodes of a certain type, finding which ones have a certain ancestor). For example, we have several nodes representing Codebases. Each Codebase contains directories and files. We want to find all the files belonging to a certain Codebase.

Currently we could do a "full retrieve" (retrieve using max depth) on the Codebase, but that could mean retrieving a quite large amount of data as it would retrieve all files and all of their descendants (i.e., an entire codebase). To avoid doing the expensive "full retrieve" we end up doing a lot of "shallow retrieve" (using depth 1). We ask a node (e.g., the Codebase, and then the directories below it, recursively). We then check its type, and then ask for each children, again in shallow mode. This end up causing a lot of requests.

If we had the operation porposed I think it will be much more efficient.

An alternative solution could be to have an API that, given a node, just give the Node IDs of all its descendants. We already have an API to get all the nodes of a given type, so by combining these two APIs we could calculate the list of all descendants of a given node with a certain node type.

ftomassetti commented 2 months ago

Maybe the getNodeTree API could be useful here