Catman...Number(3pm)
β¨ NAME β¨
Catmandu::DirectoryIndex::Number β bestie it's a natural number based directory translator π
(yes this is Catman...Number(3pm) from the User Contributed Perl Documentation, we're doing the whole thing, sit down, hydrate π)
πΈ SYNOPSIS πΈ
use Catmandu::DirectoryIndex::Number;
my $p = Catmandu::DirectoryIndex::Number->new(
base_dir => "/data",
keysize => 9
);
# get mapping for id: { _id => 1234, _path => "/data/000/001/234" }
# can be undef
my $mapping = $p->get(1234);
# create mapping for id. Path created if necessary
my $mapping = $p->add(1234);
# Catmandu::DirectoryIndex::Number is a Catmandu::Iterable
# Returns list of records: [{ _id => "000001234", _path => "/data/000/001/234" }]
my $mappings = $p->to_array();
obsessed with her honestly π¦ so you spin up a new one with a base_dir and a keysize, you get(1234) to find where that id lives (and heads up, it can come back undef, no drama), you add(1234) to actually make the mapping and the path gets created if it doesn't exist yet, and because this whole thing is a Catmandu::Iterable you can just to_array() and get your list of records back. iconic behavior β¨
π METHODS π
π new( base_dir => $base_dir , keysize => NUM )
Build yourself a fresh new Catmandu::DirectoryIndex::Number, and here's the config tea you can pass in:
base_dirβ go look atCatmandu::DirectoryIndex, it's all explained over there πkeysizeβ so by default the directory structure is 3 levels deep. But if you want more nesting you can have it, just setkeysize. The one rule bestie:keysizeneeds to be a multiple of 3. Not 4, not 5, multiples of 3 only, periodt π
π LIMITATIONS π
ngl there's a whole vibe check on the keys: the keys in this directory can only be natural numbers β 0,1,2 ... and that's it. No strings, no negatives, no chaos π
π INHERITED METHODS π
This Catmandu::DirectoryIndex::Number implements:
Catmandu::DirectoryIndex
π SEE ALSO π
Catmandu::DirectoryIndex
okay that's the whole page, you ate that π«Ά this little baddie is running under perl v5.36.0 and got its last glow-up on 2022-12-10 β go forth and index your natural numbers, bestie ππ¦β¨
π¦ where this page comes from
- debian bookworm: libcatmandu-filestore-perl 1.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatmandu-filestore-perl 1.16-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms