lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [11/34] Migrate Lucy's index classes to IVARS.
Date Wed, 17 Jul 2013 14:12:31 GMT
http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/PostingListWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingListWriter.c b/core/Lucy/Index/PostingListWriter.c
index f56e8f8..9436e18 100644
--- a/core/Lucy/Index/PostingListWriter.c
+++ b/core/Lucy/Index/PostingListWriter.c
@@ -62,36 +62,38 @@ PListWriter_init(PostingListWriter *self, Schema *schema, Snapshot *snapshot,
                  Segment *segment, PolyReader *polyreader,
                  LexiconWriter *lex_writer) {
     DataWriter_init((DataWriter*)self, schema, snapshot, segment, polyreader);
+    PostingListWriterIVARS *const ivars = PListWriter_IVARS(self);
 
     // Assign.
-    self->lex_writer = (LexiconWriter*)INCREF(lex_writer);
+    ivars->lex_writer = (LexiconWriter*)INCREF(lex_writer);
 
     // Init.
-    self->pools          = VA_new(Schema_Num_Fields(schema));
-    self->mem_thresh     = default_mem_thresh;
-    self->mem_pool       = MemPool_new(0);
-    self->lex_temp_out   = NULL;
-    self->post_temp_out  = NULL;
+    ivars->pools          = VA_new(Schema_Num_Fields(schema));
+    ivars->mem_thresh     = default_mem_thresh;
+    ivars->mem_pool       = MemPool_new(0);
+    ivars->lex_temp_out   = NULL;
+    ivars->post_temp_out  = NULL;
 
     return self;
 }
 
 static void
 S_lazy_init(PostingListWriter *self) {
-    if (!self->lex_temp_out) {
-        Folder  *folder         = self->folder;
-        CharBuf *seg_name       = Seg_Get_Name(self->segment);
+    PostingListWriterIVARS *const ivars = PListWriter_IVARS(self);
+    if (!ivars->lex_temp_out) {
+        Folder  *folder         = ivars->folder;
+        CharBuf *seg_name       = Seg_Get_Name(ivars->segment);
         CharBuf *lex_temp_path  = CB_newf("%o/lextemp", seg_name);
         CharBuf *post_temp_path = CB_newf("%o/ptemp", seg_name);
         CharBuf *skip_path      = CB_newf("%o/postings.skip", seg_name);
 
         // Open temp streams and final skip stream.
-        self->lex_temp_out  = Folder_Open_Out(folder, lex_temp_path);
-        if (!self->lex_temp_out) { RETHROW(INCREF(Err_get_error())); }
-        self->post_temp_out = Folder_Open_Out(folder, post_temp_path);
-        if (!self->post_temp_out) { RETHROW(INCREF(Err_get_error())); }
-        self->skip_out = Folder_Open_Out(folder, skip_path);
-        if (!self->skip_out) { RETHROW(INCREF(Err_get_error())); }
+        ivars->lex_temp_out  = Folder_Open_Out(folder, lex_temp_path);
+        if (!ivars->lex_temp_out) { RETHROW(INCREF(Err_get_error())); }
+        ivars->post_temp_out = Folder_Open_Out(folder, post_temp_path);
+        if (!ivars->post_temp_out) { RETHROW(INCREF(Err_get_error())); }
+        ivars->skip_out = Folder_Open_Out(folder, skip_path);
+        if (!ivars->skip_out) { RETHROW(INCREF(Err_get_error())); }
 
         DECREF(skip_path);
         DECREF(post_temp_path);
@@ -101,26 +103,28 @@ S_lazy_init(PostingListWriter *self) {
 
 static PostingPool*
 S_lazy_init_posting_pool(PostingListWriter *self, int32_t field_num) {
-    PostingPool *pool = (PostingPool*)VA_Fetch(self->pools, field_num);
+    PostingListWriterIVARS *const ivars = PListWriter_IVARS(self);
+    PostingPool *pool = (PostingPool*)VA_Fetch(ivars->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);
-        VA_Store(self->pools, field_num, (Obj*)pool);
+        CharBuf *field = Seg_Field_Name(ivars->segment, field_num);
+        pool = PostPool_new(ivars->schema, ivars->snapshot, ivars->segment,
+                            ivars->polyreader, field, ivars->lex_writer,
+                            ivars->mem_pool, ivars->lex_temp_out,
+                            ivars->post_temp_out, ivars->skip_out);
+        VA_Store(ivars->pools, field_num, (Obj*)pool);
     }
     return pool;
 }
 
 void
 PListWriter_destroy(PostingListWriter *self) {
-    DECREF(self->lex_writer);
-    DECREF(self->mem_pool);
-    DECREF(self->pools);
-    DECREF(self->lex_temp_out);
-    DECREF(self->post_temp_out);
-    DECREF(self->skip_out);
+    PostingListWriterIVARS *const ivars = PListWriter_IVARS(self);
+    DECREF(ivars->lex_writer);
+    DECREF(ivars->mem_pool);
+    DECREF(ivars->pools);
+    DECREF(ivars->lex_temp_out);
+    DECREF(ivars->post_temp_out);
+    DECREF(ivars->skip_out);
     SUPER_DESTROY(self, POSTINGLISTWRITER);
 }
 
@@ -139,6 +143,7 @@ void
 PListWriter_add_inverted_doc(PostingListWriter *self, Inverter *inverter,
                              int32_t doc_id) {
     S_lazy_init(self);
+    PostingListWriterIVARS *const ivars = PListWriter_IVARS(self);
 
     // Iterate over fields in document, adding the content of indexed fields
     // to their respective PostingPools.
@@ -161,21 +166,22 @@ PListWriter_add_inverted_doc(PostingListWriter *self, Inverter *inverter,
     // If our PostingPools have collectively passed the memory threshold,
     // flush all of them, then release all the RawPostings with a single
     // action.
-    if (MemPool_Get_Consumed(self->mem_pool) > self->mem_thresh) {
-        for (uint32_t i = 0, max = VA_Get_Size(self->pools); i < max; i++) {
-            PostingPool *const pool = (PostingPool*)VA_Fetch(self->pools, i);
+    if (MemPool_Get_Consumed(ivars->mem_pool) > ivars->mem_thresh) {
+        for (uint32_t i = 0, max = VA_Get_Size(ivars->pools); i < max; i++) {
+            PostingPool *const pool = (PostingPool*)VA_Fetch(ivars->pools, i);
             if (pool) { PostPool_Flush(pool); }
         }
-        MemPool_Release_All(self->mem_pool);
+        MemPool_Release_All(ivars->mem_pool);
     }
 }
 
 void
 PListWriter_add_segment(PostingListWriter *self, SegReader *reader,
                         I32Array *doc_map) {
+    PostingListWriterIVARS *const ivars = PListWriter_IVARS(self);
     Segment *other_segment = SegReader_Get_Segment(reader);
-    Schema  *schema        = self->schema;
-    Segment *segment       = self->segment;
+    Schema  *schema        = ivars->schema;
+    Segment *segment       = ivars->segment;
     VArray  *all_fields    = Schema_All_Fields(schema);
     S_lazy_init(self);
 
@@ -202,32 +208,34 @@ PListWriter_add_segment(PostingListWriter *self, SegReader *reader,
 
 void
 PListWriter_finish(PostingListWriter *self) {
+    PostingListWriterIVARS *const ivars = PListWriter_IVARS(self);
+
     // If S_lazy_init was never called, we have no data, so bail out.
-    if (!self->lex_temp_out) { return; }
+    if (!ivars->lex_temp_out) { return; }
 
-    Folder  *folder = self->folder;
-    CharBuf *seg_name = Seg_Get_Name(self->segment);
+    Folder  *folder = ivars->folder;
+    CharBuf *seg_name = Seg_Get_Name(ivars->segment);
     CharBuf *lex_temp_path  = CB_newf("%o/lextemp", seg_name);
     CharBuf *post_temp_path = CB_newf("%o/ptemp", seg_name);
 
     // Close temp streams.
-    OutStream_Close(self->lex_temp_out);
-    OutStream_Close(self->post_temp_out);
+    OutStream_Close(ivars->lex_temp_out);
+    OutStream_Close(ivars->post_temp_out);
 
     // Try to free up some memory.
-    for (uint32_t i = 0, max = VA_Get_Size(self->pools); i < max; i++) {
-        PostingPool *pool = (PostingPool*)VA_Fetch(self->pools, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->pools); i < max; i++) {
+        PostingPool *pool = (PostingPool*)VA_Fetch(ivars->pools, i);
         if (pool) { PostPool_Shrink(pool); }
     }
 
     // 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);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->pools); i < max; i++) {
+        PostingPool *pool = (PostingPool*)VA_Delete(ivars->pools, i);
         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.)
-            PostPool_Set_Mem_Thresh(pool, self->mem_thresh);
+            PostPool_Set_Mem_Thresh(pool, ivars->mem_thresh);
             PostPool_Flip(pool);
             PostPool_Finish(pool);
             DECREF(pool);
@@ -235,24 +243,24 @@ PListWriter_finish(PostingListWriter *self) {
     }
 
     // Store metadata.
-    Seg_Store_Metadata_Str(self->segment, "postings", 8,
+    Seg_Store_Metadata_Str(ivars->segment, "postings", 8,
                            (Obj*)PListWriter_Metadata(self));
 
     // Close down and clean up.
-    OutStream_Close(self->skip_out);
+    OutStream_Close(ivars->skip_out);
     if (!Folder_Delete(folder, lex_temp_path)) {
         THROW(ERR, "Couldn't delete %o", lex_temp_path);
     }
     if (!Folder_Delete(folder, post_temp_path)) {
         THROW(ERR, "Couldn't delete %o", post_temp_path);
     }
-    DECREF(self->skip_out);
-    self->skip_out = NULL;
+    DECREF(ivars->skip_out);
+    ivars->skip_out = NULL;
     DECREF(post_temp_path);
     DECREF(lex_temp_path);
 
     // Dispatch the LexiconWriter.
-    LexWriter_Finish(self->lex_writer);
+    LexWriter_Finish(ivars->lex_writer);
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index f2c1146..6bd21b0 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -76,68 +76,70 @@ PostPool_init(PostingPool *self, Schema *schema, Snapshot *snapshot,
               OutStream *skip_out) {
     // Init.
     SortEx_init((SortExternal*)self, sizeof(Obj*));
-    self->doc_base         = 0;
-    self->last_doc_id      = 0;
-    self->doc_map          = NULL;
-    self->post_count       = 0;
-    self->lexicon          = NULL;
-    self->plist            = NULL;
-    self->lex_temp_in      = NULL;
-    self->post_temp_in     = NULL;
-    self->lex_start        = INT64_MAX;
-    self->post_start       = INT64_MAX;
-    self->lex_end          = 0;
-    self->post_end         = 0;
-    self->skip_stepper     = SkipStepper_new();
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    ivars->doc_base         = 0;
+    ivars->last_doc_id      = 0;
+    ivars->doc_map          = NULL;
+    ivars->post_count       = 0;
+    ivars->lexicon          = NULL;
+    ivars->plist            = NULL;
+    ivars->lex_temp_in      = NULL;
+    ivars->post_temp_in     = NULL;
+    ivars->lex_start        = INT64_MAX;
+    ivars->post_start       = INT64_MAX;
+    ivars->lex_end          = 0;
+    ivars->post_end         = 0;
+    ivars->skip_stepper     = SkipStepper_new();
 
     // Assign.
-    self->schema         = (Schema*)INCREF(schema);
-    self->snapshot       = (Snapshot*)INCREF(snapshot);
-    self->segment        = (Segment*)INCREF(segment);
-    self->polyreader     = (PolyReader*)INCREF(polyreader);
-    self->lex_writer     = (LexiconWriter*)INCREF(lex_writer);
-    self->mem_pool       = (MemoryPool*)INCREF(mem_pool);
-    self->field          = CB_Clone(field);
-    self->lex_temp_out   = (OutStream*)INCREF(lex_temp_out);
-    self->post_temp_out  = (OutStream*)INCREF(post_temp_out);
-    self->skip_out       = (OutStream*)INCREF(skip_out);
+    ivars->schema         = (Schema*)INCREF(schema);
+    ivars->snapshot       = (Snapshot*)INCREF(snapshot);
+    ivars->segment        = (Segment*)INCREF(segment);
+    ivars->polyreader     = (PolyReader*)INCREF(polyreader);
+    ivars->lex_writer     = (LexiconWriter*)INCREF(lex_writer);
+    ivars->mem_pool       = (MemoryPool*)INCREF(mem_pool);
+    ivars->field          = CB_Clone(field);
+    ivars->lex_temp_out   = (OutStream*)INCREF(lex_temp_out);
+    ivars->post_temp_out  = (OutStream*)INCREF(post_temp_out);
+    ivars->skip_out       = (OutStream*)INCREF(skip_out);
 
     // Derive.
     Similarity *sim = Schema_Fetch_Sim(schema, field);
-    self->posting   = Sim_Make_Posting(sim);
-    self->type      = (FieldType*)INCREF(Schema_Fetch_Type(schema, field));
-    self->field_num = Seg_Field_Num(segment, field);
+    ivars->posting   = Sim_Make_Posting(sim);
+    ivars->type      = (FieldType*)INCREF(Schema_Fetch_Type(schema, field));
+    ivars->field_num = Seg_Field_Num(segment, field);
 
     return self;
 }
 
 void
 PostPool_destroy(PostingPool *self) {
-    DECREF(self->schema);
-    DECREF(self->snapshot);
-    DECREF(self->segment);
-    DECREF(self->polyreader);
-    DECREF(self->lex_writer);
-    DECREF(self->mem_pool);
-    DECREF(self->field);
-    DECREF(self->doc_map);
-    DECREF(self->lexicon);
-    DECREF(self->plist);
-    DECREF(self->lex_temp_out);
-    DECREF(self->post_temp_out);
-    DECREF(self->skip_out);
-    DECREF(self->lex_temp_in);
-    DECREF(self->post_temp_in);
-    DECREF(self->posting);
-    DECREF(self->skip_stepper);
-    DECREF(self->type);
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    DECREF(ivars->schema);
+    DECREF(ivars->snapshot);
+    DECREF(ivars->segment);
+    DECREF(ivars->polyreader);
+    DECREF(ivars->lex_writer);
+    DECREF(ivars->mem_pool);
+    DECREF(ivars->field);
+    DECREF(ivars->doc_map);
+    DECREF(ivars->lexicon);
+    DECREF(ivars->plist);
+    DECREF(ivars->lex_temp_out);
+    DECREF(ivars->post_temp_out);
+    DECREF(ivars->skip_out);
+    DECREF(ivars->lex_temp_in);
+    DECREF(ivars->post_temp_in);
+    DECREF(ivars->posting);
+    DECREF(ivars->skip_stepper);
+    DECREF(ivars->type);
     SUPER_DESTROY(self, POSTINGPOOL);
 }
 
 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;
@@ -159,27 +161,28 @@ PostPool_compare(PostingPool *self, void *va, void *vb) {
 
 MemoryPool*
 PostPool_get_mem_pool(PostingPool *self) {
-    return self->mem_pool;
+    return PostPool_IVARS(self)->mem_pool;
 }
 
 void
 PostPool_flip(PostingPool *self) {
-    uint32_t num_runs   = VA_Get_Size(self->runs);
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    uint32_t num_runs   = VA_Get_Size(ivars->runs);
     uint32_t sub_thresh = num_runs > 0
-                          ? self->mem_thresh / num_runs
-                          : self->mem_thresh;
+                          ? ivars->mem_thresh / num_runs
+                          : ivars->mem_thresh;
 
     if (num_runs) {
-        Folder  *folder = PolyReader_Get_Folder(self->polyreader);
-        CharBuf *seg_name = Seg_Get_Name(self->segment);
+        Folder  *folder = PolyReader_Get_Folder(ivars->polyreader);
+        CharBuf *seg_name = Seg_Get_Name(ivars->segment);
         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) {
+        ivars->lex_temp_in = Folder_Open_In(folder, lex_temp_path);
+        if (!ivars->lex_temp_in) {
             RETHROW(INCREF(Err_get_error()));
         }
-        self->post_temp_in = Folder_Open_In(folder, post_temp_path);
-        if (!self->post_temp_in) {
+        ivars->post_temp_in = Folder_Open_In(folder, post_temp_path);
+        if (!ivars->post_temp_in) {
             RETHROW(INCREF(Err_get_error()));
         }
         DECREF(lex_temp_path);
@@ -187,44 +190,47 @@ PostPool_flip(PostingPool *self) {
     }
 
     PostPool_Sort_Cache(self);
-    if (num_runs && (self->cache_max - self->cache_tick) > 0) {
+    if (num_runs && (ivars->cache_max - ivars->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);
+            = PostPool_new(ivars->schema, ivars->snapshot, ivars->segment,
+                           ivars->polyreader, ivars->field, ivars->lex_writer,
+                           ivars->mem_pool, ivars->lex_temp_out,
+                           ivars->post_temp_out, ivars->skip_out);
         PostPool_Grow_Cache(run, num_items);
-        memcpy(run->cache, ((Obj**)self->cache) + self->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);
-        self->cache_tick = 0;
-        self->cache_max = 0;
+        ivars->cache_tick = 0;
+        ivars->cache_max = 0;
     }
 
     // Assign.
     for (uint32_t i = 0; i < num_runs; i++) {
-        PostingPool *run = (PostingPool*)VA_Fetch(self->runs, i);
+        PostingPool *run = (PostingPool*)VA_Fetch(ivars->runs, i);
         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);
+            if (!PostPool_IVARS(run)->lexicon) {
+                S_fresh_flip(run, ivars->lex_temp_in, ivars->post_temp_in);
             }
         }
     }
 
-    self->flipped = true;
+    ivars->flipped = true;
 }
 
 void
 PostPool_add_segment(PostingPool *self, SegReader *reader, I32Array *doc_map,
                      int32_t doc_base) {
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
     LexiconReader *lex_reader = (LexiconReader*)SegReader_Fetch(
                                     reader, VTable_Get_Name(LEXICONREADER));
     Lexicon *lexicon = lex_reader
-                       ? LexReader_Lexicon(lex_reader, self->field, NULL)
+                       ? LexReader_Lexicon(lex_reader, ivars->field, NULL)
                        : NULL;
 
     if (lexicon) {
@@ -232,49 +238,51 @@ PostPool_add_segment(PostingPool *self, SegReader *reader, I32Array *doc_map,
             = (PostingListReader*)SegReader_Fetch(
                   reader, VTable_Get_Name(POSTINGLISTREADER));
         PostingList *plist = plist_reader
-                             ? PListReader_Posting_List(plist_reader, self->field, NULL)
+                             ? PListReader_Posting_List(plist_reader, ivars->field, NULL)
                              : NULL;
         if (!plist) {
             THROW(ERR, "Got a Lexicon but no PostingList for '%o' in '%o'",
-                  self->field, SegReader_Get_Seg_Name(reader));
+                  ivars->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);
-        run->lexicon  = lexicon;
-        run->plist    = plist;
-        run->doc_base = doc_base;
-        run->doc_map  = (I32Array*)INCREF(doc_map);
+            = PostPool_new(ivars->schema, ivars->snapshot, ivars->segment,
+                           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);
+        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);
     }
 }
 
 void
 PostPool_shrink(PostingPool *self) {
-    if (self->cache_max - self->cache_tick > 0) {
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    if (ivars->cache_max - ivars->cache_tick > 0) {
         size_t cache_count = PostPool_Cache_Count(self);
         size_t size        = cache_count * sizeof(Obj*);
-        if (self->cache_tick > 0) {
-            Obj **start = ((Obj**)self->cache) + self->cache_tick;
-            memmove(self->cache, start, size);
+        if (ivars->cache_tick > 0) {
+            Obj **start = ((Obj**)ivars->cache) + ivars->cache_tick;
+            memmove(ivars->cache, start, size);
         }
-        self->cache      = (uint8_t*)REALLOCATE(self->cache, size);
-        self->cache_tick = 0;
-        self->cache_max  = cache_count;
-        self->cache_cap  = cache_count;
+        ivars->cache      = (uint8_t*)REALLOCATE(ivars->cache, size);
+        ivars->cache_tick = 0;
+        ivars->cache_max  = cache_count;
+        ivars->cache_cap  = cache_count;
     }
     else {
-        FREEMEM(self->cache);
-        self->cache      = NULL;
-        self->cache_tick = 0;
-        self->cache_max  = 0;
-        self->cache_cap  = 0;
+        FREEMEM(ivars->cache);
+        ivars->cache      = NULL;
+        ivars->cache_tick = 0;
+        ivars->cache_max  = 0;
+        ivars->cache_cap  = 0;
     }
-    self->scratch_cap = 0;
-    FREEMEM(self->scratch);
-    self->scratch = NULL;
+    ivars->scratch_cap = 0;
+    FREEMEM(ivars->scratch);
+    ivars->scratch = NULL;
 
     // It's not necessary to iterate over the runs, because they don't have
     // any cache costs until Refill() gets called.
@@ -282,42 +290,45 @@ PostPool_shrink(PostingPool *self) {
 
 void
 PostPool_flush(PostingPool *self) {
+    PostingPoolIVARS *const ivars = PostPool_IVARS(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);
+        = PostPool_new(ivars->schema, ivars->snapshot, ivars->segment,
+                       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(self->schema, self->snapshot,
-                                            self->segment, self->polyreader,
-                                            self->post_temp_out);
+        = (PostingWriter*)RawPostWriter_new(ivars->schema, ivars->snapshot,
+                                            ivars->segment, ivars->polyreader,
+                                            ivars->post_temp_out);
 
     // Borrow the cache.
-    run->cache      = self->cache;
-    run->cache_tick = self->cache_tick;
-    run->cache_max  = self->cache_max;
-    run->cache_cap  = self->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(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);
+    LexWriter_Enter_Temp_Mode(ivars->lex_writer, ivars->field,
+                              ivars->lex_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(self->lex_temp_out);
-    run->post_end = OutStream_Tell(self->post_temp_out);
-    LexWriter_Leave_Temp_Mode(self->lex_writer);
+    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.
@@ -328,38 +339,46 @@ PostPool_flush(PostingPool *self) {
 
 void
 PostPool_finish(PostingPool *self) {
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+
     // Bail if there's no data.
     if (!PostPool_Peek(self)) { return; }
 
-    Similarity *sim = Schema_Fetch_Sim(self->schema, self->field);
+    Similarity *sim = Schema_Fetch_Sim(ivars->schema, ivars->field);
     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);
+        = Sim_Make_Posting_Writer(sim, ivars->schema, ivars->snapshot,
+                                  ivars->segment, ivars->polyreader,
+                                  ivars->field_num);
+    LexWriter_Start_Field(ivars->lex_writer, ivars->field_num);
+    S_write_terms_and_postings(self, post_writer, ivars->skip_out);
+    LexWriter_Finish_Field(ivars->lex_writer, ivars->field_num);
     DECREF(post_writer);
 }
 
 static void
 S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
                            OutStream *skip_stream) {
-    TermInfo      *const tinfo          = TInfo_new(0);
-    TermInfo      *const skip_tinfo     = TInfo_new(0);
-    CharBuf       *const last_term_text = CB_new(0);
-    LexiconWriter *const lex_writer     = self->lex_writer;
-    SkipStepper   *const skip_stepper   = self->skip_stepper;
-    int32_t        last_skip_doc        = 0;
-    int64_t        last_skip_filepos    = 0;
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    TermInfo      *const tinfo            = TInfo_new(0);
+    TermInfo      *const skip_tinfo       = TInfo_new(0);
+    TermInfoIVARS *const tinfo_ivars      = TInfo_IVARS(tinfo);
+    TermInfoIVARS *const skip_tinfo_ivars = TInfo_IVARS(skip_tinfo);
+    CharBuf       *const last_term_text   = CB_new(0);
+    LexiconWriter *const lex_writer       = ivars->lex_writer;
+    SkipStepper   *const skip_stepper     = ivars->skip_stepper;
+    SkipStepperIVARS *const skip_stepper_ivars
+        = SkipStepper_IVARS(skip_stepper);
+    int32_t        last_skip_doc          = 0;
+    int64_t        last_skip_filepos      = 0;
     const int32_t  skip_interval
-        = Arch_Skip_Interval(Schema_Get_Architecture(self->schema));
+        = Arch_Skip_Interval(Schema_Get_Architecture(ivars->schema));
 
     // Prime heldover variables.
     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);
@@ -379,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;
             }
@@ -400,14 +420,14 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
             PostWriter_Start_Term(post_writer, tinfo);
 
             // Init skip data in preparation for the next term.
-            skip_stepper->doc_id  = 0;
-            skip_stepper->filepos = tinfo->post_filepos;
+            skip_stepper_ivars->doc_id  = 0;
+            skip_stepper_ivars->filepos = tinfo_ivars->post_filepos;
             last_skip_doc         = 0;
-            last_skip_filepos     = tinfo->post_filepos;
+            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);
         }
@@ -419,24 +439,24 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
         PostWriter_Write_Posting(post_writer, posting);
 
         // Doc freq lags by one iter.
-        tinfo->doc_freq++;
+        tinfo_ivars->doc_freq++;
 
         //  Write skip data.
         if (skip_stream != NULL
             && same_text_as_last
-            && tinfo->doc_freq % skip_interval == 0
-            && tinfo->doc_freq != 0
+            && tinfo_ivars->doc_freq % skip_interval == 0
+            && tinfo_ivars->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);
+            if (tinfo_ivars->doc_freq == skip_interval) {
+                tinfo_ivars->skip_filepos = OutStream_Tell(skip_stream);
             }
             // Write deltas.
-            last_skip_doc         = skip_stepper->doc_id;
-            last_skip_filepos     = skip_stepper->filepos;
-            skip_stepper->doc_id  = posting->doc_id;
+            last_skip_doc               = skip_stepper_ivars->doc_id;
+            last_skip_filepos           = skip_stepper_ivars->filepos;
+            skip_stepper_ivars->doc_id  = post_ivars->doc_id;
             PostWriter_Update_Skip_Info(post_writer, skip_tinfo);
-            skip_stepper->filepos = skip_tinfo->post_filepos;
+            skip_stepper_ivars->filepos = skip_tinfo_ivars->post_filepos;
             SkipStepper_Write_Record(skip_stepper, skip_stream,
                                      last_skip_doc, last_skip_filepos);
         }
@@ -448,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.
@@ -458,45 +479,45 @@ S_write_terms_and_postings(PostingPool *self, PostingWriter *post_writer,
 
 uint32_t
 PostPool_refill(PostingPool *self) {
-    Lexicon *const     lexicon     = self->lexicon;
-    PostingList *const plist       = self->plist;
-    I32Array    *const doc_map     = self->doc_map;
-    const uint32_t     mem_thresh  = self->mem_thresh;
-    const int32_t      doc_base    = self->doc_base;
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    Lexicon *const     lexicon     = ivars->lexicon;
+    PostingList *const plist       = ivars->plist;
+    I32Array    *const doc_map     = ivars->doc_map;
+    const uint32_t     mem_thresh  = ivars->mem_thresh;
+    const int32_t      doc_base    = ivars->doc_base;
     uint32_t           num_elems   = 0; // number of items recovered
-    MemoryPool        *mem_pool;
     CharBuf           *term_text   = NULL;
 
-    if (self->lexicon == NULL) { return 0; }
+    if (ivars->lexicon == NULL) { return 0; }
     else { term_text = (CharBuf*)Lex_Get_Term(lexicon); }
 
     // Make sure cache is empty.
-    if (self->cache_max - self->cache_tick > 0) {
+    if (ivars->cache_max - ivars->cache_tick > 0) {
         THROW(ERR, "Refill called but cache contains %u32 items",
-              self->cache_max - self->cache_tick);
+              ivars->cache_max - ivars->cache_tick);
     }
-    self->cache_max  = 0;
-    self->cache_tick = 0;
+    ivars->cache_max  = 0;
+    ivars->cache_tick = 0;
 
     // Ditch old MemoryPool and get another.
-    DECREF(self->mem_pool);
-    self->mem_pool = MemPool_new(0);
-    mem_pool       = self->mem_pool;
+    DECREF(ivars->mem_pool);
+    ivars->mem_pool = MemPool_new(0);
+    MemoryPool *const mem_pool = ivars->mem_pool;
+    MemoryPoolIVARS *const mem_pool_ivars = MemPool_IVARS(mem_pool);
 
-    while (1) {
-        RawPosting *raw_posting;
 
-        if (self->post_count == 0) {
+    while (1) {
+        if (ivars->post_count == 0) {
             // Read a term.
             if (Lex_Next(lexicon)) {
-                self->post_count = Lex_Doc_Freq(lexicon);
+                ivars->post_count = Lex_Doc_Freq(lexicon);
                 term_text = (CharBuf*)Lex_Get_Term(lexicon);
                 if (term_text && !Obj_Is_A((Obj*)term_text, CHARBUF)) {
                     THROW(ERR, "Only CharBuf terms are supported for now");
                 }
                 Posting *posting = PList_Get_Posting(plist);
                 Post_Set_Doc_ID(posting, doc_base);
-                self->last_doc_id = doc_base;
+                ivars->last_doc_id = doc_base;
             }
             // Bail if we've read everything in this run.
             else {
@@ -505,39 +526,40 @@ PostPool_refill(PostingPool *self) {
         }
 
         // Bail if we've hit the ceiling for this run's cache.
-        if (mem_pool->consumed >= mem_thresh && num_elems > 0) {
+        if (mem_pool_ivars->consumed >= mem_thresh && num_elems > 0) {
             break;
         }
 
         // Read a posting from the input stream.
-        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--;
+        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.
-        if (num_elems >= self->cache_cap) {
+        if (num_elems >= ivars->cache_cap) {
             size_t new_cap = Memory_oversize(num_elems + 1, sizeof(Obj*));
             PostPool_Grow_Cache(self, new_cap);
         }
-        Obj **cache = (Obj**)self->cache;
-        cache[num_elems] = (Obj*)raw_posting;
+        Obj **cache = (Obj**)ivars->cache;
+        cache[num_elems] = (Obj*)rawpost;
         num_elems++;
     }
 
     // Reset the cache array position and length; remember file pos.
-    self->cache_max   = num_elems;
-    self->cache_tick  = 0;
+    ivars->cache_max   = num_elems;
+    ivars->cache_tick  = 0;
 
     return num_elems;
 }
@@ -545,46 +567,48 @@ 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,
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    Post_Add_Inversion_To_Pool(ivars->posting, self, inversion, ivars->type,
                                doc_id, doc_boost, length_norm);
 }
 
 static void
 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;
+    PostingPoolIVARS *const ivars = PostPool_IVARS(self);
+    if (ivars->flipped) { THROW(ERR, "Can't Flip twice"); }
+    ivars->flipped = true;
 
     // Sort RawPostings in cache, if any.
     PostPool_Sort_Cache(self);
 
     // Bail if never flushed.
-    if (self->lex_end == 0) { return; }
+    if (ivars->lex_end == 0) { return; }
 
     // Get a Lexicon.
     CharBuf *lex_alias = CB_newf("%o-%i64-to-%i64",
                                  InStream_Get_Filename(lex_temp_in),
-                                 self->lex_start, self->lex_end);
+                                 ivars->lex_start, ivars->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);
+                                     lex_temp_in, lex_alias, ivars->lex_start,
+                                     ivars->lex_end - ivars->lex_start);
+    ivars->lexicon = (Lexicon*)RawLex_new(
+                        ivars->schema, ivars->field, lex_temp_in_dupe, 0,
+                        ivars->lex_end - ivars->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);
+                  ivars->post_start, ivars->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,
+        = InStream_Reopen(post_temp_in, post_alias, ivars->post_start,
+                          ivars->post_end - ivars->post_start);
+    ivars->plist
+        = (PostingList*)RawPList_new(ivars->schema, ivars->field,
                                      post_temp_in_dupe, 0,
-                                     self->post_end - self->post_start);
+                                     ivars->post_end - ivars->post_start);
     DECREF(post_alias);
     DECREF(post_temp_in_dupe);
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/RawLexicon.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/RawLexicon.c b/core/Lucy/Index/RawLexicon.c
index eef6eac..49e4e20 100644
--- a/core/Lucy/Index/RawLexicon.c
+++ b/core/Lucy/Index/RawLexicon.c
@@ -37,47 +37,52 @@ RawLex_init(RawLexicon *self, Schema *schema, const CharBuf *field,
             InStream *instream, int64_t start, int64_t end) {
     FieldType *type = Schema_Fetch_Type(schema, field);
     Lex_init((Lexicon*)self, field);
+    RawLexiconIVARS *const ivars = RawLex_IVARS(self);
 
     // Assign
-    self->start = start;
-    self->end   = end;
-    self->len   = end - start;
-    self->instream = (InStream*)INCREF(instream);
+    ivars->start = start;
+    ivars->end   = end;
+    ivars->len   = end - start;
+    ivars->instream = (InStream*)INCREF(instream);
 
     // Get ready to begin.
-    InStream_Seek(self->instream, self->start);
+    InStream_Seek(ivars->instream, ivars->start);
 
     // Get steppers.
-    self->term_stepper  = FType_Make_Term_Stepper(type);
-    self->tinfo_stepper = (TermStepper*)MatchTInfoStepper_new(schema);
+    ivars->term_stepper  = FType_Make_Term_Stepper(type);
+    ivars->tinfo_stepper = (TermStepper*)MatchTInfoStepper_new(schema);
 
     return self;
 }
 
 void
 RawLex_destroy(RawLexicon *self) {
-    DECREF(self->instream);
-    DECREF(self->term_stepper);
-    DECREF(self->tinfo_stepper);
+    RawLexiconIVARS *const ivars = RawLex_IVARS(self);
+    DECREF(ivars->instream);
+    DECREF(ivars->term_stepper);
+    DECREF(ivars->tinfo_stepper);
     SUPER_DESTROY(self, RAWLEXICON);
 }
 
 bool
 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);
+    RawLexiconIVARS *const ivars = RawLex_IVARS(self);
+    if (InStream_Tell(ivars->instream) >= ivars->len) { return false; }
+    TermStepper_Read_Delta(ivars->term_stepper, ivars->instream);
+    TermStepper_Read_Delta(ivars->tinfo_stepper, ivars->instream);
     return true;
 }
 
 Obj*
 RawLex_get_term(RawLexicon *self) {
-    return TermStepper_Get_Value(self->term_stepper);
+    RawLexiconIVARS *const ivars = RawLex_IVARS(self);
+    return TermStepper_Get_Value(ivars->term_stepper);
 }
 
 int32_t
 RawLex_doc_freq(RawLexicon *self) {
-    TermInfo *tinfo = (TermInfo*)TermStepper_Get_Value(self->tinfo_stepper);
+    RawLexiconIVARS *const ivars = RawLex_IVARS(self);
+    TermInfo *tinfo = (TermInfo*)TermStepper_Get_Value(ivars->tinfo_stepper);
     return tinfo ? TInfo_Get_Doc_Freq(tinfo) : 0;
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/RawPostingList.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/RawPostingList.c b/core/Lucy/Index/RawPostingList.c
index a22a015..9d5dd0a 100644
--- a/core/Lucy/Index/RawPostingList.c
+++ b/core/Lucy/Index/RawPostingList.c
@@ -36,32 +36,35 @@ RawPostingList*
 RawPList_init(RawPostingList *self, Schema *schema, const CharBuf *field,
               InStream *instream, int64_t start, int64_t end) {
     PList_init((PostingList*)self);
-    self->start     = start;
-    self->end       = end;
-    self->len       = end - start;
-    self->instream  = (InStream*)INCREF(instream);
-    Similarity *sim = Schema_Fetch_Sim(schema, field);
-    self->posting   = Sim_Make_Posting(sim);
-    InStream_Seek(self->instream, self->start);
+    RawPostingListIVARS *const ivars = RawPList_IVARS(self);
+    ivars->start     = start;
+    ivars->end       = end;
+    ivars->len       = end - start;
+    ivars->instream  = (InStream*)INCREF(instream);
+    Similarity *sim  = Schema_Fetch_Sim(schema, field);
+    ivars->posting   = Sim_Make_Posting(sim);
+    InStream_Seek(ivars->instream, ivars->start);
     return self;
 }
 
 void
 RawPList_destroy(RawPostingList *self) {
-    DECREF(self->instream);
-    DECREF(self->posting);
+    RawPostingListIVARS *const ivars = RawPList_IVARS(self);
+    DECREF(ivars->instream);
+    DECREF(ivars->posting);
     SUPER_DESTROY(self, RAWPOSTINGLIST);
 }
 
 Posting*
 RawPList_get_posting(RawPostingList *self) {
-    return self->posting;
+    return RawPList_IVARS(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,
+    RawPostingListIVARS *const ivars = RawPList_IVARS(self);
+    return Post_Read_Raw(ivars->posting, ivars->instream,
                          last_doc_id, term_text, mem_pool);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/SegLexicon.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SegLexicon.c b/core/Lucy/Index/SegLexicon.c
index 06704f2..3a6523f 100644
--- a/core/Lucy/Index/SegLexicon.c
+++ b/core/Lucy/Index/SegLexicon.c
@@ -58,6 +58,7 @@ SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
     CharBuf *filename = CB_newf("%o/lexicon-%i32.dat", seg_name, field_num);
 
     Lex_init((Lexicon*)self, field);
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
 
     // Check format.
     if (!format) { THROW(ERR, "Missing 'format'"); }
@@ -72,19 +73,19 @@ SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
     if (!counts) { THROW(ERR, "Failed to extract 'counts'"); }
     else {
         Obj *count = CERTIFY(Hash_Fetch(counts, (Obj*)field), OBJ);
-        self->size = (int32_t)Obj_To_I64(count);
+        ivars->size = (int32_t)Obj_To_I64(count);
     }
 
     // Assign.
-    self->segment        = (Segment*)INCREF(segment);
+    ivars->segment        = (Segment*)INCREF(segment);
 
     // Derive.
-    self->lex_index      = LexIndex_new(schema, folder, segment, field);
-    self->field_num      = field_num;
-    self->index_interval = Arch_Index_Interval(arch);
-    self->skip_interval  = Arch_Skip_Interval(arch);
-    self->instream       = Folder_Open_In(folder, filename);
-    if (!self->instream) {
+    ivars->lex_index      = LexIndex_new(schema, folder, segment, field);
+    ivars->field_num      = field_num;
+    ivars->index_interval = Arch_Index_Interval(arch);
+    ivars->skip_interval  = Arch_Skip_Interval(arch);
+    ivars->instream       = Folder_Open_In(folder, filename);
+    if (!ivars->instream) {
         Err *error = (Err*)INCREF(Err_get_error());
         DECREF(filename);
         DECREF(self);
@@ -93,28 +94,30 @@ SegLex_init(SegLexicon *self, Schema *schema, Folder *folder,
     DECREF(filename);
 
     // Define the term_num as "not yet started".
-    self->term_num = -1;
+    ivars->term_num = -1;
 
     // Get steppers.
-    self->term_stepper  = FType_Make_Term_Stepper(type);
-    self->tinfo_stepper = (TermStepper*)MatchTInfoStepper_new(schema);
+    ivars->term_stepper  = FType_Make_Term_Stepper(type);
+    ivars->tinfo_stepper = (TermStepper*)MatchTInfoStepper_new(schema);
 
     return self;
 }
 
 void
 SegLex_destroy(SegLexicon *self) {
-    DECREF(self->segment);
-    DECREF(self->term_stepper);
-    DECREF(self->tinfo_stepper);
-    DECREF(self->lex_index);
-    DECREF(self->instream);
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
+    DECREF(ivars->segment);
+    DECREF(ivars->term_stepper);
+    DECREF(ivars->tinfo_stepper);
+    DECREF(ivars->lex_index);
+    DECREF(ivars->instream);
     SUPER_DESTROY(self, SEGLEXICON);
 }
 
 void
 SegLex_seek(SegLexicon *self, Obj *target) {
-    LexIndex *const lex_index = self->lex_index;
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
+    LexIndex *const lex_index = ivars->lex_index;
 
     // Reset upon null term.
     if (target == NULL) {
@@ -126,13 +129,13 @@ SegLex_seek(SegLexicon *self, Obj *target) {
     LexIndex_Seek(lex_index, target);
     TermInfo *target_tinfo = LexIndex_Get_Term_Info(lex_index);
     TermInfo *my_tinfo
-        = (TermInfo*)TermStepper_Get_Value(self->tinfo_stepper);
+        = (TermInfo*)TermStepper_Get_Value(ivars->tinfo_stepper);
     Obj *lex_index_term = Obj_Clone(LexIndex_Get_Term(lex_index));
     TInfo_Mimic(my_tinfo, (Obj*)target_tinfo);
-    TermStepper_Set_Value(self->term_stepper, lex_index_term);
+    TermStepper_Set_Value(ivars->term_stepper, lex_index_term);
     DECREF(lex_index_term);
-    InStream_Seek(self->instream, TInfo_Get_Lex_FilePos(target_tinfo));
-    self->term_num = LexIndex_Get_Term_Num(lex_index);
+    InStream_Seek(ivars->instream, TInfo_Get_Lex_FilePos(target_tinfo));
+    ivars->term_num = LexIndex_Get_Term_Num(lex_index);
 
     // Scan to the precise location.
     S_scan_to(self, target);
@@ -140,59 +143,67 @@ SegLex_seek(SegLexicon *self, Obj *target) {
 
 void
 SegLex_reset(SegLexicon* self) {
-    self->term_num = -1;
-    InStream_Seek(self->instream, 0);
-    TermStepper_Reset(self->term_stepper);
-    TermStepper_Reset(self->tinfo_stepper);
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
+    ivars->term_num = -1;
+    InStream_Seek(ivars->instream, 0);
+    TermStepper_Reset(ivars->term_stepper);
+    TermStepper_Reset(ivars->tinfo_stepper);
 }
 
 int32_t
 SegLex_get_field_num(SegLexicon *self) {
-    return self->field_num;
+    return SegLex_IVARS(self)->field_num;
 }
 
 Obj*
 SegLex_get_term(SegLexicon *self) {
-    return TermStepper_Get_Value(self->term_stepper);
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
+    return TermStepper_Get_Value(ivars->term_stepper);
 }
 
 int32_t
 SegLex_doc_freq(SegLexicon *self) {
-    TermInfo *tinfo = (TermInfo*)TermStepper_Get_Value(self->tinfo_stepper);
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
+    TermInfo *tinfo = (TermInfo*)TermStepper_Get_Value(ivars->tinfo_stepper);
     return tinfo ? TInfo_Get_Doc_Freq(tinfo) : 0;
 }
 
 TermInfo*
 SegLex_get_term_info(SegLexicon *self) {
-    return (TermInfo*)TermStepper_Get_Value(self->tinfo_stepper);
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
+    return (TermInfo*)TermStepper_Get_Value(ivars->tinfo_stepper);
 }
 
 Segment*
 SegLex_get_segment(SegLexicon *self) {
-    return self->segment;
+    return SegLex_IVARS(self)->segment;
 }
 
 bool
 SegLex_next(SegLexicon *self) {
+    SegLexiconIVARS *const ivars = SegLex_IVARS(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
-        TermStepper_Reset(self->term_stepper);
-        TermStepper_Reset(self->tinfo_stepper);
+    if (++ivars->term_num >= ivars->size) {
+        ivars->term_num = ivars->size; // don't keep growing
+        TermStepper_Reset(ivars->term_stepper);
+        TermStepper_Reset(ivars->tinfo_stepper);
         return false;
     }
 
     // Read next term/terminfo.
-    TermStepper_Read_Delta(self->term_stepper, self->instream);
-    TermStepper_Read_Delta(self->tinfo_stepper, self->instream);
+    TermStepper_Read_Delta(ivars->term_stepper, ivars->instream);
+    TermStepper_Read_Delta(ivars->tinfo_stepper, ivars->instream);
 
     return true;
 }
 
 static void
 S_scan_to(SegLexicon *self, Obj *target) {
+    SegLexiconIVARS *const ivars = SegLex_IVARS(self);
+
     // (mildly evil encapsulation violation, since value can be null)
-    Obj *current = TermStepper_Get_Value(self->term_stepper);
+    Obj *current = TermStepper_Get_Value(ivars->term_stepper);
     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));
@@ -201,7 +212,7 @@ S_scan_to(SegLexicon *self, Obj *target) {
     // Keep looping until the term text is ge target.
     do {
         const int32_t comparison = Obj_Compare_To(current, target);
-        if (comparison >= 0 &&  self->term_num != -1) { break; }
+        if (comparison >= 0 && ivars->term_num != -1) { break; }
     } while (SegLex_Next(self));
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/SegPostingList.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SegPostingList.c b/core/Lucy/Index/SegPostingList.c
index ae9122e..bebd52d 100644
--- a/core/Lucy/Index/SegPostingList.c
+++ b/core/Lucy/Index/SegPostingList.c
@@ -51,6 +51,7 @@ SegPList_new(PostingListReader *plist_reader, const CharBuf *field) {
 SegPostingList*
 SegPList_init(SegPostingList *self, PostingListReader *plist_reader,
               const CharBuf *field) {
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
     Schema       *const schema   = PListReader_Get_Schema(plist_reader);
     Folder       *const folder   = PListReader_Get_Folder(plist_reader);
     Segment      *const segment  = PListReader_Get_Segment(plist_reader);
@@ -62,36 +63,36 @@ SegPList_init(SegPostingList *self, PostingListReader *plist_reader,
     CharBuf      *skip_file      = CB_newf("%o/postings.skip", seg_name);
 
     // Init.
-    self->doc_freq        = 0;
-    self->count           = 0;
+    ivars->doc_freq        = 0;
+    ivars->count           = 0;
 
     // Init skipping vars.
-    self->skip_stepper    = SkipStepper_new();
-    self->skip_count      = 0;
-    self->num_skips       = 0;
+    ivars->skip_stepper    = SkipStepper_new();
+    ivars->skip_count      = 0;
+    ivars->num_skips       = 0;
 
     // Assign.
-    self->plist_reader    = (PostingListReader*)INCREF(plist_reader);
-    self->field           = CB_Clone(field);
-    self->skip_interval   = Arch_Skip_Interval(arch);
+    ivars->plist_reader    = (PostingListReader*)INCREF(plist_reader);
+    ivars->field           = CB_Clone(field);
+    ivars->skip_interval   = Arch_Skip_Interval(arch);
 
     // Derive.
-    Similarity *sim = Schema_Fetch_Sim(schema, field);
-    self->posting   = Sim_Make_Posting(sim);
-    self->field_num = field_num;
+    Similarity *sim  = Schema_Fetch_Sim(schema, field);
+    ivars->posting   = Sim_Make_Posting(sim);
+    ivars->field_num = field_num;
 
     // Open both a main stream and a skip stream if the field exists.
     if (Folder_Exists(folder, post_file)) {
-        self->post_stream = Folder_Open_In(folder, post_file);
-        if (!self->post_stream) {
+        ivars->post_stream = Folder_Open_In(folder, post_file);
+        if (!ivars->post_stream) {
             Err *error = (Err*)INCREF(Err_get_error());
             DECREF(post_file);
             DECREF(skip_file);
             DECREF(self);
             RETHROW(error);
         }
-        self->skip_stream = Folder_Open_In(folder, skip_file);
-        if (!self->skip_stream) {
+        ivars->skip_stream = Folder_Open_In(folder, skip_file);
+        if (!ivars->skip_stream) {
             Err *error = (Err*)INCREF(Err_get_error());
             DECREF(post_file);
             DECREF(skip_file);
@@ -101,8 +102,8 @@ SegPList_init(SegPostingList *self, PostingListReader *plist_reader,
     }
     else {
         //  Empty, so don't bother with these.
-        self->post_stream = NULL;
-        self->skip_stream = NULL;
+        ivars->post_stream = NULL;
+        ivars->skip_stream = NULL;
     }
     DECREF(post_file);
     DECREF(skip_file);
@@ -112,16 +113,17 @@ SegPList_init(SegPostingList *self, PostingListReader *plist_reader,
 
 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);
-        DECREF(self->post_stream);
-        DECREF(self->skip_stream);
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    DECREF(ivars->plist_reader);
+    DECREF(ivars->posting);
+    DECREF(ivars->skip_stepper);
+    DECREF(ivars->field);
+
+    if (ivars->post_stream != NULL) {
+        InStream_Close(ivars->post_stream);
+        InStream_Close(ivars->skip_stream);
+        DECREF(ivars->post_stream);
+        DECREF(ivars->skip_stream);
     }
 
     SUPER_DESTROY(self, SEGPOSTINGLIST);
@@ -129,56 +131,61 @@ SegPList_destroy(SegPostingList *self) {
 
 Posting*
 SegPList_get_posting(SegPostingList *self) {
-    return self->posting;
+    return SegPList_IVARS(self)->posting;
 }
 
 uint32_t
 SegPList_get_doc_freq(SegPostingList *self) {
-    return self->doc_freq;
+    return SegPList_IVARS(self)->doc_freq;
 }
 
 int32_t
 SegPList_get_doc_id(SegPostingList *self) {
-    return self->posting->doc_id;
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    return Post_IVARS(ivars->posting)->doc_id;
 }
 
 uint32_t
 SegPList_get_count(SegPostingList *self) {
-    return self->count;
+    return SegPList_IVARS(self)->count;
 }
 
 InStream*
 SegPList_get_post_stream(SegPostingList *self) {
-    return self->post_stream;
+    return SegPList_IVARS(self)->post_stream;
 }
 
 int32_t
 SegPList_next(SegPostingList *self) {
-    InStream *const post_stream = self->post_stream;
-    Posting  *const posting     = self->posting;
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    InStream *const post_stream = ivars->post_stream;
+    Posting  *const posting     = ivars->posting;
 
     // Bail if we're out of docs.
-    if (self->count >= self->doc_freq) {
+    if (ivars->count >= ivars->doc_freq) {
         Post_Reset(posting);
         return 0;
     }
-    self->count++;
+    ivars->count++;
 
     Post_Read_Record(posting, post_stream);
 
-    return posting->doc_id;
+    return Post_IVARS(posting)->doc_id;
 }
 
 int32_t
 SegPList_advance(SegPostingList *self, int32_t target) {
-    Posting *posting          = self->posting;
-    const uint32_t skip_interval = self->skip_interval;
-
-    if (self->doc_freq >= skip_interval) {
-        InStream *post_stream           = self->post_stream;
-        InStream *skip_stream           = self->skip_stream;
-        SkipStepper *const skip_stepper = self->skip_stepper;
-        uint32_t new_doc_id             = skip_stepper->doc_id;
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    PostingIVARS *const posting_ivars = Post_IVARS(ivars->posting);
+    const uint32_t skip_interval = ivars->skip_interval;
+
+    if (ivars->doc_freq >= skip_interval) {
+        InStream *post_stream           = ivars->post_stream;
+        InStream *skip_stream           = ivars->skip_stream;
+        SkipStepper *const skip_stepper = ivars->skip_stepper;
+        SkipStepperIVARS *const skip_stepper_ivars
+            = SkipStepper_IVARS(skip_stepper);
+        uint32_t new_doc_id             = skip_stepper_ivars->doc_id;
         int64_t new_filepos             = InStream_Tell(post_stream);
 
         /* Assuming the default skip_interval of 16...
@@ -188,28 +195,28 @@ SegPList_advance(SegPostingList *self, int32_t target) {
          * yet, but we'll have already gone past 5 of the 16 skip docs --
          * ergo, the modulus in the following formula.
          */
-        int32_t num_skipped = 0 - (self->count % skip_interval);
-        if (num_skipped == 0 && self->count != 0) {
+        int32_t num_skipped = 0 - (ivars->count % skip_interval);
+        if (num_skipped == 0 && ivars->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;
+        while (target > skip_stepper_ivars->doc_id) {
+            new_doc_id  = skip_stepper_ivars->doc_id;
+            new_filepos = skip_stepper_ivars->filepos;
 
-            if (skip_stepper->doc_id != 0
-                && skip_stepper->doc_id >= posting->doc_id
+            if (skip_stepper_ivars->doc_id != 0
+                && skip_stepper_ivars->doc_id >= posting_ivars->doc_id
                ) {
                 num_skipped += skip_interval;
             }
 
-            if (self->skip_count >= self->num_skips) {
+            if (ivars->skip_count >= ivars->num_skips) {
                 break;
             }
 
             SkipStepper_Read_Record(skip_stepper, skip_stream);
-            self->skip_count++;
+            ivars->skip_count++;
         }
 
         // If we found something to skip, skip it.
@@ -219,10 +226,10 @@ SegPList_advance(SegPostingList *self, int32_t target) {
             InStream_Seek(post_stream, new_filepos);
 
             // Jump to the new doc id.
-            posting->doc_id = new_doc_id;
+            posting_ivars->doc_id = new_doc_id;
 
             // Increase count by the number of docs we skipped over.
-            self->count += num_skipped;
+            ivars->count += num_skipped;
         }
     }
 
@@ -237,22 +244,25 @@ SegPList_advance(SegPostingList *self, int32_t target) {
 
 void
 SegPList_seek(SegPostingList *self, Obj *target) {
-    LexiconReader *lex_reader = PListReader_Get_Lex_Reader(self->plist_reader);
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    LexiconReader *lex_reader = PListReader_Get_Lex_Reader(ivars->plist_reader);
     TermInfo      *tinfo      = LexReader_Fetch_Term_Info(lex_reader,
-                                                          self->field, target);
+                                                          ivars->field, target);
     S_seek_tinfo(self, tinfo);
     DECREF(tinfo);
 }
 
 void
 SegPList_seek_lex(SegPostingList *self, Lexicon *lexicon) {
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+
     // 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
+            == PListReader_Get_Segment(ivars->plist_reader)) // i.e. same segment
        ) {
         S_seek_tinfo(self, SegLex_Get_Term_Info(seg_lexicon));
     }
@@ -266,40 +276,43 @@ SegPList_seek_lex(SegPostingList *self, Lexicon *lexicon) {
 
 static void
 S_seek_tinfo(SegPostingList *self, TermInfo *tinfo) {
-    self->count = 0;
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    ivars->count = 0;
 
     if (tinfo == NULL) {
         // Next will return false; other methods invalid now.
-        self->doc_freq = 0;
+        ivars->doc_freq = 0;
     }
     else {
         // Transfer doc_freq, seek main stream.
         int64_t post_filepos = TInfo_Get_Post_FilePos(tinfo);
-        self->doc_freq       = TInfo_Get_Doc_Freq(tinfo);
-        InStream_Seek(self->post_stream, post_filepos);
+        ivars->doc_freq      = TInfo_Get_Doc_Freq(tinfo);
+        InStream_Seek(ivars->post_stream, post_filepos);
 
         // Prepare posting.
-        Post_Reset(self->posting);
+        Post_Reset(ivars->posting);
 
         // Prepare to skip.
-        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));
+        ivars->skip_count = 0;
+        ivars->num_skips  = ivars->doc_freq / ivars->skip_interval;
+        SkipStepper_Set_ID_And_Filepos(ivars->skip_stepper, 0, post_filepos);
+        InStream_Seek(ivars->skip_stream, TInfo_Get_Skip_FilePos(tinfo));
     }
 }
 
 Matcher*
 SegPList_make_matcher(SegPostingList *self, Similarity *sim,
                       Compiler *compiler, bool need_score) {
-    return Post_Make_Matcher(self->posting, sim, (PostingList*)self, compiler,
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    return Post_Make_Matcher(ivars->posting, sim, (PostingList*)self, compiler,
                              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,
+    SegPostingListIVARS *const ivars = SegPList_IVARS(self);
+    return Post_Read_Raw(ivars->posting, ivars->post_stream,
                          last_doc_id, term_text, mem_pool);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/SegReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SegReader.c b/core/Lucy/Index/SegReader.c
index ad803b2..e9a1ba6 100644
--- a/core/Lucy/Index/SegReader.c
+++ b/core/Lucy/Index/SegReader.c
@@ -47,11 +47,12 @@ SegReader_init(SegReader *self, Schema *schema, Folder *folder,
 
     IxReader_init((IndexReader*)self, schema, folder, snapshot, segments,
                   seg_tick, NULL);
+    SegReaderIVARS *const ivars = SegReader_IVARS(self);
     segment = SegReader_Get_Segment(self);
 
-    self->doc_max    = (int32_t)Seg_Get_Count(segment);
-    self->seg_name   = (CharBuf*)INCREF(Seg_Get_Name(segment));
-    self->seg_num    = Seg_Get_Number(segment);
+    ivars->doc_max    = (int32_t)Seg_Get_Count(segment);
+    ivars->seg_name   = (CharBuf*)INCREF(Seg_Get_Name(segment));
+    ivars->seg_num    = Seg_Get_Number(segment);
     Err *error = Err_trap(S_try_init_components, self);
     if (error) {
         // An error occurred, so clean up self and rethrow the exception.
@@ -61,8 +62,8 @@ SegReader_init(SegReader *self, Schema *schema, Folder *folder,
 
     DeletionsReader *del_reader
         = (DeletionsReader*)Hash_Fetch(
-              self->components, (Obj*)VTable_Get_Name(DELETIONSREADER));
-    self->del_count = del_reader ? DelReader_Del_Count(del_reader) : 0;
+              ivars->components, (Obj*)VTable_Get_Name(DELETIONSREADER));
+    ivars->del_count = del_reader ? DelReader_Del_Count(del_reader) : 0;
 
     return self;
 }
@@ -77,43 +78,46 @@ S_try_init_components(void *context) {
 
 void
 SegReader_destroy(SegReader *self) {
-    DECREF(self->seg_name);
+    SegReaderIVARS *const ivars = SegReader_IVARS(self);
+    DECREF(ivars->seg_name);
     SUPER_DESTROY(self, SEGREADER);
 }
 
 void
 SegReader_register(SegReader *self, const CharBuf *api,
                    DataReader *component) {
-    if (Hash_Fetch(self->components, (Obj*)api)) {
+    SegReaderIVARS *const ivars = SegReader_IVARS(self);
+    if (Hash_Fetch(ivars->components, (Obj*)api)) {
         THROW(ERR, "Interface '%o' already registered");
     }
     CERTIFY(component, DATAREADER);
-    Hash_Store(self->components, (Obj*)api, (Obj*)component);
+    Hash_Store(ivars->components, (Obj*)api, (Obj*)component);
 }
 
 CharBuf*
 SegReader_get_seg_name(SegReader *self) {
-    return self->seg_name;
+    return SegReader_IVARS(self)->seg_name;
 }
 
 int64_t
 SegReader_get_seg_num(SegReader *self) {
-    return self->seg_num;
+    return SegReader_IVARS(self)->seg_num;
 }
 
 int32_t
 SegReader_del_count(SegReader *self) {
-    return self->del_count;
+    return SegReader_IVARS(self)->del_count;
 }
 
 int32_t
 SegReader_doc_max(SegReader *self) {
-    return self->doc_max;
+    return SegReader_IVARS(self)->doc_max;
 }
 
 int32_t
 SegReader_doc_count(SegReader *self) {
-    return self->doc_max - self->del_count;
+    SegReaderIVARS *const ivars = SegReader_IVARS(self);
+    return ivars->doc_max - ivars->del_count;
 }
 
 I32Array*

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/SegWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SegWriter.c b/core/Lucy/Index/SegWriter.c
index 02fe391..6280664 100644
--- a/core/Lucy/Index/SegWriter.c
+++ b/core/Lucy/Index/SegWriter.c
@@ -42,46 +42,52 @@ SegWriter_init(SegWriter *self, Schema *schema, Snapshot *snapshot,
                Segment *segment, PolyReader *polyreader) {
     Architecture *arch   = Schema_Get_Architecture(schema);
     DataWriter_init((DataWriter*)self, schema, snapshot, segment, polyreader);
-    self->by_api   = Hash_new(0);
-    self->inverter = Inverter_new(schema, segment);
-    self->writers  = VA_new(16);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    ivars->by_api   = Hash_new(0);
+    ivars->inverter = Inverter_new(schema, segment);
+    ivars->writers  = VA_new(16);
     Arch_Init_Seg_Writer(arch, self);
     return self;
 }
 
 void
 SegWriter_destroy(SegWriter *self) {
-    DECREF(self->inverter);
-    DECREF(self->writers);
-    DECREF(self->by_api);
-    DECREF(self->del_writer);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    DECREF(ivars->inverter);
+    DECREF(ivars->writers);
+    DECREF(ivars->by_api);
+    DECREF(ivars->del_writer);
     SUPER_DESTROY(self, SEGWRITER);
 }
 
 void
 SegWriter_register(SegWriter *self, const CharBuf *api,
                    DataWriter *component) {
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
     CERTIFY(component, DATAWRITER);
-    if (Hash_Fetch(self->by_api, (Obj*)api)) {
+    if (Hash_Fetch(ivars->by_api, (Obj*)api)) {
         THROW(ERR, "API %o already registered", api);
     }
-    Hash_Store(self->by_api, (Obj*)api, (Obj*)component);
+    Hash_Store(ivars->by_api, (Obj*)api, (Obj*)component);
 }
 
 Obj*
 SegWriter_fetch(SegWriter *self, const CharBuf *api) {
-    return Hash_Fetch(self->by_api, (Obj*)api);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    return Hash_Fetch(ivars->by_api, (Obj*)api);
 }
 
 void
 SegWriter_add_writer(SegWriter *self, DataWriter *writer) {
-    VA_Push(self->writers, (Obj*)writer);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    VA_Push(ivars->writers, (Obj*)writer);
 }
 
 void
 SegWriter_prep_seg_dir(SegWriter *self) {
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
     Folder  *folder   = SegWriter_Get_Folder(self);
-    CharBuf *seg_name = Seg_Get_Name(self->segment);
+    CharBuf *seg_name = Seg_Get_Name(ivars->segment);
 
     // Clear stale segment files from crashed indexing sessions.
     if (Folder_Exists(folder, seg_name)) {
@@ -98,17 +104,19 @@ SegWriter_prep_seg_dir(SegWriter *self) {
 
 void
 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);
-    SegWriter_Add_Inverted_Doc(self, self->inverter, doc_id);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    int32_t doc_id = (int32_t)Seg_Increment_Count(ivars->segment, 1);
+    Inverter_Invert_Doc(ivars->inverter, doc);
+    Inverter_Set_Boost(ivars->inverter, boost);
+    SegWriter_Add_Inverted_Doc(self, ivars->inverter, doc_id);
 }
 
 void
 SegWriter_add_inverted_doc(SegWriter *self, Inverter *inverter,
                            int32_t doc_id) {
-    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
-        DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->writers); i < max; i++) {
+        DataWriter *writer = (DataWriter*)VA_Fetch(ivars->writers, i);
         DataWriter_Add_Inverted_Doc(writer, inverter, doc_id);
     }
 }
@@ -118,24 +126,27 @@ SegWriter_add_inverted_doc(SegWriter *self, Inverter *inverter,
 // probably out of sync.
 static void
 S_adjust_doc_id(SegWriter *self, SegReader *reader, I32Array *doc_map) {
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
     uint32_t doc_count = SegReader_Doc_Max(reader);
     for (uint32_t i = 1, max = I32Arr_Get_Size(doc_map); i < max; i++) {
         if (I32Arr_Get(doc_map, i) == 0) { doc_count--; }
     }
-    Seg_Increment_Count(self->segment, doc_count);
+    Seg_Increment_Count(ivars->segment, doc_count);
 }
 
 void
 SegWriter_add_segment(SegWriter *self, SegReader *reader, I32Array *doc_map) {
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+
     // Bulk add the slab of documents to the various writers.
-    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
-        DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->writers); i < max; i++) {
+        DataWriter *writer = (DataWriter*)VA_Fetch(ivars->writers, i);
         DataWriter_Add_Segment(writer, reader, doc_map);
     }
 
     // Bulk add the segment to the DeletionsWriter, so that it can merge
     // previous segment files as necessary.
-    DelWriter_Add_Segment(self->del_writer, reader, doc_map);
+    DelWriter_Add_Segment(ivars->del_writer, reader, doc_map);
 
     // Adust the document id.
     S_adjust_doc_id(self, reader, doc_map);
@@ -144,15 +155,16 @@ SegWriter_add_segment(SegWriter *self, SegReader *reader, I32Array *doc_map) {
 void
 SegWriter_merge_segment(SegWriter *self, SegReader *reader,
                         I32Array *doc_map) {
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
     Snapshot *snapshot = SegWriter_Get_Snapshot(self);
     CharBuf  *seg_name = Seg_Get_Name(SegReader_Get_Segment(reader));
 
     // Have all the sub-writers merge the segment.
-    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
-        DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->writers); i < max; i++) {
+        DataWriter *writer = (DataWriter*)VA_Fetch(ivars->writers, i);
         DataWriter_Merge_Segment(writer, reader, doc_map);
     }
-    DelWriter_Merge_Segment(self->del_writer, reader, doc_map);
+    DelWriter_Merge_Segment(ivars->del_writer, reader, doc_map);
 
     // Remove seg directory from snapshot.
     Snapshot_Delete_Entry(snapshot, seg_name);
@@ -163,15 +175,16 @@ SegWriter_merge_segment(SegWriter *self, SegReader *reader,
 
 void
 SegWriter_delete_segment(SegWriter *self, SegReader *reader) {
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
     Snapshot *snapshot = SegWriter_Get_Snapshot(self);
     CharBuf  *seg_name = Seg_Get_Name(SegReader_Get_Segment(reader));
 
     // Have all the sub-writers delete the segment.
-    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
-        DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->writers); i < max; i++) {
+        DataWriter *writer = (DataWriter*)VA_Fetch(ivars->writers, i);
         DataWriter_Delete_Segment(writer, reader);
     }
-    DelWriter_Delete_Segment(self->del_writer, reader);
+    DelWriter_Delete_Segment(ivars->del_writer, reader);
 
     // Remove seg directory from snapshot.
     Snapshot_Delete_Entry(snapshot, seg_name);
@@ -179,39 +192,42 @@ SegWriter_delete_segment(SegWriter *self, SegReader *reader) {
 
 void
 SegWriter_finish(SegWriter *self) {
-    CharBuf *seg_name = Seg_Get_Name(self->segment);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    CharBuf *seg_name = Seg_Get_Name(ivars->segment);
 
     // Finish off children.
-    for (uint32_t i = 0, max = VA_Get_Size(self->writers); i < max; i++) {
-        DataWriter *writer = (DataWriter*)VA_Fetch(self->writers, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->writers); i < max; i++) {
+        DataWriter *writer = (DataWriter*)VA_Fetch(ivars->writers, i);
         DataWriter_Finish(writer);
     }
 
     // Write segment metadata and add the segment directory to the snapshot.
     Snapshot *snapshot = SegWriter_Get_Snapshot(self);
     CharBuf *segmeta_filename = CB_newf("%o/segmeta.json", seg_name);
-    Seg_Write_File(self->segment, self->folder);
+    Seg_Write_File(ivars->segment, ivars->folder);
     Snapshot_Add_Entry(snapshot, seg_name);
     DECREF(segmeta_filename);
 
     // Collapse segment files into compound file.
-    Folder_Consolidate(self->folder, seg_name);
+    Folder_Consolidate(ivars->folder, seg_name);
 }
 
 void
 SegWriter_add_data_writer(SegWriter *self, DataWriter *writer) {
-    VA_Push(self->writers, (Obj*)writer);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    VA_Push(ivars->writers, (Obj*)writer);
 }
 
 void
 SegWriter_set_del_writer(SegWriter *self, DeletionsWriter *del_writer) {
-    DECREF(self->del_writer);
-    self->del_writer = (DeletionsWriter*)INCREF(del_writer);
+    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
+    DECREF(ivars->del_writer);
+    ivars->del_writer = (DeletionsWriter*)INCREF(del_writer);
 }
 
 DeletionsWriter*
 SegWriter_get_del_writer(SegWriter *self) {
-    return self->del_writer;
+    return SegWriter_IVARS(self)->del_writer;
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/Segment.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Segment.c b/core/Lucy/Index/Segment.c
index 69365ed..ddcebee 100644
--- a/core/Lucy/Index/Segment.c
+++ b/core/Lucy/Index/Segment.c
@@ -33,23 +33,25 @@ Seg_new(int64_t number) {
 
 Segment*
 Seg_init(Segment *self, int64_t number) {
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+
     // Validate.
     if (number < 0) { THROW(ERR, "Segment number %i64 less than 0", number); }
 
     // Init.
-    self->metadata  = Hash_new(0);
-    self->count     = 0;
-    self->by_num    = VA_new(2);
-    self->by_name   = Hash_new(0);
+    ivars->metadata  = Hash_new(0);
+    ivars->count     = 0;
+    ivars->by_num    = VA_new(2);
+    ivars->by_name   = Hash_new(0);
 
     // Start field numbers at 1, not 0.
-    VA_Push(self->by_num, (Obj*)CB_newf(""));
+    VA_Push(ivars->by_num, (Obj*)CB_newf(""));
 
     // Assign.
-    self->number = number;
+    ivars->number = number;
 
     // Derive.
-    self->name = Seg_num_to_name(number);
+    ivars->name = Seg_num_to_name(number);
 
     return self;
 }
@@ -77,16 +79,18 @@ Seg_valid_seg_name(const CharBuf *name) {
 
 void
 Seg_destroy(Segment *self) {
-    DECREF(self->name);
-    DECREF(self->metadata);
-    DECREF(self->by_name);
-    DECREF(self->by_num);
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    DECREF(ivars->name);
+    DECREF(ivars->metadata);
+    DECREF(ivars->by_name);
+    DECREF(ivars->by_num);
     SUPER_DESTROY(self, SEGMENT);
 }
 
 bool
 Seg_read_file(Segment *self, Folder *folder) {
-    CharBuf *filename = CB_newf("%o/segmeta.json", self->name);
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    CharBuf *filename = CB_newf("%o/segmeta.json", ivars->name);
     Hash    *metadata = (Hash*)Json_slurp_json(folder, filename);
     Hash    *my_metadata;
 
@@ -96,16 +100,16 @@ Seg_read_file(Segment *self, Folder *folder) {
     CERTIFY(metadata, HASH);
 
     // Grab metadata for the Segment object itself.
-    DECREF(self->metadata);
-    self->metadata = metadata;
+    DECREF(ivars->metadata);
+    ivars->metadata = metadata;
     my_metadata
-        = (Hash*)CERTIFY(Hash_Fetch_Str(self->metadata, "segmeta", 7), HASH);
+        = (Hash*)CERTIFY(Hash_Fetch_Str(ivars->metadata, "segmeta", 7), HASH);
 
     // Assign.
     Obj *count = Hash_Fetch_Str(my_metadata, "count", 5);
     if (!count) { count = Hash_Fetch_Str(my_metadata, "doc_count", 9); }
     if (!count) { THROW(ERR, "Missing 'count'"); }
-    else { self->count = Obj_To_I64(count); }
+    else { ivars->count = Obj_To_I64(count); }
 
     // Get list of field nums.
     VArray *source_by_num = (VArray*)Hash_Fetch_Str(my_metadata,
@@ -116,10 +120,10 @@ Seg_read_file(Segment *self, Folder *folder) {
     }
 
     // Init.
-    DECREF(self->by_num);
-    DECREF(self->by_name);
-    self->by_num  = VA_new(num_fields);
-    self->by_name = Hash_new(num_fields);
+    DECREF(ivars->by_num);
+    DECREF(ivars->by_name);
+    ivars->by_num  = VA_new(num_fields);
+    ivars->by_name = Hash_new(num_fields);
 
     // Copy the list of fields from the source.
     for (uint32_t i = 0; i < num_fields; i++) {
@@ -132,68 +136,72 @@ Seg_read_file(Segment *self, Folder *folder) {
 
 void
 Seg_write_file(Segment *self, Folder *folder) {
+    SegmentIVARS *const ivars = Seg_IVARS(self);
     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, "name", 4, (Obj*)CB_Clone(self->name));
-    Hash_Store_Str(my_metadata, "field_names", 11, INCREF(self->by_num));
+                   (Obj*)CB_newf("%i64", ivars->count));
+    Hash_Store_Str(my_metadata, "name", 4, (Obj*)CB_Clone(ivars->name));
+    Hash_Store_Str(my_metadata, "field_names", 11, INCREF(ivars->by_num));
     Hash_Store_Str(my_metadata, "format", 6, (Obj*)CB_newf("%i32", 1));
-    Hash_Store_Str(self->metadata, "segmeta", 7, (Obj*)my_metadata);
+    Hash_Store_Str(ivars->metadata, "segmeta", 7, (Obj*)my_metadata);
 
-    CharBuf *filename = CB_newf("%o/segmeta.json", self->name);
-    bool result = Json_spew_json((Obj*)self->metadata, folder, filename);
+    CharBuf *filename = CB_newf("%o/segmeta.json", ivars->name);
+    bool result = Json_spew_json((Obj*)ivars->metadata, folder, filename);
     DECREF(filename);
     if (!result) { RETHROW(INCREF(Err_get_error())); }
 }
 
 int32_t
 Seg_add_field(Segment *self, const CharBuf *field) {
-    Integer32 *num = (Integer32*)Hash_Fetch(self->by_name, (Obj*)field);
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    Integer32 *num = (Integer32*)Hash_Fetch(ivars->by_name, (Obj*)field);
     if (num) {
         return Int32_Get_Value(num);
     }
     else {
-        int32_t field_num = VA_Get_Size(self->by_num);
-        Hash_Store(self->by_name, (Obj*)field, (Obj*)Int32_new(field_num));
-        VA_Push(self->by_num, (Obj*)CB_Clone(field));
+        int32_t field_num = VA_Get_Size(ivars->by_num);
+        Hash_Store(ivars->by_name, (Obj*)field, (Obj*)Int32_new(field_num));
+        VA_Push(ivars->by_num, (Obj*)CB_Clone(field));
         return field_num;
     }
 }
 
 CharBuf*
 Seg_get_name(Segment *self) {
-    return self->name;
+    return Seg_IVARS(self)->name;
 }
 
 int64_t
 Seg_get_number(Segment *self) {
-    return self->number;
+    return Seg_IVARS(self)->number;
 }
 
 void
 Seg_set_count(Segment *self, int64_t count) {
-    self->count = count;
+    Seg_IVARS(self)->count = count;
 }
 
 int64_t
 Seg_get_count(Segment *self) {
-    return self->count;
+    return Seg_IVARS(self)->count;
 }
 
 int64_t
 Seg_increment_count(Segment *self, int64_t increment) {
-    self->count += increment;
-    return self->count;
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    ivars->count += increment;
+    return ivars->count;
 }
 
 void
 Seg_store_metadata(Segment *self, const CharBuf *key, Obj *value) {
-    if (Hash_Fetch(self->metadata, (Obj*)key)) {
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    if (Hash_Fetch(ivars->metadata, (Obj*)key)) {
         THROW(ERR, "Metadata key '%o' already registered", key);
     }
-    Hash_Store(self->metadata, (Obj*)key, value);
+    Hash_Store(ivars->metadata, (Obj*)key, value);
 }
 
 void
@@ -205,31 +213,36 @@ Seg_store_metadata_str(Segment *self, const char *key, size_t key_len,
 
 Obj*
 Seg_fetch_metadata(Segment *self, const CharBuf *key) {
-    return Hash_Fetch(self->metadata, (Obj*)key);
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    return Hash_Fetch(ivars->metadata, (Obj*)key);
 }
 
 Obj*
 Seg_fetch_metadata_str(Segment *self, const char *key, size_t len) {
-    return Hash_Fetch_Str(self->metadata, key, len);
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    return Hash_Fetch_Str(ivars->metadata, key, len);
 }
 
 Hash*
 Seg_get_metadata(Segment *self) {
-    return self->metadata;
+    return Seg_IVARS(self)->metadata;
 }
 
 int32_t
 Seg_compare_to(Segment *self, Obj *other) {
     Segment *other_seg = (Segment*)CERTIFY(other, SEGMENT);
-    if (self->number <  other_seg->number)      { return -1; }
-    else if (self->number == other_seg->number) { return 0;  }
-    else                                        { return 1;  }
+    SegmentIVARS *const ivars = Seg_IVARS(self);
+    SegmentIVARS *const ovars = Seg_IVARS(other_seg);
+    if (ivars->number < ovars->number)       { return -1; }
+    else if (ivars->number == ovars->number) { return 0;  }
+    else                                     { return 1;  }
 }
 
 CharBuf*
 Seg_field_name(Segment *self, int32_t field_num) {
+    SegmentIVARS *const ivars = Seg_IVARS(self);
     return field_num
-           ? (CharBuf*)VA_Fetch(self->by_num, field_num)
+           ? (CharBuf*)VA_Fetch(ivars->by_num, field_num)
            : NULL;
 }
 
@@ -239,7 +252,8 @@ Seg_field_num(Segment *self, const CharBuf *field) {
         return 0;
     }
     else {
-        Integer32 *num = (Integer32*)Hash_Fetch(self->by_name, (Obj*)field);
+        SegmentIVARS *const ivars = Seg_IVARS(self);
+        Integer32 *num = (Integer32*)Hash_Fetch(ivars->by_name, (Obj*)field);
         return num ? Int32_Get_Value(num) : 0;
     }
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/Similarity.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/Similarity.c b/core/Lucy/Index/Similarity.c
index 2118cdc..a583ef1 100644
--- a/core/Lucy/Index/Similarity.c
+++ b/core/Lucy/Index/Similarity.c
@@ -39,14 +39,16 @@ Sim_new() {
 
 Similarity*
 Sim_init(Similarity *self) {
-    self->norm_decoder = NULL;
+    SimilarityIVARS *const ivars = Sim_IVARS(self);
+    ivars->norm_decoder = NULL;
     return self;
 }
 
 void
 Sim_destroy(Similarity *self) {
-    if (self->norm_decoder) {
-        FREEMEM(self->norm_decoder);
+    SimilarityIVARS *const ivars = Sim_IVARS(self);
+    if (ivars->norm_decoder) {
+        FREEMEM(ivars->norm_decoder);
     }
     SUPER_DESTROY(self, SIMILARITY);
 }
@@ -67,14 +69,15 @@ Sim_make_posting_writer(Similarity *self, Schema *schema, Snapshot *snapshot,
 
 float*
 Sim_get_norm_decoder(Similarity *self) {
-    if (!self->norm_decoder) {
+    SimilarityIVARS *const ivars = Sim_IVARS(self);
+    if (!ivars->norm_decoder) {
         // Cache decoded boost bytes.
-        self->norm_decoder = (float*)MALLOCATE(256 * sizeof(float));
+        ivars->norm_decoder = (float*)MALLOCATE(256 * sizeof(float));
         for (uint32_t i = 0; i < 256; i++) {
-            self->norm_decoder[i] = Sim_Decode_Norm(self, i);
+            ivars->norm_decoder[i] = Sim_Decode_Norm(self, i);
         }
     }
-    return self->norm_decoder;
+    return ivars->norm_decoder;
 }
 
 Obj*

http://git-wip-us.apache.org/repos/asf/lucy/blob/965fdb2a/core/Lucy/Index/SkipStepper.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SkipStepper.c b/core/Lucy/Index/SkipStepper.c
index f07b9f3..33ce450 100644
--- a/core/Lucy/Index/SkipStepper.c
+++ b/core/Lucy/Index/SkipStepper.c
@@ -27,10 +27,11 @@
 SkipStepper*
 SkipStepper_new() {
     SkipStepper *self = (SkipStepper*)VTable_Make_Obj(SKIPSTEPPER);
+    SkipStepperIVARS *const ivars = SkipStepper_IVARS(self);
 
     // Init.
-    self->doc_id   = 0;
-    self->filepos  = 0;
+    ivars->doc_id   = 0;
+    ivars->filepos  = 0;
 
     return self;
 }
@@ -38,29 +39,33 @@ SkipStepper_new() {
 void
 SkipStepper_set_id_and_filepos(SkipStepper *self, int32_t doc_id,
                                int64_t filepos) {
-    self->doc_id  = doc_id;
-    self->filepos = filepos;
+    SkipStepperIVARS *const ivars = SkipStepper_IVARS(self);
+    ivars->doc_id  = doc_id;
+    ivars->filepos = filepos;
 }
 
 void
 SkipStepper_read_record(SkipStepper *self, InStream *instream) {
-    self->doc_id   += InStream_Read_C32(instream);
-    self->filepos  += InStream_Read_C64(instream);
+    SkipStepperIVARS *const ivars = SkipStepper_IVARS(self);
+    ivars->doc_id   += InStream_Read_C32(instream);
+    ivars->filepos  += InStream_Read_C64(instream);
 }
 
 CharBuf*
 SkipStepper_to_string(SkipStepper *self) {
+    SkipStepperIVARS *const ivars = SkipStepper_IVARS(self);
     char *ptr = (char*)MALLOCATE(60);
     size_t len = sprintf(ptr, "skip doc: %u file pointer: %" PRId64,
-                         self->doc_id, self->filepos);
+                         ivars->doc_id, ivars->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) {
-    const int32_t delta_doc_id = self->doc_id - last_doc_id;
-    const int64_t delta_filepos = self->filepos - last_filepos;
+    SkipStepperIVARS *const ivars = SkipStepper_IVARS(self);
+    const int32_t delta_doc_id = ivars->doc_id - last_doc_id;
+    const int64_t delta_filepos = ivars->filepos - last_filepos;
 
     // Write delta doc id.
     OutStream_Write_C32(outstream, delta_doc_id);


Mime
View raw message