This project has retired. For details please refer to its Attic page.
Lucy::Index::DeletionsWriter – C API Documentation
Apache Lucy™

Lucy::Index::DeletionsWriter

parcel Lucy
class variable LUCY_DELETIONSWRITER
struct symbol lucy_DeletionsWriter
class nickname lucy_DelWriter
header file Lucy/Index/DeletionsWriter.h

Name

Lucy::Index::DeletionsWriter – Abstract base class for marking documents as deleted.

Description

Subclasses of DeletionsWriter provide a low-level mechanism for declaring a document deleted from an index.

Because files in an index are never modified, and because it is not practical to delete entire segments, a DeletionsWriter does not actually remove documents from the index. Instead, it communicates to a search-time companion DeletionsReader which documents are deleted in such a way that it can create a Matcher iterator.

Documents are truly deleted only when the segments which contain them are merged into new ones.

Methods

Delete_By_Term (abstract)
void
lucy_DelWriter_Delete_By_Term(
    lucy_DeletionsWriter *self,
    cfish_String *field,
    cfish_Obj *term
);

Delete all documents in the index that index the supplied term.

field

The name of an indexed field. (If it is not spec’d as indexed, an error will occur.)

term

The term which identifies docs to be marked as deleted. If field is associated with an Analyzer, term will be processed automatically (so don’t pre-process it yourself).

Delete_By_Query (abstract)
void
lucy_DelWriter_Delete_By_Query(
    lucy_DeletionsWriter *self,
    lucy_Query *query
);

Delete all documents in the index that match query.

query

A Query.

Updated (abstract)
bool
lucy_DelWriter_Updated(
    lucy_DeletionsWriter *self
);

Returns true if there are updates that need to be written.

Seg_Del_Count (abstract)
int32_t
lucy_DelWriter_Seg_Del_Count(
    lucy_DeletionsWriter *self,
    cfish_String *seg_name
);

Return the number of deletions for a given segment.

seg_name

The name of the segment.

Methods inherited from Lucy::Index::DataWriter

Add_Segment (abstract)
void
lucy_DelWriter_Add_Segment(
    lucy_DeletionsWriter *self,
    lucy_SegReader *reader,
    lucy_I32Array *doc_map
);

Add content from an existing segment into the one currently being written.

reader

The SegReader containing content to add.

doc_map

An array of integers mapping old document ids to new. Deleted documents are mapped to 0, indicating that they should be skipped.

Delete_Segment
void
lucy_DelWriter_Delete_Segment(
    lucy_DeletionsWriter *self,
    lucy_SegReader *reader
);

Remove a segment’s data. The default implementation is a no-op, as all files within the segment directory will be automatically deleted. 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.

reader

The SegReader containing content to merge, which must represent a segment which is part of the the current snapshot.

Merge_Segment
void
lucy_DelWriter_Merge_Segment(
    lucy_DeletionsWriter *self,
    lucy_SegReader *reader,
    lucy_I32Array *doc_map
);

Move content from an existing segment into the one currently being written.

The default implementation calls Add_Segment() then Delete_Segment().

reader

The SegReader containing content to merge, which must represent a segment which is part of the the current snapshot.

doc_map

An array of integers mapping old document ids to new. Deleted documents are mapped to 0, indicating that they should be skipped.

Finish (abstract)
void
lucy_DelWriter_Finish(
    lucy_DeletionsWriter *self
);

Complete the segment: close all streams, store metadata, etc.

Metadata
cfish_Hash* // incremented
lucy_DelWriter_Metadata(
    lucy_DeletionsWriter *self
);

Arbitrary metadata to be serialized and stored by the Segment. The default implementation supplies a hash with a single key-value pair for “format”.

Format (abstract)
int32_t
lucy_DelWriter_Format(
    lucy_DeletionsWriter *self
);

Every writer must specify a file format revision number, which should increment each time the format changes. Responsibility for revision checking is left to the companion DataReader.

Get_Snapshot
lucy_Snapshot*
lucy_DelWriter_Get_Snapshot(
    lucy_DeletionsWriter *self
);

Accessor for “snapshot” member var.

Get_Segment
lucy_Segment*
lucy_DelWriter_Get_Segment(
    lucy_DeletionsWriter *self
);

Accessor for “segment” member var.

Get_PolyReader
lucy_PolyReader*
lucy_DelWriter_Get_PolyReader(
    lucy_DeletionsWriter *self
);

Accessor for “polyreader” member var.

Get_Schema
lucy_Schema*
lucy_DelWriter_Get_Schema(
    lucy_DeletionsWriter *self
);

Accessor for “schema” member var.

Get_Folder
lucy_Folder*
lucy_DelWriter_Get_Folder(
    lucy_DeletionsWriter *self
);

Accessor for “folder” member var.

Inheritance

Lucy::Index::DeletionsWriter is a Lucy::Index::DataWriter is a Clownfish::Obj.