'\x16...'
to '\x1D...'
- Keys that represent contents of the directory tree. This is basically “all possible positive integers”. The prefix of each key is a directory node down below.
'\xFE'
- Prefix for all keys related to the directory tree node hierarchy.
'\xFE\x01version\x00'
- Version of the directory tree formatted as: <<V1:32/little-unsigned, V2:32/little-unsigned, V3:32/little-unsigned>>
'\xFE\x01\xFE\x00'
- the root node of the tree
'\xFE\x01\xFE\x00\x01layer\x00'
- the “layer” of the given node. This is set at node creation time and never mutated by the directory layer. If a layer is provided when opening nodes it checks to see that the layer matches nodes that are read. When there‘s a mismatch an error is thrown. I believe the purpose of this is so that users of the DirectoryLayer can assert a primitive “ownership” over part of the directory tree with some guarantee that they won’t accidentally trample over each other. However, if “layer” is the binary string “partition” then this becomes a whole new thing which I'll discuss below.
'\xFE\x01\xFE\x00\x16' - The prefix for all child nodes of the root node. The pattern here is basically
‘\xFE’` + erlfdb_tupe:pack({node.key(), 0}) although its using erlfdb_subspaces under the hood. I may ixnay subspaces in the directory layer because the syntax really isn't all that useful in Erlang.
'\xFE\x01\xFE\x00\x16\x02foo\x00'
-> '\x17\x05'
- A child node named “foo” which has a node id of \x17\x05
.
'\xFE\x17\x05\x16\x02bar\x00'
-> '\x17\x19'
- A child of “foo” named “bar” with node id '\x17\x19'
. The tree is made by recursively following these paths.
'\xFE\x17\x19\x01layer\x00'
-> 'partition'
A node id has its layer value set to partition which means that this node is “DirectoryPartition” which basically means its node id is pasted onto the front of every subtree node. This can be useful to do a range scan against an entire subtree. However, directories can not be moved across partition boundaries (because that would require changing all of their key prefixes). Also, it makes key lengths slightly longer by the length of the short node id string.
Partitions are roughly equivalent to a nested directory tree re-rooted outside the main directory tree. All of the contents and node keys share the same prefix based on the node id of the partition.
A warning to future readers, this list of names is used fairly consistently by the erlfdb
DirectoryLayer, however they are not all used in the Python implementation. So any comparison between the two requires some fairly decent knowledge of how things work. This is mostly because the Python implementation doesn't actually bother naming things and instead has a number of long function invocations that gloss over where we might need to assign something to a variable in Erlang.
These are all based on the assumption that my schema is at least relatively close to reality and also by staring at the Python implementation. However, the Python implementation makes extensive use of OO inheritance as well as syntactical sugar via magic methods. These algorithms are my general reinterpretation of the Python approach in Erlang terms.
Some common assumptions here:
\xFE\x01\xFE\x00
) (though this will obviously be parameterizable).'\xFE' + node_id
del_children(child_id)
clear_range for all content related to child_id