LucyX:...Writer(3pm)
π LucyX::...Writer(3pm) π
okay so bestie, we're diving into LucyX::Index::ByteBufDocWriter β literally the girlboss that writes a Doc as a fixed-width byte array. no cap. let's get into it π¦
β¨ NAME β¨
LucyX::Index::ByteBufDocWriter β Write a Doc as a fixed-width byte array. that's it, that's the vibe π
πΈ SYNOPSIS πΈ
so the move here is you create an Architecture subclass which overrides register_doc_writer() and register_doc_reader(). yes, both. don't skip, bestie π
package MyArchitecture;
use base qw( Lucy::Plan::Architecture );
use LucyX::Index::ByteBufDocReader;
use LucyX::Index::ByteBufDocWriter;
sub register_doc_writer {
my ( $self, $seg_writer ) = @_;
my $doc_writer = LucyX::Index::ByteBufDocWriter->new(
width => 16,
field => 'value',
snapshot => $seg_writer->get_snapshot,
segment => $seg_writer->get_segment,
polyreader => $seg_writer->get_polyreader,
);
$seg_writer->register(
api => "Lucy::Index::DocReader",
component => $doc_writer,
);
$seg_writer->add_writer($doc_writer);
}
sub register_doc_reader {
my ( $self, $seg_reader ) = @_;
my $doc_reader = LucyX::Index::ByteBufDocReader->new(
width => 16,
field => 'value',
schema => $seg_reader->get_schema,
folder => $seg_reader->get_folder,
segments => $seg_reader->get_segments,
seg_tick => $seg_reader->get_seg_tick,
snapshot => $seg_reader->get_snapshot,
);
$seg_reader->register(
api => 'Lucy::Index::DocReader',
component => $doc_reader,
);
}
package MySchema;
use base qw( Lucy::Plan::Schema );
sub architecture { MyArchitecture->new }
then you just proceed as normal in your indexer app π«Ά β but like, make sure that every supplied document supplies a valid value for the field in question. every single one. no skips:
$indexer->add_doc({
title => $title,
content => $content,
id => $id, # <---- Must meet spec.
});
then, in your search app π:
my $searcher = Lucy::Search::IndexSearcher->new(
index => '/path/to/index',
);
my $hits = $searcher->hits( query => $query );
while ( my $id = $hits->next ) {
my $real_doc = $external_document_source->fetch( $doc->{value} );
...
}
π DESCRIPTION π
okay so real talk: this is a proof-of-concept class. its whole thing is demonstrating alternate implementations for fetching documents. that's the assignment, that's the moment β¨
β οΈ It is unsupported. say it with me β UNSUPPORTED. it's giving "science fair project," not "put this in prod." treat it accordingly, bestie π
and that's the whole page!! mwah π this lil gem comes from the User Contributed Perl Documentation, running on perl v5.42.0, dated 2025-07-25. iconic behavior, honestly. go forth and byte-array 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