parcel | Lucy |
class variable | LUCY_SEGMENT |
struct symbol | lucy_Segment |
class nickname | lucy_Seg |
header file | Lucy/Index/Segment.h |
Lucy::Index::Segment – Warehouse for information about one segment of an inverted index.
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.
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 name.
Returns: the field’s field number, which is a positive integer.
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.
String identifying an index component.
JSON-izable data structure.
cfish_Obj*
lucy_Seg_Fetch_Metadata(
lucy_Segment *self,
cfish_String *key
);
Fetch a value from the Segment’s metadata hash.
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 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.
cfish_String*
lucy_Seg_Get_Name(
lucy_Segment *self
);
Getter for the object’s seg name.
int64_t
lucy_Seg_Get_Number(
lucy_Segment *self
);
Getter for the segment number.
void
lucy_Seg_Set_Count(
lucy_Segment *self,
int64_t count
);
Setter for the object’s document count.
int64_t
lucy_Seg_Get_Count(
lucy_Segment *self
);
Getter for the object’s document count.
int32_t
lucy_Seg_Compare_To(
lucy_Segment *self,
cfish_Obj *other
);
Compare by segment number.
Lucy::Index::Segment is a Clownfish::Obj.
Copyright © 2010-2015 The Apache Software Foundation, Licensed under the
Apache License, Version 2.0.
Apache Lucy, Lucy, Apache, the Apache feather logo, and the Apache Lucy project logo are trademarks of The
Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their
respective owners.