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 [8/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/PostingListReader.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingListReader.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingListReader.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingListReader.cfh Sun May 1 23:50:24 2011
@@ -25,8 +25,8 @@ class Lucy::Index::PostingListReader cni
inherits Lucy::Index::DataReader {
inert PostingListReader*
- init(PostingListReader *self, Schema *schema = NULL,
- Folder *folder = NULL, Snapshot *snapshot = NULL,
+ init(PostingListReader *self, Schema *schema = NULL,
+ Folder *folder = NULL, Snapshot *snapshot = NULL,
VArray *segments = NULL, int32_t seg_tick = -1);
/** Returns a PostingList, or NULL if either <code>field</code> is NULL or
@@ -61,7 +61,7 @@ class Lucy::Index::DefaultPostingListRea
inert DefaultPostingListReader*
init(DefaultPostingListReader *self, Schema *schema, Folder *folder,
- Snapshot *snapshot, VArray *segments, int32_t seg_tick,
+ Snapshot *snapshot, VArray *segments, int32_t seg_tick,
LexiconReader *lex_reader);
public incremented nullable SegPostingList*
Modified: incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.c Sun May 1 23:50:24 2011
@@ -50,19 +50,17 @@ S_lazy_init_posting_pool(PostingListWrit
PostingListWriter*
PListWriter_new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, LexiconWriter *lex_writer)
-{
- PostingListWriter *self
+ PolyReader *polyreader, LexiconWriter *lex_writer) {
+ PostingListWriter *self
= (PostingListWriter*)VTable_Make_Obj(POSTINGLISTWRITER);
return PListWriter_init(self, schema, snapshot, segment, polyreader,
- lex_writer);
+ lex_writer);
}
PostingListWriter*
PListWriter_init(PostingListWriter *self, Schema *schema, Snapshot *snapshot,
Segment *segment, PolyReader *polyreader,
- LexiconWriter *lex_writer)
-{
+ LexiconWriter *lex_writer) {
DataWriter_init((DataWriter*)self, schema, snapshot, segment, polyreader);
// Assign.
@@ -79,8 +77,7 @@ PListWriter_init(PostingListWriter *self
}
static void
-S_lazy_init(PostingListWriter *self)
-{
+S_lazy_init(PostingListWriter *self) {
if (!self->lex_temp_out) {
Folder *folder = self->folder;
CharBuf *seg_name = Seg_Get_Name(self->segment);
@@ -103,22 +100,21 @@ S_lazy_init(PostingListWriter *self)
}
static PostingPool*
-S_lazy_init_posting_pool(PostingListWriter *self, int32_t field_num)
-{
+S_lazy_init_posting_pool(PostingListWriter *self, int32_t field_num) {
PostingPool *pool = (PostingPool*)VA_Fetch(self->pools, field_num);
if (!pool && field_num != 0) {
CharBuf *field = Seg_Field_Name(self->segment, field_num);
pool = PostPool_new(self->schema, self->snapshot, self->segment,
- self->polyreader, field, self->lex_writer, self->mem_pool,
- self->lex_temp_out, self->post_temp_out, self->skip_out);
+ self->polyreader, field, self->lex_writer,
+ self->mem_pool, self->lex_temp_out,
+ self->post_temp_out, self->skip_out);
VA_Store(self->pools, field_num, (Obj*)pool);
}
return pool;
}
void
-PListWriter_destroy(PostingListWriter *self)
-{
+PListWriter_destroy(PostingListWriter *self) {
DECREF(self->lex_writer);
DECREF(self->mem_pool);
DECREF(self->pools);
@@ -129,22 +125,19 @@ PListWriter_destroy(PostingListWriter *s
}
void
-PListWriter_set_default_mem_thresh(size_t mem_thresh)
-{
+PListWriter_set_default_mem_thresh(size_t mem_thresh) {
default_mem_thresh = mem_thresh;
}
int32_t
-PListWriter_format(PostingListWriter *self)
-{
+PListWriter_format(PostingListWriter *self) {
UNUSED_VAR(self);
return PListWriter_current_file_format;
}
void
-PListWriter_add_inverted_doc(PostingListWriter *self, Inverter *inverter,
- int32_t doc_id)
-{
+PListWriter_add_inverted_doc(PostingListWriter *self, Inverter *inverter,
+ int32_t doc_id) {
S_lazy_init(self);
// Iterate over fields in document, adding the content of indexed fields
@@ -158,10 +151,10 @@ PListWriter_add_inverted_doc(PostingList
Inversion *inversion = Inverter_Get_Inversion(inverter);
Similarity *sim = Inverter_Get_Similarity(inverter);
PostingPool *pool = S_lazy_init_posting_pool(self, field_num);
- float length_norm
+ float length_norm
= Sim_Length_Norm(sim, Inversion_Get_Size(inversion));
- PostPool_Add_Inversion(pool, inversion, doc_id, doc_boost,
- length_norm);
+ PostPool_Add_Inversion(pool, inversion, doc_id, doc_boost,
+ length_norm);
}
}
@@ -179,27 +172,28 @@ PListWriter_add_inverted_doc(PostingList
void
PListWriter_add_segment(PostingListWriter *self, SegReader *reader,
- I32Array *doc_map)
-{
- Segment *other_segment = SegReader_Get_Segment(reader);
- Schema *schema = self->schema;
- Segment *segment = self->segment;
- VArray *all_fields = Schema_All_Fields(schema);
+ I32Array *doc_map) {
+ Segment *other_segment = SegReader_Get_Segment(reader);
+ Schema *schema = self->schema;
+ Segment *segment = self->segment;
+ VArray *all_fields = Schema_All_Fields(schema);
S_lazy_init(self);
for (uint32_t i = 0, max = VA_Get_Size(all_fields); i < max; i++) {
- CharBuf *field = (CharBuf*)VA_Fetch(all_fields, i);
- FieldType *type = Schema_Fetch_Type(schema, field);
+ CharBuf *field = (CharBuf*)VA_Fetch(all_fields, i);
+ FieldType *type = Schema_Fetch_Type(schema, field);
int32_t old_field_num = Seg_Field_Num(other_segment, field);
int32_t new_field_num = Seg_Field_Num(segment, field);
if (!FType_Indexed(type)) { continue; }
- if (!old_field_num) { continue; } // not in old segment
- if (!new_field_num) { THROW(ERR, "Unrecognized field: %o", field); }
+ if (!old_field_num) { continue; } // not in old segment
+ if (!new_field_num) {
+ THROW(ERR, "Unrecognized field: %o", field);
+ }
PostingPool *pool = S_lazy_init_posting_pool(self, new_field_num);
- PostPool_Add_Segment(pool, reader, doc_map,
- (int32_t)Seg_Get_Count(segment));
+ PostPool_Add_Segment(pool, reader, doc_map,
+ (int32_t)Seg_Get_Count(segment));
}
// Clean up.
@@ -207,8 +201,7 @@ PListWriter_add_segment(PostingListWrite
}
void
-PListWriter_finish(PostingListWriter *self)
-{
+PListWriter_finish(PostingListWriter *self) {
// If S_lazy_init was never called, we have no data, so bail out.
if (!self->lex_temp_out) { return; }
@@ -230,7 +223,7 @@ PListWriter_finish(PostingListWriter *se
// Write postings for each field.
for (uint32_t i = 0, max = VA_Get_Size(self->pools); i < max; i++) {
PostingPool *pool = (PostingPool*)VA_Delete(self->pools, i);
- if (pool) {
+ if (pool) {
// Write out content for each PostingPool. Let each PostingPool
// use more RAM while finishing. (This is a little dicy, because if
// Shrink() was ineffective, we may double the RAM footprint.)
@@ -242,8 +235,8 @@ PListWriter_finish(PostingListWriter *se
}
// Store metadata.
- Seg_Store_Metadata_Str(self->segment, "postings", 8,
- (Obj*)PListWriter_Metadata(self));
+ Seg_Store_Metadata_Str(self->segment, "postings", 8,
+ (Obj*)PListWriter_Metadata(self));
// Close down and clean up.
OutStream_Close(self->skip_out);
@@ -254,7 +247,7 @@ PListWriter_finish(PostingListWriter *se
THROW(ERR, "Couldn't delete %o", post_temp_path);
}
DECREF(self->skip_out);
- self->skip_out = NULL;
+ self->skip_out = NULL;
DECREF(post_temp_path);
DECREF(lex_temp_path);
Modified: incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingListWriter.cfh Sun May 1 23:50:24 2011
@@ -37,7 +37,7 @@ class Lucy::Index::PostingListWriter cni
inert incremented PostingListWriter*
new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, LexiconWriter *lex_writer);
+ PolyReader *polyreader, LexiconWriter *lex_writer);
inert PostingListWriter*
init(PostingListWriter *self, Schema *schema, Snapshot *snapshot,
@@ -48,7 +48,7 @@ class Lucy::Index::PostingListWriter cni
set_default_mem_thresh(size_t mem_thresh);
public void
- Add_Inverted_Doc(PostingListWriter *self, Inverter *inverter,
+ Add_Inverted_Doc(PostingListWriter *self, Inverter *inverter,
int32_t doc_id);
public void
@@ -58,7 +58,7 @@ class Lucy::Index::PostingListWriter cni
public void
Finish(PostingListWriter *self);
- public int32_t
+ public int32_t
Format(PostingListWriter *self);
public void
Modified: incubator/lucy/trunk/core/Lucy/Index/PostingPool.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingPool.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingPool.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingPool.c Sun May 1 23:50:24 2011
@@ -48,7 +48,7 @@
// Prepare to read back postings from disk.
static void
-S_fresh_flip(PostingPool *self, InStream *lex_temp_in,
+S_fresh_flip(PostingPool *self, InStream *lex_temp_in,
InStream *post_temp_in);
// Main loop.
@@ -57,24 +57,23 @@ S_write_terms_and_postings(PostingPool *
OutStream *skip_stream);
PostingPool*
-PostPool_new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, const CharBuf *field,
- LexiconWriter *lex_writer, MemoryPool *mem_pool,
+PostPool_new(Schema *schema, Snapshot *snapshot, Segment *segment,
+ PolyReader *polyreader, const CharBuf *field,
+ LexiconWriter *lex_writer, MemoryPool *mem_pool,
OutStream *lex_temp_out, OutStream *post_temp_out,
- OutStream *skip_out)
-{
+ OutStream *skip_out) {
PostingPool *self = (PostingPool*)VTable_Make_Obj(POSTINGPOOL);
- return PostPool_init(self, schema, snapshot, segment, polyreader, field,
- lex_writer, mem_pool, lex_temp_out, post_temp_out, skip_out);
+ return PostPool_init(self, schema, snapshot, segment, polyreader, field,
+ lex_writer, mem_pool, lex_temp_out, post_temp_out,
+ skip_out);
}
PostingPool*
-PostPool_init(PostingPool *self, Schema *schema, Snapshot *snapshot,
- Segment *segment, PolyReader *polyreader, const CharBuf *field,
- LexiconWriter *lex_writer, MemoryPool *mem_pool,
- OutStream *lex_temp_out, OutStream *post_temp_out,
- OutStream *skip_out)
-{
+PostPool_init(PostingPool *self, Schema *schema, Snapshot *snapshot,
+ Segment *segment, PolyReader *polyreader, const CharBuf *field,
+ LexiconWriter *lex_writer, MemoryPool *mem_pool,
+ OutStream *lex_temp_out, OutStream *post_temp_out,
+ OutStream *skip_out) {
// Init.
SortEx_init((SortExternal*)self, sizeof(Obj*));
self->doc_base = 0;
@@ -113,8 +112,7 @@ PostPool_init(PostingPool *self, Schema
}
void
-PostPool_destroy(PostingPool *self)
-{
+PostPool_destroy(PostingPool *self) {
DECREF(self->schema);
DECREF(self->snapshot);
DECREF(self->segment);
@@ -137,13 +135,12 @@ PostPool_destroy(PostingPool *self)
}
int
-PostPool_compare(PostingPool *self, void *va, void *vb)
-{
+PostPool_compare(PostingPool *self, void *va, void *vb) {
RawPosting *const a = *(RawPosting**)va;
RawPosting *const b = *(RawPosting**)vb;
const size_t a_len = a->content_len;
const size_t b_len = b->content_len;
- const size_t len = a_len < b_len? a_len : b_len;
+ const size_t len = a_len < b_len ? a_len : b_len;
int comparison = memcmp(a->blob, b->blob, len);
UNUSED_VAR(self);
@@ -161,16 +158,17 @@ PostPool_compare(PostingPool *self, void
}
MemoryPool*
-PostPool_get_mem_pool(PostingPool *self) { return self->mem_pool; }
+PostPool_get_mem_pool(PostingPool *self) {
+ return self->mem_pool;
+}
void
-PostPool_flip(PostingPool *self)
-{
+PostPool_flip(PostingPool *self) {
uint32_t i;
- uint32_t num_runs = VA_Get_Size(self->runs);
- uint32_t sub_thresh = num_runs > 0
- ? self->mem_thresh / num_runs
- : self->mem_thresh;
+ uint32_t num_runs = VA_Get_Size(self->runs);
+ uint32_t sub_thresh = num_runs > 0
+ ? self->mem_thresh / num_runs
+ : self->mem_thresh;
if (num_runs) {
Folder *folder = PolyReader_Get_Folder(self->polyreader);
@@ -178,11 +176,11 @@ PostPool_flip(PostingPool *self)
CharBuf *lex_temp_path = CB_newf("%o/lextemp", seg_name);
CharBuf *post_temp_path = CB_newf("%o/ptemp", seg_name);
self->lex_temp_in = Folder_Open_In(folder, lex_temp_path);
- if (!self->lex_temp_in) {
+ if (!self->lex_temp_in) {
RETHROW(INCREF(Err_get_error()));
}
self->post_temp_in = Folder_Open_In(folder, post_temp_path);
- if (!self->post_temp_in) {
+ if (!self->post_temp_in) {
RETHROW(INCREF(Err_get_error()));
}
DECREF(lex_temp_path);
@@ -193,13 +191,14 @@ PostPool_flip(PostingPool *self)
if (num_runs && (self->cache_max - self->cache_tick) > 0) {
uint32_t num_items = PostPool_Cache_Count(self);
// Cheap imitation of flush. FIXME.
- PostingPool *run = PostPool_new(self->schema, self->snapshot,
- self->segment, self->polyreader, self->field, self->lex_writer,
- self->mem_pool, self->lex_temp_out, self->post_temp_out,
- self->skip_out);
+ PostingPool *run
+ = PostPool_new(self->schema, self->snapshot, self->segment,
+ self->polyreader, self->field, self->lex_writer,
+ self->mem_pool, self->lex_temp_out,
+ self->post_temp_out, self->skip_out);
PostPool_Grow_Cache(run, num_items);
- memcpy(run->cache, ((Obj**)self->cache) + self->cache_tick,
- num_items * sizeof(Obj*));
+ memcpy(run->cache, ((Obj**)self->cache) + self->cache_tick,
+ num_items * sizeof(Obj*));
run->cache_max = num_items;
PostPool_Add_Run(self, (SortExternal*)run);
self->cache_tick = 0;
@@ -212,8 +211,7 @@ PostPool_flip(PostingPool *self)
if (run != NULL) {
PostPool_Set_Mem_Thresh(run, sub_thresh);
if (!run->lexicon) {
- S_fresh_flip(run, self->lex_temp_in,
- self->post_temp_in);
+ S_fresh_flip(run, self->lex_temp_in, self->post_temp_in);
}
}
}
@@ -223,28 +221,29 @@ PostPool_flip(PostingPool *self)
void
PostPool_add_segment(PostingPool *self, SegReader *reader, I32Array *doc_map,
- int32_t doc_base)
-{
- LexiconReader *lex_reader = (LexiconReader*)SegReader_Fetch(reader,
- VTable_Get_Name(LEXICONREADER));
- Lexicon *lexicon = lex_reader
- ? LexReader_Lexicon(lex_reader, self->field, NULL)
- : NULL;
+ int32_t doc_base) {
+ LexiconReader *lex_reader = (LexiconReader*)SegReader_Fetch(
+ reader, VTable_Get_Name(LEXICONREADER));
+ Lexicon *lexicon = lex_reader
+ ? LexReader_Lexicon(lex_reader, self->field, NULL)
+ : NULL;
if (lexicon) {
- PostingListReader *plist_reader = (PostingListReader*)SegReader_Fetch(reader,
- VTable_Get_Name(POSTINGLISTREADER));
- PostingList *plist = plist_reader
- ? PListReader_Posting_List(plist_reader, self->field, NULL)
- : NULL;
+ PostingListReader *plist_reader
+ = (PostingListReader*)SegReader_Fetch(
+ reader, VTable_Get_Name(POSTINGLISTREADER));
+ PostingList *plist = plist_reader
+ ? PListReader_Posting_List(plist_reader, self->field, NULL)
+ : NULL;
if (!plist) {
THROW(ERR, "Got a Lexicon but no PostingList for '%o' in '%o'",
- self->field, SegReader_Get_Seg_Name(reader));
+ self->field, SegReader_Get_Seg_Name(reader));
}
- PostingPool *run = PostPool_new(self->schema, self->snapshot,
- self->segment, self->polyreader, self->field, self->lex_writer,
- self->mem_pool, self->lex_temp_out, self->post_temp_out,
- self->skip_out);
+ PostingPool *run
+ = PostPool_new(self->schema, self->snapshot, self->segment,
+ self->polyreader, self->field, self->lex_writer,
+ self->mem_pool, self->lex_temp_out,
+ self->post_temp_out, self->skip_out);
run->lexicon = lexicon;
run->plist = plist;
run->doc_base = doc_base;
@@ -254,8 +253,7 @@ PostPool_add_segment(PostingPool *self,
}
void
-PostPool_shrink(PostingPool *self)
-{
+PostPool_shrink(PostingPool *self) {
if (self->cache_max - self->cache_tick > 0) {
size_t cache_count = PostPool_Cache_Count(self);
size_t size = cache_count * sizeof(Obj*);
@@ -267,7 +265,7 @@ PostPool_shrink(PostingPool *self)
self->cache_tick = 0;
self->cache_max = cache_count;
self->cache_cap = cache_count;
- }
+ }
else {
FREEMEM(self->cache);
self->cache = NULL;
@@ -283,19 +281,20 @@ PostPool_shrink(PostingPool *self)
// any cache costs until Refill() gets called.
}
-void
-PostPool_flush(PostingPool *self)
-{
+void
+PostPool_flush(PostingPool *self) {
// Don't add a run unless we have data to put in it.
if (PostPool_Cache_Count(self) == 0) { return; }
- PostingPool *run = PostPool_new(self->schema, self->snapshot,
- self->segment, self->polyreader, self->field, self->lex_writer,
- self->mem_pool, self->lex_temp_out, self->post_temp_out,
- self->skip_out);
- PostingWriter *post_writer = (PostingWriter*)RawPostWriter_new(
- self->schema, self->snapshot, self->segment, self->polyreader,
- self->post_temp_out);
+ PostingPool *run
+ = PostPool_new(self->schema, self->snapshot, self->segment,
+ self->polyreader, self->field, self->lex_writer,
+ self->mem_pool, self->lex_temp_out,
+ self->post_temp_out, self->skip_out);
+ PostingWriter *post_writer
+ = (PostingWriter*)RawPostWriter_new(self->schema, self->snapshot,
+ self->segment, self->polyreader,
+ self->post_temp_out);
// Borrow the cache.
run->cache = self->cache;
@@ -304,13 +303,13 @@ PostPool_flush(PostingPool *self)
run->cache_cap = self->cache_cap;
// Write to temp files.
- LexWriter_Enter_Temp_Mode(self->lex_writer, self->field,
- self->lex_temp_out);
+ LexWriter_Enter_Temp_Mode(self->lex_writer, self->field,
+ self->lex_temp_out);
run->lex_start = OutStream_Tell(self->lex_temp_out);
run->post_start = OutStream_Tell(self->post_temp_out);
PostPool_Sort_Cache(self);
S_write_terms_and_postings(run, post_writer, NULL);
-
+
run->lex_end = OutStream_Tell(self->lex_temp_out);
run->post_end = OutStream_Tell(self->post_temp_out);
LexWriter_Leave_Temp_Mode(self->lex_writer);
@@ -329,15 +328,15 @@ PostPool_flush(PostingPool *self)
}
void
-PostPool_finish(PostingPool *self)
-{
+PostPool_finish(PostingPool *self) {
// Bail if there's no data.
if (!PostPool_Peek(self)) { return; }
Similarity *sim = Schema_Fetch_Sim(self->schema, self->field);
- PostingWriter *post_writer = Sim_Make_Posting_Writer(sim,
- self->schema, self->snapshot, self->segment, self->polyreader,
- self->field_num);
+ PostingWriter *post_writer
+ = Sim_Make_Posting_Writer(sim, self->schema, self->snapshot,
+ self->segment, self->polyreader,
+ self->field_num);
LexWriter_Start_Field(self->lex_writer, self->field_num);
S_write_terms_and_postings(self, post_writer, self->skip_out);
LexWriter_Finish_Field(self->lex_writer, self->field_num);
@@ -346,8 +345,7 @@ PostPool_finish(PostingPool *self)
static void
S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
- OutStream *skip_stream)
-{
+ OutStream *skip_stream) {
TermInfo *const tinfo = TInfo_new(0);
TermInfo *const skip_tinfo = TInfo_new(0);
CharBuf *const last_term_text = CB_new(0);
@@ -361,7 +359,8 @@ S_write_terms_and_postings(PostingPool *
// Prime heldover variables.
RawPosting *posting = (RawPosting*)CERTIFY(
- (*(RawPosting**)PostPool_Fetch(self)), RAWPOSTING);
+ (*(RawPosting**)PostPool_Fetch(self)),
+ RAWPOSTING);
CB_Mimic_Str(last_term_text, posting->blob, posting->content_len);
char *last_text_buf = (char*)CB_Get_Ptr8(last_term_text);
uint32_t last_text_size = CB_Get_Size(last_term_text);
@@ -378,15 +377,15 @@ S_write_terms_and_postings(PostingPool *
}
else {
// Compare once.
- if ( posting->content_len != last_text_size
+ if (posting->content_len != last_text_size
|| memcmp(&posting->blob, last_text_buf, last_text_size) != 0
- ) {
+ ) {
same_text_as_last = false;
}
}
// If the term text changes, process the last term.
- if ( !same_text_as_last ) {
+ if (!same_text_as_last) {
// Hand off to LexiconWriter.
LexWriter_Add_Term(lex_writer, last_term_text, tinfo);
@@ -401,8 +400,8 @@ S_write_terms_and_postings(PostingPool *
last_skip_filepos = tinfo->post_filepos;
// Remember the term_text so we can write string diffs.
- CB_Mimic_Str(last_term_text, posting->blob,
- posting->content_len);
+ CB_Mimic_Str(last_term_text, posting->blob,
+ posting->content_len);
last_text_buf = (char*)CB_Get_Ptr8(last_term_text);
last_text_size = CB_Get_Size(last_term_text);
@@ -420,14 +419,14 @@ S_write_terms_and_postings(PostingPool *
tinfo->doc_freq++;
// Write skip data.
- if ( skip_stream != NULL
- && same_text_as_last
+ if (skip_stream != NULL
+ && same_text_as_last
&& tinfo->doc_freq % skip_interval == 0
&& tinfo->doc_freq != 0
- ) {
+ ) {
// If first skip group, save skip stream pos for term info.
if (tinfo->doc_freq == skip_interval) {
- tinfo->skip_filepos = OutStream_Tell(skip_stream);
+ tinfo->skip_filepos = OutStream_Tell(skip_stream);
}
// Write deltas.
last_skip_doc = skip_stepper->doc_id;
@@ -436,7 +435,7 @@ S_write_terms_and_postings(PostingPool *
PostWriter_Update_Skip_Info(post_writer, skip_tinfo);
skip_stepper->filepos = skip_tinfo->post_filepos;
SkipStepper_Write_Record(skip_stepper, skip_stream,
- last_skip_doc, last_skip_filepos);
+ last_skip_doc, last_skip_filepos);
}
// Remember last doc id because we need it for delta encoding.
@@ -446,9 +445,9 @@ S_write_terms_and_postings(PostingPool *
// DECREF(posting); // No!! DON'T destroy!!!
void *address = PostPool_Fetch(self);
- posting = address
- ? *(RawPosting**)address
- : NULL;
+ posting = address
+ ? *(RawPosting**)address
+ : NULL;
}
// Clean up.
@@ -458,8 +457,7 @@ S_write_terms_and_postings(PostingPool *
}
uint32_t
-PostPool_refill(PostingPool *self)
-{
+PostPool_refill(PostingPool *self) {
Lexicon *const lexicon = self->lexicon;
PostingList *const plist = self->plist;
I32Array *const doc_map = self->doc_map;
@@ -475,7 +473,7 @@ PostPool_refill(PostingPool *self)
// Make sure cache is empty.
if (self->cache_max - self->cache_tick > 0) {
THROW(ERR, "Refill called but cache contains %u32 items",
- self->cache_max - self->cache_tick);
+ self->cache_max - self->cache_tick);
}
self->cache_max = 0;
self->cache_tick = 0;
@@ -514,16 +512,16 @@ PostPool_refill(PostingPool *self)
}
// Read a posting from the input stream.
- raw_posting = PList_Read_Raw(plist, self->last_doc_id, term_text,
- mem_pool);
+ raw_posting = PList_Read_Raw(plist, self->last_doc_id, term_text,
+ mem_pool);
self->last_doc_id = raw_posting->doc_id;
self->post_count--;
// Skip deletions.
if (doc_map != NULL) {
- const int32_t remapped = I32Arr_Get(doc_map,
- raw_posting->doc_id - doc_base);
- if ( !remapped ) {
+ const int32_t remapped
+ = I32Arr_Get(doc_map, raw_posting->doc_id - doc_base);
+ if (!remapped) {
continue;
}
raw_posting->doc_id = remapped;
@@ -547,17 +545,15 @@ PostPool_refill(PostingPool *self)
}
void
-PostPool_add_inversion(PostingPool *self, Inversion *inversion, int32_t doc_id,
- float doc_boost, float length_norm)
-{
- Post_Add_Inversion_To_Pool(self->posting, self, inversion,
- self->type, doc_id, doc_boost, length_norm);
+PostPool_add_inversion(PostingPool *self, Inversion *inversion, int32_t doc_id,
+ float doc_boost, float length_norm) {
+ Post_Add_Inversion_To_Pool(self->posting, self, inversion, self->type,
+ doc_id, doc_boost, length_norm);
}
static void
-S_fresh_flip(PostingPool *self, InStream *lex_temp_in,
- InStream *post_temp_in)
-{
+S_fresh_flip(PostingPool *self, InStream *lex_temp_in,
+ InStream *post_temp_in) {
if (self->flipped) { THROW(ERR, "Can't Flip twice"); }
self->flipped = true;
@@ -569,22 +565,28 @@ S_fresh_flip(PostingPool *self, InStream
// Get a Lexicon.
CharBuf *lex_alias = CB_newf("%o-%i64-to-%i64",
- InStream_Get_Filename(lex_temp_in), self->lex_start, self->lex_end);
- InStream *lex_temp_in_dupe = InStream_Reopen(lex_temp_in,
- lex_alias, self->lex_start, self->lex_end - self->lex_start);
- self->lexicon = (Lexicon*)RawLex_new(self->schema, self->field,
- lex_temp_in_dupe, 0, self->lex_end - self->lex_start);
+ InStream_Get_Filename(lex_temp_in),
+ self->lex_start, self->lex_end);
+ InStream *lex_temp_in_dupe = InStream_Reopen(
+ lex_temp_in, lex_alias, self->lex_start,
+ self->lex_end - self->lex_start);
+ self->lexicon = (Lexicon*)RawLex_new(
+ self->schema, self->field, lex_temp_in_dupe, 0,
+ self->lex_end - self->lex_start);
DECREF(lex_alias);
DECREF(lex_temp_in_dupe);
// Get a PostingList.
- CharBuf *post_alias = CB_newf("%o-%i64-to-%i64",
- InStream_Get_Filename(post_temp_in), self->post_start,
- self->post_end);
- InStream *post_temp_in_dupe = InStream_Reopen(post_temp_in,
- post_alias, self->post_start, self->post_end - self->post_start);
- self->plist = (PostingList*)RawPList_new(self->schema, self->field,
- post_temp_in_dupe, 0, self->post_end - self->post_start);
+ CharBuf *post_alias
+ = CB_newf("%o-%i64-to-%i64", InStream_Get_Filename(post_temp_in),
+ self->post_start, self->post_end);
+ InStream *post_temp_in_dupe
+ = InStream_Reopen(post_temp_in, post_alias, self->post_start,
+ self->post_end - self->post_start);
+ self->plist
+ = (PostingList*)RawPList_new(self->schema, self->field,
+ post_temp_in_dupe, 0,
+ self->post_end - self->post_start);
DECREF(post_alias);
DECREF(post_temp_in_dupe);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/PostingPool.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/PostingPool.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/PostingPool.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/PostingPool.cfh Sun May 1 23:50:24 2011
@@ -50,23 +50,23 @@ class Lucy::Index::PostingPool cnick Pos
int64_t post_end;
inert incremented PostingPool*
- new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader, const CharBuf *field,
- LexiconWriter *lex_writer, MemoryPool *mem_pool,
- OutStream *lex_temp_out, OutStream *post_temp_out,
+ new(Schema *schema, Snapshot *snapshot, Segment *segment,
+ PolyReader *polyreader, const CharBuf *field,
+ LexiconWriter *lex_writer, MemoryPool *mem_pool,
+ OutStream *lex_temp_out, OutStream *post_temp_out,
OutStream *skip_out);
inert PostingPool*
- init(PostingPool *self, Schema *schema, Snapshot *snapshot,
- Segment *segment, PolyReader *polyreader, const CharBuf *field,
- LexiconWriter *lex_writer, MemoryPool *mem_pool,
- OutStream *lex_temp_out, OutStream *post_temp_out,
+ init(PostingPool *self, Schema *schema, Snapshot *snapshot,
+ Segment *segment, PolyReader *polyreader, const CharBuf *field,
+ LexiconWriter *lex_writer, MemoryPool *mem_pool,
+ OutStream *lex_temp_out, OutStream *post_temp_out,
OutStream *skip_out);
/** Add a field's inverted content.
*/
void
- Add_Inversion(PostingPool *self, Inversion *inversion, int32_t doc_id,
+ Add_Inversion(PostingPool *self, Inversion *inversion, int32_t doc_id,
float doc_boost, float length_norm);
/** Reduce RAM footprint as much as possible.
@@ -78,7 +78,7 @@ class Lucy::Index::PostingPool cnick Pos
Get_Mem_Pool(PostingPool *self);
void
- Add_Segment(PostingPool *self, SegReader *reader, I32Array *doc_map,
+ Add_Segment(PostingPool *self, SegReader *reader, I32Array *doc_map,
int32_t doc_base);
void
Modified: incubator/lucy/trunk/core/Lucy/Index/RawLexicon.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/RawLexicon.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/RawLexicon.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/RawLexicon.c Sun May 1 23:50:24 2011
@@ -26,20 +26,18 @@
#include "Lucy/Store/InStream.h"
RawLexicon*
-RawLex_new(Schema *schema, const CharBuf *field, InStream *instream,
- int64_t start, int64_t end)
-{
+RawLex_new(Schema *schema, const CharBuf *field, InStream *instream,
+ int64_t start, int64_t end) {
RawLexicon *self = (RawLexicon*)VTable_Make_Obj(RAWLEXICON);
return RawLex_init(self, schema, field, instream, start, end);
}
RawLexicon*
RawLex_init(RawLexicon *self, Schema *schema, const CharBuf *field,
- InStream *instream, int64_t start, int64_t end)
-{
+ InStream *instream, int64_t start, int64_t end) {
FieldType *type = Schema_Fetch_Type(schema, field);
Lex_init((Lexicon*)self, field);
-
+
// Assign
self->start = start;
self->end = end;
@@ -57,8 +55,7 @@ RawLex_init(RawLexicon *self, Schema *sc
}
void
-RawLex_destroy(RawLexicon *self)
-{
+RawLex_destroy(RawLexicon *self) {
DECREF(self->instream);
DECREF(self->term_stepper);
DECREF(self->tinfo_stepper);
@@ -66,8 +63,7 @@ RawLex_destroy(RawLexicon *self)
}
bool_t
-RawLex_next(RawLexicon *self)
-{
+RawLex_next(RawLexicon *self) {
if (InStream_Tell(self->instream) >= self->len) { return false; }
TermStepper_Read_Delta(self->term_stepper, self->instream);
TermStepper_Read_Delta(self->tinfo_stepper, self->instream);
@@ -75,14 +71,12 @@ RawLex_next(RawLexicon *self)
}
Obj*
-RawLex_get_term(RawLexicon *self)
-{
+RawLex_get_term(RawLexicon *self) {
return TermStepper_Get_Value(self->term_stepper);
}
int32_t
-RawLex_doc_freq(RawLexicon *self)
-{
+RawLex_doc_freq(RawLexicon *self) {
TermInfo *tinfo = (TermInfo*)TermStepper_Get_Value(self->tinfo_stepper);
return tinfo ? TInfo_Get_Doc_Freq(tinfo) : 0;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/RawLexicon.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/RawLexicon.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/RawLexicon.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/RawLexicon.cfh Sun May 1 23:50:24 2011
@@ -20,7 +20,7 @@ parcel Lucy;
*/
class Lucy::Index::RawLexicon cnick RawLex
inherits Lucy::Index::Lexicon {
-
+
InStream *instream;
TermStepper *term_stepper;
TermStepper *tinfo_stepper;
@@ -29,17 +29,17 @@ class Lucy::Index::RawLexicon cnick RawL
int64_t len;
inert incremented RawLexicon*
- new(Schema *schema, const CharBuf *field, InStream *instream,
+ new(Schema *schema, const CharBuf *field, InStream *instream,
int64_t start, int64_t end);
inert RawLexicon*
- init(RawLexicon *self, Schema *schema, const CharBuf *field,
+ init(RawLexicon *self, Schema *schema, const CharBuf *field,
InStream *instream, int64_t start, int64_t end);
public void
Destroy(RawLexicon *self);
- public bool_t
+ public bool_t
Next(RawLexicon *self);
public nullable Obj*
Modified: incubator/lucy/trunk/core/Lucy/Index/RawPostingList.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/RawPostingList.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/RawPostingList.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/RawPostingList.c Sun May 1 23:50:24 2011
@@ -26,17 +26,15 @@
#include "Lucy/Util/MemoryPool.h"
RawPostingList*
-RawPList_new(Schema *schema, const CharBuf *field, InStream *instream,
- int64_t start, int64_t end)
-{
+RawPList_new(Schema *schema, const CharBuf *field, InStream *instream,
+ int64_t start, int64_t end) {
RawPostingList *self = (RawPostingList*)VTable_Make_Obj(RAWPOSTINGLIST);
return RawPList_init(self, schema, field, instream, start, end);
}
RawPostingList*
RawPList_init(RawPostingList *self, Schema *schema, const CharBuf *field,
- InStream *instream, int64_t start, int64_t end)
-{
+ InStream *instream, int64_t start, int64_t end) {
PList_init((PostingList*)self);
self->start = start;
self->end = end;
@@ -49,25 +47,22 @@ RawPList_init(RawPostingList *self, Sche
}
void
-RawPList_destroy(RawPostingList *self)
-{
+RawPList_destroy(RawPostingList *self) {
DECREF(self->instream);
DECREF(self->posting);
SUPER_DESTROY(self, RAWPOSTINGLIST);
}
Posting*
-RawPList_get_posting(RawPostingList *self)
-{
+RawPList_get_posting(RawPostingList *self) {
return self->posting;
}
RawPosting*
RawPList_read_raw(RawPostingList *self, int32_t last_doc_id, CharBuf *term_text,
- MemoryPool *mem_pool)
-{
- return Post_Read_Raw(self->posting, self->instream,
- last_doc_id, term_text, mem_pool);
+ MemoryPool *mem_pool) {
+ return Post_Read_Raw(self->posting, self->instream,
+ last_doc_id, term_text, mem_pool);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/RawPostingList.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/RawPostingList.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/RawPostingList.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/RawPostingList.cfh Sun May 1 23:50:24 2011
@@ -18,7 +18,7 @@ parcel Lucy;
class Lucy::Index::RawPostingList cnick RawPList
inherits Lucy::Index::PostingList {
-
+
Posting *posting;
InStream *instream;
int64_t start;
@@ -26,11 +26,11 @@ class Lucy::Index::RawPostingList cnick
int64_t len;
inert incremented RawPostingList*
- new(Schema *schema, const CharBuf *field, InStream *instream,
+ new(Schema *schema, const CharBuf *field, InStream *instream,
int64_t start, int64_t end);
inert RawPostingList*
- init(RawPostingList *self, Schema *schema, const CharBuf *field,
+ init(RawPostingList *self, Schema *schema, const CharBuf *field,
InStream *instream, int64_t lex_start, int64_t lex_end);
public void
Modified: incubator/lucy/trunk/core/Lucy/Index/SegLexicon.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegLexicon.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegLexicon.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegLexicon.c Sun May 1 23:50:24 2011
@@ -37,19 +37,18 @@ static void
S_scan_to(SegLexicon *self, Obj *target);
SegLexicon*
-SegLex_new(Schema *schema, Folder *folder, Segment *segment,
- const CharBuf *field)
-{
+SegLex_new(Schema *schema, Folder *folder, Segment *segment,
+ const CharBuf *field) {
SegLexicon *self = (SegLexicon*)VTable_Make_Obj(SEGLEXICON);
return SegLex_init(self, schema, folder, segment, field);
}
SegLexicon*
-SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
- Segment *segment, const CharBuf *field)
-{
+SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
+ Segment *segment, const CharBuf *field) {
Hash *metadata = (Hash*)CERTIFY(
- Seg_Fetch_Metadata_Str(segment, "lexicon", 7), HASH);
+ Seg_Fetch_Metadata_Str(segment, "lexicon", 7),
+ HASH);
Architecture *arch = Schema_Get_Architecture(schema);
Hash *counts = (Hash*)Hash_Fetch_Str(metadata, "counts", 6);
Obj *format = Hash_Fetch_Str(metadata, "format", 6);
@@ -59,13 +58,13 @@ SegLex_init(SegLexicon *self, Schema *sc
CharBuf *filename = CB_newf("%o/lexicon-%i32.dat", seg_name, field_num);
Lex_init((Lexicon*)self, field);
-
+
// Check format.
if (!format) { THROW(ERR, "Missing 'format'"); }
else {
if (Obj_To_I64(format) > LexWriter_current_file_format) {
THROW(ERR, "Unsupported lexicon format: %i64",
- Obj_To_I64(format));
+ Obj_To_I64(format));
}
}
@@ -104,8 +103,7 @@ SegLex_init(SegLexicon *self, Schema *sc
}
void
-SegLex_destroy(SegLexicon *self)
-{
+SegLex_destroy(SegLexicon *self) {
DECREF(self->segment);
DECREF(self->term_stepper);
DECREF(self->tinfo_stepper);
@@ -115,8 +113,7 @@ SegLex_destroy(SegLexicon *self)
}
void
-SegLex_seek(SegLexicon *self, Obj *target)
-{
+SegLex_seek(SegLexicon *self, Obj *target) {
LexIndex *const lex_index = self->lex_index;
// Reset upon null term.
@@ -144,8 +141,7 @@ SegLex_seek(SegLexicon *self, Obj *targe
}
void
-SegLex_reset(SegLexicon* self)
-{
+SegLex_reset(SegLexicon* self) {
self->term_num = -1;
InStream_Seek(self->instream, 0);
TermStepper_Reset(self->term_stepper);
@@ -153,36 +149,33 @@ SegLex_reset(SegLexicon* self)
}
int32_t
-SegLex_get_field_num(SegLexicon *self)
-{
+SegLex_get_field_num(SegLexicon *self) {
return self->field_num;
}
Obj*
-SegLex_get_term(SegLexicon *self)
-{
+SegLex_get_term(SegLexicon *self) {
return TermStepper_Get_Value(self->term_stepper);
}
int32_t
-SegLex_doc_freq(SegLexicon *self)
-{
+SegLex_doc_freq(SegLexicon *self) {
TermInfo *tinfo = (TermInfo*)TermStepper_Get_Value(self->tinfo_stepper);
return tinfo ? TInfo_Get_Doc_Freq(tinfo) : 0;
}
TermInfo*
-SegLex_get_term_info(SegLexicon *self)
-{
+SegLex_get_term_info(SegLexicon *self) {
return (TermInfo*)TermStepper_Get_Value(self->tinfo_stepper);
}
Segment*
-SegLex_get_segment(SegLexicon *self) { return self->segment; }
+SegLex_get_segment(SegLexicon *self) {
+ return self->segment;
+}
-bool_t
-SegLex_next(SegLexicon *self)
-{
+bool_t
+SegLex_next(SegLexicon *self) {
// If we've run out of terms, null out and return.
if (++self->term_num >= self->size) {
self->term_num = self->size; // don't keep growing
@@ -199,13 +192,12 @@ SegLex_next(SegLexicon *self)
}
static void
-S_scan_to(SegLexicon *self, Obj *target)
-{
+S_scan_to(SegLexicon *self, Obj *target) {
// (mildly evil encapsulation violation, since value can be null)
Obj *current = TermStepper_Get_Value(self->term_stepper);
- if ( !Obj_Is_A(target, Obj_Get_VTable(current)) ) {
+ if (!Obj_Is_A(target, Obj_Get_VTable(current))) {
THROW(ERR, "Target is a %o, and not comparable to a %o",
- Obj_Get_Class_Name(target), Obj_Get_Class_Name(current));
+ Obj_Get_Class_Name(target), Obj_Get_Class_Name(current));
}
// Keep looping until the term text is ge target.
Modified: incubator/lucy/trunk/core/Lucy/Index/SegLexicon.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegLexicon.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegLexicon.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegLexicon.cfh Sun May 1 23:50:24 2011
@@ -40,7 +40,7 @@ class Lucy::Index::SegLexicon cnick SegL
* @param field The field whose terms the Lexicon will iterate over.
*/
inert incremented SegLexicon*
- new(Schema *schema, Folder *folder, Segment *segment,
+ new(Schema *schema, Folder *folder, Segment *segment,
const CharBuf *field);
inert SegLexicon*
@@ -53,7 +53,7 @@ class Lucy::Index::SegLexicon cnick SegL
int32_t
Get_Field_Num(SegLexicon *self);
- Segment*
+ Segment*
Get_Segment(SegLexicon *self);
public void
Modified: incubator/lucy/trunk/core/Lucy/Index/SegPostingList.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegPostingList.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegPostingList.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegPostingList.c Sun May 1 23:50:24 2011
@@ -43,23 +43,21 @@ static void
S_seek_tinfo(SegPostingList *self, TermInfo *tinfo);
SegPostingList*
-SegPList_new(PostingListReader *plist_reader, const CharBuf *field)
-{
+SegPList_new(PostingListReader *plist_reader, const CharBuf *field) {
SegPostingList *self = (SegPostingList*)VTable_Make_Obj(SEGPOSTINGLIST);
return SegPList_init(self, plist_reader, field);
}
SegPostingList*
-SegPList_init(SegPostingList *self, PostingListReader *plist_reader,
- const CharBuf *field)
-{
+SegPList_init(SegPostingList *self, PostingListReader *plist_reader,
+ const CharBuf *field) {
Schema *const schema = PListReader_Get_Schema(plist_reader);
Folder *const folder = PListReader_Get_Folder(plist_reader);
Segment *const segment = PListReader_Get_Segment(plist_reader);
Architecture *const arch = Schema_Get_Architecture(schema);
CharBuf *const seg_name = Seg_Get_Name(segment);
int32_t field_num = Seg_Field_Num(segment, field);
- CharBuf *post_file = CB_newf("%o/postings-%i32.dat",
+ CharBuf *post_file = CB_newf("%o/postings-%i32.dat",
seg_name, field_num);
CharBuf *skip_file = CB_newf("%o/postings.skip", seg_name);
@@ -76,7 +74,7 @@ SegPList_init(SegPostingList *self, Post
self->plist_reader = (PostingListReader*)INCREF(plist_reader);
self->field = CB_Clone(field);
self->skip_interval = Arch_Skip_Interval(arch);
-
+
// Derive.
Similarity *sim = Schema_Fetch_Sim(schema, field);
self->posting = Sim_Make_Posting(sim);
@@ -93,7 +91,7 @@ SegPList_init(SegPostingList *self, Post
RETHROW(error);
}
self->skip_stream = Folder_Open_In(folder, skip_file);
- if (!self->skip_stream) {
+ if (!self->skip_stream) {
Err *error = (Err*)INCREF(Err_get_error());
DECREF(post_file);
DECREF(skip_file);
@@ -112,14 +110,13 @@ SegPList_init(SegPostingList *self, Post
return self;
}
-void
-SegPList_destroy(SegPostingList *self)
-{
+void
+SegPList_destroy(SegPostingList *self) {
DECREF(self->plist_reader);
DECREF(self->posting);
DECREF(self->skip_stepper);
DECREF(self->field);
-
+
if (self->post_stream != NULL) {
InStream_Close(self->post_stream);
InStream_Close(self->skip_stream);
@@ -131,31 +128,32 @@ SegPList_destroy(SegPostingList *self)
}
Posting*
-SegPList_get_posting(SegPostingList *self)
-{
+SegPList_get_posting(SegPostingList *self) {
return self->posting;
}
uint32_t
-SegPList_get_doc_freq(SegPostingList *self)
-{
+SegPList_get_doc_freq(SegPostingList *self) {
return self->doc_freq;
}
int32_t
-SegPList_get_doc_id(SegPostingList *self)
-{
+SegPList_get_doc_id(SegPostingList *self) {
return self->posting->doc_id;
}
uint32_t
-SegPList_get_count(SegPostingList *self) { return self->count; }
+SegPList_get_count(SegPostingList *self) {
+ return self->count;
+}
+
InStream*
-SegPList_get_post_stream(SegPostingList *self) { return self->post_stream; }
+SegPList_get_post_stream(SegPostingList *self) {
+ return self->post_stream;
+}
int32_t
-SegPList_next(SegPostingList *self)
-{
+SegPList_next(SegPostingList *self) {
InStream *const post_stream = self->post_stream;
Posting *const posting = self->posting;
@@ -172,8 +170,7 @@ SegPList_next(SegPostingList *self)
}
int32_t
-SegPList_advance(SegPostingList *self, int32_t target)
-{
+SegPList_advance(SegPostingList *self, int32_t target) {
Posting *posting = self->posting;
const uint32_t skip_interval = self->skip_interval;
@@ -192,18 +189,18 @@ SegPList_advance(SegPostingList *self, i
* ergo, the modulus in the following formula.
*/
int32_t num_skipped = 0 - (self->count % skip_interval);
- if (num_skipped == 0 && self->count != 0) {
- num_skipped = 0 - skip_interval;
+ if (num_skipped == 0 && self->count != 0) {
+ num_skipped = 0 - skip_interval;
}
// See if there's anything to skip.
while (target > skip_stepper->doc_id) {
- new_doc_id = skip_stepper->doc_id;
- new_filepos = skip_stepper->filepos;
+ new_doc_id = skip_stepper->doc_id;
+ new_filepos = skip_stepper->filepos;
- if ( skip_stepper->doc_id != 0
+ if (skip_stepper->doc_id != 0
&& skip_stepper->doc_id >= posting->doc_id
- ) {
+ ) {
num_skipped += skip_interval;
}
@@ -233,32 +230,30 @@ SegPList_advance(SegPostingList *self, i
while (1) {
int32_t doc_id = SegPList_Next(self);
if (doc_id == 0 || doc_id >= target) {
- return doc_id;
+ return doc_id;
}
}
}
void
-SegPList_seek(SegPostingList *self, Obj *target)
-{
+SegPList_seek(SegPostingList *self, Obj *target) {
LexiconReader *lex_reader = PListReader_Get_Lex_Reader(self->plist_reader);
- TermInfo *tinfo = LexReader_Fetch_Term_Info(lex_reader,
- self->field, target);
+ TermInfo *tinfo = LexReader_Fetch_Term_Info(lex_reader,
+ self->field, target);
S_seek_tinfo(self, tinfo);
DECREF(tinfo);
}
void
-SegPList_seek_lex(SegPostingList *self, Lexicon *lexicon)
-{
+SegPList_seek_lex(SegPostingList *self, Lexicon *lexicon) {
// Maybe true, maybe not.
SegLexicon *const seg_lexicon = (SegLexicon*)lexicon;
// Optimized case.
- if ( Obj_Is_A((Obj*)lexicon, SEGLEXICON)
- && (SegLex_Get_Segment(seg_lexicon) ==
- PListReader_Get_Segment(self->plist_reader)) // i.e. same segment
- ) {
+ if (Obj_Is_A((Obj*)lexicon, SEGLEXICON)
+ && (SegLex_Get_Segment(seg_lexicon)
+ == PListReader_Get_Segment(self->plist_reader)) // i.e. same segment
+ ) {
S_seek_tinfo(self, SegLex_Get_Term_Info(seg_lexicon));
}
// Punt case. This is more expensive because of the call to
@@ -270,8 +265,7 @@ SegPList_seek_lex(SegPostingList *self,
}
static void
-S_seek_tinfo(SegPostingList *self, TermInfo *tinfo)
-{
+S_seek_tinfo(SegPostingList *self, TermInfo *tinfo) {
self->count = 0;
if (tinfo == NULL) {
@@ -288,27 +282,25 @@ S_seek_tinfo(SegPostingList *self, TermI
Post_Reset(self->posting);
// Prepare to skip.
- self->skip_count = 0;
- self->num_skips = self->doc_freq / self->skip_interval;
+ self->skip_count = 0;
+ self->num_skips = self->doc_freq / self->skip_interval;
SkipStepper_Set_ID_And_Filepos(self->skip_stepper, 0, post_filepos);
InStream_Seek(self->skip_stream, TInfo_Get_Skip_FilePos(tinfo));
}
}
Matcher*
-SegPList_make_matcher(SegPostingList *self, Similarity *sim,
- Compiler *compiler, bool_t need_score)
-{
+SegPList_make_matcher(SegPostingList *self, Similarity *sim,
+ Compiler *compiler, bool_t need_score) {
return Post_Make_Matcher(self->posting, sim, (PostingList*)self, compiler,
- need_score);
+ need_score);
}
RawPosting*
SegPList_read_raw(SegPostingList *self, int32_t last_doc_id, CharBuf *term_text,
- MemoryPool *mem_pool)
-{
- return Post_Read_Raw(self->posting, self->post_stream,
- last_doc_id, term_text, mem_pool);
+ MemoryPool *mem_pool) {
+ return Post_Read_Raw(self->posting, self->post_stream,
+ last_doc_id, term_text, mem_pool);
}
Modified: incubator/lucy/trunk/core/Lucy/Index/SegPostingList.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegPostingList.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegPostingList.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegPostingList.cfh Sun May 1 23:50:24 2011
@@ -39,7 +39,7 @@ class Lucy::Index::SegPostingList cnick
new(PostingListReader *plist_reader, const CharBuf *field);
inert SegPostingList*
- init(SegPostingList *self, PostingListReader *plist_reader,
+ init(SegPostingList *self, PostingListReader *plist_reader,
const CharBuf *field);
InStream*
Modified: incubator/lucy/trunk/core/Lucy/Index/SegReader.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegReader.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegReader.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegReader.c Sun May 1 23:50:24 2011
@@ -30,22 +30,20 @@
#include "Lucy/Store/Folder.h"
SegReader*
-SegReader_new(Schema *schema, Folder *folder, Snapshot *snapshot,
- VArray *segments, int32_t seg_tick)
-{
+SegReader_new(Schema *schema, Folder *folder, Snapshot *snapshot,
+ VArray *segments, int32_t seg_tick) {
SegReader *self = (SegReader*)VTable_Make_Obj(SEGREADER);
return SegReader_init(self, schema, folder, snapshot, segments, seg_tick);
}
SegReader*
SegReader_init(SegReader *self, Schema *schema, Folder *folder,
- Snapshot *snapshot, VArray *segments, int32_t seg_tick)
-{
+ Snapshot *snapshot, VArray *segments, int32_t seg_tick) {
CharBuf *mess;
Segment *segment;
IxReader_init((IndexReader*)self, schema, folder, snapshot, segments,
- seg_tick, NULL);
+ seg_tick, NULL);
segment = SegReader_Get_Segment(self);
self->doc_max = (int32_t)Seg_Get_Count(segment);
@@ -58,23 +56,23 @@ SegReader_init(SegReader *self, Schema *
Err_throw_mess(ERR, mess);
}
{
- 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;
}
return self;
}
void
-SegReader_destroy(SegReader *self)
-{
+SegReader_destroy(SegReader *self) {
DECREF(self->seg_name);
SUPER_DESTROY(self, SEGREADER);
}
void
-SegReader_register(SegReader *self, const CharBuf *api, DataReader *component)
-{
+SegReader_register(SegReader *self, const CharBuf *api,
+ DataReader *component) {
if (Hash_Fetch(self->components, (Obj*)api)) {
THROW(ERR, "Interface '%o' already registered");
}
@@ -83,39 +81,39 @@ SegReader_register(SegReader *self, cons
}
CharBuf*
-SegReader_get_seg_name(SegReader *self) { return self->seg_name; }
+SegReader_get_seg_name(SegReader *self) {
+ return self->seg_name;
+}
+
int64_t
-SegReader_get_seg_num(SegReader *self) { return self->seg_num; }
+SegReader_get_seg_num(SegReader *self) {
+ return self->seg_num;
+}
int32_t
-SegReader_del_count(SegReader *self)
-{
+SegReader_del_count(SegReader *self) {
return self->del_count;
}
int32_t
-SegReader_doc_max(SegReader *self)
-{
+SegReader_doc_max(SegReader *self) {
return self->doc_max;
}
int32_t
-SegReader_doc_count(SegReader *self)
-{
+SegReader_doc_count(SegReader *self) {
return self->doc_max - self->del_count;
}
I32Array*
-SegReader_offsets(SegReader *self)
-{
+SegReader_offsets(SegReader *self) {
int32_t *ints = (int32_t*)CALLOCATE(1, sizeof(int32_t));
UNUSED_VAR(self);
return I32Arr_new_steal(ints, 1);
}
VArray*
-SegReader_seg_readers(SegReader *self)
-{
+SegReader_seg_readers(SegReader *self) {
VArray *seg_readers = VA_new(1);
VA_Push(seg_readers, INCREF(self));
return seg_readers;
Modified: incubator/lucy/trunk/core/Lucy/Index/SegReader.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegReader.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegReader.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegReader.cfh Sun May 1 23:50:24 2011
@@ -49,7 +49,7 @@ class Lucy::Index::SegReader inherits Lu
* <code>segments</code> that this particular SegReader is assigned to.
*/
inert SegReader*
- init(SegReader *self, Schema *schema, Folder *folder,
+ init(SegReader *self, Schema *schema, Folder *folder,
Snapshot *snapshot = NULL, VArray *segments, int32_t seg_tick);
public void
@@ -71,7 +71,7 @@ class Lucy::Index::SegReader inherits Lu
* @param component A DataReader.
*/
public void
- Register(SegReader *self, const CharBuf *api,
+ Register(SegReader *self, const CharBuf *api,
decremented DataReader *component);
/** Return the name of the segment.
@@ -92,7 +92,7 @@ class Lucy::Index::SegReader inherits Lu
public int32_t
Doc_Count(SegReader *self);
-
+
public incremented I32Array*
Offsets(SegReader *self);
Modified: incubator/lucy/trunk/core/Lucy/Index/SegWriter.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegWriter.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegWriter.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegWriter.c Sun May 1 23:50:24 2011
@@ -32,16 +32,14 @@
SegWriter*
SegWriter_new(Schema *schema, Snapshot *snapshot, Segment *segment,
- PolyReader *polyreader)
-{
+ PolyReader *polyreader) {
SegWriter *self = (SegWriter*)VTable_Make_Obj(SEGWRITER);
return SegWriter_init(self, schema, snapshot, segment, polyreader);
}
SegWriter*
SegWriter_init(SegWriter *self, Schema *schema, Snapshot *snapshot,
- Segment *segment, PolyReader *polyreader)
-{
+ Segment *segment, PolyReader *polyreader) {
Architecture *arch = Schema_Get_Architecture(schema);
DataWriter_init((DataWriter*)self, schema, snapshot, segment, polyreader);
self->by_api = Hash_new(0);
@@ -52,8 +50,7 @@ SegWriter_init(SegWriter *self, Schema *
}
void
-SegWriter_destroy(SegWriter *self)
-{
+SegWriter_destroy(SegWriter *self) {
DECREF(self->inverter);
DECREF(self->writers);
DECREF(self->by_api);
@@ -62,8 +59,8 @@ SegWriter_destroy(SegWriter *self)
}
void
-SegWriter_register(SegWriter *self, const CharBuf *api, DataWriter *component)
-{
+SegWriter_register(SegWriter *self, const CharBuf *api,
+ DataWriter *component) {
CERTIFY(component, DATAWRITER);
if (Hash_Fetch(self->by_api, (Obj*)api)) {
THROW(ERR, "API %o already registered", api);
@@ -72,27 +69,24 @@ SegWriter_register(SegWriter *self, cons
}
Obj*
-SegWriter_fetch(SegWriter *self, const CharBuf *api)
-{
+SegWriter_fetch(SegWriter *self, const CharBuf *api) {
return Hash_Fetch(self->by_api, (Obj*)api);
}
void
-SegWriter_add_writer(SegWriter *self, DataWriter *writer)
-{
+SegWriter_add_writer(SegWriter *self, DataWriter *writer) {
VA_Push(self->writers, (Obj*)writer);
}
void
-SegWriter_prep_seg_dir(SegWriter *self)
-{
+SegWriter_prep_seg_dir(SegWriter *self) {
Folder *folder = SegWriter_Get_Folder(self);
CharBuf *seg_name = Seg_Get_Name(self->segment);
// Clear stale segment files from crashed indexing sessions.
if (Folder_Exists(folder, seg_name)) {
bool_t result = Folder_Delete_Tree(folder, seg_name);
- if (!result) {
+ if (!result) {
THROW(ERR, "Couldn't completely remove '%o'", seg_name);
}
}
@@ -105,8 +99,7 @@ SegWriter_prep_seg_dir(SegWriter *self)
}
void
-SegWriter_add_doc(SegWriter *self, Doc *doc, float boost)
-{
+SegWriter_add_doc(SegWriter *self, Doc *doc, float boost) {
int32_t doc_id = (int32_t)Seg_Increment_Count(self->segment, 1);
Inverter_Invert_Doc(self->inverter, doc);
Inverter_Set_Boost(self->inverter, boost);
@@ -114,8 +107,8 @@ SegWriter_add_doc(SegWriter *self, Doc *
}
void
-SegWriter_add_inverted_doc(SegWriter *self, Inverter *inverter, int32_t doc_id)
-{
+SegWriter_add_inverted_doc(SegWriter *self, Inverter *inverter,
+ int32_t doc_id) {
uint32_t i, max;
for (i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
@@ -127,8 +120,7 @@ SegWriter_add_inverted_doc(SegWriter *se
// SegReader's number because the DeletionsWriter and the SegReader are
// probably out of sync.
static void
-S_adjust_doc_id(SegWriter *self, SegReader *reader, I32Array *doc_map)
-{
+S_adjust_doc_id(SegWriter *self, SegReader *reader, I32Array *doc_map) {
uint32_t doc_count = SegReader_Doc_Max(reader);
uint32_t i, max;
for (i = 1, max = I32Arr_Get_Size(doc_map); i < max; i++) {
@@ -138,8 +130,7 @@ S_adjust_doc_id(SegWriter *self, SegRead
}
void
-SegWriter_add_segment(SegWriter *self, SegReader *reader, I32Array *doc_map)
-{
+SegWriter_add_segment(SegWriter *self, SegReader *reader, I32Array *doc_map) {
uint32_t i, max;
// Bulk add the slab of documents to the various writers.
@@ -157,8 +148,8 @@ SegWriter_add_segment(SegWriter *self, S
}
void
-SegWriter_merge_segment(SegWriter *self, SegReader *reader, I32Array *doc_map)
-{
+SegWriter_merge_segment(SegWriter *self, SegReader *reader,
+ I32Array *doc_map) {
Snapshot *snapshot = SegWriter_Get_Snapshot(self);
CharBuf *seg_name = Seg_Get_Name(SegReader_Get_Segment(reader));
uint32_t i, max;
@@ -178,8 +169,7 @@ SegWriter_merge_segment(SegWriter *self,
}
void
-SegWriter_delete_segment(SegWriter *self, SegReader *reader)
-{
+SegWriter_delete_segment(SegWriter *self, SegReader *reader) {
Snapshot *snapshot = SegWriter_Get_Snapshot(self);
CharBuf *seg_name = Seg_Get_Name(SegReader_Get_Segment(reader));
uint32_t i, max;
@@ -196,8 +186,7 @@ SegWriter_delete_segment(SegWriter *self
}
void
-SegWriter_finish(SegWriter *self)
-{
+SegWriter_finish(SegWriter *self) {
CharBuf *seg_name = Seg_Get_Name(self->segment);
uint32_t i, max;
@@ -221,19 +210,19 @@ SegWriter_finish(SegWriter *self)
}
void
-SegWriter_add_data_writer(SegWriter *self, DataWriter *writer)
-{
+SegWriter_add_data_writer(SegWriter *self, DataWriter *writer) {
VA_Push(self->writers, (Obj*)writer);
}
void
-SegWriter_set_del_writer(SegWriter *self, DeletionsWriter *del_writer)
-{
+SegWriter_set_del_writer(SegWriter *self, DeletionsWriter *del_writer) {
DECREF(self->del_writer);
self->del_writer = (DeletionsWriter*)INCREF(del_writer);
}
DeletionsWriter*
-SegWriter_get_del_writer(SegWriter *self) { return self->del_writer; }
+SegWriter_get_del_writer(SegWriter *self) {
+ return self->del_writer;
+}
Modified: incubator/lucy/trunk/core/Lucy/Index/SegWriter.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SegWriter.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SegWriter.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SegWriter.cfh Sun May 1 23:50:24 2011
@@ -65,7 +65,7 @@ class Lucy::Index::SegWriter inherits Lu
* @param component A DataWriter.
*/
public void
- Register(SegWriter *self, const CharBuf *api,
+ Register(SegWriter *self, const CharBuf *api,
decremented DataWriter *component);
/** Retrieve a registered component.
@@ -107,11 +107,11 @@ class Lucy::Index::SegWriter inherits Lu
Add_Inverted_Doc(SegWriter *self, Inverter *inverter, int32_t doc_id);
public void
- Add_Segment(SegWriter *self, SegReader *reader,
+ Add_Segment(SegWriter *self, SegReader *reader,
I32Array *doc_map = NULL);
public void
- Merge_Segment(SegWriter *self, SegReader *reader,
+ Merge_Segment(SegWriter *self, SegReader *reader,
I32Array *doc_map = NULL);
public void
Modified: incubator/lucy/trunk/core/Lucy/Index/Segment.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Segment.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Segment.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Segment.c Sun May 1 23:50:24 2011
@@ -26,15 +26,13 @@
#include "Lucy/Util/IndexFileNames.h"
Segment*
-Seg_new(int64_t number)
-{
+Seg_new(int64_t number) {
Segment *self = (Segment*)VTable_Make_Obj(SEGMENT);
return Seg_init(self, number);
}
Segment*
-Seg_init(Segment *self, int64_t number)
-{
+Seg_init(Segment *self, int64_t number) {
// Validate.
if (number < 0) { THROW(ERR, "Segment number %i64 less than 0", number); }
@@ -57,16 +55,14 @@ Seg_init(Segment *self, int64_t number)
}
CharBuf*
-Seg_num_to_name(int64_t number)
-{
+Seg_num_to_name(int64_t number) {
char base36[StrHelp_MAX_BASE36_BYTES];
StrHelp_to_base36(number, &base36);
return CB_newf("seg_%s", &base36);
}
bool_t
-Seg_valid_seg_name(const CharBuf *name)
-{
+Seg_valid_seg_name(const CharBuf *name) {
if (CB_Starts_With_Str(name, "seg_", 4)) {
ZombieCharBuf *scratch = ZCB_WRAP(name);
ZCB_Nip(scratch, 4);
@@ -80,8 +76,7 @@ Seg_valid_seg_name(const CharBuf *name)
}
void
-Seg_destroy(Segment *self)
-{
+Seg_destroy(Segment *self) {
DECREF(self->name);
DECREF(self->metadata);
DECREF(self->by_name);
@@ -90,8 +85,7 @@ Seg_destroy(Segment *self)
}
bool_t
-Seg_read_file(Segment *self, Folder *folder)
-{
+Seg_read_file(Segment *self, Folder *folder) {
CharBuf *filename = CB_newf("%o/segmeta.json", self->name);
Hash *metadata = (Hash*)Json_slurp_json(folder, filename);
Hash *my_metadata;
@@ -104,8 +98,8 @@ Seg_read_file(Segment *self, Folder *fol
// Grab metadata for the Segment object itself.
DECREF(self->metadata);
self->metadata = metadata;
- my_metadata = (Hash*)CERTIFY(
- Hash_Fetch_Str(self->metadata, "segmeta", 7), HASH);
+ my_metadata
+ = (Hash*)CERTIFY(Hash_Fetch_Str(self->metadata, "segmeta", 7), HASH);
// Assign.
{
@@ -118,8 +112,8 @@ Seg_read_file(Segment *self, Folder *fol
// Get list of field nums.
{
uint32_t i;
- VArray *source_by_num = (VArray*)Hash_Fetch_Str(my_metadata,
- "field_names", 11);
+ VArray *source_by_num = (VArray*)Hash_Fetch_Str(my_metadata,
+ "field_names", 11);
uint32_t num_fields = source_by_num ? VA_Get_Size(source_by_num) : 0;
if (source_by_num == NULL) {
THROW(ERR, "Failed to extract 'field_names' from metadata");
@@ -142,13 +136,12 @@ Seg_read_file(Segment *self, Folder *fol
}
void
-Seg_write_file(Segment *self, Folder *folder)
-{
+Seg_write_file(Segment *self, Folder *folder) {
Hash *my_metadata = Hash_new(16);
// Store metadata specific to this Segment object.
- Hash_Store_Str(my_metadata, "count", 5,
- (Obj*)CB_newf("%i64", self->count) );
+ Hash_Store_Str(my_metadata, "count", 5,
+ (Obj*)CB_newf("%i64", self->count));
Hash_Store_Str(my_metadata, "name", 4, (Obj*)CB_Clone(self->name));
Hash_Store_Str(my_metadata, "field_names", 11, INCREF(self->by_num));
Hash_Store_Str(my_metadata, "format", 6, (Obj*)CB_newf("%i32", 1));
@@ -156,16 +149,15 @@ Seg_write_file(Segment *self, Folder *fo
{
CharBuf *filename = CB_newf("%o/segmeta.json", self->name);
- bool_t result
+ bool_t result
= Json_spew_json((Obj*)self->metadata, folder, filename);
DECREF(filename);
if (!result) { RETHROW(INCREF(Err_get_error())); }
}
}
-int32_t
-Seg_add_field(Segment *self, const CharBuf *field)
-{
+int32_t
+Seg_add_field(Segment *self, const CharBuf *field) {
Integer32 *num = (Integer32*)Hash_Fetch(self->by_name, (Obj*)field);
if (num) {
return Int32_Get_Value(num);
@@ -179,24 +171,33 @@ Seg_add_field(Segment *self, const CharB
}
CharBuf*
-Seg_get_name(Segment *self) { return self->name; }
+Seg_get_name(Segment *self) {
+ return self->name;
+}
+
int64_t
-Seg_get_number(Segment *self) { return self->number; }
+Seg_get_number(Segment *self) {
+ return self->number;
+}
+
void
-Seg_set_count(Segment *self, int64_t count) { self->count = count; }
+Seg_set_count(Segment *self, int64_t count) {
+ self->count = count;
+}
+
int64_t
-Seg_get_count(Segment *self) { return self->count; }
+Seg_get_count(Segment *self) {
+ return self->count;
+}
int64_t
-Seg_increment_count(Segment *self, int64_t increment)
-{
- self->count += increment;
- return self->count;
+Seg_increment_count(Segment *self, int64_t increment) {
+ self->count += increment;
+ return self->count;
}
void
-Seg_store_metadata(Segment *self, const CharBuf *key, Obj *value)
-{
+Seg_store_metadata(Segment *self, const CharBuf *key, Obj *value) {
if (Hash_Fetch(self->metadata, (Obj*)key)) {
THROW(ERR, "Metadata key '%o' already registered", key);
}
@@ -204,48 +205,44 @@ Seg_store_metadata(Segment *self, const
}
void
-Seg_store_metadata_str(Segment *self, const char *key, size_t key_len,
- Obj *value)
-{
+Seg_store_metadata_str(Segment *self, const char *key, size_t key_len,
+ Obj *value) {
ZombieCharBuf *k = ZCB_WRAP_STR((char*)key, key_len);
Seg_Store_Metadata(self, (CharBuf*)k, value);
}
Obj*
-Seg_fetch_metadata(Segment *self, const CharBuf *key)
-{
+Seg_fetch_metadata(Segment *self, const CharBuf *key) {
return Hash_Fetch(self->metadata, (Obj*)key);
}
Obj*
-Seg_fetch_metadata_str(Segment *self, const char *key, size_t len)
-{
+Seg_fetch_metadata_str(Segment *self, const char *key, size_t len) {
return Hash_Fetch_Str(self->metadata, key, len);
}
Hash*
-Seg_get_metadata(Segment *self) { return self->metadata; }
-
+Seg_get_metadata(Segment *self) {
+ return self->metadata;
+}
+
int32_t
-Seg_compare_to(Segment *self, Obj *other)
-{
+Seg_compare_to(Segment *self, Obj *other) {
Segment *other_seg = (Segment*)CERTIFY(other, SEGMENT);
- if (self->number < other_seg->number) { return -1; }
+ if (self->number < other_seg->number) { return -1; }
else if (self->number == other_seg->number) { return 0; }
else { return 1; }
}
CharBuf*
-Seg_field_name(Segment *self, int32_t field_num)
-{
- return field_num
- ? (CharBuf*)VA_Fetch(self->by_num, field_num)
- : NULL;
+Seg_field_name(Segment *self, int32_t field_num) {
+ return field_num
+ ? (CharBuf*)VA_Fetch(self->by_num, field_num)
+ : NULL;
}
int32_t
-Seg_field_num(Segment *self, const CharBuf *field)
-{
+Seg_field_num(Segment *self, const CharBuf *field) {
if (field == NULL) {
return 0;
}
Modified: incubator/lucy/trunk/core/Lucy/Index/Segment.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Segment.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Segment.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Segment.cfh Sun May 1 23:50:24 2011
@@ -73,11 +73,11 @@ class Lucy::Index::Segment cnick Seg inh
* @param metadata JSON-izable data structure.
*/
public void
- Store_Metadata(Segment *self, const CharBuf *key,
+ Store_Metadata(Segment *self, const CharBuf *key,
decremented Obj *metadata);
void
- Store_Metadata_Str(Segment *self, const char *key, size_t len,
+ Store_Metadata_Str(Segment *self, const char *key, size_t len,
decremented Obj *value);
/** Fetch a value from the Segment's metadata hash.
@@ -120,7 +120,7 @@ class Lucy::Index::Segment cnick Seg inh
/** Getter for the object's document count.
*/
- public int64_t
+ public int64_t
Get_Count(Segment *self);
/** Add <code>increment</code> to the object's document count, then return
Modified: incubator/lucy/trunk/core/Lucy/Index/Similarity.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Similarity.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Similarity.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Similarity.c Sun May 1 23:50:24 2011
@@ -31,22 +31,19 @@
#include "Lucy/Store/OutStream.h"
Similarity*
-Sim_new()
-{
+Sim_new() {
Similarity *self = (Similarity*)VTable_Make_Obj(SIMILARITY);
return Sim_init(self);
}
Similarity*
-Sim_init(Similarity *self)
-{
+Sim_init(Similarity *self) {
self->norm_decoder = NULL;
return self;
}
void
-Sim_destroy(Similarity *self)
-{
+Sim_destroy(Similarity *self) {
if (self->norm_decoder) {
FREEMEM(self->norm_decoder);
}
@@ -54,24 +51,21 @@ Sim_destroy(Similarity *self)
}
Posting*
-Sim_make_posting(Similarity *self)
-{
+Sim_make_posting(Similarity *self) {
return (Posting*)ScorePost_new(self);
}
PostingWriter*
Sim_make_posting_writer(Similarity *self, Schema *schema, Snapshot *snapshot,
Segment *segment, PolyReader *polyreader,
- int32_t field_num)
-{
+ int32_t field_num) {
UNUSED_VAR(self);
- return (PostingWriter*)MatchPostWriter_new(schema, snapshot, segment,
- polyreader, field_num);
+ return (PostingWriter*)MatchPostWriter_new(schema, snapshot, segment,
+ polyreader, field_num);
}
float*
-Sim_get_norm_decoder(Similarity *self)
-{
+Sim_get_norm_decoder(Similarity *self) {
if (!self->norm_decoder) {
// Cache decoded boost bytes.
self->norm_decoder = (float*)MALLOCATE(256 * sizeof(float));
@@ -79,24 +73,22 @@ Sim_get_norm_decoder(Similarity *self)
self->norm_decoder[i] = Sim_Decode_Norm(self, i);
}
}
- return self->norm_decoder;
+ return self->norm_decoder;
}
Obj*
-Sim_dump(Similarity *self)
-{
+Sim_dump(Similarity *self) {
Hash *dump = Hash_new(0);
- Hash_Store_Str(dump, "_class", 6,
- (Obj*)CB_Clone(Sim_Get_Class_Name(self)));
+ Hash_Store_Str(dump, "_class", 6,
+ (Obj*)CB_Clone(Sim_Get_Class_Name(self)));
return (Obj*)dump;
}
Similarity*
-Sim_load(Similarity *self, Obj *dump)
-{
+Sim_load(Similarity *self, Obj *dump) {
Hash *source = (Hash*)CERTIFY(dump, HASH);
- CharBuf *class_name = (CharBuf*)CERTIFY(
- Hash_Fetch_Str(source, "_class", 6), CHARBUF);
+ CharBuf *class_name
+ = (CharBuf*)CERTIFY(Hash_Fetch_Str(source, "_class", 6), CHARBUF);
VTable *vtable = VTable_singleton(class_name, NULL);
Similarity *loaded = (Similarity*)VTable_Make_Obj(vtable);
UNUSED_VAR(self);
@@ -104,15 +96,13 @@ Sim_load(Similarity *self, Obj *dump)
}
void
-Sim_serialize(Similarity *self, OutStream *target)
-{
+Sim_serialize(Similarity *self, OutStream *target) {
// Only the class name.
CB_Serialize(Sim_Get_Class_Name(self), target);
}
Similarity*
-Sim_deserialize(Similarity *self, InStream *instream)
-{
+Sim_deserialize(Similarity *self, InStream *instream) {
CharBuf *class_name = CB_deserialize(NULL, instream);
if (!self) {
VTable *vtable = VTable_singleton(class_name, SIMILARITY);
@@ -120,7 +110,7 @@ Sim_deserialize(Similarity *self, InStre
}
else if (!CB_Equals(class_name, (Obj*)Sim_Get_Class_Name(self))) {
THROW(ERR, "Class name mismatch: '%o' '%o'", Sim_Get_Class_Name(self),
- class_name);
+ class_name);
}
DECREF(class_name);
@@ -129,15 +119,13 @@ Sim_deserialize(Similarity *self, InStre
}
bool_t
-Sim_equals(Similarity *self, Obj *other)
-{
+Sim_equals(Similarity *self, Obj *other) {
if (Sim_Get_VTable(self) != Obj_Get_VTable(other)) return false;
return true;
}
float
-Sim_idf(Similarity *self, int64_t doc_freq, int64_t total_docs)
-{
+Sim_idf(Similarity *self, int64_t doc_freq, int64_t total_docs) {
UNUSED_VAR(self);
if (total_docs == 0) {
// Guard against log of zero error, return meaningless number.
@@ -146,20 +134,18 @@ Sim_idf(Similarity *self, int64_t doc_fr
else {
double total_documents = (double)total_docs;
double document_freq = (double)doc_freq;
- return (float)(1 + log( total_documents / (1 + document_freq) ));
+ return (float)(1 + log(total_documents / (1 + document_freq)));
}
}
float
-Sim_tf(Similarity *self, float freq)
-{
+Sim_tf(Similarity *self, float freq) {
UNUSED_VAR(self);
return (float)sqrt(freq);
}
uint32_t
-Sim_encode_norm(Similarity *self, float f)
-{
+Sim_encode_norm(Similarity *self, float f) {
uint32_t norm;
UNUSED_VAR(self);
@@ -173,13 +159,13 @@ Sim_encode_norm(Similarity *self, float
else {
const uint32_t bits = *(uint32_t*)&f;
uint32_t mantissa = (bits & 0xffffff) >> 21;
- uint32_t exponent = (((bits >> 24) & 0x7f)-63) + 15;
+ uint32_t exponent = (((bits >> 24) & 0x7f) - 63) + 15;
if (exponent > 31) {
exponent = 31;
mantissa = 7;
}
-
+
norm = (exponent << 3) | mantissa;
}
@@ -187,8 +173,7 @@ Sim_encode_norm(Similarity *self, float
}
float
-Sim_decode_norm(Similarity *self, uint32_t input)
-{
+Sim_decode_norm(Similarity *self, uint32_t input) {
uint8_t byte = input & 0xFF;
uint32_t result;
UNUSED_VAR(self);
@@ -199,39 +184,36 @@ Sim_decode_norm(Similarity *self, uint32
else {
const uint32_t mantissa = byte & 7;
const uint32_t exponent = (byte >> 3) & 31;
- result = ((exponent+(63-15)) << 24) | (mantissa << 21);
+ result = ((exponent + (63 - 15)) << 24) | (mantissa << 21);
}
-
+
return *(float*)&result;
}
-float
-Sim_length_norm(Similarity *self, uint32_t num_tokens)
-{
+float
+Sim_length_norm(Similarity *self, uint32_t num_tokens) {
UNUSED_VAR(self);
if (num_tokens == 0) { // guard against div by zero
return 0;
}
else {
- return (float)( 1.0 / sqrt((double)num_tokens) );
+ return (float)(1.0 / sqrt((double)num_tokens));
}
}
float
-Sim_query_norm(Similarity *self, float sum_of_squared_weights)
-{
+Sim_query_norm(Similarity *self, float sum_of_squared_weights) {
UNUSED_VAR(self);
if (sum_of_squared_weights == 0.0f) { // guard against div by zero
return 0;
}
else {
- return (float)( 1.0 / sqrt(sum_of_squared_weights) );
+ return (float)(1.0 / sqrt(sum_of_squared_weights));
}
}
float
-Sim_coord(Similarity *self, uint32_t overlap, uint32_t max_overlap)
-{
+Sim_coord(Similarity *self, uint32_t overlap, uint32_t max_overlap) {
UNUSED_VAR(self);
if (max_overlap == 0) {
return 1;
Modified: incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/Similarity.cfh Sun May 1 23:50:24 2011
@@ -43,7 +43,7 @@ class Lucy::Index::Similarity cnick Sim
/** Constructor. Takes no arguments.
*/
- public inert Similarity*
+ public inert Similarity*
init(Similarity *self);
/** Factory method for creating a Posting.
@@ -54,8 +54,8 @@ class Lucy::Index::Similarity cnick Sim
/** Factory method for creating a PostingWriter.
*/
incremented PostingWriter*
- Make_Posting_Writer(Similarity *self, Schema *schema, Snapshot *snapshot,
- Segment *segment, PolyReader *polyreader,
+ Make_Posting_Writer(Similarity *self, Schema *schema, Snapshot *snapshot,
+ Segment *segment, PolyReader *polyreader,
int32_t field_num);
/** Return a score factor based on the frequency of a term in a given
@@ -64,7 +64,7 @@ class Lucy::Index::Similarity cnick Sim
* freqs, since the more times a doc matches, the more relevant it is
* likely to be.
*/
- public float
+ public float
TF(Similarity *self, float freq);
/** Calculate the Inverse Document Frequecy for a term in a given
@@ -110,7 +110,7 @@ class Lucy::Index::Similarity cnick Sim
* range covered by the single-byte encoding is 7x10^9 to 2x10^-9. The
* accuracy is about one significant decimal digit.
*/
- uint32_t
+ uint32_t
Encode_Norm(Similarity *self, float f);
/** See encode_norm.
@@ -124,10 +124,10 @@ class Lucy::Index::Similarity cnick Sim
public void
Destroy(Similarity *self);
- public incremented Obj*
+ public incremented Obj*
Dump(Similarity *self);
- public incremented Similarity*
+ public incremented Similarity*
Load(Similarity *self, Obj *dump);
public bool_t
Modified: incubator/lucy/trunk/core/Lucy/Index/SkipStepper.c
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SkipStepper.c?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SkipStepper.c (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SkipStepper.c Sun May 1 23:50:24 2011
@@ -25,8 +25,7 @@
#include "Lucy/Store/OutStream.h"
SkipStepper*
-SkipStepper_new()
-{
+SkipStepper_new() {
SkipStepper *self = (SkipStepper*)VTable_Make_Obj(SKIPSTEPPER);
// Init.
@@ -37,32 +36,29 @@ SkipStepper_new()
}
void
-SkipStepper_set_id_and_filepos(SkipStepper *self, int32_t doc_id, int64_t filepos)
-{
+SkipStepper_set_id_and_filepos(SkipStepper *self, int32_t doc_id,
+ int64_t filepos) {
self->doc_id = doc_id;
self->filepos = filepos;
}
void
-SkipStepper_read_record(SkipStepper *self, InStream *instream)
-{
+SkipStepper_read_record(SkipStepper *self, InStream *instream) {
self->doc_id += InStream_Read_C32(instream);
self->filepos += InStream_Read_C64(instream);
}
CharBuf*
-SkipStepper_to_string(SkipStepper *self)
-{
+SkipStepper_to_string(SkipStepper *self) {
char *ptr = (char*)MALLOCATE(60);
- size_t len = sprintf(ptr, "skip doc: %u file pointer: %" I64P,
- self->doc_id, self->filepos);
+ size_t len = sprintf(ptr, "skip doc: %u file pointer: %" I64P,
+ self->doc_id, self->filepos);
return CB_new_steal_from_trusted_str(ptr, len, 60);
}
void
-SkipStepper_write_record(SkipStepper *self, OutStream *outstream,
- int32_t last_doc_id, int64_t last_filepos)
-{
+SkipStepper_write_record(SkipStepper *self, OutStream *outstream,
+ int32_t last_doc_id, int64_t last_filepos) {
const int32_t delta_doc_id = self->doc_id - last_doc_id;
const int64_t delta_filepos = self->filepos - last_filepos;
Modified: incubator/lucy/trunk/core/Lucy/Index/SkipStepper.cfh
URL: http://svn.apache.org/viewvc/incubator/lucy/trunk/core/Lucy/Index/SkipStepper.cfh?rev=1098445&r1=1098444&r2=1098445&view=diff
==============================================================================
--- incubator/lucy/trunk/core/Lucy/Index/SkipStepper.cfh (original)
+++ incubator/lucy/trunk/core/Lucy/Index/SkipStepper.cfh Sun May 1 23:50:24 2011
@@ -28,7 +28,7 @@ class Lucy::Index::SkipStepper inherits
Read_Record(SkipStepper *self, InStream *instream);
void
- Write_Record(SkipStepper *self, OutStream *outstream,
+ Write_Record(SkipStepper *self, OutStream *outstream,
int32_t last_doc_id, int64_t last_filepos);
/** Set a base document id and a base file position which Read_Record