Hi!
I’m currently implementing the Directory for the unofficial Rust client and I’m confused around the idea of the DirectoryPartition
.
I do think something is wrong around my mental representation of the Directory, and I would love some help to find which part
On the Python bindings, we have this:
def _contents_of_node(self, node, path, layer=None):
prefix = self._node_subspace.unpack(node.key())[0]
if layer == b'partition':
return DirectoryPartition(self._path + path, prefix, self)
else:
return DirectorySubspace(self._path + path, prefix, self, layer)
It looks like a DirectoryPartition
is kind of a nested Directory inside a node_subspace
, which is confirmed by the Go’s related struct:
type directoryPartition struct {
directoryLayer
parentDirectoryLayer directoryLayer
}
I do not see the point of having another Directory
with his own {node, hca} subspaces
inside the node_subspace
of the parent.
I also don’t understand the relevant documentation:
Under normal operation, a directory does not share a common key prefix with its subdirectories. As a result, related directories are not necessarily located together in key-space.
Are we talking about the content_subspace
or the node_subspace
? Both of them have a key-prefix:
- the
content_subspace
has an prefix for all sub-directories, - the
node_subspace
can be configured at creation.
This means that you cannot use a single range query to read all contents of a directory and its descendants simultaneously, for example.
Why can’t we *just* scan the node_subspace
? Here’s how I represent the directory, for a path like []string{"app", "my-app"}
:
+
|
| version = (1,0,0) # Directory's version
|
| +
| "hca"| # used to allocate numbers like 12 and 42
| +
\xFE |
node's | (0,"app")=12 # id allocated by the hca for "path"
subspace | (0,"app","layer")="" # layer allow an ownership's mecanism
|
|
| (0,"app",0,"my-app","layer")="" # layer allow an ownership's mecanism
| (0,"app",0,"my-app")=42 # id allocated by the hca for "layer"
+
+
|
|
(12,42) |
content | # data's subspace for path "app","my-app"
subspace |
|
+
As we are packing any nested path in the previous subspace (here "my-app"
is a Subspace packed from the “app” subspace, himself packed from the node_subspace
), I don’t see why we cannot scan between
(\xFE, 0)
and(\xFE, 1)
for theroot_node
,(\xFE, 0, ...some nested path..., 0)
and(\xFE, ...some nested path..., 1)
for any nested node,
and filter the “layer” row key?
For most applications this behavior is acceptable, but in some cases it may be useful to have a directory tree in your hierarchy where every directory shares a common prefix.
I guess here we are talking about the content_subspace
, but we do have a common prefix: the parent, like in my exemple "my-app"
is prefixed by the integer generated for "app"
.
Thanks for reading me, and stay safe,
PierreZ