The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

# ***********************************************
#
# !!!! DO NOT EDIT !!!!
#
# This file was auto-generated by Build.PL.
#
# ***********************************************
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
=encoding utf8
=head1 NAME
Lucy::Index::SegWriter - Write one segment of an index.
=head1 DESCRIPTION
SegWriter is a conduit through which information fed to Indexer passes. It
manages L<Segment|Lucy::Index::Segment> and Inverter, invokes the
L<Analyzer|Lucy::Analysis::Analyzer> chain, and feeds low
level L<DataWriters|Lucy::Index::DataWriter> such as
PostingListWriter and DocWriter.
The sub-components of a SegWriter are determined by
L<Architecture|Lucy::Plan::Architecture>. DataWriter components
which are added to the stack of writers via L<add_writer()|/add_writer> have
Add_Inverted_Doc() invoked for each document supplied to SegWriter’s
L<add_doc()|/add_doc>.
=head1 METHODS
=head2 register
$seg_writer->register(
api => $api # required
component => $component # required
);
Register a DataWriter component with the SegWriter. (Note that
registration simply makes the writer available via L<fetch()|/fetch>, so you may
also want to call L<add_writer()|/add_writer>).
=over
=item *
B<api> - The name of the DataWriter api which C<writer>
implements.
=item *
B<component> - A DataWriter.
=back
=head2 fetch
my $retval = $seg_writer->fetch($api);
Retrieve a registered component.
=over
=item *
B<api> - The name of the DataWriter api which the component
implements.
=back
=head2 add_writer
$seg_writer->add_writer($writer);
Add a DataWriter to the SegWriter’s stack of writers.
=head2 add_doc
$seg_writer->add_doc(
doc => $doc # required
boost => $boost # default: 1.0
);
Add a document to the segment. Inverts C<doc>, increments
the Segment’s internal document id, then calls Add_Inverted_Doc(),
feeding all sub-writers.
=head2 add_segment
$seg_writer->add_segment(
reader => $reader # required
doc_map => $doc_map # default: undef
);
Add content from an existing segment into the one currently being
written.
=over
=item *
B<reader> - The SegReader containing content to add.
=item *
B<doc_map> - An array of integers mapping old document ids to
new. Deleted documents are mapped to 0, indicating that they should be
skipped.
=back
=head2 finish
$seg_writer->finish();
Complete the segment: close all streams, store metadata, etc.
=head1 INHERITANCE
Lucy::Index::SegWriter isa L<Lucy::Index::DataWriter> isa Clownfish::Obj.
=cut