lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [06/11] git commit: refs/heads/ivars-wip1 - Fixup Lucy Index classes IVARS glitches.
Date Thu, 11 Jul 2013 22:33:31 GMT
Fixup Lucy Index classes IVARS glitches.

(Will be folded into earlier commit before merging to master.)


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/ea242c84
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/ea242c84
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/ea242c84

Branch: refs/heads/ivars-wip1
Commit: ea242c84db0bfbe4136dcfa2bf3f5453febb4424
Parents: 7af7e94
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Thu Jul 11 15:03:55 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Thu Jul 11 15:03:55 2013 -0700

----------------------------------------------------------------------
 core/Lucy/Index/HighlightWriter.c | 25 ++++++-----
 core/Lucy/Index/Inverter.c        |  2 +-
 core/Lucy/Index/LexIndex.c        | 10 ++---
 core/Lucy/Index/PostingPool.c     | 76 ++++++++++++++++++----------------
 4 files changed, 61 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/ea242c84/core/Lucy/Index/HighlightWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightWriter.c b/core/Lucy/Index/HighlightWriter.c
index b398552..d1ce83a 100644
--- a/core/Lucy/Index/HighlightWriter.c
+++ b/core/Lucy/Index/HighlightWriter.c
@@ -155,15 +155,16 @@ HLWriter_tv_buf(HighlightWriter *self, Inversion *inversion) {
     Inversion_Reset(inversion);
     while ((tokens = Inversion_Next_Cluster(inversion, &freq)) != NULL) {
         Token *token = *tokens;
-        int32_t overlap = StrHelp_overlap(last_text, token->text,
-                                          last_len, token->len);
+        TokenIVARS *token_ivars = Token_IVARS(token);
+        int32_t overlap = StrHelp_overlap(last_text, token_ivars->text,
+                                          last_len, token_ivars->len);
         char *ptr;
         char *orig;
         size_t old_size = BB_Get_Size(tv_buf);
         size_t new_size = old_size
                           + C32_MAX_BYTES      // overlap
                           + C32_MAX_BYTES      // length of string diff
-                          + (token->len - overlap) // diff char data
+                          + (token_ivars->len - overlap) // diff char data
                           + C32_MAX_BYTES                // num prox
                           + (C32_MAX_BYTES * freq * 3);  // pos data
 
@@ -177,22 +178,24 @@ HLWriter_tv_buf(HighlightWriter *self, Inversion *inversion) {
 
         // Append the string diff to the tv_buf.
         NumUtil_encode_c32(overlap, &ptr);
-        NumUtil_encode_c32((token->len - overlap), &ptr);
-        memcpy(ptr, (token->text + overlap), (token->len - overlap));
-        ptr += token->len - overlap;
+        NumUtil_encode_c32((token_ivars->len - overlap), &ptr);
+        memcpy(ptr, (token_ivars->text + overlap),
+               (token_ivars->len - overlap));
+        ptr += token_ivars->len - overlap;
 
         // Save text and text_len for comparison next loop.
-        last_text = token->text;
-        last_len  = token->len;
+        last_text = token_ivars->text;
+        last_len  = token_ivars->len;
 
         // Append the number of positions for this term.
         NumUtil_encode_c32(freq, &ptr);
 
         do {
+            token_ivars = Token_IVARS(token);
             // Add position, start_offset, and end_offset to tv_buf.
-            NumUtil_encode_c32(token->pos, &ptr);
-            NumUtil_encode_c32(token->start_offset, &ptr);
-            NumUtil_encode_c32(token->end_offset, &ptr);
+            NumUtil_encode_c32(token_ivars->pos, &ptr);
+            NumUtil_encode_c32(token_ivars->start_offset, &ptr);
+            NumUtil_encode_c32(token_ivars->end_offset, &ptr);
 
         } while (--freq && (token = *++tokens));
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/ea242c84/core/Lucy/Index/Inverter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Inverter.c b/core/Lucy/Index/Inverter.c
index 7bf5807..77c0bcc 100644
--- a/core/Lucy/Index/Inverter.c
+++ b/core/Lucy/Index/Inverter.c
@@ -88,7 +88,7 @@ Inverter_next(Inverter *self) {
     InverterIVARS *const ivars = Inverter_IVARS(self);
     ivars->current = (InverterEntry*)VA_Fetch(ivars->entries, ++ivars->tick);
     if (!ivars->current) { ivars->current = ivars->blank; } // Exhausted.
-    return ivars->current->field_num;
+    return InvEntry_IVARS(ivars->current)->field_num;
 }
 
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/ea242c84/core/Lucy/Index/LexIndex.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/LexIndex.c b/core/Lucy/Index/LexIndex.c
index bc252f4..3d3200e 100644
--- a/core/Lucy/Index/LexIndex.c
+++ b/core/Lucy/Index/LexIndex.c
@@ -125,16 +125,16 @@ static void
 S_read_entry(LexIndex *self) {
     LexIndexIVARS *const ivars = LexIndex_IVARS(self);
     InStream *ix_in  = ivars->ix_in;
-    TermInfo *tinfo  = ivars->tinfo;
+    TermInfoIVARS *const tinfo_ivars = TInfo_IVARS(ivars->tinfo);
     int64_t offset = (int64_t)NumUtil_decode_bigend_u64(ivars->offsets + ivars->tick);
     InStream_Seek(ix_in, offset);
     TermStepper_Read_Key_Frame(ivars->term_stepper, ix_in);
-    tinfo->doc_freq     = InStream_Read_C32(ix_in);
-    tinfo->post_filepos = InStream_Read_C64(ix_in);
-    tinfo->skip_filepos = tinfo->doc_freq >= ivars->skip_interval
+    tinfo_ivars->doc_freq     = InStream_Read_C32(ix_in);
+    tinfo_ivars->post_filepos = InStream_Read_C64(ix_in);
+    tinfo_ivars->skip_filepos = tinfo_ivars->doc_freq >= ivars->skip_interval
                           ? InStream_Read_C64(ix_in)
                           : 0;
-    tinfo->lex_filepos  = InStream_Read_C64(ix_in);
+    tinfo_ivars->lex_filepos  = InStream_Read_C64(ix_in);
 }
 
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/ea242c84/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index 1580a6a..6bd21b0 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -138,8 +138,8 @@ PostPool_destroy(PostingPool *self) {
 
 int
 PostPool_compare(PostingPool *self, void *va, void *vb) {
-    RawPosting *const a     = *(RawPosting**)va;
-    RawPosting *const b     = *(RawPosting**)vb;
+    RawPostingIVARS *const a     = RawPost_IVARS(*(RawPosting**)va);
+    RawPostingIVARS *const b     = RawPost_IVARS(*(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;
@@ -199,9 +199,11 @@ PostPool_flip(PostingPool *self) {
                            ivars->mem_pool, ivars->lex_temp_out,
                            ivars->post_temp_out, ivars->skip_out);
         PostPool_Grow_Cache(run, num_items);
-        memcpy(run->cache, ((Obj**)ivars->cache) + ivars->cache_tick,
+        PostingPoolIVARS *const run_ivars = PostPool_IVARS(run);
+
+        memcpy(run_ivars->cache, ((Obj**)ivars->cache) + ivars->cache_tick,
                num_items * sizeof(Obj*));
-        run->cache_max = num_items;
+        run_ivars->cache_max = num_items;
         PostPool_Add_Run(self, (SortExternal*)run);
         ivars->cache_tick = 0;
         ivars->cache_max = 0;
@@ -212,7 +214,7 @@ PostPool_flip(PostingPool *self) {
         PostingPool *run = (PostingPool*)VA_Fetch(ivars->runs, i);
         if (run != NULL) {
             PostPool_Set_Mem_Thresh(run, sub_thresh);
-            if (!run->lexicon) {
+            if (!PostPool_IVARS(run)->lexicon) {
                 S_fresh_flip(run, ivars->lex_temp_in, ivars->post_temp_in);
             }
         }
@@ -247,10 +249,11 @@ PostPool_add_segment(PostingPool *self, SegReader *reader, I32Array
*doc_map,
                            ivars->polyreader, ivars->field, ivars->lex_writer,
                            ivars->mem_pool, ivars->lex_temp_out,
                            ivars->post_temp_out, ivars->skip_out);
-        run->lexicon  = lexicon;
-        run->plist    = plist;
-        run->doc_base = doc_base;
-        run->doc_map  = (I32Array*)INCREF(doc_map);
+        PostingPoolIVARS *const run_ivars = PostPool_IVARS(run);
+        run_ivars->lexicon  = lexicon;
+        run_ivars->plist    = plist;
+        run_ivars->doc_base = doc_base;
+        run_ivars->doc_map  = (I32Array*)INCREF(doc_map);
         PostPool_Add_Run(self, (SortExternal*)run);
     }
 }
@@ -297,34 +300,35 @@ PostPool_flush(PostingPool *self) {
                        ivars->polyreader, ivars->field, ivars->lex_writer,
                        ivars->mem_pool, ivars->lex_temp_out,
                        ivars->post_temp_out, ivars->skip_out);
+    PostingPoolIVARS *const run_ivars = PostPool_IVARS(run);
     PostingWriter *post_writer
         = (PostingWriter*)RawPostWriter_new(ivars->schema, ivars->snapshot,
                                             ivars->segment, ivars->polyreader,
                                             ivars->post_temp_out);
 
     // Borrow the cache.
-    run->cache      = ivars->cache;
-    run->cache_tick = ivars->cache_tick;
-    run->cache_max  = ivars->cache_max;
-    run->cache_cap  = ivars->cache_cap;
+    run_ivars->cache      = ivars->cache;
+    run_ivars->cache_tick = ivars->cache_tick;
+    run_ivars->cache_max  = ivars->cache_max;
+    run_ivars->cache_cap  = ivars->cache_cap;
 
     // Write to temp files.
     LexWriter_Enter_Temp_Mode(ivars->lex_writer, ivars->field,
                               ivars->lex_temp_out);
-    run->lex_start  = OutStream_Tell(ivars->lex_temp_out);
-    run->post_start = OutStream_Tell(ivars->post_temp_out);
+    run_ivars->lex_start  = OutStream_Tell(ivars->lex_temp_out);
+    run_ivars->post_start = OutStream_Tell(ivars->post_temp_out);
     PostPool_Sort_Cache(self);
     S_write_terms_and_postings(run, post_writer, NULL);
 
-    run->lex_end  = OutStream_Tell(ivars->lex_temp_out);
-    run->post_end = OutStream_Tell(ivars->post_temp_out);
+    run_ivars->lex_end  = OutStream_Tell(ivars->lex_temp_out);
+    run_ivars->post_end = OutStream_Tell(ivars->post_temp_out);
     LexWriter_Leave_Temp_Mode(ivars->lex_writer);
 
     // Return the cache and empty it.
-    run->cache      = NULL;
-    run->cache_tick = 0;
-    run->cache_max  = 0;
-    run->cache_cap  = 0;
+    run_ivars->cache      = NULL;
+    run_ivars->cache_tick = 0;
+    run_ivars->cache_max  = 0;
+    run_ivars->cache_cap  = 0;
     PostPool_Clear_Cache(self);
 
     // Add the run to the array.
@@ -373,7 +377,8 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
     RawPosting *posting = (RawPosting*)CERTIFY(
                               (*(RawPosting**)PostPool_Fetch(self)),
                               RAWPOSTING);
-    CB_Mimic_Str(last_term_text, posting->blob, posting->content_len);
+    RawPostingIVARS *post_ivars = RawPost_IVARS(posting);
+    CB_Mimic_Str(last_term_text, post_ivars->blob, post_ivars->content_len);
     char *last_text_buf = (char*)CB_Get_Ptr8(last_term_text);
     uint32_t last_text_size = CB_Get_Size(last_term_text);
     SkipStepper_Set_ID_And_Filepos(skip_stepper, 0, 0);
@@ -393,12 +398,13 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
             // On the last iter, use an empty string to make LexiconWriter
             // DTRT.
             posting = sentinel;
+            post_ivars = RawPost_IVARS(posting);
             same_text_as_last = false;
         }
         else {
             // Compare once.
-            if (posting->content_len != last_text_size
-                || memcmp(&posting->blob, last_text_buf, last_text_size) != 0
+            if (post_ivars->content_len != last_text_size
+                || memcmp(&post_ivars->blob, last_text_buf, last_text_size) != 0
                ) {
                 same_text_as_last = false;
             }
@@ -420,8 +426,8 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
             last_skip_filepos     = tinfo_ivars->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, post_ivars->blob,
+                         post_ivars->content_len);
             last_text_buf  = (char*)CB_Get_Ptr8(last_term_text);
             last_text_size = CB_Get_Size(last_term_text);
         }
@@ -448,7 +454,7 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
             // Write deltas.
             last_skip_doc               = skip_stepper_ivars->doc_id;
             last_skip_filepos           = skip_stepper_ivars->filepos;
-            skip_stepper_ivars->doc_id  = posting->doc_id;
+            skip_stepper_ivars->doc_id  = post_ivars->doc_id;
             PostWriter_Update_Skip_Info(post_writer, skip_tinfo);
             skip_stepper_ivars->filepos = skip_tinfo_ivars->post_filepos;
             SkipStepper_Write_Record(skip_stepper, skip_stream,
@@ -462,6 +468,7 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
         posting = address
                   ? *(RawPosting**)address
                   : NULL;
+        post_ivars = RawPost_IVARS(posting);
     }
 
     // Clean up.
@@ -500,8 +507,6 @@ PostPool_refill(PostingPool *self) {
 
 
     while (1) {
-        RawPosting *raw_posting;
-
         if (ivars->post_count == 0) {
             // Read a term.
             if (Lex_Next(lexicon)) {
@@ -526,19 +531,20 @@ PostPool_refill(PostingPool *self) {
         }
 
         // Read a posting from the input stream.
-        raw_posting = PList_Read_Raw(plist, ivars->last_doc_id, term_text,
-                                     mem_pool);
-        ivars->last_doc_id = raw_posting->doc_id;
+        RawPosting *rawpost
+            = PList_Read_Raw(plist, ivars->last_doc_id, term_text, mem_pool);
+        RawPostingIVARS *const rawpost_ivars = RawPost_IVARS(rawpost);
+        ivars->last_doc_id = rawpost_ivars->doc_id;
         ivars->post_count--;
 
         // Skip deletions.
         if (doc_map != NULL) {
             const int32_t remapped
-                = I32Arr_Get(doc_map, raw_posting->doc_id - doc_base);
+                = I32Arr_Get(doc_map, rawpost_ivars->doc_id - doc_base);
             if (!remapped) {
                 continue;
             }
-            raw_posting->doc_id = remapped;
+            rawpost_ivars->doc_id = remapped;
         }
 
         // Add to the run's cache.
@@ -547,7 +553,7 @@ PostPool_refill(PostingPool *self) {
             PostPool_Grow_Cache(self, new_cap);
         }
         Obj **cache = (Obj**)ivars->cache;
-        cache[num_elems] = (Obj*)raw_posting;
+        cache[num_elems] = (Obj*)rawpost;
         num_elems++;
     }
 


Mime
View raw message