You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2011/05/02 01:50:38 UTC
[lucy-commits] svn commit: r1098445 [7/23] - in /incubator/lucy/trunk: charmonizer/
charmonizer/src/Charmonizer/ charmonizer/src/Charmonizer/Core/
charmonizer/src/Charmonizer/Probe/ charmonizer/src/Charmonizer/Test/
clownfish/lib/ clownfish/lib/Clownfish/Binding/ clo...
Modified: incubator/lucy/trunk/core/Lucy/Index/LexiconReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/LexiconReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/LexiconReader.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/LexiconReader.c Sun May 1 23:50:24 2011
@@ -31,38 +31,34 @@
LexiconReader*
LexReader_init(LexiconReader *self, Schema *schema, Folder *folder,
- Snapshot *snapshot, VArray *segments, int32_t seg_tick)
-{
+ Snapshot *snapshot, VArray *segments, int32_t seg_tick) {
DataReader_init((DataReader*)self, schema, folder, snapshot, segments,
- seg_tick);
+ seg_tick);
ABSTRACT_CLASS_CHECK(self, LEXICONREADER);
return self;
}
LexiconReader*
-LexReader_aggregator(LexiconReader *self, VArray *readers, I32Array *offsets)
-{
+LexReader_aggregator(LexiconReader *self, VArray *readers, I32Array *offsets) {
UNUSED_VAR(self);
return (LexiconReader*)PolyLexReader_new(readers, offsets);
}
PolyLexiconReader*
-PolyLexReader_new(VArray *readers, I32Array *offsets)
-{
- PolyLexiconReader *self
+PolyLexReader_new(VArray *readers, I32Array *offsets) {
+ PolyLexiconReader *self
= (PolyLexiconReader*)VTable_Make_Obj(POLYLEXICONREADER);
return PolyLexReader_init(self, readers, offsets);
}
PolyLexiconReader*
-PolyLexReader_init(PolyLexiconReader *self, VArray *readers,
- I32Array *offsets)
-{
+PolyLexReader_init(PolyLexiconReader *self, VArray *readers,
+ I32Array *offsets) {
uint32_t i, max;
Schema *schema = NULL;
for (i = 0, max = VA_Get_Size(readers); i < max; i++) {
- LexiconReader *reader = (LexiconReader*)CERTIFY(
- VA_Fetch(readers, i), LEXICONREADER);
+ LexiconReader *reader
+ = (LexiconReader*)CERTIFY(VA_Fetch(readers, i), LEXICONREADER);
if (!schema) { schema = LexReader_Get_Schema(reader); }
}
LexReader_init((LexiconReader*)self, schema, NULL, NULL, NULL, -1);
@@ -72,12 +68,11 @@ PolyLexReader_init(PolyLexiconReader *se
}
void
-PolyLexReader_close(PolyLexiconReader *self)
-{
+PolyLexReader_close(PolyLexiconReader *self) {
if (self->readers) {
uint32_t i, max;
for (i = 0, max = VA_Get_Size(self->readers); i < max; i++) {
- LexiconReader *reader
+ LexiconReader *reader
= (LexiconReader*)VA_Fetch(self->readers, i);
if (reader) { LexReader_Close(reader); }
}
@@ -86,8 +81,7 @@ PolyLexReader_close(PolyLexiconReader *s
}
void
-PolyLexReader_destroy(PolyLexiconReader *self)
-{
+PolyLexReader_destroy(PolyLexiconReader *self) {
DECREF(self->readers);
DECREF(self->offsets);
SUPER_DESTROY(self, POLYLEXICONREADER);
@@ -95,8 +89,7 @@ PolyLexReader_destroy(PolyLexiconReader
Lexicon*
PolyLexReader_lexicon(PolyLexiconReader *self, const CharBuf *field,
- Obj *term)
-{
+ Obj *term) {
PolyLexicon *lexicon = NULL;
if (field != NULL) {
@@ -117,8 +110,7 @@ PolyLexReader_lexicon(PolyLexiconReader
uint32_t
PolyLexReader_doc_freq(PolyLexiconReader *self, const CharBuf *field,
- Obj *term)
-{
+ Obj *term) {
uint32_t doc_freq = 0;
uint32_t i, max;
for (i = 0, max = VA_Get_Size(self->readers); i < max; i++) {
@@ -132,30 +124,28 @@ PolyLexReader_doc_freq(PolyLexiconReader
DefaultLexiconReader*
DefLexReader_new(Schema *schema, Folder *folder, Snapshot *snapshot,
- VArray *segments, int32_t seg_tick)
-{
- DefaultLexiconReader *self
+ VArray *segments, int32_t seg_tick) {
+ DefaultLexiconReader *self
= (DefaultLexiconReader*)VTable_Make_Obj(DEFAULTLEXICONREADER);
- return DefLexReader_init(self, schema, folder, snapshot, segments,
- seg_tick);
+ return DefLexReader_init(self, schema, folder, snapshot, segments,
+ seg_tick);
}
// Indicate whether it is safe to build a SegLexicon using the given
// parameters. Will return false if the field is not indexed or if no terms
// are present for this field in this segment.
static bool_t
-S_has_data(Schema *schema, Folder *folder, Segment *segment, CharBuf *field)
-{
+S_has_data(Schema *schema, Folder *folder, Segment *segment, CharBuf *field) {
FieldType *type = Schema_Fetch_Type(schema, field);
- if ( !type || !FType_Indexed(type)) {
+ if (!type || !FType_Indexed(type)) {
// If the field isn't indexed, bail out.
return false;
}
else {
// Bail out if there are no terms for this field in this segment.
- int32_t field_num = Seg_Field_Num(segment, field);
- CharBuf *seg_name = Seg_Get_Name(segment);
+ int32_t field_num = Seg_Field_Num(segment, field);
+ CharBuf *seg_name = Seg_Get_Name(segment);
CharBuf *file = CB_newf("%o/lexicon-%i32.dat", seg_name, field_num);
bool_t retval = Folder_Exists(folder, file);
DECREF(file);
@@ -165,14 +155,13 @@ S_has_data(Schema *schema, Folder *folde
DefaultLexiconReader*
DefLexReader_init(DefaultLexiconReader *self, Schema *schema, Folder *folder,
- Snapshot *snapshot, VArray *segments, int32_t seg_tick)
-{
+ Snapshot *snapshot, VArray *segments, int32_t seg_tick) {
Segment *segment;
uint32_t i, max;
// Init.
LexReader_init((LexiconReader*)self, schema, folder, snapshot, segments,
- seg_tick);
+ seg_tick);
segment = DefLexReader_Get_Segment(self);
// Build an array of SegLexicon objects.
@@ -189,29 +178,26 @@ DefLexReader_init(DefaultLexiconReader *
}
void
-DefLexReader_close(DefaultLexiconReader *self)
-{
+DefLexReader_close(DefaultLexiconReader *self) {
DECREF(self->lexicons);
self->lexicons = NULL;
}
void
-DefLexReader_destroy(DefaultLexiconReader *self)
-{
+DefLexReader_destroy(DefaultLexiconReader *self) {
DECREF(self->lexicons);
SUPER_DESTROY(self, DEFAULTLEXICONREADER);
}
Lexicon*
-DefLexReader_lexicon(DefaultLexiconReader *self, const CharBuf *field,
- Obj *term)
-{
+DefLexReader_lexicon(DefaultLexiconReader *self, const CharBuf *field,
+ Obj *term) {
int32_t field_num = Seg_Field_Num(self->segment, field);
SegLexicon *orig = (SegLexicon*)VA_Fetch(self->lexicons, field_num);
SegLexicon *lexicon = NULL;
if (orig) { // i.e. has data
- lexicon
+ lexicon
= SegLex_new(self->schema, self->folder, self->segment, field);
SegLex_Seek(lexicon, term);
}
@@ -219,12 +205,11 @@ DefLexReader_lexicon(DefaultLexiconReade
return (Lexicon*)lexicon;
}
-static TermInfo*
-S_find_tinfo(DefaultLexiconReader *self, const CharBuf *field, Obj *target)
-{
+static TermInfo*
+S_find_tinfo(DefaultLexiconReader *self, const CharBuf *field, Obj *target) {
if (field != NULL && target != NULL) {
int32_t field_num = Seg_Field_Num(self->segment, field);
- SegLexicon *lexicon
+ SegLexicon *lexicon
= (SegLexicon*)VA_Fetch(self->lexicons, field_num);
if (lexicon) {
@@ -244,17 +229,15 @@ S_find_tinfo(DefaultLexiconReader *self,
}
TermInfo*
-DefLexReader_fetch_term_info(DefaultLexiconReader *self,
- const CharBuf *field, Obj *target)
-{
+DefLexReader_fetch_term_info(DefaultLexiconReader *self,
+ const CharBuf *field, Obj *target) {
TermInfo *tinfo = S_find_tinfo(self, field, target);
return tinfo ? TInfo_Clone(tinfo) : NULL;
}
uint32_t
DefLexReader_doc_freq(DefaultLexiconReader *self, const CharBuf *field,
- Obj *term)
-{
+ Obj *term) {
TermInfo *tinfo = S_find_tinfo(self, field, term);
return tinfo ? TInfo_Get_Doc_Freq(tinfo) : 0;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/LexiconReader.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/LexiconReader.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/LexiconReader.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/LexiconReader.cfh Sun May 1 23:50:24 2011
@@ -20,12 +20,12 @@ parcel Lucy;
*
* LexiconReader reads term dictionary information.
*/
-abstract class Lucy::Index::LexiconReader cnick LexReader
+abstract class Lucy::Index::LexiconReader cnick LexReader
inherits Lucy::Index::DataReader {
inert LexiconReader*
init(LexiconReader *self, Schema *schema = NULL, Folder *folder = NULL,
- Snapshot *snapshot = NULL, VArray *segments = NULL,
+ Snapshot *snapshot = NULL, VArray *segments = NULL,
int32_t seg_tick = -1);
/** Return a new Lexicon for the given <code>field</code>. Will return
@@ -83,7 +83,7 @@ class Lucy::Index::PolyLexiconReader cni
Destroy(PolyLexiconReader *self);
}
-class Lucy::Index::DefaultLexiconReader cnick DefLexReader
+class Lucy::Index::DefaultLexiconReader cnick DefLexReader
inherits Lucy::Index::LexiconReader {
VArray *lexicons;
@@ -93,11 +93,11 @@ class Lucy::Index::DefaultLexiconReader
int32_t seg_tick);
inert DefaultLexiconReader*
- init(DefaultLexiconReader *self, Schema *schema, Folder *folder,
+ init(DefaultLexiconReader *self, Schema *schema, Folder *folder,
Snapshot *snapshot, VArray *segments, int32_t seg_tick);
public incremented nullable Lexicon*
- Lexicon(DefaultLexiconReader *self, const CharBuf *field,
+ Lexicon(DefaultLexiconReader *self, const CharBuf *field,
Obj *term = NULL);
/** Return the number of documents in which the term appears.
@@ -106,7 +106,7 @@ class Lucy::Index::DefaultLexiconReader
Doc_Freq(DefaultLexiconReader *self, const CharBuf *field, Obj *term);
incremented nullable TermInfo*
- Fetch_Term_Info(DefaultLexiconReader *self, const CharBuf *field,
+ Fetch_Term_Info(DefaultLexiconReader *self, const CharBuf *field,
Obj *term);
public void
Modified: incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.c Sun May 1 23:50:24 2011
@@ -35,17 +35,15 @@ int32_t LexWriter_current_file_format =
LexiconWriter*
LexWriter_new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader)
-{
+ PolyReader *polyreader) {
LexiconWriter *self = (LexiconWriter*)VTable_Make_Obj(LEXICONWRITER);
return LexWriter_init(self, schema, snapshot, segment, polyreader);
}
LexiconWriter*
LexWriter_init(LexiconWriter *self, Schema *schema, Snapshot *snapshot,
- Segment *segment, PolyReader *polyreader)
-{
- Architecture *arch = Schema_Get_Architecture(schema);
+ Segment *segment, PolyReader *polyreader) {
+ Architecture *arch = Schema_Get_Architecture(schema);
DataWriter_init((DataWriter*)self, schema, snapshot, segment, polyreader);
@@ -72,8 +70,7 @@ LexWriter_init(LexiconWriter *self, Sche
}
void
-LexWriter_destroy(LexiconWriter *self)
-{
+LexWriter_destroy(LexiconWriter *self) {
DECREF(self->term_stepper);
DECREF(self->tinfo_stepper);
DECREF(self->dat_file);
@@ -88,29 +85,27 @@ LexWriter_destroy(LexiconWriter *self)
}
static void
-S_add_last_term_to_ix(LexiconWriter *self)
-{
+S_add_last_term_to_ix(LexiconWriter *self) {
// Write file pointer to index record.
OutStream_Write_I64(self->ixix_out, OutStream_Tell(self->ix_out));
// Write term and file pointer to main record. Track count of terms added
// to ix.
TermStepper_Write_Key_Frame(self->term_stepper,
- self->ix_out, TermStepper_Get_Value(self->term_stepper));
- TermStepper_Write_Key_Frame(self->tinfo_stepper,
- self->ix_out, TermStepper_Get_Value(self->tinfo_stepper));
+ self->ix_out, TermStepper_Get_Value(self->term_stepper));
+ TermStepper_Write_Key_Frame(self->tinfo_stepper,
+ self->ix_out, TermStepper_Get_Value(self->tinfo_stepper));
OutStream_Write_C64(self->ix_out, OutStream_Tell(self->dat_out));
self->ix_count++;
}
-void
-LexWriter_add_term(LexiconWriter* self, CharBuf* term_text, TermInfo* tinfo)
-{
+void
+LexWriter_add_term(LexiconWriter* self, CharBuf* term_text, TermInfo* tinfo) {
OutStream *dat_out = self->dat_out;
- if ( (self->count % self->index_interval == 0)
- && !self->temp_mode
- ) {
+ if ((self->count % self->index_interval == 0)
+ && !self->temp_mode
+ ) {
// Write a subset of entries to lexicon.ix.
S_add_last_term_to_ix(self);
}
@@ -123,14 +118,13 @@ LexWriter_add_term(LexiconWriter* self,
}
void
-LexWriter_start_field(LexiconWriter *self, int32_t field_num)
-{
+LexWriter_start_field(LexiconWriter *self, int32_t field_num) {
Segment *const segment = LexWriter_Get_Segment(self);
Folder *const folder = LexWriter_Get_Folder(self);
Schema *const schema = LexWriter_Get_Schema(self);
CharBuf *const seg_name = Seg_Get_Name(segment);
CharBuf *const field = Seg_Field_Name(segment, field_num);
- FieldType *const type = Schema_Fetch_Type(schema, field);
+ FieldType *const type = Schema_Fetch_Type(schema, field);
// Open outstreams.
CB_setf(self->dat_file, "%o/lexicon-%i32.dat", seg_name, field_num);
@@ -151,15 +145,14 @@ LexWriter_start_field(LexiconWriter *sel
}
void
-LexWriter_finish_field(LexiconWriter *self, int32_t field_num)
-{
+LexWriter_finish_field(LexiconWriter *self, int32_t field_num) {
CharBuf *field = Seg_Field_Name(self->segment, field_num);
-
+
// Store count of terms for this field as metadata.
- Hash_Store(self->counts, (Obj*)field,
- (Obj*)CB_newf("%i32", self->count));
- Hash_Store(self->ix_counts, (Obj*)field,
- (Obj*)CB_newf("%i32", self->ix_count));
+ Hash_Store(self->counts, (Obj*)field,
+ (Obj*)CB_newf("%i32", self->count));
+ Hash_Store(self->ix_counts, (Obj*)field,
+ (Obj*)CB_newf("%i32", self->ix_count));
// Close streams.
OutStream_Close(self->dat_out);
@@ -178,9 +171,8 @@ LexWriter_finish_field(LexiconWriter *se
}
void
-LexWriter_enter_temp_mode(LexiconWriter *self, const CharBuf *field,
- OutStream *temp_outstream)
-{
+LexWriter_enter_temp_mode(LexiconWriter *self, const CharBuf *field,
+ OutStream *temp_outstream) {
Schema *schema = LexWriter_Get_Schema(self);
FieldType *type = Schema_Fetch_Type(schema, field);
@@ -201,18 +193,16 @@ LexWriter_enter_temp_mode(LexiconWriter
}
void
-LexWriter_leave_temp_mode(LexiconWriter *self)
-{
+LexWriter_leave_temp_mode(LexiconWriter *self) {
DECREF(self->term_stepper);
self->term_stepper = NULL;
DECREF(self->dat_out);
- self->dat_out = NULL;
+ self->dat_out = NULL;
self->temp_mode = false;
}
void
-LexWriter_finish(LexiconWriter *self)
-{
+LexWriter_finish(LexiconWriter *self) {
// Ensure that streams were closed (by calling Finish_Field or
// Leave_Temp_Mode).
if (self->dat_out != NULL) {
@@ -227,21 +217,20 @@ LexWriter_finish(LexiconWriter *self)
// Store metadata.
Seg_Store_Metadata_Str(self->segment, "lexicon", 7,
- (Obj*)LexWriter_Metadata(self));
+ (Obj*)LexWriter_Metadata(self));
}
Hash*
-LexWriter_metadata(LexiconWriter *self)
-{
+LexWriter_metadata(LexiconWriter *self) {
Hash *const metadata = DataWriter_metadata((DataWriter*)self);
Hash *const counts = (Hash*)INCREF(self->counts);
Hash *const ix_counts = (Hash*)INCREF(self->ix_counts);
// Placeholders.
if (Hash_Get_Size(counts) == 0) {
- Hash_Store_Str(counts, "none", 4, (Obj*)CB_newf("%i32", (int32_t)0) );
- Hash_Store_Str(ix_counts, "none", 4,
- (Obj*)CB_newf("%i32", (int32_t)0) );
+ Hash_Store_Str(counts, "none", 4, (Obj*)CB_newf("%i32", (int32_t)0));
+ Hash_Store_Str(ix_counts, "none", 4,
+ (Obj*)CB_newf("%i32", (int32_t)0));
}
Hash_Store_Str(metadata, "counts", 6, (Obj*)counts);
@@ -251,9 +240,8 @@ LexWriter_metadata(LexiconWriter *self)
}
void
-LexWriter_add_segment(LexiconWriter *self, SegReader *reader,
- I32Array *doc_map)
-{
+LexWriter_add_segment(LexiconWriter *self, SegReader *reader,
+ I32Array *doc_map) {
// No-op, since the data gets added via PostingListWriter.
UNUSED_VAR(self);
UNUSED_VAR(reader);
@@ -261,8 +249,7 @@ LexWriter_add_segment(LexiconWriter *sel
}
int32_t
-LexWriter_format(LexiconWriter *self)
-{
+LexWriter_format(LexiconWriter *self) {
UNUSED_VAR(self);
return LexWriter_current_file_format;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/LexiconWriter.cfh Sun May 1 23:50:24 2011
@@ -43,7 +43,7 @@ class Lucy::Index::LexiconWriter cnick L
new(Schema *schema, Snapshot *snapshot, Segment *segment,
PolyReader *polyreader);
- inert LexiconWriter*
+ inert LexiconWriter*
init(LexiconWriter *self, Schema *schema, Snapshot *snapshot,
Segment *segment, PolyReader *polyreader);
@@ -60,7 +60,7 @@ class Lucy::Index::LexiconWriter cnick L
/** Prepare to write terms to a temporary file.
*/
void
- Enter_Temp_Mode(LexiconWriter *self, const CharBuf *field,
+ Enter_Temp_Mode(LexiconWriter *self, const CharBuf *field,
OutStream *temp_outstream);
/** Stop writing terms to temp file. Abandon (but don't close) the file.
@@ -75,7 +75,7 @@ class Lucy::Index::LexiconWriter cnick L
Add_Term(LexiconWriter* self, CharBuf* term_text, TermInfo* tinfo);
public void
- Add_Segment(LexiconWriter *self, SegReader *reader,
+ Add_Segment(LexiconWriter *self, SegReader *reader,
I32Array *doc_map = NULL);
public incremented Hash*
Modified: incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.c Sun May 1 23:50:24 2011
@@ -29,18 +29,16 @@ static void
S_refresh_lex_q(SegLexQueue *lex_q, VArray *seg_lexicons, Obj *target);
PolyLexicon*
-PolyLex_new(const CharBuf *field, VArray *sub_readers)
-{
+PolyLex_new(const CharBuf *field, VArray *sub_readers) {
PolyLexicon *self = (PolyLexicon*)VTable_Make_Obj(POLYLEXICON);
return PolyLex_init(self, field, sub_readers);
}
PolyLexicon*
-PolyLex_init(PolyLexicon *self, const CharBuf *field, VArray *sub_readers)
-{
- uint32_t i;
- uint32_t num_sub_readers = VA_Get_Size(sub_readers);
- VArray *seg_lexicons = VA_new(num_sub_readers);
+PolyLex_init(PolyLexicon *self, const CharBuf *field, VArray *sub_readers) {
+ uint32_t i;
+ uint32_t num_sub_readers = VA_Get_Size(sub_readers);
+ VArray *seg_lexicons = VA_new(num_sub_readers);
// Init.
Lex_init((Lexicon*)self, field);
@@ -65,8 +63,7 @@ PolyLex_init(PolyLexicon *self, const Ch
}
void
-PolyLex_destroy(PolyLexicon *self)
-{
+PolyLex_destroy(PolyLexicon *self) {
DECREF(self->seg_lexicons);
DECREF(self->lex_q);
DECREF(self->term);
@@ -74,8 +71,7 @@ PolyLex_destroy(PolyLexicon *self)
}
static void
-S_refresh_lex_q(SegLexQueue *lex_q, VArray *seg_lexicons, Obj *target)
-{
+S_refresh_lex_q(SegLexQueue *lex_q, VArray *seg_lexicons, Obj *target) {
uint32_t i, max;
// Empty out the queue.
@@ -87,7 +83,7 @@ S_refresh_lex_q(SegLexQueue *lex_q, VArr
// Refill the queue.
for (i = 0, max = VA_Get_Size(seg_lexicons); i < max; i++) {
- SegLexicon *const seg_lexicon
+ SegLexicon *const seg_lexicon
= (SegLexicon*)VA_Fetch(seg_lexicons, i);
SegLex_Seek(seg_lexicon, target);
if (SegLex_Get_Term(seg_lexicon) != NULL) {
@@ -97,12 +93,11 @@ S_refresh_lex_q(SegLexQueue *lex_q, VArr
}
void
-PolyLex_reset(PolyLexicon *self)
-{
+PolyLex_reset(PolyLexicon *self) {
uint32_t i;
VArray *seg_lexicons = self->seg_lexicons;
- uint32_t num_segs = VA_Get_Size(seg_lexicons);
- SegLexQueue *lex_q = self->lex_q;
+ uint32_t num_segs = VA_Get_Size(seg_lexicons);
+ SegLexQueue *lex_q = self->lex_q;
// Empty out the queue.
while (1) {
@@ -113,7 +108,7 @@ PolyLex_reset(PolyLexicon *self)
// Fill the queue with valid SegLexicons.
for (i = 0; i < num_segs; i++) {
- SegLexicon *const seg_lexicon
+ SegLexicon *const seg_lexicon
= (SegLexicon*)VA_Fetch(seg_lexicons, i);
SegLex_Reset(seg_lexicon);
if (SegLex_Next(seg_lexicon)) {
@@ -128,17 +123,16 @@ PolyLex_reset(PolyLexicon *self)
}
bool_t
-PolyLex_next(PolyLexicon *self)
-{
- SegLexQueue *lex_q = self->lex_q;
+PolyLex_next(PolyLexicon *self) {
+ SegLexQueue *lex_q = self->lex_q;
SegLexicon *top_seg_lexicon = (SegLexicon*)SegLexQ_Peek(lex_q);
-
+
// Churn through queue items with equal terms.
while (top_seg_lexicon != NULL) {
- Obj *const candidate = SegLex_Get_Term(top_seg_lexicon);
- if ( (candidate && !self->term)
- || Obj_Compare_To(self->term, candidate) != 0
- ) {
+ Obj *const candidate = SegLex_Get_Term(top_seg_lexicon);
+ if ((candidate && !self->term)
+ || Obj_Compare_To(self->term, candidate) != 0
+ ) {
// Succeed if the next item in the queue has a different term.
DECREF(self->term);
self->term = Obj_Clone(candidate);
@@ -161,8 +155,7 @@ PolyLex_next(PolyLexicon *self)
}
void
-PolyLex_seek(PolyLexicon *self, Obj *target)
-{
+PolyLex_seek(PolyLexicon *self, Obj *target) {
VArray *seg_lexicons = self->seg_lexicons;
SegLexQueue *lex_q = self->lex_q;
@@ -192,28 +185,24 @@ PolyLex_seek(PolyLexicon *self, Obj *tar
} while (PolyLex_Next(self));
}
-Obj*
-PolyLex_get_term(PolyLexicon *self)
-{
+Obj*
+PolyLex_get_term(PolyLexicon *self) {
return self->term;
}
uint32_t
-PolyLex_get_num_seg_lexicons(PolyLexicon *self)
-{
+PolyLex_get_num_seg_lexicons(PolyLexicon *self) {
return VA_Get_Size(self->seg_lexicons);
}
SegLexQueue*
-SegLexQ_new(uint32_t max_size)
-{
+SegLexQ_new(uint32_t max_size) {
SegLexQueue *self = (SegLexQueue*)VTable_Make_Obj(SEGLEXQUEUE);
return (SegLexQueue*)PriQ_init((PriorityQueue*)self, max_size);
}
bool_t
-SegLexQ_less_than(SegLexQueue *self, Obj *a, Obj *b)
-{
+SegLexQ_less_than(SegLexQueue *self, Obj *a, Obj *b) {
SegLexicon *const lex_a = (SegLexicon*)a;
SegLexicon *const lex_b = (SegLexicon*)b;
Obj *const term_a = SegLex_Get_Term(lex_a);
Modified: incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PolyLexicon.cfh Sun May 1 23:50:24 2011
@@ -41,10 +41,10 @@ class Lucy::Index::PolyLexicon cnick Pol
public bool_t
Next(PolyLexicon *self);
- public void
+ public void
Reset(PolyLexicon *self);
- public nullable Obj*
+ public nullable Obj*
Get_Term(PolyLexicon *self);
uint32_t
Modified: incubator/lucy/trunk/core/Lucy/Index/PolyReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PolyReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PolyReader.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PolyReader.c Sun May 1 23:50:24 2011
@@ -35,37 +35,34 @@
// Obtain/release read locks and commit locks. If self->manager is
// NULL, do nothing.
-static void
+static void
S_obtain_read_lock(PolyReader *self, const CharBuf *snapshot_filename);
-static void
+static void
S_obtain_deletion_lock(PolyReader *self);
-static void
+static void
S_release_read_lock(PolyReader *self);
-static void
+static void
S_release_deletion_lock(PolyReader *self);
static Folder*
S_derive_folder(Obj *index);
PolyReader*
-PolyReader_new(Schema *schema, Folder *folder, Snapshot *snapshot,
- IndexManager *manager, VArray *sub_readers)
-{
+PolyReader_new(Schema *schema, Folder *folder, Snapshot *snapshot,
+ IndexManager *manager, VArray *sub_readers) {
PolyReader *self = (PolyReader*)VTable_Make_Obj(POLYREADER);
- return PolyReader_init(self, schema, folder, snapshot, manager,
- sub_readers);
+ return PolyReader_init(self, schema, folder, snapshot, manager,
+ sub_readers);
}
PolyReader*
-PolyReader_open(Obj *index, Snapshot *snapshot, IndexManager *manager)
-{
+PolyReader_open(Obj *index, Snapshot *snapshot, IndexManager *manager) {
PolyReader *self = (PolyReader*)VTable_Make_Obj(POLYREADER);
return PolyReader_do_open(self, index, snapshot, manager);
}
static Obj*
-S_first_non_null(VArray *array)
-{
+S_first_non_null(VArray *array) {
uint32_t i, max;
for (i = 0, max = VA_Get_Size(array); i < max; i++) {
Obj *thing = VA_Fetch(array, i);
@@ -75,8 +72,7 @@ S_first_non_null(VArray *array)
}
static void
-S_init_sub_readers(PolyReader *self, VArray *sub_readers)
-{
+S_init_sub_readers(PolyReader *self, VArray *sub_readers) {
uint32_t i;
uint32_t num_sub_readers = VA_Get_Size(sub_readers);
int32_t *starts = (int32_t*)MALLOCATE(num_sub_readers * sizeof(int32_t));
@@ -98,8 +94,8 @@ S_init_sub_readers(PolyReader *self, VAr
Hash_Iterate(components);
while (Hash_Next(components, (Obj**)&api, (Obj**)&component)) {
VArray *readers = (VArray*)Hash_Fetch(data_readers, (Obj*)api);
- if (!readers) {
- readers = VA_new(num_sub_readers);
+ if (!readers) {
+ readers = VA_new(num_sub_readers);
Hash_Store(data_readers, (Obj*)api, (Obj*)readers);
}
VA_Store(readers, i, INCREF(component));
@@ -113,8 +109,9 @@ S_init_sub_readers(PolyReader *self, VAr
Hash_Iterate(data_readers);
while (Hash_Next(data_readers, (Obj**)&api, (Obj**)&readers)) {
DataReader *datareader = (DataReader*)CERTIFY(
- S_first_non_null(readers), DATAREADER);
- DataReader *aggregator
+ S_first_non_null(readers),
+ DATAREADER);
+ DataReader *aggregator
= DataReader_Aggregator(datareader, readers, self->offsets);
if (aggregator) {
CERTIFY(aggregator, DATAREADER);
@@ -125,37 +122,37 @@ S_init_sub_readers(PolyReader *self, VAr
DECREF(data_readers);
{
- DeletionsReader *del_reader = (DeletionsReader*)Hash_Fetch(
- self->components, (Obj*)VTable_Get_Name(DELETIONSREADER));
+ DeletionsReader *del_reader
+ = (DeletionsReader*)Hash_Fetch(
+ self->components, (Obj*)VTable_Get_Name(DELETIONSREADER));
self->del_count = del_reader ? DelReader_Del_Count(del_reader) : 0;
}
}
PolyReader*
-PolyReader_init(PolyReader *self, Schema *schema, Folder *folder,
- Snapshot *snapshot, IndexManager *manager,
- VArray *sub_readers)
-{
+PolyReader_init(PolyReader *self, Schema *schema, Folder *folder,
+ Snapshot *snapshot, IndexManager *manager,
+ VArray *sub_readers) {
self->doc_max = 0;
self->del_count = 0;
- if (sub_readers) {
+ if (sub_readers) {
uint32_t num_segs = VA_Get_Size(sub_readers);
VArray *segments = VA_new(num_segs);
uint32_t i;
for (i = 0; i < num_segs; i++) {
- SegReader *seg_reader = (SegReader*)CERTIFY(
- VA_Fetch(sub_readers, i), SEGREADER);
+ SegReader *seg_reader
+ = (SegReader*)CERTIFY(VA_Fetch(sub_readers, i), SEGREADER);
VA_Push(segments, INCREF(SegReader_Get_Segment(seg_reader)));
}
- IxReader_init((IndexReader*)self, schema, folder, snapshot,
- segments, -1, manager);
+ IxReader_init((IndexReader*)self, schema, folder, snapshot,
+ segments, -1, manager);
DECREF(segments);
- S_init_sub_readers(self, sub_readers);
+ S_init_sub_readers(self, sub_readers);
}
else {
- IxReader_init((IndexReader*)self, schema, folder, snapshot,
- NULL, -1, manager);
+ IxReader_init((IndexReader*)self, schema, folder, snapshot,
+ NULL, -1, manager);
self->sub_readers = VA_new(0);
self->offsets = I32Arr_new_steal(NULL, 0);
}
@@ -164,29 +161,26 @@ PolyReader_init(PolyReader *self, Schema
}
void
-PolyReader_close(PolyReader *self)
-{
- PolyReader_close_t super_close
+PolyReader_close(PolyReader *self) {
+ PolyReader_close_t super_close
= (PolyReader_close_t)SUPER_METHOD(POLYREADER, PolyReader, Close);
uint32_t i, max;
for (i = 0, max = VA_Get_Size(self->sub_readers); i < max; i++) {
SegReader *seg_reader = (SegReader*)VA_Fetch(self->sub_readers, i);
- SegReader_Close(seg_reader);
+ SegReader_Close(seg_reader);
}
super_close(self);
}
void
-PolyReader_destroy(PolyReader *self)
-{
+PolyReader_destroy(PolyReader *self) {
DECREF(self->sub_readers);
DECREF(self->offsets);
SUPER_DESTROY(self, POLYREADER);
}
Obj*
-S_try_open_elements(PolyReader *self)
-{
+S_try_open_elements(PolyReader *self) {
VArray *files = Snapshot_List(self->snapshot);
Folder *folder = PolyReader_Get_Folder(self);
uint32_t num_segs = 0;
@@ -202,9 +196,9 @@ S_try_open_elements(PolyReader *self)
if (Seg_valid_seg_name(entry)) {
num_segs++;
}
- else if ( CB_Starts_With_Str(entry, "schema_", 7)
+ else if (CB_Starts_With_Str(entry, "schema_", 7)
&& CB_Ends_With_Str(entry, ".json", 5)
- ) {
+ ) {
uint64_t gen = IxFileNames_extract_gen(entry);
if (gen > latest_schema_gen) {
latest_schema_gen = gen;
@@ -225,7 +219,7 @@ S_try_open_elements(PolyReader *self)
if (dump) { // read file successfully
DECREF(self->schema);
self->schema = (Schema*)CERTIFY(
- VTable_Load_Obj(SCHEMA, (Obj*)dump), SCHEMA);
+ VTable_Load_Obj(SCHEMA, (Obj*)dump), SCHEMA);
DECREF(dump);
DECREF(schema_file);
schema_file = NULL;
@@ -279,11 +273,10 @@ CharBuf* PolyReader_race_condition_debug
int32_t PolyReader_debug1_num_passes = 0;
PolyReader*
-PolyReader_do_open(PolyReader *self, Obj *index, Snapshot *snapshot,
- IndexManager *manager)
-{
- Folder *folder = S_derive_folder(index);
- uint64_t last_gen = 0;
+PolyReader_do_open(PolyReader *self, Obj *index, Snapshot *snapshot,
+ IndexManager *manager) {
+ Folder *folder = S_derive_folder(index);
+ uint64_t last_gen = 0;
PolyReader_init(self, NULL, folder, snapshot, manager, NULL);
DECREF(folder);
@@ -312,7 +305,7 @@ PolyReader_do_open(PolyReader *self, Obj
// and return NULL.
if (!target_snap_file) { break; }
}
-
+
// Derive "generation" of this snapshot file from its name.
gen = IxFileNames_extract_gen(target_snap_file);
@@ -326,7 +319,7 @@ PolyReader_do_open(PolyReader *self, Obj
ZombieCharBuf *temp = ZCB_WRAP_STR("temp", 4);
if (Folder_Exists(folder, (CharBuf*)temp)) {
bool_t success = Folder_Rename(folder, (CharBuf*)temp,
- PolyReader_race_condition_debug1);
+ PolyReader_race_condition_debug1);
if (!success) { RETHROW(INCREF(Err_get_error())); }
}
PolyReader_debug1_num_passes++;
@@ -334,9 +327,9 @@ PolyReader_do_open(PolyReader *self, Obj
// If a Snapshot object was passed in, the file has already been read.
// If that's not the case, we must read the file we just picked.
- if (!snapshot) {
- CharBuf *error = PolyReader_try_read_snapshot(self->snapshot,
- folder, target_snap_file);
+ if (!snapshot) {
+ CharBuf *error = PolyReader_try_read_snapshot(self->snapshot, folder,
+ target_snap_file);
if (error) {
S_release_read_lock(self);
@@ -388,8 +381,7 @@ PolyReader_do_open(PolyReader *self, Obj
}
static Folder*
-S_derive_folder(Obj *index)
-{
+S_derive_folder(Obj *index) {
Folder *folder = NULL;
if (Obj_Is_A(index, FOLDER)) {
folder = (Folder*)INCREF(index);
@@ -404,34 +396,31 @@ S_derive_folder(Obj *index)
}
static void
-S_obtain_deletion_lock(PolyReader *self)
-{
+S_obtain_deletion_lock(PolyReader *self) {
self->deletion_lock = IxManager_Make_Deletion_Lock(self->manager);
Lock_Clear_Stale(self->deletion_lock);
if (!Lock_Obtain(self->deletion_lock)) {
DECREF(self->deletion_lock);
self->deletion_lock = NULL;
- THROW(LOCKERR, "Couldn't get commit lock");
+ THROW(LOCKERR, "Couldn't get commit lock");
}
}
static void
-S_obtain_read_lock(PolyReader *self, const CharBuf *snapshot_file_name)
-{
+S_obtain_read_lock(PolyReader *self, const CharBuf *snapshot_file_name) {
if (!self->manager) { return; }
self->read_lock = IxManager_Make_Snapshot_Read_Lock(self->manager,
- snapshot_file_name);
+ snapshot_file_name);
Lock_Clear_Stale(self->read_lock);
if (!Lock_Obtain(self->read_lock)) {
DECREF(self->read_lock);
- THROW(LOCKERR, "Couldn't get read lock for %o", snapshot_file_name);
+ THROW(LOCKERR, "Couldn't get read lock for %o", snapshot_file_name);
}
}
static void
-S_release_read_lock(PolyReader *self)
-{
+S_release_read_lock(PolyReader *self) {
if (self->read_lock) {
Lock_Release(self->read_lock);
DECREF(self->read_lock);
@@ -440,8 +429,7 @@ S_release_read_lock(PolyReader *self)
}
static void
-S_release_deletion_lock(PolyReader *self)
-{
+S_release_deletion_lock(PolyReader *self) {
if (self->deletion_lock) {
Lock_Release(self->deletion_lock);
DECREF(self->deletion_lock);
@@ -449,58 +437,54 @@ S_release_deletion_lock(PolyReader *self
}
}
-int32_t
-PolyReader_doc_max(PolyReader *self)
-{
+int32_t
+PolyReader_doc_max(PolyReader *self) {
return self->doc_max;
}
int32_t
-PolyReader_doc_count(PolyReader *self)
-{
+PolyReader_doc_count(PolyReader *self) {
return self->doc_max - self->del_count;
}
int32_t
-PolyReader_del_count(PolyReader *self)
-{
+PolyReader_del_count(PolyReader *self) {
return self->del_count;
}
I32Array*
-PolyReader_offsets(PolyReader *self)
-{
+PolyReader_offsets(PolyReader *self) {
return (I32Array*)INCREF(self->offsets);
}
VArray*
-PolyReader_seg_readers(PolyReader *self)
-{
+PolyReader_seg_readers(PolyReader *self) {
return (VArray*)VA_Shallow_Copy(self->sub_readers);
}
VArray*
-PolyReader_get_seg_readers(PolyReader *self) { return self->sub_readers; }
+PolyReader_get_seg_readers(PolyReader *self) {
+ return self->sub_readers;
+}
uint32_t
-PolyReader_sub_tick(I32Array *offsets, int32_t doc_id)
-{
+PolyReader_sub_tick(I32Array *offsets, int32_t doc_id) {
int32_t size = I32Arr_Get_Size(offsets);
if (size == 0) {
return 0;
}
-
- int32_t lo = -1;
- int32_t hi = size;
+
+ int32_t lo = -1;
+ int32_t hi = size;
while (hi - lo > 1) {
- int32_t mid = lo + ((hi - lo) / 2);
+ int32_t mid = lo + ((hi - lo) / 2);
int32_t offset = I32Arr_Get(offsets, mid);
if (doc_id <= offset) {
hi = mid;
- }
+ }
else {
lo = mid;
- }
+ }
}
if (hi == size) {
hi--;
@@ -518,5 +502,5 @@ PolyReader_sub_tick(I32Array *offsets, i
return hi;
}
-
+
Modified: incubator/lucy/trunk/core/Lucy/Index/PolyReader.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PolyReader.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PolyReader.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PolyReader.cfh Sun May 1 23:50:24 2011
@@ -44,16 +44,16 @@ class Lucy::Index::PolyReader inherits L
* Read-locking is off by default; supplying this argument turns it on.
*/
public inert nullable PolyReader*
- do_open(PolyReader *self, Obj *index, Snapshot *snapshot = NULL,
+ do_open(PolyReader *self, Obj *index, Snapshot *snapshot = NULL,
IndexManager *manager = NULL);
public inert incremented PolyReader*
- new(Schema *schema = NULL, Folder *folder, Snapshot *snapshot = NULL,
+ new(Schema *schema = NULL, Folder *folder, Snapshot *snapshot = NULL,
IndexManager *manager = NULL, VArray *sub_readers = NULL);
public inert PolyReader*
- init(PolyReader *self, Schema *schema = NULL, Folder *folder,
- Snapshot *snapshot = NULL, IndexManager *manager = NULL,
+ init(PolyReader *self, Schema *schema = NULL, Folder *folder,
+ Snapshot *snapshot = NULL, IndexManager *manager = NULL,
VArray *sub_readers = NULL);
/** Attempt to open a SegReader for each Segment that the Snapshot knows
@@ -67,12 +67,12 @@ class Lucy::Index::PolyReader inherits L
* NULL. If an exception occurs, catch it and return its error message.
*/
inert incremented nullable CharBuf*
- try_read_snapshot(Snapshot *snapshot, Folder *folder,
+ try_read_snapshot(Snapshot *snapshot, Folder *folder,
const CharBuf *path);
inert CharBuf* race_condition_debug1;
inert int32_t debug1_num_passes;
-
+
/** Determine which sub-reader a document id belongs to.
*/
inert uint32_t
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting.c Sun May 1 23:50:24 2011
@@ -29,23 +29,26 @@
#include "Lucy/Store/InStream.h"
Posting*
-Post_init(Posting *self)
-{
+Post_init(Posting *self) {
self->doc_id = 0;
return self;
}
void
-Post_set_doc_id(Posting *self, int32_t doc_id) { self->doc_id = doc_id; }
+Post_set_doc_id(Posting *self, int32_t doc_id) {
+ self->doc_id = doc_id;
+}
+
int32_t
-Post_get_doc_id(Posting *self) { return self->doc_id; }
+Post_get_doc_id(Posting *self) {
+ return self->doc_id;
+}
PostingWriter*
PostWriter_init(PostingWriter *self, Schema *schema, Snapshot *snapshot,
- Segment *segment, PolyReader *polyreader, int32_t field_num)
-{
+ Segment *segment, PolyReader *polyreader, int32_t field_num) {
DataWriter_init((DataWriter*)self, schema, snapshot, segment,
- polyreader);
+ polyreader);
self->field_num = field_num;
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting.cfh Sun May 1 23:50:24 2011
@@ -39,28 +39,28 @@ class Lucy::Index::Posting cnick Post in
* Updates the state of the document id, but nothing else.
*/
abstract incremented RawPosting*
- Read_Raw(Posting *self, InStream *instream, int32_t last_doc_id,
+ Read_Raw(Posting *self, InStream *instream, int32_t last_doc_id,
CharBuf *term_text, MemoryPool *mem_pool);
/** Process an Inversion into RawPosting objects and add them all to the
* supplied PostingPool.
*/
abstract void
- Add_Inversion_To_Pool(Posting *self, PostingPool *post_pool,
- Inversion *inversion, FieldType *type,
- int32_t doc_id, float doc_boost,
+ Add_Inversion_To_Pool(Posting *self, PostingPool *post_pool,
+ Inversion *inversion, FieldType *type,
+ int32_t doc_id, float doc_boost,
float length_norm);
public void
Set_Doc_ID(Posting *self, int32_t doc_id);
- public int32_t
+ public int32_t
Get_Doc_ID(Posting *self);
/** Factory method for creating a Matcher.
*/
abstract incremented Matcher*
- Make_Matcher(Posting *self, Similarity *sim, PostingList *plist,
+ Make_Matcher(Posting *self, Similarity *sim, PostingList *plist,
Compiler *compiler, bool_t need_score);
}
@@ -70,7 +70,7 @@ abstract class Lucy::Index::Posting::Pos
int32_t field_num;
inert PostingWriter*
- init(PostingWriter *self, Schema *schema, Snapshot *snapshot,
+ init(PostingWriter *self, Schema *schema, Snapshot *snapshot,
Segment *segment, PolyReader *polyreader, int32_t field_num);
/** Take a RawPosting that was flattened earlier and write it to the
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.c Sun May 1 23:50:24 2011
@@ -44,43 +44,40 @@
#include "Lucy/Util/MemoryPool.h"
#define MAX_RAW_POSTING_LEN(_text_len) \
- ( sizeof(RawPosting) \
- + _text_len + 1 /* term text content */ \
- )
+ ( sizeof(RawPosting) \
+ + _text_len + 1 /* term text content */ \
+ )
MatchPosting*
-MatchPost_new(Similarity *sim)
-{
+MatchPost_new(Similarity *sim) {
MatchPosting *self = (MatchPosting*)VTable_Make_Obj(MATCHPOSTING);
return MatchPost_init(self, sim);
}
MatchPosting*
-MatchPost_init(MatchPosting *self, Similarity *sim)
-{
+MatchPost_init(MatchPosting *self, Similarity *sim) {
self->sim = (Similarity*)INCREF(sim);
return (MatchPosting*)Post_init((Posting*)self);
}
void
-MatchPost_destroy(MatchPosting *self)
-{
+MatchPost_destroy(MatchPosting *self) {
DECREF(self->sim);
SUPER_DESTROY(self, MATCHPOSTING);
}
int32_t
-MatchPost_get_freq(MatchPosting *self) { return self->freq; }
+MatchPost_get_freq(MatchPosting *self) {
+ return self->freq;
+}
void
-MatchPost_reset(MatchPosting *self)
-{
+MatchPost_reset(MatchPosting *self) {
self->doc_id = 0;
}
void
-MatchPost_read_record(MatchPosting *self, InStream *instream)
-{
+MatchPost_read_record(MatchPosting *self, InStream *instream) {
const uint32_t doc_code = InStream_Read_C32(instream);
const uint32_t doc_delta = doc_code >> 1;
@@ -96,29 +93,27 @@ MatchPost_read_record(MatchPosting *self
RawPosting*
MatchPost_read_raw(MatchPosting *self, InStream *instream, int32_t last_doc_id,
- CharBuf *term_text, MemoryPool *mem_pool)
-{
- char *const text_buf = (char*)CB_Get_Ptr8(term_text);
- const size_t text_size = CB_Get_Size(term_text);
- const uint32_t doc_code = InStream_Read_C32(instream);
- const uint32_t delta_doc = doc_code >> 1;
- const int32_t doc_id = last_doc_id + delta_doc;
- const uint32_t freq = (doc_code & 1)
- ? 1
- : InStream_Read_C32(instream);
- size_t raw_post_bytes = MAX_RAW_POSTING_LEN(text_size);
- void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
+ CharBuf *term_text, MemoryPool *mem_pool) {
+ char *const text_buf = (char*)CB_Get_Ptr8(term_text);
+ const size_t text_size = CB_Get_Size(term_text);
+ const uint32_t doc_code = InStream_Read_C32(instream);
+ const uint32_t delta_doc = doc_code >> 1;
+ const int32_t doc_id = last_doc_id + delta_doc;
+ const uint32_t freq = (doc_code & 1)
+ ? 1
+ : InStream_Read_C32(instream);
+ size_t raw_post_bytes = MAX_RAW_POSTING_LEN(text_size);
+ void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
UNUSED_VAR(self);
return RawPost_new(allocation, doc_id, freq, text_buf, text_size);
}
void
-MatchPost_add_inversion_to_pool(MatchPosting *self, PostingPool *post_pool,
- Inversion *inversion, FieldType *type,
- int32_t doc_id, float doc_boost,
- float length_norm)
-{
+MatchPost_add_inversion_to_pool(MatchPosting *self, PostingPool *post_pool,
+ Inversion *inversion, FieldType *type,
+ int32_t doc_id, float doc_boost,
+ float length_norm) {
MemoryPool *mem_pool = PostPool_Get_Mem_Pool(post_pool);
Token **tokens;
uint32_t freq;
@@ -129,23 +124,21 @@ MatchPost_add_inversion_to_pool(MatchPos
UNUSED_VAR(length_norm);
Inversion_Reset(inversion);
- while ( (tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL ) {
+ while ((tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL) {
Token *token = *tokens;
uint32_t raw_post_bytes = MAX_RAW_POSTING_LEN(token->len);
- RawPosting *raw_posting = RawPost_new(
- MemPool_Grab(mem_pool, raw_post_bytes), doc_id, freq,
- token->text, token->len
- );
+ RawPosting *raw_posting
+ = RawPost_new(MemPool_Grab(mem_pool, raw_post_bytes), doc_id,
+ freq, token->text, token->len);
PostPool_Feed(post_pool, &raw_posting);
}
}
MatchPostingMatcher*
-MatchPost_make_matcher(MatchPosting *self, Similarity *sim,
+MatchPost_make_matcher(MatchPosting *self, Similarity *sim,
PostingList *plist, Compiler *compiler,
- bool_t need_score)
-{
- MatchPostingMatcher *matcher
+ bool_t need_score) {
+ MatchPostingMatcher *matcher
= (MatchPostingMatcher*)VTable_Make_Obj(MATCHPOSTINGMATCHER);
UNUSED_VAR(self);
UNUSED_VAR(need_score);
@@ -156,40 +149,36 @@ MatchPost_make_matcher(MatchPosting *sel
MatchPostingMatcher*
MatchPostMatcher_init(MatchPostingMatcher *self, Similarity *sim,
- PostingList *plist, Compiler *compiler)
-{
+ PostingList *plist, Compiler *compiler) {
TermMatcher_init((TermMatcher*)self, sim, plist, compiler);
return self;
}
float
-MatchPostMatcher_score(MatchPostingMatcher* self)
-{
+MatchPostMatcher_score(MatchPostingMatcher* self) {
return self->weight;
}
/***************************************************************************/
MatchPostingWriter*
-MatchPostWriter_new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, int32_t field_num)
-{
- MatchPostingWriter *self
+MatchPostWriter_new(Schema *schema, Snapshot *snapshot, Segment *segment,
+ PolyReader *polyreader, int32_t field_num) {
+ MatchPostingWriter *self
= (MatchPostingWriter*)VTable_Make_Obj(MATCHPOSTINGWRITER);
return MatchPostWriter_init(self, schema, snapshot, segment, polyreader,
- field_num);
+ field_num);
}
MatchPostingWriter*
-MatchPostWriter_init(MatchPostingWriter *self, Schema *schema,
- Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, int32_t field_num)
-{
+MatchPostWriter_init(MatchPostingWriter *self, Schema *schema,
+ Snapshot *snapshot, Segment *segment,
+ PolyReader *polyreader, int32_t field_num) {
Folder *folder = PolyReader_Get_Folder(polyreader);
- CharBuf *filename
+ CharBuf *filename
= CB_newf("%o/postings-%i32.dat", Seg_Get_Name(segment), field_num);
PostWriter_init((PostingWriter*)self, schema, snapshot, segment,
- polyreader, field_num);
+ polyreader, field_num);
self->outstream = Folder_Open_Out(folder, filename);
if (!self->outstream) { RETHROW(INCREF(Err_get_error())); }
DECREF(filename);
@@ -197,15 +186,13 @@ MatchPostWriter_init(MatchPostingWriter
}
void
-MatchPostWriter_destroy(MatchPostingWriter *self)
-{
+MatchPostWriter_destroy(MatchPostingWriter *self) {
DECREF(self->outstream);
SUPER_DESTROY(self, MATCHPOSTINGWRITER);
}
void
-MatchPostWriter_write_posting(MatchPostingWriter *self, RawPosting *posting)
-{
+MatchPostWriter_write_posting(MatchPostingWriter *self, RawPosting *posting) {
OutStream *const outstream = self->outstream;
const int32_t doc_id = posting->doc_id;
const uint32_t delta_doc = doc_id - self->last_doc_id;
@@ -224,31 +211,27 @@ MatchPostWriter_write_posting(MatchPosti
}
void
-MatchPostWriter_start_term(MatchPostingWriter *self, TermInfo *tinfo)
-{
+MatchPostWriter_start_term(MatchPostingWriter *self, TermInfo *tinfo) {
self->last_doc_id = 0;
tinfo->post_filepos = OutStream_Tell(self->outstream);
}
void
-MatchPostWriter_update_skip_info(MatchPostingWriter *self, TermInfo *tinfo)
-{
+MatchPostWriter_update_skip_info(MatchPostingWriter *self, TermInfo *tinfo) {
tinfo->post_filepos = OutStream_Tell(self->outstream);
}
/***************************************************************************/
MatchTermInfoStepper*
-MatchTInfoStepper_new(Schema *schema)
-{
- MatchTermInfoStepper *self
+MatchTInfoStepper_new(Schema *schema) {
+ MatchTermInfoStepper *self
= (MatchTermInfoStepper*)VTable_Make_Obj(MATCHTERMINFOSTEPPER);
return MatchTInfoStepper_init(self, schema);
}
MatchTermInfoStepper*
-MatchTInfoStepper_init(MatchTermInfoStepper *self, Schema *schema)
-{
+MatchTInfoStepper_init(MatchTermInfoStepper *self, Schema *schema) {
Architecture *arch = Schema_Get_Architecture(schema);
TermStepper_init((TermStepper*)self);
self->skip_interval = Arch_Skip_Interval(arch);
@@ -257,15 +240,13 @@ MatchTInfoStepper_init(MatchTermInfoStep
}
void
-MatchTInfoStepper_reset(MatchTermInfoStepper *self)
-{
+MatchTInfoStepper_reset(MatchTermInfoStepper *self) {
TInfo_Reset((TermInfo*)self->value);
}
void
-MatchTInfoStepper_write_key_frame(MatchTermInfoStepper *self,
- OutStream *outstream, Obj *value)
-{
+MatchTInfoStepper_write_key_frame(MatchTermInfoStepper *self,
+ OutStream *outstream, Obj *value) {
TermInfo *tinfo = (TermInfo*)CERTIFY(value, TERMINFO);
int32_t doc_freq = TInfo_Get_Doc_Freq(tinfo);
@@ -284,9 +265,8 @@ MatchTInfoStepper_write_key_frame(MatchT
}
void
-MatchTInfoStepper_write_delta(MatchTermInfoStepper *self,
- OutStream *outstream, Obj *value)
-{
+MatchTInfoStepper_write_delta(MatchTermInfoStepper *self,
+ OutStream *outstream, Obj *value) {
TermInfo *tinfo = (TermInfo*)CERTIFY(value, TERMINFO);
TermInfo *last_tinfo = (TermInfo*)self->value;
int32_t doc_freq = TInfo_Get_Doc_Freq(tinfo);
@@ -307,9 +287,8 @@ MatchTInfoStepper_write_delta(MatchTermI
}
void
-MatchTInfoStepper_read_key_frame(MatchTermInfoStepper *self,
- InStream *instream)
-{
+MatchTInfoStepper_read_key_frame(MatchTermInfoStepper *self,
+ InStream *instream) {
TermInfo *const tinfo = (TermInfo*)self->value;
// Read doc freq.
@@ -328,8 +307,7 @@ MatchTInfoStepper_read_key_frame(MatchTe
}
void
-MatchTInfoStepper_read_delta(MatchTermInfoStepper *self, InStream *instream)
-{
+MatchTInfoStepper_read_delta(MatchTermInfoStepper *self, InStream *instream) {
TermInfo *const tinfo = (TermInfo*)self->value;
// Read doc freq.
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/MatchPosting.cfh Sun May 1 23:50:24 2011
@@ -45,20 +45,20 @@ class Lucy::Index::Posting::MatchPosting
Read_Record(MatchPosting *self, InStream *instream);
incremented RawPosting*
- Read_Raw(MatchPosting *self, InStream *instream, int32_t last_doc_id,
+ Read_Raw(MatchPosting *self, InStream *instream, int32_t last_doc_id,
CharBuf *term_text, MemoryPool *mem_pool);
void
- Add_Inversion_To_Pool(MatchPosting *self, PostingPool *post_pool,
- Inversion *inversion, FieldType *type,
- int32_t doc_id, float doc_boost,
+ Add_Inversion_To_Pool(MatchPosting *self, PostingPool *post_pool,
+ Inversion *inversion, FieldType *type,
+ int32_t doc_id, float doc_boost,
float length_norm);
public void
Reset(MatchPosting *self);
incremented MatchPostingMatcher*
- Make_Matcher(MatchPosting *self, Similarity *sim, PostingList *plist,
+ Make_Matcher(MatchPosting *self, Similarity *sim, PostingList *plist,
Compiler *compiler, bool_t need_score);
}
@@ -66,7 +66,7 @@ class Lucy::Index::Posting::MatchPosting
inherits Lucy::Search::TermMatcher {
inert MatchPostingMatcher*
- init(MatchPostingMatcher *self, Similarity *similarity,
+ init(MatchPostingMatcher *self, Similarity *similarity,
PostingList *posting_list, Compiler *compiler);
public float
@@ -80,7 +80,7 @@ class Lucy::Index::Posting::MatchPosting
int32_t last_doc_id;
inert incremented MatchPostingWriter*
- new(Schema *schema, Snapshot *snapshot, Segment *segment,
+ new(Schema *schema, Snapshot *snapshot, Segment *segment,
PolyReader *polyreader, int32_t field_num);
inert MatchPostingWriter*
@@ -100,22 +100,22 @@ class Lucy::Index::Posting::MatchPosting
Update_Skip_Info(MatchPostingWriter *self, TermInfo *tinfo);
}
-class Lucy::Index::Posting::MatchPosting::MatchTermInfoStepper
+class Lucy::Index::Posting::MatchPosting::MatchTermInfoStepper
cnick MatchTInfoStepper inherits Lucy::Index::TermStepper {
int32_t skip_interval;
-
+
inert incremented MatchTermInfoStepper*
new(Schema *schema);
inert MatchTermInfoStepper*
init(MatchTermInfoStepper *self, Schema *schema);
- public void
+ public void
Reset(MatchTermInfoStepper *self);
public void
- Write_Key_Frame(MatchTermInfoStepper *self, OutStream *outstream,
+ Write_Key_Frame(MatchTermInfoStepper *self, OutStream *outstream,
Obj *value);
public void
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.c Sun May 1 23:50:24 2011
@@ -30,8 +30,8 @@
#include "Lucy/Store/OutStream.h"
#include "Lucy/Util/StringHelper.h"
-RawPosting RAWPOSTING_BLANK = {
- RAWPOSTING,
+RawPosting RAWPOSTING_BLANK = {
+ RAWPOSTING,
{1}, // ref.count
0, // doc_id
1, // freq
@@ -42,9 +42,8 @@ RawPosting RAWPOSTING_BLANK = {
RawPosting*
-RawPost_new(void *pre_allocated_memory, int32_t doc_id, uint32_t freq,
- char *term_text, size_t term_text_len)
-{
+RawPost_new(void *pre_allocated_memory, int32_t doc_id, uint32_t freq,
+ char *term_text, size_t term_text_len) {
RawPosting *self = (RawPosting*)pre_allocated_memory;
self->vtable = RAWPOSTING;
self->ref.count = 1; // never used
@@ -58,28 +57,24 @@ RawPost_new(void *pre_allocated_memory,
}
void
-RawPost_destroy(RawPosting *self)
-{
+RawPost_destroy(RawPosting *self) {
UNUSED_VAR(self);
THROW(ERR, "Illegal attempt to destroy RawPosting object");
}
uint32_t
-RawPost_get_refcount(RawPosting* self)
-{
+RawPost_get_refcount(RawPosting* self) {
UNUSED_VAR(self);
return 1;
}
RawPosting*
-RawPost_inc_refcount(RawPosting* self)
-{
+RawPost_inc_refcount(RawPosting* self) {
return self;
}
uint32_t
-RawPost_dec_refcount(RawPosting* self)
-{
+RawPost_dec_refcount(RawPosting* self) {
UNUSED_VAR(self);
return 1;
}
@@ -88,50 +83,44 @@ RawPost_dec_refcount(RawPosting* self)
RawPostingWriter*
RawPostWriter_new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, OutStream *outstream)
-{
- RawPostingWriter *self
+ PolyReader *polyreader, OutStream *outstream) {
+ RawPostingWriter *self
= (RawPostingWriter*)VTable_Make_Obj(RAWPOSTINGWRITER);
- return RawPostWriter_init(self, schema, snapshot, segment, polyreader,
- outstream);
+ return RawPostWriter_init(self, schema, snapshot, segment, polyreader,
+ outstream);
}
RawPostingWriter*
-RawPostWriter_init(RawPostingWriter *self, Schema *schema,
- Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, OutStream *outstream)
-{
+RawPostWriter_init(RawPostingWriter *self, Schema *schema,
+ Snapshot *snapshot, Segment *segment,
+ PolyReader *polyreader, OutStream *outstream) {
const int32_t invalid_field_num = 0;
PostWriter_init((PostingWriter*)self, schema, snapshot, segment,
- polyreader, invalid_field_num);
+ polyreader, invalid_field_num);
self->outstream = (OutStream*)INCREF(outstream);
self->last_doc_id = 0;
return self;
}
void
-RawPostWriter_start_term(RawPostingWriter *self, TermInfo *tinfo)
-{
+RawPostWriter_start_term(RawPostingWriter *self, TermInfo *tinfo) {
self->last_doc_id = 0;
tinfo->post_filepos = OutStream_Tell(self->outstream);
}
void
-RawPostWriter_update_skip_info(RawPostingWriter *self, TermInfo *tinfo)
-{
+RawPostWriter_update_skip_info(RawPostingWriter *self, TermInfo *tinfo) {
tinfo->post_filepos = OutStream_Tell(self->outstream);
}
void
-RawPostWriter_destroy(RawPostingWriter *self)
-{
+RawPostWriter_destroy(RawPostingWriter *self) {
DECREF(self->outstream);
SUPER_DESTROY(self, RAWPOSTINGWRITER);
}
void
-RawPostWriter_write_posting(RawPostingWriter *self, RawPosting *posting)
-{
+RawPostWriter_write_posting(RawPostingWriter *self, RawPosting *posting) {
OutStream *const outstream = self->outstream;
const int32_t doc_id = posting->doc_id;
const uint32_t delta_doc = doc_id - self->last_doc_id;
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/RawPosting.cfh Sun May 1 23:50:24 2011
@@ -56,7 +56,7 @@ class Lucy::Index::RawPosting cnick RawP
incremented RawPosting*
Inc_RefCount(RawPosting* self);
- uint32_t
+ uint32_t
Dec_RefCount(RawPosting* self);
/** Throws an error.
@@ -72,11 +72,11 @@ class Lucy::Index::Posting::RawPostingWr
int32_t last_doc_id;
inert incremented RawPostingWriter*
- new(Schema *schema, Snapshot *snapshot, Segment *segment,
+ new(Schema *schema, Snapshot *snapshot, Segment *segment,
PolyReader *polyreader, OutStream *outstream);
inert RawPostingWriter*
- init(RawPostingWriter *self, Schema *schema, Snapshot *snapshot,
+ init(RawPostingWriter *self, Schema *schema, Snapshot *snapshot,
Segment *segment, PolyReader *polyreader, OutStream *outstream);
public void
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.c Sun May 1 23:50:24 2011
@@ -34,49 +34,45 @@
#define FREQ_MAX_LEN C32_MAX_BYTES
#define MAX_RAW_POSTING_LEN(_text_len, _freq) \
- ( sizeof(RawPosting) \
- + _text_len /* term text content */ \
- + FREQ_MAX_LEN /* freq c32 */ \
- + (C32_MAX_BYTES * _freq) /* positions deltas */ \
- + _freq /* per-pos boost byte */ \
- )
+ ( sizeof(RawPosting) \
+ + _text_len /* term text content */ \
+ + FREQ_MAX_LEN /* freq c32 */ \
+ + (C32_MAX_BYTES * _freq) /* positions deltas */ \
+ + _freq /* per-pos boost byte */ \
+ )
RichPosting*
-RichPost_new(Similarity *sim)
-{
+RichPost_new(Similarity *sim) {
RichPosting *self = (RichPosting*)VTable_Make_Obj(RICHPOSTING);
return RichPost_init(self, sim);
}
RichPosting*
-RichPost_init(RichPosting *self, Similarity *sim)
-{
+RichPost_init(RichPosting *self, Similarity *sim) {
ScorePost_init((ScorePosting*)self, sim);
self->prox_boosts = NULL;
return self;
}
void
-RichPost_destroy(RichPosting *self)
-{
+RichPost_destroy(RichPosting *self) {
FREEMEM(self->prox_boosts);
SUPER_DESTROY(self, RICHPOSTING);
}
void
-RichPost_read_record(RichPosting *self, InStream *instream)
-{
+RichPost_read_record(RichPosting *self, InStream *instream) {
float *const norm_decoder = self->norm_decoder;
uint32_t doc_code;
uint32_t num_prox = 0;
- uint32_t position = 0;
+ uint32_t position = 0;
uint32_t *positions;
float *prox_boosts;
float aggregate_weight = 0.0;
// Decode delta doc.
doc_code = InStream_Read_C32(instream);
- self->doc_id += doc_code >> 1;
+ self->doc_id += doc_code >> 1;
// If the stored num was odd, the freq is 1.
if (doc_code & 1) {
@@ -85,14 +81,14 @@ RichPost_read_record(RichPosting *self,
// Otherwise, freq was stored as a C32.
else {
self->freq = InStream_Read_C32(instream);
- }
+ }
// Read positions, aggregate per-position boost byte into weight.
num_prox = self->freq;
if (num_prox > self->prox_cap) {
- self->prox
+ self->prox
= (uint32_t*)REALLOCATE(self->prox, num_prox * sizeof(uint32_t));
- self->prox_boosts
+ self->prox_boosts
= (float*)REALLOCATE(self->prox_boosts, num_prox * sizeof(float));
}
positions = self->prox;
@@ -101,7 +97,7 @@ RichPost_read_record(RichPosting *self,
while (num_prox--) {
position += InStream_Read_C32(instream);
*positions++ = position;
- *prox_boosts = norm_decoder[ InStream_Read_U8(instream) ];
+ *prox_boosts = norm_decoder[InStream_Read_U8(instream)];
aggregate_weight += *prox_boosts;
prox_boosts++;
}
@@ -109,11 +105,10 @@ RichPost_read_record(RichPosting *self,
}
void
-RichPost_add_inversion_to_pool(RichPosting *self, PostingPool *post_pool,
- Inversion *inversion, FieldType *type,
+RichPost_add_inversion_to_pool(RichPosting *self, PostingPool *post_pool,
+ Inversion *inversion, FieldType *type,
int32_t doc_id, float doc_boost,
- float length_norm)
-{
+ float length_norm) {
MemoryPool *mem_pool = PostPool_Get_Mem_Pool(post_pool);
Similarity *sim = self->sim;
float field_boost = doc_boost * FType_Get_Boost(type) * length_norm;
@@ -121,13 +116,12 @@ RichPost_add_inversion_to_pool(RichPosti
uint32_t freq;
Inversion_Reset(inversion);
- while ( (tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL ) {
+ while ((tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL) {
Token *token = *tokens;
uint32_t raw_post_bytes = MAX_RAW_POSTING_LEN(token->len, freq);
- RawPosting *raw_posting = RawPost_new(
- MemPool_Grab(mem_pool, raw_post_bytes), doc_id, freq,
- token->text, token->len
- );
+ RawPosting *raw_posting
+ = RawPost_new(MemPool_Grab(mem_pool, raw_post_bytes), doc_id,
+ freq, token->text, token->len);
char *const start = raw_posting->blob + token->len;
char *dest = start;
uint32_t last_prox = 0;
@@ -140,7 +134,7 @@ RichPost_add_inversion_to_pool(RichPosti
const float boost = field_boost * t->boost;
NumUtil_encode_c32(prox_delta, &dest);
- last_prox = t->pos;
+ last_prox = t->pos;
*((uint8_t*)dest) = Sim_Encode_Norm(sim, boost);
dest++;
@@ -155,21 +149,20 @@ RichPost_add_inversion_to_pool(RichPosti
}
RawPosting*
-RichPost_read_raw(RichPosting *self, InStream *instream, int32_t last_doc_id,
- CharBuf *term_text, MemoryPool *mem_pool)
-{
+RichPost_read_raw(RichPosting *self, InStream *instream, int32_t last_doc_id,
+ CharBuf *term_text, MemoryPool *mem_pool) {
char *const text_buf = (char*)CB_Get_Ptr8(term_text);
const size_t text_size = CB_Get_Size(term_text);
const uint32_t doc_code = InStream_Read_C32(instream);
const uint32_t delta_doc = doc_code >> 1;
const int32_t doc_id = last_doc_id + delta_doc;
- const uint32_t freq = (doc_code & 1)
- ? 1
- : InStream_Read_C32(instream);
+ const uint32_t freq = (doc_code & 1)
+ ? 1
+ : InStream_Read_C32(instream);
size_t raw_post_bytes = MAX_RAW_POSTING_LEN(text_size, freq);
void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
- RawPosting *const raw_posting = RawPost_new(allocation, doc_id, freq,
- text_buf, text_size);
+ RawPosting *const raw_posting
+ = RawPost_new(allocation, doc_id, freq, text_buf, text_size);
uint32_t num_prox = freq;
char *const start = raw_posting->blob + text_size;
char * dest = start;
@@ -191,10 +184,9 @@ RichPost_read_raw(RichPosting *self, InS
}
RichPostingMatcher*
-RichPost_make_matcher(RichPosting *self, Similarity *sim,
+RichPost_make_matcher(RichPosting *self, Similarity *sim,
PostingList *plist, Compiler *compiler,
- bool_t need_score)
-{
+ bool_t need_score) {
RichPostingMatcher* matcher
= (RichPostingMatcher*)VTable_Make_Obj(RICHPOSTINGMATCHER);
UNUSED_VAR(self);
@@ -203,11 +195,10 @@ RichPost_make_matcher(RichPosting *self,
}
RichPostingMatcher*
-RichPostMatcher_init(RichPostingMatcher *self, Similarity *sim,
- PostingList *plist, Compiler *compiler)
-{
- return (RichPostingMatcher*)ScorePostMatcher_init(
- (ScorePostingMatcher*)self, sim, plist, compiler);
+RichPostMatcher_init(RichPostingMatcher *self, Similarity *sim,
+ PostingList *plist, Compiler *compiler) {
+ return (RichPostingMatcher*)ScorePostMatcher_init((ScorePostingMatcher*)self,
+ sim, plist, compiler);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/RichPosting.cfh Sun May 1 23:50:24 2011
@@ -46,17 +46,17 @@ class Lucy::Index::Posting::RichPosting
Read_Record(RichPosting *self, InStream *instream);
incremented RawPosting*
- Read_Raw(RichPosting *self, InStream *instream, int32_t last_doc_id,
+ Read_Raw(RichPosting *self, InStream *instream, int32_t last_doc_id,
CharBuf *term_text, MemoryPool *mem_pool);
void
- Add_Inversion_To_Pool(RichPosting *self, PostingPool *post_pool,
- Inversion *inversion, FieldType *type,
- int32_t doc_id, float doc_boost,
+ Add_Inversion_To_Pool(RichPosting *self, PostingPool *post_pool,
+ Inversion *inversion, FieldType *type,
+ int32_t doc_id, float doc_boost,
float length_norm);
incremented RichPostingMatcher*
- Make_Matcher(RichPosting *self, Similarity *sim, PostingList *plist,
+ Make_Matcher(RichPosting *self, Similarity *sim, PostingList *plist,
Compiler *compiler, bool_t need_score);
}
@@ -64,7 +64,7 @@ class Lucy::Index::Posting::RichPostingM
inherits Lucy::Index::Posting::ScorePostingMatcher {
inert RichPostingMatcher*
- init(RichPostingMatcher *self, Similarity *similarity,
+ init(RichPostingMatcher *self, Similarity *similarity,
PostingList *posting_list, Compiler *compiler);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.c Sun May 1 23:50:24 2011
@@ -36,23 +36,21 @@
#define FIELD_BOOST_LEN 1
#define FREQ_MAX_LEN C32_MAX_BYTES
#define MAX_RAW_POSTING_LEN(_text_len, _freq) \
- ( sizeof(RawPosting) \
- + _text_len /* term text content */ \
- + FIELD_BOOST_LEN /* field boost byte */ \
- + FREQ_MAX_LEN /* freq c32 */ \
- + (C32_MAX_BYTES * _freq) /* positions deltas */ \
- )
+ ( sizeof(RawPosting) \
+ + _text_len /* term text content */ \
+ + FIELD_BOOST_LEN /* field boost byte */ \
+ + FREQ_MAX_LEN /* freq c32 */ \
+ + (C32_MAX_BYTES * _freq) /* positions deltas */ \
+ )
ScorePosting*
-ScorePost_new(Similarity *sim)
-{
+ScorePost_new(Similarity *sim) {
ScorePosting *self = (ScorePosting*)VTable_Make_Obj(SCOREPOSTING);
return ScorePost_init(self, sim);
}
ScorePosting*
-ScorePost_init(ScorePosting *self, Similarity *sim)
-{
+ScorePost_init(ScorePosting *self, Similarity *sim) {
MatchPost_init((MatchPosting*)self, sim);
self->norm_decoder = Sim_Get_Norm_Decoder(sim);
self->freq = 0;
@@ -63,21 +61,21 @@ ScorePost_init(ScorePosting *self, Simil
}
void
-ScorePost_destroy(ScorePosting *self)
-{
+ScorePost_destroy(ScorePosting *self) {
FREEMEM(self->prox);
SUPER_DESTROY(self, SCOREPOSTING);
}
uint32_t*
-ScorePost_get_prox(ScorePosting *self) { return self->prox; }
+ScorePost_get_prox(ScorePosting *self) {
+ return self->prox;
+}
void
-ScorePost_add_inversion_to_pool(ScorePosting *self, PostingPool *post_pool,
- Inversion *inversion, FieldType *type,
- int32_t doc_id, float doc_boost,
- float length_norm)
-{
+ScorePost_add_inversion_to_pool(ScorePosting *self, PostingPool *post_pool,
+ Inversion *inversion, FieldType *type,
+ int32_t doc_id, float doc_boost,
+ float length_norm) {
MemoryPool *mem_pool = PostPool_Get_Mem_Pool(post_pool);
Similarity *sim = self->sim;
float field_boost = doc_boost * FType_Get_Boost(type) * length_norm;
@@ -86,13 +84,12 @@ ScorePost_add_inversion_to_pool(ScorePos
uint32_t freq;
Inversion_Reset(inversion);
- while ( (tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL ) {
+ while ((tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL) {
Token *token = *tokens;
uint32_t raw_post_bytes = MAX_RAW_POSTING_LEN(token->len, freq);
- RawPosting *raw_posting = RawPost_new(
- MemPool_Grab(mem_pool, raw_post_bytes), doc_id, freq,
- token->text, token->len
- );
+ RawPosting *raw_posting
+ = RawPost_new(MemPool_Grab(mem_pool, raw_post_bytes), doc_id,
+ freq, token->text, token->len);
char *const start = raw_posting->blob + token->len;
char *dest = start;
uint32_t last_prox = 0;
@@ -107,7 +104,7 @@ ScorePost_add_inversion_to_pool(ScorePos
Token *const t = tokens[i];
const uint32_t prox_delta = t->pos - last_prox;
NumUtil_encode_c32(prox_delta, &dest);
- last_prox = t->pos;
+ last_prox = t->pos;
}
// Resize raw posting memory allocation.
@@ -119,18 +116,16 @@ ScorePost_add_inversion_to_pool(ScorePos
}
void
-ScorePost_reset(ScorePosting *self)
-{
- self->doc_id = 0;
- self->freq = 0;
- self->weight = 0.0;
+ScorePost_reset(ScorePosting *self) {
+ self->doc_id = 0;
+ self->freq = 0;
+ self->weight = 0.0;
}
void
-ScorePost_read_record(ScorePosting *self, InStream *instream)
-{
+ScorePost_read_record(ScorePosting *self, InStream *instream) {
uint32_t num_prox;
- uint32_t position = 0;
+ uint32_t position = 0;
uint32_t *positions;
const size_t max_start_bytes = (C32_MAX_BYTES * 2) + 1;
char *buf = InStream_Buf(instream, max_start_bytes);
@@ -147,14 +142,14 @@ ScorePost_read_record(ScorePosting *self
}
// Decode boost/norm byte.
- self->weight = self->norm_decoder[ *(uint8_t*)buf ];
+ self->weight = self->norm_decoder[*(uint8_t*)buf];
buf++;
// Read positions.
num_prox = self->freq;
if (num_prox > self->prox_cap) {
- self->prox = (uint32_t*)REALLOCATE(self->prox,
- num_prox * sizeof(uint32_t));
+ self->prox = (uint32_t*)REALLOCATE(
+ self->prox, num_prox * sizeof(uint32_t));
self->prox_cap = num_prox;
}
positions = self->prox;
@@ -170,22 +165,21 @@ ScorePost_read_record(ScorePosting *self
}
RawPosting*
-ScorePost_read_raw(ScorePosting *self, InStream *instream,
- int32_t last_doc_id, CharBuf *term_text,
- MemoryPool *mem_pool)
-{
+ScorePost_read_raw(ScorePosting *self, InStream *instream,
+ int32_t last_doc_id, CharBuf *term_text,
+ MemoryPool *mem_pool) {
char *const text_buf = (char*)CB_Get_Ptr8(term_text);
const size_t text_size = CB_Get_Size(term_text);
const uint32_t doc_code = InStream_Read_C32(instream);
const uint32_t delta_doc = doc_code >> 1;
const int32_t doc_id = last_doc_id + delta_doc;
- const uint32_t freq = (doc_code & 1)
- ? 1
- : InStream_Read_C32(instream);
+ const uint32_t freq = (doc_code & 1)
+ ? 1
+ : InStream_Read_C32(instream);
size_t raw_post_bytes = MAX_RAW_POSTING_LEN(text_size, freq);
void *const allocation = MemPool_Grab(mem_pool, raw_post_bytes);
- RawPosting *const raw_posting = RawPost_new(allocation, doc_id, freq,
- text_buf, text_size);
+ RawPosting *const raw_posting
+ = RawPost_new(allocation, doc_id, freq, text_buf, text_size);
uint32_t num_prox = freq;
char *const start = raw_posting->blob + text_size;
char *dest = start;
@@ -209,10 +203,9 @@ ScorePost_read_raw(ScorePosting *self, I
}
ScorePostingMatcher*
-ScorePost_make_matcher(ScorePosting *self, Similarity *sim,
+ScorePost_make_matcher(ScorePosting *self, Similarity *sim,
PostingList *plist, Compiler *compiler,
- bool_t need_score)
-{
+ bool_t need_score) {
ScorePostingMatcher *matcher
= (ScorePostingMatcher*)VTable_Make_Obj(SCOREPOSTINGMATCHER);
UNUSED_VAR(self);
@@ -221,9 +214,8 @@ ScorePost_make_matcher(ScorePosting *sel
}
ScorePostingMatcher*
-ScorePostMatcher_init(ScorePostingMatcher *self, Similarity *sim,
- PostingList *plist, Compiler *compiler)
-{
+ScorePostMatcher_init(ScorePostingMatcher *self, Similarity *sim,
+ PostingList *plist, Compiler *compiler) {
uint32_t i;
// Init.
@@ -236,18 +228,17 @@ ScorePostMatcher_init(ScorePostingMatche
}
return self;
-}
+}
float
-ScorePostMatcher_score(ScorePostingMatcher* self)
-{
+ScorePostMatcher_score(ScorePostingMatcher* self) {
ScorePosting *const posting = (ScorePosting*)self->posting;
const uint32_t freq = posting->freq;
-
+
// Calculate initial score based on frequency of term.
- float score = (freq < TERMMATCHER_SCORE_CACHE_SIZE)
- ? self->score_cache[freq] // cache hit
- : Sim_TF(self->sim, (float)freq) * self->weight;
+ float score = (freq < TERMMATCHER_SCORE_CACHE_SIZE)
+ ? self->score_cache[freq] // cache hit
+ : Sim_TF(self->sim, (float)freq) * self->weight;
// Factor in field-length normalization and doc/field/prox boost.
score *= posting->weight;
@@ -256,8 +247,7 @@ ScorePostMatcher_score(ScorePostingMatch
}
void
-ScorePostMatcher_destroy(ScorePostingMatcher *self)
-{
+ScorePostMatcher_destroy(ScorePostingMatcher *self) {
FREEMEM(self->score_cache);
SUPER_DESTROY(self, SCOREPOSTINGMATCHER);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Posting/ScorePosting.cfh Sun May 1 23:50:24 2011
@@ -43,20 +43,20 @@ class Lucy::Index::Posting::ScorePosting
Read_Record(ScorePosting *self, InStream *instream);
incremented RawPosting*
- Read_Raw(ScorePosting *self, InStream *instream, int32_t last_doc_id,
+ Read_Raw(ScorePosting *self, InStream *instream, int32_t last_doc_id,
CharBuf *term_text, MemoryPool *mem_pool);
void
- Add_Inversion_To_Pool(ScorePosting *self, PostingPool *post_pool,
- Inversion *inversion, FieldType *type,
- int32_t doc_id, float doc_boost,
+ Add_Inversion_To_Pool(ScorePosting *self, PostingPool *post_pool,
+ Inversion *inversion, FieldType *type,
+ int32_t doc_id, float doc_boost,
float length_norm);
public void
Reset(ScorePosting *self);
incremented ScorePostingMatcher*
- Make_Matcher(ScorePosting *self, Similarity *sim, PostingList *plist,
+ Make_Matcher(ScorePosting *self, Similarity *sim, PostingList *plist,
Compiler *compiler, bool_t need_score);
nullable uint32_t*
@@ -69,7 +69,7 @@ class Lucy::Index::Posting::ScorePosting
float *score_cache;
inert ScorePostingMatcher*
- init(ScorePostingMatcher *self, Similarity *sim, PostingList *plist,
+ init(ScorePostingMatcher *self, Similarity *sim, PostingList *plist,
Compiler *compiler);
public float
Modified: incubator/lucy/trunk/core/Lucy/Index/PostingList.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingList.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingList.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingList.c Sun May 1 23:50:24 2011
@@ -25,8 +25,7 @@
#include "Lucy/Util/Memory.h"
PostingList*
-PList_init(PostingList *self)
-{
+PList_init(PostingList *self) {
ABSTRACT_CLASS_CHECK(self, POSTINGLIST);
return self;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/PostingListReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingListReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingListReader.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingListReader.c Sun May 1 23:50:24 2011
@@ -31,19 +31,17 @@
#include "Lucy/Store/Folder.h"
PostingListReader*
-PListReader_init(PostingListReader *self, Schema *schema, Folder *folder,
- Snapshot *snapshot, VArray *segments, int32_t seg_tick)
-{
+PListReader_init(PostingListReader *self, Schema *schema, Folder *folder,
+ Snapshot *snapshot, VArray *segments, int32_t seg_tick) {
DataReader_init((DataReader*)self, schema, folder, snapshot, segments,
- seg_tick);
+ seg_tick);
ABSTRACT_CLASS_CHECK(self, POSTINGLISTREADER);
return self;
}
PostingListReader*
-PListReader_aggregator(PostingListReader *self, VArray *readers,
- I32Array *offsets)
-{
+PListReader_aggregator(PostingListReader *self, VArray *readers,
+ I32Array *offsets) {
UNUSED_VAR(self);
UNUSED_VAR(readers);
UNUSED_VAR(offsets);
@@ -52,22 +50,20 @@ PListReader_aggregator(PostingListReader
DefaultPostingListReader*
DefPListReader_new(Schema *schema, Folder *folder, Snapshot *snapshot,
- VArray *segments, int32_t seg_tick,
- LexiconReader *lex_reader)
-{
- DefaultPostingListReader *self = (DefaultPostingListReader*)
- VTable_Make_Obj(DEFAULTPOSTINGLISTREADER);
- return DefPListReader_init(self, schema, folder, snapshot, segments,
- seg_tick, lex_reader);
+ VArray *segments, int32_t seg_tick,
+ LexiconReader *lex_reader) {
+ DefaultPostingListReader *self
+ = (DefaultPostingListReader*)VTable_Make_Obj(DEFAULTPOSTINGLISTREADER);
+ return DefPListReader_init(self, schema, folder, snapshot, segments,
+ seg_tick, lex_reader);
}
DefaultPostingListReader*
-DefPListReader_init(DefaultPostingListReader *self, Schema *schema,
+DefPListReader_init(DefaultPostingListReader *self, Schema *schema,
Folder *folder, Snapshot *snapshot, VArray *segments,
- int32_t seg_tick, LexiconReader *lex_reader)
-{
- PListReader_init((PostingListReader*)self, schema, folder, snapshot,
- segments, seg_tick);
+ int32_t seg_tick, LexiconReader *lex_reader) {
+ PListReader_init((PostingListReader*)self, schema, folder, snapshot,
+ segments, seg_tick);
Segment *segment = DefPListReader_Get_Segment(self);
// Derive.
@@ -76,9 +72,9 @@ DefPListReader_init(DefaultPostingListRe
// Check format.
{
Hash *my_meta = (Hash*)Seg_Fetch_Metadata_Str(segment, "postings", 8);
- if (!my_meta) {
- my_meta = (Hash*)Seg_Fetch_Metadata_Str(segment,
- "posting_list", 12);
+ if (!my_meta) {
+ my_meta = (Hash*)Seg_Fetch_Metadata_Str(segment,
+ "posting_list", 12);
}
if (my_meta) {
@@ -86,19 +82,18 @@ DefPListReader_init(DefaultPostingListRe
if (!format) { THROW(ERR, "Missing 'format' var"); }
else {
if (Obj_To_I64(format) != PListWriter_current_file_format) {
- THROW(ERR, "Unsupported postings format: %i64",
- Obj_To_I64(format));
+ THROW(ERR, "Unsupported postings format: %i64",
+ Obj_To_I64(format));
}
}
}
}
-
+
return self;
}
void
-DefPListReader_close(DefaultPostingListReader *self)
-{
+DefPListReader_close(DefaultPostingListReader *self) {
if (self->lex_reader) {
LexReader_Close(self->lex_reader);
DECREF(self->lex_reader);
@@ -107,17 +102,15 @@ DefPListReader_close(DefaultPostingListR
}
void
-DefPListReader_destroy(DefaultPostingListReader *self)
-{
+DefPListReader_destroy(DefaultPostingListReader *self) {
DECREF(self->lex_reader);
SUPER_DESTROY(self, DEFAULTPOSTINGLISTREADER);
}
SegPostingList*
-DefPListReader_posting_list(DefaultPostingListReader *self,
- const CharBuf *field, Obj *target)
-{
- FieldType *type = Schema_Fetch_Type(self->schema, field);
+DefPListReader_posting_list(DefaultPostingListReader *self,
+ const CharBuf *field, Obj *target) {
+ FieldType *type = Schema_Fetch_Type(self->schema, field);
// Only return an object if we've got an indexed field.
if (type != NULL && FType_Indexed(type)) {
@@ -131,7 +124,7 @@ DefPListReader_posting_list(DefaultPosti
}
LexiconReader*
-DefPListReader_get_lex_reader(DefaultPostingListReader *self)
- { return self->lex_reader; }
-
+DefPListReader_get_lex_reader(DefaultPostingListReader *self) {
+ return self->lex_reader;
+}