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

Lucy::Index::Segment

parcel Lucy
class variable LUCY_SEGMENT
struct symbol lucy_Segment
class nickname lucy_Seg
header file Lucy/Index/Segment.h

Name

Lucy::Index::Segment – Warehouse for information about one segment of an inverted index.

Description

Apache Lucy’s indexes are made up of individual “segments”, each of which is is an independent inverted index. On the file system, each segment is a directory within the main index directory whose name starts with “seg_”: “seg_2”, “seg_5a”, etc.

Each Segment object keeps track of information about an index segment: its fields, document count, and so on. The Segment object itself writes one file, segmeta.json; besides storing info needed by Segment itself, the “segmeta” file serves as a central repository for metadata generated by other index components – relieving them of the burden of storing metadata themselves.

Methods

Add_Field
int32_t
lucy_Seg_Add_Field(
    lucy_Segment *self,
    cfish_String *field
);

Register a new field and assign it a field number. If the field was already known, nothing happens.

field

Field name.

Returns: the field’s field number, which is a positive integer.

Store_Metadata
void
lucy_Seg_Store_Metadata(
    lucy_Segment *self,
    cfish_String *key,
    cfish_Obj *metadata // decremented
);

Store arbitrary information in the segment’s metadata hash, to be serialized later. Throws an error if key is used twice.

key

String identifying an index component.

metadata

JSON-izable data structure.

Fetch_Metadata
cfish_Obj*
lucy_Seg_Fetch_Metadata(
    lucy_Segment *self,
    cfish_String *key
);

Fetch a value from the Segment’s metadata hash.

Field_Num
int32_t
lucy_Seg_Field_Num(
    lucy_Segment *self,
    cfish_String *field
);

Given a field name, return its field number for this segment (which may differ from its number in other segments). Return 0 (an invalid field number) if the field name can’t be found.

field

Field name.

Field_Name
cfish_String*
lucy_Seg_Field_Name(
    lucy_Segment *self,
    int32_t field_num
);

Given a field number, return the name of its field, or NULL if the field name can’t be found.

Get_Name
cfish_String*
lucy_Seg_Get_Name(
    lucy_Segment *self
);

Getter for the object’s seg name.

Get_Number
int64_t
lucy_Seg_Get_Number(
    lucy_Segment *self
);

Getter for the segment number.

Set_Count
void
lucy_Seg_Set_Count(
    lucy_Segment *self,
    int64_t count
);

Setter for the object’s document count.

Get_Count
int64_t
lucy_Seg_Get_Count(
    lucy_Segment *self
);

Getter for the object’s document count.

Compare_To
int32_t
lucy_Seg_Compare_To(
    lucy_Segment *self,
    cfish_Obj *other
);

Compare by segment number.

Inheritance

Lucy::Index::Segment is a Clownfish::Obj.