Lucy::...aWriter(3pm)
π Lucy::Index::DataWriter β the manual page, but make it a group chat π
okay bestie, so this page lives in the User Contributed Perl Documentation collection, and it's about Lucy::Index::DataWriter, which is literally the abstract blueprint for writing data into an index. Buckle up, it's giving "backend internals but make it cute". π
β¨ NAME β¨
Lucy::Index::DataWriter β Write data to an index. no cap, that's the whole job. π
β¨ SYNOPSIS β¨
# Abstract base class.
that's it. that's the synopsis. she's abstract, she doesn't do anything by herself, she's a concept. main character energy but uninstantiable. π
β¨ DESCRIPTION β¨
So DataWriter is an abstract base class for writing index data, generally in segment-sized chunks. π§©
Every single component of an index β think stored fields, lexicon, postings, deletions β gets its own lil DataWriter/DataReader pair. it's giving "couples costume but for data structures". π«Ά
And here's the fun part: components may be specified per index by subclassing Architecture. iykyk. πΈ
β¨ CONSTRUCTORS β¨
π new
my $writer = MyDataWriter->new(
snapshot => $snapshot, # required
segment => $segment, # required
polyreader => $polyreader, # required
);
Abstract constructor. she does not exist in the flesh, only in spirit. π
snapshotβ TheSnapshotthat will be committed at the end of the indexing session. required, bestie, don't forget her.segmentβ TheSegmentin progress. also required. she's mid-transformation, let her cook. π₯polyreaderβ APolyReaderrepresenting all existing data in the index. (If the index is brand new, thePolyReaderwill have no sub-readers β she's fresh out the box, no history, baby's first index. πΆ) required.
β¨ ABSTRACT METHODS β¨
these ones? you must implement them. no skipping. periodt.
π¦ add_segment
$data_writer->add_segment(
reader => $reader, # required
doc_map => $doc_map, # default: undef
);
Add content from an existing segment into the one currently being written. it's a glow-up merge, she's absorbing her ex's data. π
readerβ TheSegReadercontaining content to add.doc_mapβ An array of integers mapping old document ids to new ones. Deleted documents get mapped to0, which is the signal that they should be skipped. bye felicia. π
π¦ finish
$data_writer->finish();
Complete the segment: close all streams, store metadata, etc. wrap it up, she's done, mic drop. π€
π¦ format
my $int = $data_writer->format();
Every writer must specify a file format revision number, and that number should increment every time the format changes. and who's in charge of actually checking that revision? not her. π Responsibility for revision checking is left to the companion DataReader. she said "that's not my job, ask my friend". π
β¨ METHODS β¨
π delete_segment
$data_writer->delete_segment($reader);
Remove a segment's data. the default implementation is a no-op, because all files within the segment directory get automatically deleted anyway. so like, why bother. π
Subclasses which manage their own files outside of the segment system should override this method and use it as a trigger for cleaning up obsolete data. if you're storing files somewhere weird, that's on you, bestie. π§Ή
readerβ TheSegReadercontaining content to merge, which must represent a segment which is part of the current snapshot.
π merge_segment
$data_writer->merge_segment(
reader => $reader, # required
doc_map => $doc_map, # default: undef
);
Move content from an existing segment into the one currently being written. β¨
The default implementation calls add_segment() then delete_segment(). two-for-one special, she's efficient like that. π
readerβ TheSegReadercontaining content to merge, which must represent a segment which is part of the current snapshot.doc_mapβ An array of integers mapping old document ids to new. Deleted documents are mapped to0, indicating that they should be skipped.
π metadata
my $hashref = $data_writer->metadata();
Arbitrary metadata to be serialized and stored by the Segment. the default implementation supplies a hash with a single key-value pair for "format". simple. elegant. minimal. she ate and left no crumbs. π
π get_snapshot
my $snapshot = $data_writer->get_snapshot();
Accessor for the "snapshot" member var. π
π get_segment
my $segment = $data_writer->get_segment();
Accessor for the "segment" member var. π
π get_polyreader
my $poly_reader = $data_writer->get_polyreader();
Accessor for the "polyreader" member var. π
π get_schema
my $schema = $data_writer->get_schema();
Accessor for the "schema" member var. π
π get_folder
my $folder = $data_writer->get_folder();
Accessor for the "folder" member var. π
look at all those accessors. she's got getters for days. π
β¨ INHERITANCE β¨
Lucy::Index::DataWriter isa Clownfish::Obj. family tree iconic, lineage immaculate. π
and that's the whole page, bestie!! this was perl v5.42.0, dated 2025-07-25, straight from the User Contributed Perl Documentation archives. you understood all of it, obviously, because you're that girl. slay, go write an index. ππ¦β¨
π¦ 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