---
name: "Lucy::Index::SegWriter"
section: "3pm"
platform: "linux"
package: "liblucy-perl"
version: "0.3.3-7+b1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Lucy::Index::SegWriter"
---

# Lucy::Index::SegWriter(3pm)

Write one segment of an index.

## NAME

Lucy::Index::SegWriter - Write one segment of an index.

## DESCRIPTION

SegWriter is a conduit through which information fed to Indexer passes.  It manages Segment and Inverter, invokes the Analyzer chain, and feeds low level DataWriters such as PostingListWriter and DocWriter.

The sub-components of a SegWriter are determined by Architecture.  DataWriter components which are added to the stack of writers via *add\_writer()* have *add\_inverted\_doc()* invoked for each document supplied to SegWriter's *add\_doc()*.

## METHODS

### add\_doc( *\[labeled params\]* )

Add a document to the segment.  Inverts `"doc"`, increments the Segment's internal document id, then calls *add\_inverted\_doc()*, feeding all sub-writers.

### add\_writer(writer)

Add a DataWriter to the SegWriter's stack of writers.

### register( *\[labeled params\]* )

Register a DataWriter component with the SegWriter.  (Note that registration simply makes the writer available via *fetch()*, so you may also want to call *add\_writer()*).

- •

  **api** - The name of the DataWriter api which `"writer"` implements.

- •

  **component** - A DataWriter.

### fetch(api)

Retrieve a registered component.

- •

  **api** - The name of the DataWriter api which the component implements.

## INHERITANCE

Lucy::Index::SegWriter isa Lucy::Index::DataWriter isa Lucy::Object::Obj.
