Mattress 0.2.1 (formerly Hatter)
Mattress is a command line tool for working with Linux extended attributes (xattrs)
Because someone else's awesome project already occupied the hatter
crate, I've changed the name of my project from "Hatter" to "Mattress" which, weird as it is, has the advantage of actually including "attr" as a substring.
The executable name has correspondingly changed from htr
to mtr
.
This version begins the introduction of simple database-like features, implemented using the filesystem and extended attributes as a substrate.
Mattress sees the world in a peculiar way: it interprets a filesystem folder as a database table with one record for each file in the folder, indexed by the "primary key" of the filename.
A nested hierarchy of directories is seen by Mattress as a database table indexed by the compound key corresponding to the nested subpath, and one "record" per file encompassed under the folder recursively.
Consider this folder ./people
of personnel records:
$ mtr get ./people/* ./people/Sandeep user.id 2 ./people/Sandeep user.name Sandeep ./people/Sandeep user.state CA ./people/Sofia user.id 1 ./people/Sofia user.name Sofia ./people/Sofia user.state WA ./people/Wulfrum user.id 0 ./people/Wulfrum user.name Wulfrum ./people/Wulfrum user.state CA
Suppose we want to index not by the name as now, but by the id
. We can do this using the new idx
command.
$ mtr idx -v -k id ./people ./people:id ./people/Sandeep -> ./people:id/2 ./people/Sofia -> ./people:id/1 ./people/Wulfrum -> ./people:id/0
The arrows show the hardlinks mapping the original ./people
folder to the indexed view ./people:id
.
We can also index by compound keys, such as here where we index by (state,id)
:
$ mtr idx -v -k state -k id ./people ./people:state:id ./people/Sandeep -> ./people:state:id/CA/2 ./people/Sofia -> ./people:state:id/WA/1 ./people/Wulfrum -> ./people:state:id/CA/0
I have some "magic" planned to speed up the get
command and ease the ergonomics (letting you reference e.g. state
, which will be taken from the path rather than from the per-file xattrs.) Eventually I'd like to allow for SQL SELECT
-style conditions, but that's for another day.