Lucy::...napshot(3pm)
π Lucy::Index::Snapshot β point-in-time index file list π
okay bestie, so this is from the User Contributed Perl Documentation corner of the manual, and it's genuinely one of the cutest little classes in Lucy. let's get into it π¦
β¨ NAME β¨
Lucy::Index::Snapshot β a point-in-time list of index files. it's giving "polaroid of your index" energy fr fr πΈ
πΈ SYNOPSIS πΈ
my $snapshot = Lucy::Index::Snapshot->new;
$snapshot->read_file( folder => $folder ); # load most recent snapshot
my $files = $snapshot->list;
print "$_\n" for @$files;
like, that's it. that's the whole vibe. you make one, you load it, you list the files, you print them. slay. π
π DESCRIPTION π
okay so a Snapshot is literally just a list of index files and folders. that's the whole thing.
but here's the iconic part: because index files, once they've been written, are never modified β like, ever, they're frozen, they don't get touched again β a Snapshot defines a point-in-time view of the data in an index. it's a timestamped selfie of your index that never changes. no cap. π«Ά
and IndexReader objects? they interpret the data associated with a single Snapshot. one reader, one snapshot, no crossover. periodt.
π§ CONSTRUCTORS π§
β¨ new
my $snapshot = Lucy::Index::Snapshot->new;
the constructor. takes no arguments. she's low maintenance, she doesn't need anything from you. π
π METHODS π
β list
my $arrayref = $snapshot->list();
returns an array of all the entries. every single one. no gatekeeping. π
π¦ num_entries
my $int = $snapshot->num_entries();
returns the number of entries β and yes bestie, that count includes directories. don't forget the directories. π’
πΈ add_entry
$snapshot->add_entry($entry);
adds a filepath to the snapshot. one (1) filepath, right into the list. π«Ά
π delete_entry
my $bool = $snapshot->delete_entry($entry);
deletes a filepath from the snapshot. bye bestie π
Returns: true if the entry actually existed and got successfully deleted, false otherwise. so like, it tells you the truth either way. honest queen. β¨
π read_file
my $result = $snapshot->read_file(
folder => $folder, # required
path => $path, # default: undef
);
decodes a snapshot file and initializes the object to reflect its contents. like, it reads the file and then becomes it. main character energy honestly. π
folderβ a Folder. required bestie, do not skip.pathβ the location of the snapshot file. if you don't supply it, the most recent snapshot file in the base directory gets chosen for you. she picks for you, and she picks well. π
Returns: the Snapshot object itself. it hands you back itself. iconic behavior.
π write_file
$snapshot->write_file(
folder => $folder, # required
path => $path, # default: undef
);
writes a snapshot file. ποΈ
β οΈ okay so important: the caller must lock the index while this operation takes place, and the operation will fail if the snapshot file already exists. no overwrites. none. don't even try it.
folderβ a Folder. required.pathβ the path of the file to write. if it'sundef, a file name will be chosen which supersedes the latest snapshot file in the index folder. so it just naturally levels up. β¬οΈ
π§ set_path
$snapshot->set_path($path);
sets the path to the file that the Snapshot object serves as a proxy for. she's standing in for the file. representative. delegate. π
π
my $string = $snapshot->get_path();
gets the path to the snapshot file. initially undef, and then it gets updated by read_file(), write_file(), and set_path(). so it starts out not knowing who it is and then finds itself. character development fr fr πβ¨
π INHERITANCE π
Lucy::Index::Snapshot isa Clownfish::Obj. it's in the family. the lineage is real. π
and that's the whole page bestie!! π this was perl v5.42.0, dated 2025-07-25, and yeah it came out of the same Lucy::...napshot(3pm) manual you're holding right now β go forth and snapshot responsibly πβ¨π¦
π¦ where this page comes from
- fedora 43: perl-Lucy 0.6.2-26.fc43 Β· Apache-2.0 AND MIT AND Unicode-DFS-2015
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms