lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [4/9] git commit: refs/heads/ivars-wip1 - Migrate Lucy's index classes to IVARS.
Date Mon, 01 Jul 2013 16:47:25 GMT
Migrate Lucy's index classes to IVARS.

Change all of Lucy's index classes to access instance vars via an IVARS struct
rather than via `self`.


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

Branch: refs/heads/ivars-wip1
Commit: 7c23ce21e7901ed0b110d62b3e624da68dc72d51
Parents: 445409a
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Sat Jun 29 17:49:23 2013 -0700
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Sun Jun 30 17:35:36 2013 -0700

----------------------------------------------------------------------
 core/Lucy/Index/BackgroundMerger.c           | 227 ++++++------
 core/Lucy/Index/BitVecDelDocs.c              |  26 +-
 core/Lucy/Index/DataReader.c                 |  38 +-
 core/Lucy/Index/DataWriter.c                 |  32 +-
 core/Lucy/Index/DeletionsReader.c            |  67 ++--
 core/Lucy/Index/DeletionsWriter.c            | 112 +++---
 core/Lucy/Index/DocReader.c                  |  69 ++--
 core/Lucy/Index/DocVector.c                  |  36 +-
 core/Lucy/Index/DocWriter.c                  |  43 ++-
 core/Lucy/Index/FilePurger.c                 |  47 +--
 core/Lucy/Index/HighlightReader.c            |  73 ++--
 core/Lucy/Index/HighlightWriter.c            |  43 ++-
 core/Lucy/Index/IndexManager.c               |  97 +++---
 core/Lucy/Index/IndexReader.c                |  51 +--
 core/Lucy/Index/Indexer.c                    | 225 ++++++------
 core/Lucy/Index/Inverter.c                   | 181 +++++-----
 core/Lucy/Index/LexIndex.c                   |  80 +++--
 core/Lucy/Index/Lexicon.c                    |   8 +-
 core/Lucy/Index/LexiconReader.c              |  52 +--
 core/Lucy/Index/LexiconWriter.c              | 190 +++++-----
 core/Lucy/Index/PolyLexicon.c                |  62 ++--
 core/Lucy/Index/PolyReader.c                 | 111 +++---
 core/Lucy/Index/Posting.c                    |  10 +-
 core/Lucy/Index/PostingListReader.c          |  20 +-
 core/Lucy/Index/PostingListWriter.c          | 106 +++---
 core/Lucy/Index/PostingPool.c                | 366 ++++++++++----------
 core/Lucy/Index/RawLexicon.c                 |  35 +-
 core/Lucy/Index/RawPostingList.c             |  25 +-
 core/Lucy/Index/SegLexicon.c                 |  87 +++--
 core/Lucy/Index/SegPostingList.c             | 153 +++++----
 core/Lucy/Index/SegReader.c                  |  30 +-
 core/Lucy/Index/SegWriter.c                  |  90 +++--
 core/Lucy/Index/Segment.c                    | 106 +++---
 core/Lucy/Index/Similarity.c                 |  17 +-
 core/Lucy/Index/SkipStepper.c                |  23 +-
 core/Lucy/Index/Snapshot.c                   |  58 ++--
 core/Lucy/Index/SortCache.c                  |  71 ++--
 core/Lucy/Index/SortCache/NumericSortCache.c |  60 ++--
 core/Lucy/Index/SortCache/TextSortCache.c    |  49 +--
 core/Lucy/Index/SortFieldWriter.c            | 401 +++++++++++-----------
 core/Lucy/Index/SortReader.c                 |  94 ++---
 core/Lucy/Index/SortWriter.c                 | 124 +++----
 core/Lucy/Index/TermInfo.c                   |  61 ++--
 core/Lucy/Index/TermStepper.c                |  18 +-
 core/Lucy/Index/TermVector.c                 |  83 ++---
 core/Lucy/Index/ZombieKeyedHash.c            |  23 +-
 46 files changed, 2167 insertions(+), 1813 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/BackgroundMerger.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/BackgroundMerger.c b/core/Lucy/Index/BackgroundMerger.c
index db80f68..a32f215 100644
--- a/core/Lucy/Index/BackgroundMerger.c
+++ b/core/Lucy/Index/BackgroundMerger.c
@@ -65,86 +65,87 @@ BGMerger_new(Obj *index, IndexManager *manager) {
 
 BackgroundMerger*
 BGMerger_init(BackgroundMerger *self, Obj *index, IndexManager *manager) {
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
     Folder *folder = S_init_folder(index);
 
     // Init.
-    self->optimize      = false;
-    self->prepared      = false;
-    self->needs_commit  = false;
-    self->snapfile      = NULL;
-    self->doc_maps      = Hash_new(0);
+    ivars->optimize      = false;
+    ivars->prepared      = false;
+    ivars->needs_commit  = false;
+    ivars->snapfile      = NULL;
+    ivars->doc_maps      = Hash_new(0);
 
     // Assign.
-    self->folder = folder;
+    ivars->folder = folder;
     if (manager) {
-        self->manager = (IndexManager*)INCREF(manager);
+        ivars->manager = (IndexManager*)INCREF(manager);
     }
     else {
-        self->manager = IxManager_new(NULL, NULL);
-        IxManager_Set_Write_Lock_Timeout(self->manager, 10000);
+        ivars->manager = IxManager_new(NULL, NULL);
+        IxManager_Set_Write_Lock_Timeout(ivars->manager, 10000);
     }
-    IxManager_Set_Folder(self->manager, folder);
+    IxManager_Set_Folder(ivars->manager, folder);
 
     // Obtain write lock (which we'll only hold briefly), then merge lock.
     S_obtain_write_lock(self);
-    if (!self->write_lock) {
+    if (!ivars->write_lock) {
         DECREF(self);
         RETHROW(INCREF(Err_get_error()));
     }
     S_obtain_merge_lock(self);
-    if (!self->merge_lock) {
+    if (!ivars->merge_lock) {
         DECREF(self);
         RETHROW(INCREF(Err_get_error()));
     }
 
     // Find the latest snapshot.  If there's no index content, bail early.
-    self->snapshot = Snapshot_Read_File(Snapshot_new(), folder, NULL);
-    if (!Snapshot_Get_Path(self->snapshot)) {
+    ivars->snapshot = Snapshot_Read_File(Snapshot_new(), folder, NULL);
+    if (!Snapshot_Get_Path(ivars->snapshot)) {
         S_release_write_lock(self);
         S_release_merge_lock(self);
         return self;
     }
 
     // Create FilePurger. Zap detritus from previous sessions.
-    self->file_purger = FilePurger_new(folder, self->snapshot, self->manager);
-    FilePurger_Purge(self->file_purger);
+    ivars->file_purger = FilePurger_new(folder, ivars->snapshot, ivars->manager);
+    FilePurger_Purge(ivars->file_purger);
 
     // Open a PolyReader, passing in the IndexManager so we get a read lock on
     // the Snapshot's files -- so that Indexers don't zap our files while
     // we're operating in the background.
-    self->polyreader = PolyReader_open((Obj*)folder, NULL, self->manager);
+    ivars->polyreader = PolyReader_open((Obj*)folder, NULL, ivars->manager);
 
     // Clone the PolyReader's schema.
-    Hash *dump = Schema_Dump(PolyReader_Get_Schema(self->polyreader));
-    self->schema = (Schema*)CERTIFY(VTable_Load_Obj(SCHEMA, (Obj*)dump),
+    Hash *dump = Schema_Dump(PolyReader_Get_Schema(ivars->polyreader));
+    ivars->schema = (Schema*)CERTIFY(VTable_Load_Obj(SCHEMA, (Obj*)dump),
                                     SCHEMA);
     DECREF(dump);
 
     // Create new Segment.
     int64_t new_seg_num
-        = IxManager_Highest_Seg_Num(self->manager, self->snapshot) + 1;
-    VArray *fields = Schema_All_Fields(self->schema);
-    self->segment = Seg_new(new_seg_num);
+        = IxManager_Highest_Seg_Num(ivars->manager, ivars->snapshot) + 1;
+    VArray *fields = Schema_All_Fields(ivars->schema);
+    ivars->segment = Seg_new(new_seg_num);
     for (uint32_t i = 0, max = VA_Get_Size(fields); i < max; i++) {
-        Seg_Add_Field(self->segment, (CharBuf*)VA_Fetch(fields, i));
+        Seg_Add_Field(ivars->segment, (CharBuf*)VA_Fetch(fields, i));
     }
     DECREF(fields);
 
     // Our "cutoff" is the segment this BackgroundMerger will write.  Now that
     // we've determined the cutoff, write the merge data file.
-    self->cutoff = Seg_Get_Number(self->segment);
-    IxManager_Write_Merge_Data(self->manager, self->cutoff);
+    ivars->cutoff = Seg_Get_Number(ivars->segment);
+    IxManager_Write_Merge_Data(ivars->manager, ivars->cutoff);
 
     /* Create the SegWriter but hold off on preparing the new segment
      * directory -- because if we don't need to merge any segments we don't
      * need it.  (We've reserved the dir by plopping down the merge.json
      * file.) */
-    self->seg_writer = SegWriter_new(self->schema, self->snapshot,
-                                     self->segment, self->polyreader);
+    ivars->seg_writer = SegWriter_new(ivars->schema, ivars->snapshot,
+                                      ivars->segment, ivars->polyreader);
 
     // Grab a local ref to the DeletionsWriter.
-    self->del_writer
-        = (DeletionsWriter*)INCREF(SegWriter_Get_Del_Writer(self->seg_writer));
+    ivars->del_writer
+        = (DeletionsWriter*)INCREF(SegWriter_Get_Del_Writer(ivars->seg_writer));
 
     // Release the write lock.  Now new Indexers can start while we work in
     // the background.
@@ -155,20 +156,21 @@ BGMerger_init(BackgroundMerger *self, Obj *index, IndexManager *manager) {
 
 void
 BGMerger_destroy(BackgroundMerger *self) {
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
     S_release_merge_lock(self);
     S_release_write_lock(self);
-    DECREF(self->schema);
-    DECREF(self->folder);
-    DECREF(self->segment);
-    DECREF(self->manager);
-    DECREF(self->polyreader);
-    DECREF(self->del_writer);
-    DECREF(self->snapshot);
-    DECREF(self->seg_writer);
-    DECREF(self->file_purger);
-    DECREF(self->write_lock);
-    DECREF(self->snapfile);
-    DECREF(self->doc_maps);
+    DECREF(ivars->schema);
+    DECREF(ivars->folder);
+    DECREF(ivars->segment);
+    DECREF(ivars->manager);
+    DECREF(ivars->polyreader);
+    DECREF(ivars->del_writer);
+    DECREF(ivars->snapshot);
+    DECREF(ivars->seg_writer);
+    DECREF(ivars->file_purger);
+    DECREF(ivars->write_lock);
+    DECREF(ivars->snapfile);
+    DECREF(ivars->doc_maps);
     SUPER_DESTROY(self, BACKGROUNDMERGER);
 }
 
@@ -197,13 +199,14 @@ S_init_folder(Obj *index) {
 
 void
 BGMerger_optimize(BackgroundMerger *self) {
-    self->optimize = true;
+    BGMerger_IVARS(self)->optimize = true;
 }
 
 static uint32_t
 S_maybe_merge(BackgroundMerger *self) {
-    VArray *to_merge = IxManager_Recycle(self->manager, self->polyreader,
-                                         self->del_writer, 0, self->optimize);
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
+    VArray *to_merge = IxManager_Recycle(ivars->manager, ivars->polyreader,
+                                         ivars->del_writer, 0, ivars->optimize);
     int32_t num_to_merge = VA_Get_Size(to_merge);
 
     // There's no point in merging one segment if it has no deletions, because
@@ -221,22 +224,22 @@ S_maybe_merge(BackgroundMerger *self) {
     }
 
     // Now that we're sure we're writing a new segment, prep the seg dir.
-    SegWriter_Prep_Seg_Dir(self->seg_writer);
+    SegWriter_Prep_Seg_Dir(ivars->seg_writer);
 
     // Consolidate segments.
     for (uint32_t i = 0, max = num_to_merge; i < max; i++) {
         SegReader *seg_reader = (SegReader*)VA_Fetch(to_merge, i);
         CharBuf   *seg_name   = SegReader_Get_Seg_Name(seg_reader);
-        int64_t    doc_count  = Seg_Get_Count(self->segment);
+        int64_t    doc_count  = Seg_Get_Count(ivars->segment);
         Matcher *deletions
-            = DelWriter_Seg_Deletions(self->del_writer, seg_reader);
+            = DelWriter_Seg_Deletions(ivars->del_writer, seg_reader);
         I32Array *doc_map = DelWriter_Generate_Doc_Map(
-                                self->del_writer, deletions,
+                                ivars->del_writer, deletions,
                                 SegReader_Doc_Max(seg_reader),
                                 (int32_t)doc_count);
 
-        Hash_Store(self->doc_maps, (Obj*)seg_name, (Obj*)doc_map);
-        SegWriter_Merge_Segment(self->seg_writer, seg_reader, doc_map);
+        Hash_Store(ivars->doc_maps, (Obj*)seg_name, (Obj*)doc_map);
+        SegWriter_Merge_Segment(ivars->seg_writer, seg_reader, doc_map);
         DECREF(deletions);
     }
 
@@ -246,14 +249,15 @@ S_maybe_merge(BackgroundMerger *self) {
 
 static bool
 S_merge_updated_deletions(BackgroundMerger *self) {
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
     Hash *updated_deletions = NULL;
 
     PolyReader *new_polyreader
-        = PolyReader_open((Obj*)self->folder, NULL, NULL);
+        = PolyReader_open((Obj*)ivars->folder, NULL, NULL);
     VArray *new_seg_readers
         = PolyReader_Get_Seg_Readers(new_polyreader);
     VArray *old_seg_readers
-        = PolyReader_Get_Seg_Readers(self->polyreader);
+        = PolyReader_Get_Seg_Readers(ivars->polyreader);
     Hash *new_segs = Hash_new(VA_Get_Size(new_seg_readers));
 
     for (uint32_t i = 0, max = VA_Get_Size(new_seg_readers); i < max; i++) {
@@ -267,7 +271,7 @@ S_merge_updated_deletions(BackgroundMerger *self) {
         CharBuf   *seg_name   = SegReader_Get_Seg_Name(seg_reader);
 
         // If this segment was merged away...
-        if (Hash_Fetch(self->doc_maps, (Obj*)seg_name)) {
+        if (Hash_Fetch(ivars->doc_maps, (Obj*)seg_name)) {
             SegReader *new_seg_reader
                 = (SegReader*)CERTIFY(
                       Hash_Fetch(new_segs, (Obj*)seg_name),
@@ -297,18 +301,18 @@ S_merge_updated_deletions(BackgroundMerger *self) {
     }
     else {
         PolyReader *merge_polyreader
-            = PolyReader_open((Obj*)self->folder, self->snapshot, NULL);
+            = PolyReader_open((Obj*)ivars->folder, ivars->snapshot, NULL);
         VArray *merge_seg_readers
             = PolyReader_Get_Seg_Readers(merge_polyreader);
         Snapshot *latest_snapshot
-            = Snapshot_Read_File(Snapshot_new(), self->folder, NULL);
+            = Snapshot_Read_File(Snapshot_new(), ivars->folder, NULL);
         int64_t new_seg_num
-            = IxManager_Highest_Seg_Num(self->manager, latest_snapshot) + 1;
+            = IxManager_Highest_Seg_Num(ivars->manager, latest_snapshot) + 1;
         Segment   *new_segment = Seg_new(new_seg_num);
-        SegWriter *seg_writer  = SegWriter_new(self->schema, self->snapshot,
+        SegWriter *seg_writer  = SegWriter_new(ivars->schema, ivars->snapshot,
                                                new_segment, merge_polyreader);
         DeletionsWriter *del_writer = SegWriter_Get_Del_Writer(seg_writer);
-        int64_t  merge_seg_num = Seg_Get_Number(self->segment);
+        int64_t  merge_seg_num = Seg_Get_Number(ivars->segment);
         uint32_t seg_tick      = INT32_MAX;
         int32_t  offset        = INT32_MAX;
         CharBuf *seg_name      = NULL;
@@ -334,7 +338,7 @@ S_merge_updated_deletions(BackgroundMerger *self) {
               ) {
             I32Array *doc_map
                 = (I32Array*)CERTIFY(
-                      Hash_Fetch(self->doc_maps, (Obj*)seg_name),
+                      Hash_Fetch(ivars->doc_maps, (Obj*)seg_name),
                       I32ARRAY);
             int32_t del;
             while (0 != (del = Matcher_Next(deletions))) {
@@ -365,11 +369,12 @@ S_merge_updated_deletions(BackgroundMerger *self) {
 
 void
 BGMerger_prepare_commit(BackgroundMerger *self) {
-    VArray   *seg_readers     = PolyReader_Get_Seg_Readers(self->polyreader);
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
+    VArray   *seg_readers     = PolyReader_Get_Seg_Readers(ivars->polyreader);
     uint32_t  num_seg_readers = VA_Get_Size(seg_readers);
     uint32_t  segs_merged     = 0;
 
-    if (self->prepared) {
+    if (ivars->prepared) {
         THROW(ERR, "Can't call Prepare_Commit() more than once");
     }
 
@@ -379,46 +384,46 @@ BGMerger_prepare_commit(BackgroundMerger *self) {
     }
 
     if (!segs_merged) {
-        // Nothing merged.  Leave self->needs_commit false and bail out.
-        self->prepared = true;
+        // Nothing merged.  Leave `needs_commit` false and bail out.
+        ivars->prepared = true;
         return;
     }
     // Finish the segment and write a new snapshot file.
     else {
-        Folder   *folder   = self->folder;
-        Snapshot *snapshot = self->snapshot;
+        Folder   *folder   = ivars->folder;
+        Snapshot *snapshot = ivars->snapshot;
 
         // Write out new deletions.
-        if (DelWriter_Updated(self->del_writer)) {
+        if (DelWriter_Updated(ivars->del_writer)) {
             // Only write out if they haven't all been applied.
             if (segs_merged != num_seg_readers) {
-                DelWriter_Finish(self->del_writer);
+                DelWriter_Finish(ivars->del_writer);
             }
         }
 
         // Finish the segment.
-        SegWriter_Finish(self->seg_writer);
+        SegWriter_Finish(ivars->seg_writer);
 
         // Grab the write lock.
         S_obtain_write_lock(self);
-        if (!self->write_lock) {
+        if (!ivars->write_lock) {
             RETHROW(INCREF(Err_get_error()));
         }
 
         // Write temporary snapshot file.
-        DECREF(self->snapfile);
-        self->snapfile = IxManager_Make_Snapshot_Filename(self->manager);
-        CB_Cat_Trusted_Str(self->snapfile, ".temp", 5);
-        Folder_Delete(folder, self->snapfile);
-        Snapshot_Write_File(snapshot, folder, self->snapfile);
+        DECREF(ivars->snapfile);
+        ivars->snapfile = IxManager_Make_Snapshot_Filename(ivars->manager);
+        CB_Cat_Trusted_Str(ivars->snapfile, ".temp", 5);
+        Folder_Delete(folder, ivars->snapfile);
+        Snapshot_Write_File(snapshot, folder, ivars->snapfile);
 
         // Determine whether the index has been updated while this background
         // merge process was running.
 
         CharBuf *start_snapfile
-            = Snapshot_Get_Path(PolyReader_Get_Snapshot(self->polyreader));
+            = Snapshot_Get_Path(PolyReader_Get_Snapshot(ivars->polyreader));
         Snapshot *latest_snapshot
-            = Snapshot_Read_File(Snapshot_new(), self->folder, NULL);
+            = Snapshot_Read_File(Snapshot_new(), ivars->folder, NULL);
         CharBuf *latest_snapfile = Snapshot_Get_Path(latest_snapshot);
         bool index_updated
             = !CB_Equals(start_snapfile, (Obj*)latest_snapfile);
@@ -440,56 +445,58 @@ BGMerger_prepare_commit(BackgroundMerger *self) {
                 CharBuf *file = (CharBuf*)VA_Fetch(files, i);
                 if (CB_Starts_With_Str(file, "seg_", 4)) {
                     int64_t gen = (int64_t)IxFileNames_extract_gen(file);
-                    if (gen > self->cutoff) {
-                        Snapshot_Add_Entry(self->snapshot, file);
+                    if (gen > ivars->cutoff) {
+                        Snapshot_Add_Entry(ivars->snapshot, file);
                     }
                 }
             }
             DECREF(files);
 
             // Since the snapshot content has changed, we need to rewrite it.
-            Folder_Delete(folder, self->snapfile);
-            Snapshot_Write_File(snapshot, folder, self->snapfile);
+            Folder_Delete(folder, ivars->snapfile);
+            Snapshot_Write_File(snapshot, folder, ivars->snapfile);
         }
 
         DECREF(latest_snapshot);
 
-        self->needs_commit = true;
+        ivars->needs_commit = true;
     }
 
     // Close reader, so that we can delete its files if appropriate.
-    PolyReader_Close(self->polyreader);
+    PolyReader_Close(ivars->polyreader);
 
-    self->prepared = true;
+    ivars->prepared = true;
 }
 
 void
 BGMerger_commit(BackgroundMerger *self) {
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
+
     // Safety check.
-    if (!self->merge_lock) {
+    if (!ivars->merge_lock) {
         THROW(ERR, "Can't call commit() more than once");
     }
 
-    if (!self->prepared) {
+    if (!ivars->prepared) {
         BGMerger_Prepare_Commit(self);
     }
 
-    if (self->needs_commit) {
+    if (ivars->needs_commit) {
         bool success = false;
-        CharBuf *temp_snapfile = CB_Clone(self->snapfile);
+        CharBuf *temp_snapfile = CB_Clone(ivars->snapfile);
 
         // Rename temp snapshot file.
-        CB_Chop(self->snapfile, sizeof(".temp") - 1);
-        success = Folder_Hard_Link(self->folder, temp_snapfile,
-                                   self->snapfile);
-        Snapshot_Set_Path(self->snapshot, self->snapfile);
+        CB_Chop(ivars->snapfile, sizeof(".temp") - 1);
+        success = Folder_Hard_Link(ivars->folder, temp_snapfile,
+                                   ivars->snapfile);
+        Snapshot_Set_Path(ivars->snapshot, ivars->snapfile);
         if (!success) {
             CharBuf *mess = CB_newf("Can't create hard link from %o to %o",
-                                    temp_snapfile, self->snapfile);
+                                    temp_snapfile, ivars->snapfile);
             DECREF(temp_snapfile);
             Err_throw_mess(ERR, mess);
         }
-        if (!Folder_Delete(self->folder, temp_snapfile)) {
+        if (!Folder_Delete(ivars->folder, temp_snapfile)) {
             CharBuf *mess = CB_newf("Can't delete %o", temp_snapfile);
             DECREF(temp_snapfile);
             Err_throw_mess(ERR, mess);
@@ -499,11 +506,11 @@ BGMerger_commit(BackgroundMerger *self) {
 
     // Release the merge lock and remove the merge data file.
     S_release_merge_lock(self);
-    IxManager_Remove_Merge_Data(self->manager);
+    IxManager_Remove_Merge_Data(ivars->manager);
 
-    if (self->needs_commit) {
+    if (ivars->needs_commit) {
         // Purge obsolete files.
-        FilePurger_Purge(self->file_purger);
+        FilePurger_Purge(ivars->file_purger);
     }
 
     // Release the write lock.
@@ -512,11 +519,12 @@ BGMerger_commit(BackgroundMerger *self) {
 
 static void
 S_obtain_write_lock(BackgroundMerger *self) {
-    Lock *write_lock = IxManager_Make_Write_Lock(self->manager);
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
+    Lock *write_lock = IxManager_Make_Write_Lock(ivars->manager);
     Lock_Clear_Stale(write_lock);
     if (Lock_Obtain(write_lock)) {
         // Only assign if successful, otherwise DESTROY unlocks -- bad!
-        self->write_lock = write_lock;
+        ivars->write_lock = write_lock;
     }
     else {
         DECREF(write_lock);
@@ -525,11 +533,12 @@ S_obtain_write_lock(BackgroundMerger *self) {
 
 static void
 S_obtain_merge_lock(BackgroundMerger *self) {
-    Lock *merge_lock = IxManager_Make_Merge_Lock(self->manager);
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
+    Lock *merge_lock = IxManager_Make_Merge_Lock(ivars->manager);
     Lock_Clear_Stale(merge_lock);
     if (Lock_Obtain(merge_lock)) {
         // Only assign if successful, same rationale as above.
-        self->merge_lock = merge_lock;
+        ivars->merge_lock = merge_lock;
     }
     else {
         // We can't get the merge lock, so it seems there must be another
@@ -540,19 +549,21 @@ S_obtain_merge_lock(BackgroundMerger *self) {
 
 static void
 S_release_write_lock(BackgroundMerger *self) {
-    if (self->write_lock) {
-        Lock_Release(self->write_lock);
-        DECREF(self->write_lock);
-        self->write_lock = NULL;
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
+    if (ivars->write_lock) {
+        Lock_Release(ivars->write_lock);
+        DECREF(ivars->write_lock);
+        ivars->write_lock = NULL;
     }
 }
 
 static void
 S_release_merge_lock(BackgroundMerger *self) {
-    if (self->merge_lock) {
-        Lock_Release(self->merge_lock);
-        DECREF(self->merge_lock);
-        self->merge_lock = NULL;
+    BackgroundMergerIVARS *const ivars = BGMerger_IVARS(self);
+    if (ivars->merge_lock) {
+        Lock_Release(ivars->merge_lock);
+        DECREF(ivars->merge_lock);
+        ivars->merge_lock = NULL;
     }
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/BitVecDelDocs.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/BitVecDelDocs.c b/core/Lucy/Index/BitVecDelDocs.c
index 690e6d5..e0dac0e 100644
--- a/core/Lucy/Index/BitVecDelDocs.c
+++ b/core/Lucy/Index/BitVecDelDocs.c
@@ -30,30 +30,30 @@ BitVecDelDocs_new(Folder *folder, const CharBuf *filename) {
 BitVecDelDocs*
 BitVecDelDocs_init(BitVecDelDocs *self, Folder *folder,
                    const CharBuf *filename) {
-    int32_t len;
-
     BitVec_init((BitVector*)self, 0);
-    self->filename = CB_Clone(filename);
-    self->instream = Folder_Open_In(folder, filename);
-    if (!self->instream) {
+    BitVecDelDocsIVARS *const ivars = BitVecDelDocs_IVARS(self);
+    ivars->filename = CB_Clone(filename);
+    ivars->instream = Folder_Open_In(folder, filename);
+    if (!ivars->instream) {
         Err *error = (Err*)INCREF(Err_get_error());
         DECREF(self);
         RETHROW(error);
     }
-    len            = (int32_t)InStream_Length(self->instream);
-    self->bits     = (uint8_t*)InStream_Buf(self->instream, len);
-    self->cap      = (uint32_t)(len * 8);
+    int32_t len    = (int32_t)InStream_Length(ivars->instream);
+    ivars->bits    = (uint8_t*)InStream_Buf(ivars->instream, len);
+    ivars->cap     = (uint32_t)(len * 8);
     return self;
 }
 
 void
 BitVecDelDocs_destroy(BitVecDelDocs *self) {
-    DECREF(self->filename);
-    if (self->instream) {
-        InStream_Close(self->instream);
-        DECREF(self->instream);
+    BitVecDelDocsIVARS *const ivars = BitVecDelDocs_IVARS(self);
+    DECREF(ivars->filename);
+    if (ivars->instream) {
+        InStream_Close(ivars->instream);
+        DECREF(ivars->instream);
     }
-    self->bits = NULL;
+    ivars->bits = NULL;
     SUPER_DESTROY(self, BITVECDELDOCS);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/DataReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DataReader.c b/core/Lucy/Index/DataReader.c
index f8df36f..3404dcf 100644
--- a/core/Lucy/Index/DataReader.c
+++ b/core/Lucy/Index/DataReader.c
@@ -26,11 +26,12 @@
 DataReader*
 DataReader_init(DataReader *self, Schema *schema, Folder *folder,
                 Snapshot *snapshot, VArray *segments, int32_t seg_tick) {
-    self->schema   = (Schema*)INCREF(schema);
-    self->folder   = (Folder*)INCREF(folder);
-    self->snapshot = (Snapshot*)INCREF(snapshot);
-    self->segments = (VArray*)INCREF(segments);
-    self->seg_tick = seg_tick;
+    DataReaderIVARS *const ivars = DataReader_IVARS(self);
+    ivars->schema   = (Schema*)INCREF(schema);
+    ivars->folder   = (Folder*)INCREF(folder);
+    ivars->snapshot = (Snapshot*)INCREF(snapshot);
+    ivars->segments = (VArray*)INCREF(segments);
+    ivars->seg_tick = seg_tick;
     if (seg_tick != -1) {
         if (!segments) {
             THROW(ERR, "No segments array provided, but seg_tick is %i32",
@@ -41,11 +42,11 @@ DataReader_init(DataReader *self, Schema *schema, Folder *folder,
             if (!segment) {
                 THROW(ERR, "No segment at seg_tick %i32", seg_tick);
             }
-            self->segment = (Segment*)INCREF(segment);
+            ivars->segment = (Segment*)INCREF(segment);
         }
     }
     else {
-        self->segment = NULL;
+        ivars->segment = NULL;
     }
 
     ABSTRACT_CLASS_CHECK(self, DATAREADER);
@@ -54,42 +55,43 @@ DataReader_init(DataReader *self, Schema *schema, Folder *folder,
 
 void
 DataReader_destroy(DataReader *self) {
-    DECREF(self->schema);
-    DECREF(self->folder);
-    DECREF(self->snapshot);
-    DECREF(self->segments);
-    DECREF(self->segment);
+    DataReaderIVARS *const ivars = DataReader_IVARS(self);
+    DECREF(ivars->schema);
+    DECREF(ivars->folder);
+    DECREF(ivars->snapshot);
+    DECREF(ivars->segments);
+    DECREF(ivars->segment);
     SUPER_DESTROY(self, DATAREADER);
 }
 
 Schema*
 DataReader_get_schema(DataReader *self) {
-    return self->schema;
+    return DataReader_IVARS(self)->schema;
 }
 
 Folder*
 DataReader_get_folder(DataReader *self) {
-    return self->folder;
+    return DataReader_IVARS(self)->folder;
 }
 
 Snapshot*
 DataReader_get_snapshot(DataReader *self) {
-    return self->snapshot;
+    return DataReader_IVARS(self)->snapshot;
 }
 
 VArray*
 DataReader_get_segments(DataReader *self) {
-    return self->segments;
+    return DataReader_IVARS(self)->segments;
 }
 
 int32_t
 DataReader_get_seg_tick(DataReader *self) {
-    return self->seg_tick;
+    return DataReader_IVARS(self)->seg_tick;
 }
 
 Segment*
 DataReader_get_segment(DataReader *self) {
-    return self->segment;
+    return DataReader_IVARS(self)->segment;
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/DataWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DataWriter.c b/core/Lucy/Index/DataWriter.c
index bddc287..3177ed6 100644
--- a/core/Lucy/Index/DataWriter.c
+++ b/core/Lucy/Index/DataWriter.c
@@ -29,48 +29,50 @@
 DataWriter*
 DataWriter_init(DataWriter *self, Schema *schema, Snapshot *snapshot,
                 Segment *segment, PolyReader *polyreader) {
-    self->snapshot   = (Snapshot*)INCREF(snapshot);
-    self->segment    = (Segment*)INCREF(segment);
-    self->polyreader = (PolyReader*)INCREF(polyreader);
-    self->schema     = (Schema*)INCREF(schema);
-    self->folder     = (Folder*)INCREF(PolyReader_Get_Folder(polyreader));
+    DataWriterIVARS *const ivars = DataWriter_IVARS(self);
+    ivars->snapshot   = (Snapshot*)INCREF(snapshot);
+    ivars->segment    = (Segment*)INCREF(segment);
+    ivars->polyreader = (PolyReader*)INCREF(polyreader);
+    ivars->schema     = (Schema*)INCREF(schema);
+    ivars->folder     = (Folder*)INCREF(PolyReader_Get_Folder(polyreader));
     ABSTRACT_CLASS_CHECK(self, DATAWRITER);
     return self;
 }
 
 void
 DataWriter_destroy(DataWriter *self) {
-    DECREF(self->snapshot);
-    DECREF(self->segment);
-    DECREF(self->polyreader);
-    DECREF(self->schema);
-    DECREF(self->folder);
+    DataWriterIVARS *const ivars = DataWriter_IVARS(self);
+    DECREF(ivars->snapshot);
+    DECREF(ivars->segment);
+    DECREF(ivars->polyreader);
+    DECREF(ivars->schema);
+    DECREF(ivars->folder);
     SUPER_DESTROY(self, DATAWRITER);
 }
 
 Snapshot*
 DataWriter_get_snapshot(DataWriter *self) {
-    return self->snapshot;
+    return DataWriter_IVARS(self)->snapshot;
 }
 
 Segment*
 DataWriter_get_segment(DataWriter *self) {
-    return self->segment;
+    return DataWriter_IVARS(self)->segment;
 }
 
 PolyReader*
 DataWriter_get_polyreader(DataWriter *self) {
-    return self->polyreader;
+    return DataWriter_IVARS(self)->polyreader;
 }
 
 Schema*
 DataWriter_get_schema(DataWriter *self) {
-    return self->schema;
+    return DataWriter_IVARS(self)->schema;
 }
 
 Folder*
 DataWriter_get_folder(DataWriter *self) {
-    return self->folder;
+    return DataWriter_IVARS(self)->folder;
 }
 
 void

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/DeletionsReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsReader.c b/core/Lucy/Index/DeletionsReader.c
index 391bf63..ef45ebd 100644
--- a/core/Lucy/Index/DeletionsReader.c
+++ b/core/Lucy/Index/DeletionsReader.c
@@ -58,54 +58,58 @@ PolyDeletionsReader*
 PolyDelReader_init(PolyDeletionsReader *self, VArray *readers,
                    I32Array *offsets) {
     DelReader_init((DeletionsReader*)self, NULL, NULL, NULL, NULL, -1);
-    self->del_count = 0;
+    PolyDeletionsReaderIVARS *const ivars = PolyDelReader_IVARS(self);
+    ivars->del_count = 0;
     for (uint32_t i = 0, max = VA_Get_Size(readers); i < max; i++) {
         DeletionsReader *reader = (DeletionsReader*)CERTIFY(
                                       VA_Fetch(readers, i), DELETIONSREADER);
-        self->del_count += DelReader_Del_Count(reader);
+        ivars->del_count += DelReader_Del_Count(reader);
     }
-    self->readers = (VArray*)INCREF(readers);
-    self->offsets = (I32Array*)INCREF(offsets);
+    ivars->readers = (VArray*)INCREF(readers);
+    ivars->offsets = (I32Array*)INCREF(offsets);
     return self;
 }
 
 void
 PolyDelReader_close(PolyDeletionsReader *self) {
-    if (self->readers) {
-        for (uint32_t i = 0, max = VA_Get_Size(self->readers); i < max; i++) {
+    PolyDeletionsReaderIVARS *const ivars = PolyDelReader_IVARS(self);
+    if (ivars->readers) {
+        for (uint32_t i = 0, max = VA_Get_Size(ivars->readers); i < max; i++) {
             DeletionsReader *reader
-                = (DeletionsReader*)VA_Fetch(self->readers, i);
+                = (DeletionsReader*)VA_Fetch(ivars->readers, i);
             if (reader) { DelReader_Close(reader); }
         }
-        VA_Clear(self->readers);
+        VA_Clear(ivars->readers);
     }
 }
 
 void
 PolyDelReader_destroy(PolyDeletionsReader *self) {
-    DECREF(self->readers);
-    DECREF(self->offsets);
+    PolyDeletionsReaderIVARS *const ivars = PolyDelReader_IVARS(self);
+    DECREF(ivars->readers);
+    DECREF(ivars->offsets);
     SUPER_DESTROY(self, POLYDELETIONSREADER);
 }
 
 int32_t
 PolyDelReader_del_count(PolyDeletionsReader *self) {
-    return self->del_count;
+    return PolyDelReader_IVARS(self)->del_count;
 }
 
 Matcher*
 PolyDelReader_iterator(PolyDeletionsReader *self) {
+    PolyDeletionsReaderIVARS *const ivars = PolyDelReader_IVARS(self);
     SeriesMatcher *deletions = NULL;
-    if (self->del_count) {
-        uint32_t num_readers = VA_Get_Size(self->readers);
+    if (ivars->del_count) {
+        uint32_t num_readers = VA_Get_Size(ivars->readers);
         VArray *matchers = VA_new(num_readers);
         for (uint32_t i = 0; i < num_readers; i++) {
             DeletionsReader *reader
-                = (DeletionsReader*)VA_Fetch(self->readers, i);
+                = (DeletionsReader*)VA_Fetch(ivars->readers, i);
             Matcher *matcher = DelReader_Iterator(reader);
             if (matcher) { VA_Store(matchers, i, (Obj*)matcher); }
         }
-        deletions = SeriesMatcher_new(matchers, self->offsets);
+        deletions = SeriesMatcher_new(matchers, ivars->offsets);
         DECREF(matchers);
     }
     return (Matcher*)deletions;
@@ -126,28 +130,32 @@ DefDelReader_init(DefaultDeletionsReader *self, Schema *schema,
                   int32_t seg_tick) {
     DelReader_init((DeletionsReader*)self, schema, folder, snapshot, segments,
                    seg_tick);
+    DefaultDeletionsReaderIVARS *const ivars = DefDelReader_IVARS(self);
     DefDelReader_Read_Deletions(self);
-    if (!self->deldocs) {
-        self->del_count = 0;
-        self->deldocs   = BitVec_new(0);
+    if (!ivars->deldocs) {
+        ivars->del_count = 0;
+        ivars->deldocs   = BitVec_new(0);
     }
     return self;
 }
 
 void
 DefDelReader_close(DefaultDeletionsReader *self) {
-    DECREF(self->deldocs);
-    self->deldocs = NULL;
+    DefaultDeletionsReaderIVARS *const ivars = DefDelReader_IVARS(self);
+    DECREF(ivars->deldocs);
+    ivars->deldocs = NULL;
 }
 
 void
 DefDelReader_destroy(DefaultDeletionsReader *self) {
-    DECREF(self->deldocs);
+    DefaultDeletionsReaderIVARS *const ivars = DefDelReader_IVARS(self);
+    DECREF(ivars->deldocs);
     SUPER_DESTROY(self, DEFAULTDELETIONSREADER);
 }
 
 BitVector*
 DefDelReader_read_deletions(DefaultDeletionsReader *self) {
+    DefaultDeletionsReaderIVARS *const ivars = DefDelReader_IVARS(self);
     VArray  *segments    = DefDelReader_Get_Segments(self);
     Segment *segment     = DefDelReader_Get_Segment(self);
     CharBuf *my_seg_name = Seg_Get_Name(segment);
@@ -179,27 +187,28 @@ DefDelReader_read_deletions(DefaultDeletionsReader *self) {
         }
     }
 
-    DECREF(self->deldocs);
+    DECREF(ivars->deldocs);
     if (del_file) {
-        self->deldocs = (BitVector*)BitVecDelDocs_new(self->folder, del_file);
-        self->del_count = del_count;
+        ivars->deldocs = (BitVector*)BitVecDelDocs_new(ivars->folder, del_file);
+        ivars->del_count = del_count;
     }
     else {
-        self->deldocs = NULL;
-        self->del_count = 0;
+        ivars->deldocs = NULL;
+        ivars->del_count = 0;
     }
 
-    return self->deldocs;
+    return ivars->deldocs;
 }
 
 Matcher*
 DefDelReader_iterator(DefaultDeletionsReader *self) {
-    return (Matcher*)BitVecMatcher_new(self->deldocs);
+    DefaultDeletionsReaderIVARS *const ivars = DefDelReader_IVARS(self);
+    return (Matcher*)BitVecMatcher_new(ivars->deldocs);
 }
 
 int32_t
 DefDelReader_del_count(DefaultDeletionsReader *self) {
-    return self->del_count;
+    return DefDelReader_IVARS(self)->del_count;
 }
 
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/DeletionsWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DeletionsWriter.c b/core/Lucy/Index/DeletionsWriter.c
index 9dc34d2..759c6de 100644
--- a/core/Lucy/Index/DeletionsWriter.c
+++ b/core/Lucy/Index/DeletionsWriter.c
@@ -82,17 +82,18 @@ DefDelWriter_init(DefaultDeletionsWriter *self, Schema *schema,
                   PolyReader *polyreader) {
 
     DataWriter_init((DataWriter*)self, schema, snapshot, segment, polyreader);
-    self->seg_readers           = PolyReader_Seg_Readers(polyreader);
-    uint32_t num_seg_readers    = VA_Get_Size(self->seg_readers);
-    self->seg_starts            = PolyReader_Offsets(polyreader);
-    self->bit_vecs              = VA_new(num_seg_readers);
-    self->updated               = (bool*)CALLOCATE(num_seg_readers, sizeof(bool));
-    self->searcher              = IxSearcher_new((Obj*)polyreader);
-    self->name_to_tick          = Hash_new(num_seg_readers);
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
+    ivars->seg_readers          = PolyReader_Seg_Readers(polyreader);
+    uint32_t num_seg_readers    = VA_Get_Size(ivars->seg_readers);
+    ivars->seg_starts           = PolyReader_Offsets(polyreader);
+    ivars->bit_vecs             = VA_new(num_seg_readers);
+    ivars->updated              = (bool*)CALLOCATE(num_seg_readers, sizeof(bool));
+    ivars->searcher             = IxSearcher_new((Obj*)polyreader);
+    ivars->name_to_tick         = Hash_new(num_seg_readers);
 
     // Materialize a BitVector of deletions for each segment.
     for (uint32_t i = 0; i < num_seg_readers; i++) {
-        SegReader *seg_reader = (SegReader*)VA_Fetch(self->seg_readers, i);
+        SegReader *seg_reader = (SegReader*)VA_Fetch(ivars->seg_readers, i);
         BitVector *bit_vec    = BitVec_new(SegReader_Doc_Max(seg_reader));
         DeletionsReader *del_reader
             = (DeletionsReader*)SegReader_Fetch(
@@ -108,8 +109,8 @@ DefDelWriter_init(DefaultDeletionsWriter *self, Schema *schema,
             }
             DECREF(seg_dels);
         }
-        VA_Store(self->bit_vecs, i, (Obj*)bit_vec);
-        Hash_Store(self->name_to_tick,
+        VA_Store(ivars->bit_vecs, i, (Obj*)bit_vec);
+        Hash_Store(ivars->name_to_tick,
                    (Obj*)SegReader_Get_Seg_Name(seg_reader),
                    (Obj*)Int32_new(i));
     }
@@ -119,30 +120,33 @@ DefDelWriter_init(DefaultDeletionsWriter *self, Schema *schema,
 
 void
 DefDelWriter_destroy(DefaultDeletionsWriter *self) {
-    DECREF(self->seg_readers);
-    DECREF(self->seg_starts);
-    DECREF(self->bit_vecs);
-    DECREF(self->searcher);
-    DECREF(self->name_to_tick);
-    FREEMEM(self->updated);
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
+    DECREF(ivars->seg_readers);
+    DECREF(ivars->seg_starts);
+    DECREF(ivars->bit_vecs);
+    DECREF(ivars->searcher);
+    DECREF(ivars->name_to_tick);
+    FREEMEM(ivars->updated);
     SUPER_DESTROY(self, DEFAULTDELETIONSWRITER);
 }
 
 static CharBuf*
 S_del_filename(DefaultDeletionsWriter *self, SegReader *target_reader) {
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
     Segment *target_seg = SegReader_Get_Segment(target_reader);
-    return CB_newf("%o/deletions-%o.bv", Seg_Get_Name(self->segment),
+    return CB_newf("%o/deletions-%o.bv", Seg_Get_Name(ivars->segment),
                    Seg_Get_Name(target_seg));
 }
 
 void
 DefDelWriter_finish(DefaultDeletionsWriter *self) {
-    Folder *const folder = self->folder;
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
+    Folder *const folder = ivars->folder;
 
-    for (uint32_t i = 0, max = VA_Get_Size(self->seg_readers); i < max; i++) {
-        SegReader *seg_reader = (SegReader*)VA_Fetch(self->seg_readers, i);
-        if (self->updated[i]) {
-            BitVector *deldocs   = (BitVector*)VA_Fetch(self->bit_vecs, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->seg_readers); i < max; i++) {
+        SegReader *seg_reader = (SegReader*)VA_Fetch(ivars->seg_readers, i);
+        if (ivars->updated[i]) {
+            BitVector *deldocs   = (BitVector*)VA_Fetch(ivars->bit_vecs, i);
             int32_t    doc_max   = SegReader_Doc_Max(seg_reader);
             double     used      = (doc_max + 1) / 8.0;
             uint32_t   byte_size = (uint32_t)ceil(used);
@@ -164,19 +168,20 @@ DefDelWriter_finish(DefaultDeletionsWriter *self) {
         }
     }
 
-    Seg_Store_Metadata_Str(self->segment, "deletions", 9,
+    Seg_Store_Metadata_Str(ivars->segment, "deletions", 9,
                            (Obj*)DefDelWriter_Metadata(self));
 }
 
 Hash*
 DefDelWriter_metadata(DefaultDeletionsWriter *self) {
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
     Hash    *const metadata = DataWriter_metadata((DataWriter*)self);
     Hash    *const files    = Hash_new(0);
 
-    for (uint32_t i = 0, max = VA_Get_Size(self->seg_readers); i < max; i++) {
-        SegReader *seg_reader = (SegReader*)VA_Fetch(self->seg_readers, i);
-        if (self->updated[i]) {
-            BitVector *deldocs   = (BitVector*)VA_Fetch(self->bit_vecs, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->seg_readers); i < max; i++) {
+        SegReader *seg_reader = (SegReader*)VA_Fetch(ivars->seg_readers, i);
+        if (ivars->updated[i]) {
+            BitVector *deldocs   = (BitVector*)VA_Fetch(ivars->bit_vecs, i);
             Segment   *segment   = SegReader_Get_Segment(seg_reader);
             Hash      *mini_meta = Hash_new(2);
             Hash_Store_Str(mini_meta, "count", 5,
@@ -200,22 +205,23 @@ DefDelWriter_format(DefaultDeletionsWriter *self) {
 Matcher*
 DefDelWriter_seg_deletions(DefaultDeletionsWriter *self,
                            SegReader *seg_reader) {
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
     Matcher *deletions    = NULL;
     Segment *segment      = SegReader_Get_Segment(seg_reader);
     CharBuf *seg_name     = Seg_Get_Name(segment);
-    Integer32 *tick_obj   = (Integer32*)Hash_Fetch(self->name_to_tick,
+    Integer32 *tick_obj   = (Integer32*)Hash_Fetch(ivars->name_to_tick,
                                                    (Obj*)seg_name);
     int32_t tick          = tick_obj ? Int32_Get_Value(tick_obj) : 0;
     SegReader *candidate  = tick_obj
-                            ? (SegReader*)VA_Fetch(self->seg_readers, tick)
+                            ? (SegReader*)VA_Fetch(ivars->seg_readers, tick)
                             : NULL;
 
     if (tick_obj) {
         DeletionsReader *del_reader
             = (DeletionsReader*)SegReader_Obtain(
                   candidate, VTable_Get_Name(DELETIONSREADER));
-        if (self->updated[tick] || DelReader_Del_Count(del_reader)) {
-            BitVector *deldocs = (BitVector*)VA_Fetch(self->bit_vecs, tick);
+        if (ivars->updated[tick] || DelReader_Del_Count(del_reader)) {
+            BitVector *deldocs = (BitVector*)VA_Fetch(ivars->bit_vecs, tick);
             deletions = (Matcher*)BitVecMatcher_new(deldocs);
         }
     }
@@ -229,10 +235,11 @@ DefDelWriter_seg_deletions(DefaultDeletionsWriter *self,
 int32_t
 DefDelWriter_seg_del_count(DefaultDeletionsWriter *self,
                            const CharBuf *seg_name) {
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
     Integer32 *tick
-        = (Integer32*)Hash_Fetch(self->name_to_tick, (Obj*)seg_name);
+        = (Integer32*)Hash_Fetch(ivars->name_to_tick, (Obj*)seg_name);
     BitVector *deldocs = tick
-                         ? (BitVector*)VA_Fetch(self->bit_vecs, Int32_Get_Value(tick))
+                         ? (BitVector*)VA_Fetch(ivars->bit_vecs, Int32_Get_Value(tick))
                          : NULL;
     return deldocs ? BitVec_Count(deldocs) : 0;
 }
@@ -240,12 +247,13 @@ DefDelWriter_seg_del_count(DefaultDeletionsWriter *self,
 void
 DefDelWriter_delete_by_term(DefaultDeletionsWriter *self,
                             const CharBuf *field, Obj *term) {
-    for (uint32_t i = 0, max = VA_Get_Size(self->seg_readers); i < max; i++) {
-        SegReader *seg_reader = (SegReader*)VA_Fetch(self->seg_readers, i);
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->seg_readers); i < max; i++) {
+        SegReader *seg_reader = (SegReader*)VA_Fetch(ivars->seg_readers, i);
         PostingListReader *plist_reader
             = (PostingListReader*)SegReader_Fetch(
                   seg_reader, VTable_Get_Name(POSTINGLISTREADER));
-        BitVector *bit_vec = (BitVector*)VA_Fetch(self->bit_vecs, i);
+        BitVector *bit_vec = (BitVector*)VA_Fetch(ivars->bit_vecs, i);
         PostingList *plist = plist_reader
                              ? PListReader_Posting_List(plist_reader, field, term)
                              : NULL;
@@ -258,7 +266,7 @@ DefDelWriter_delete_by_term(DefaultDeletionsWriter *self,
                 num_zapped += !BitVec_Get(bit_vec, doc_id);
                 BitVec_Set(bit_vec, doc_id);
             }
-            if (num_zapped) { self->updated[i] = true; }
+            if (num_zapped) { ivars->updated[i] = true; }
             DECREF(plist);
         }
     }
@@ -266,12 +274,13 @@ DefDelWriter_delete_by_term(DefaultDeletionsWriter *self,
 
 void
 DefDelWriter_delete_by_query(DefaultDeletionsWriter *self, Query *query) {
-    Compiler *compiler = Query_Make_Compiler(query, (Searcher*)self->searcher,
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
+    Compiler *compiler = Query_Make_Compiler(query, (Searcher*)ivars->searcher,
                                              Query_Get_Boost(query), false);
 
-    for (uint32_t i = 0, max = VA_Get_Size(self->seg_readers); i < max; i++) {
-        SegReader *seg_reader = (SegReader*)VA_Fetch(self->seg_readers, i);
-        BitVector *bit_vec = (BitVector*)VA_Fetch(self->bit_vecs, i);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->seg_readers); i < max; i++) {
+        SegReader *seg_reader = (SegReader*)VA_Fetch(ivars->seg_readers, i);
+        BitVector *bit_vec = (BitVector*)VA_Fetch(ivars->bit_vecs, i);
         Matcher *matcher = Compiler_Make_Matcher(compiler, seg_reader, false);
 
         if (matcher) {
@@ -283,7 +292,7 @@ DefDelWriter_delete_by_query(DefaultDeletionsWriter *self, Query *query) {
                 num_zapped += !BitVec_Get(bit_vec, doc_id);
                 BitVec_Set(bit_vec, doc_id);
             }
-            if (num_zapped) { self->updated[i] = true; }
+            if (num_zapped) { ivars->updated[i] = true; }
 
             DECREF(matcher);
         }
@@ -294,21 +303,23 @@ DefDelWriter_delete_by_query(DefaultDeletionsWriter *self, Query *query) {
 
 void
 DefDelWriter_delete_by_doc_id(DefaultDeletionsWriter *self, int32_t doc_id) {
-    uint32_t   sub_tick   = PolyReader_sub_tick(self->seg_starts, doc_id);
-    BitVector *bit_vec    = (BitVector*)VA_Fetch(self->bit_vecs, sub_tick);
-    uint32_t   offset     = I32Arr_Get(self->seg_starts, sub_tick);
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
+    uint32_t   sub_tick   = PolyReader_sub_tick(ivars->seg_starts, doc_id);
+    BitVector *bit_vec    = (BitVector*)VA_Fetch(ivars->bit_vecs, sub_tick);
+    uint32_t   offset     = I32Arr_Get(ivars->seg_starts, sub_tick);
     int32_t    seg_doc_id = doc_id - offset;
 
     if (!BitVec_Get(bit_vec, seg_doc_id)) {
-        self->updated[sub_tick] = true;
+        ivars->updated[sub_tick] = true;
         BitVec_Set(bit_vec, seg_doc_id);
     }
 }
 
 bool
 DefDelWriter_updated(DefaultDeletionsWriter *self) {
-    for (uint32_t i = 0, max = VA_Get_Size(self->seg_readers); i < max; i++) {
-        if (self->updated[i]) { return true; }
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
+    for (uint32_t i = 0, max = VA_Get_Size(ivars->seg_readers); i < max; i++) {
+        if (ivars->updated[i]) { return true; }
     }
     return false;
 }
@@ -327,12 +338,13 @@ DefDelWriter_add_segment(DefaultDeletionsWriter *self, SegReader *reader,
 void
 DefDelWriter_merge_segment(DefaultDeletionsWriter *self, SegReader *reader,
                            I32Array *doc_map) {
+    DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self);
     UNUSED_VAR(doc_map);
     Segment *segment = SegReader_Get_Segment(reader);
     Hash *del_meta = (Hash*)Seg_Fetch_Metadata_Str(segment, "deletions", 9);
 
     if (del_meta) {
-        VArray *seg_readers = self->seg_readers;
+        VArray *seg_readers = ivars->seg_readers;
         Hash   *files = (Hash*)Hash_Fetch_Str(del_meta, "files", 5);
         if (files) {
             CharBuf *seg;
@@ -360,7 +372,7 @@ DefDelWriter_merge_segment(DefaultDeletionsWriter *self, SegReader *reader,
                             = (DeletionsReader*)SegReader_Obtain(
                                   candidate, VTable_Get_Name(DELETIONSREADER));
                         if (count == DelReader_Del_Count(del_reader)) {
-                            self->updated[i] = true;
+                            ivars->updated[i] = true;
                         }
                         break;
                     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/DocReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocReader.c b/core/Lucy/Index/DocReader.c
index 934969b..24c8052 100644
--- a/core/Lucy/Index/DocReader.c
+++ b/core/Lucy/Index/DocReader.c
@@ -51,37 +51,41 @@ PolyDocReader_new(VArray *readers, I32Array *offsets) {
 PolyDocReader*
 PolyDocReader_init(PolyDocReader *self, VArray *readers, I32Array *offsets) {
     DocReader_init((DocReader*)self, NULL, NULL, NULL, NULL, -1);
+    PolyDocReaderIVARS *const ivars = PolyDocReader_IVARS(self);
     for (uint32_t i = 0, max = VA_Get_Size(readers); i < max; i++) {
         CERTIFY(VA_Fetch(readers, i), DOCREADER);
     }
-    self->readers = (VArray*)INCREF(readers);
-    self->offsets = (I32Array*)INCREF(offsets);
+    ivars->readers = (VArray*)INCREF(readers);
+    ivars->offsets = (I32Array*)INCREF(offsets);
     return self;
 }
 
 void
 PolyDocReader_close(PolyDocReader *self) {
-    if (self->readers) {
-        for (uint32_t i = 0, max = VA_Get_Size(self->readers); i < max; i++) {
-            DocReader *reader = (DocReader*)VA_Fetch(self->readers, i);
+    PolyDocReaderIVARS *const ivars = PolyDocReader_IVARS(self);
+    if (ivars->readers) {
+        for (uint32_t i = 0, max = VA_Get_Size(ivars->readers); i < max; i++) {
+            DocReader *reader = (DocReader*)VA_Fetch(ivars->readers, i);
             if (reader) { DocReader_Close(reader); }
         }
-        VA_Clear(self->readers);
+        VA_Clear(ivars->readers);
     }
 }
 
 void
 PolyDocReader_destroy(PolyDocReader *self) {
-    DECREF(self->readers);
-    DECREF(self->offsets);
+    PolyDocReaderIVARS *const ivars = PolyDocReader_IVARS(self);
+    DECREF(ivars->readers);
+    DECREF(ivars->offsets);
     SUPER_DESTROY(self, POLYDOCREADER);
 }
 
 HitDoc*
 PolyDocReader_fetch_doc(PolyDocReader *self, int32_t doc_id) {
-    uint32_t seg_tick = PolyReader_sub_tick(self->offsets, doc_id);
-    int32_t  offset   = I32Arr_Get(self->offsets, seg_tick);
-    DocReader *doc_reader = (DocReader*)VA_Fetch(self->readers, seg_tick);
+    PolyDocReaderIVARS *const ivars = PolyDocReader_IVARS(self);
+    uint32_t seg_tick = PolyReader_sub_tick(ivars->offsets, doc_id);
+    int32_t  offset   = I32Arr_Get(ivars->offsets, seg_tick);
+    DocReader *doc_reader = (DocReader*)VA_Fetch(ivars->readers, seg_tick);
     HitDoc *hit_doc = NULL;
     if (!doc_reader) {
         THROW(ERR, "Invalid doc_id: %i32", doc_id);
@@ -104,22 +108,24 @@ DefDocReader_new(Schema *schema, Folder *folder, Snapshot *snapshot,
 
 void
 DefDocReader_close(DefaultDocReader *self) {
-    if (self->dat_in != NULL) {
-        InStream_Close(self->dat_in);
-        DECREF(self->dat_in);
-        self->dat_in = NULL;
+    DefaultDocReaderIVARS *const ivars = DefDocReader_IVARS(self);
+    if (ivars->dat_in != NULL) {
+        InStream_Close(ivars->dat_in);
+        DECREF(ivars->dat_in);
+        ivars->dat_in = NULL;
     }
-    if (self->ix_in != NULL) {
-        InStream_Close(self->ix_in);
-        DECREF(self->ix_in);
-        self->ix_in = NULL;
+    if (ivars->ix_in != NULL) {
+        InStream_Close(ivars->ix_in);
+        DECREF(ivars->ix_in);
+        ivars->ix_in = NULL;
     }
 }
 
 void
 DefDocReader_destroy(DefaultDocReader *self) {
-    DECREF(self->ix_in);
-    DECREF(self->dat_in);
+    DefaultDocReaderIVARS *const ivars = DefDocReader_IVARS(self);
+    DECREF(ivars->ix_in);
+    DECREF(ivars->dat_in);
     SUPER_DESTROY(self, DEFAULTDOCREADER);
 }
 
@@ -130,6 +136,7 @@ DefDocReader_init(DefaultDocReader *self, Schema *schema, Folder *folder,
     Segment *segment;
     DocReader_init((DocReader*)self, schema, folder, snapshot, segments,
                    seg_tick);
+    DefaultDocReaderIVARS *const ivars = DefDocReader_IVARS(self);
     segment = DefDocReader_Get_Segment(self);
     metadata = (Hash*)Seg_Fetch_Metadata_Str(segment, "documents", 9);
 
@@ -154,16 +161,16 @@ DefDocReader_init(DefaultDocReader *self, Schema *schema, Folder *folder,
 
         // Get streams.
         if (Folder_Exists(folder, ix_file)) {
-            self->ix_in = Folder_Open_In(folder, ix_file);
-            if (!self->ix_in) {
+            ivars->ix_in = Folder_Open_In(folder, ix_file);
+            if (!ivars->ix_in) {
                 Err *error = (Err*)INCREF(Err_get_error());
                 DECREF(ix_file);
                 DECREF(dat_file);
                 DECREF(self);
                 RETHROW(error);
             }
-            self->dat_in = Folder_Open_In(folder, dat_file);
-            if (!self->dat_in) {
+            ivars->dat_in = Folder_Open_In(folder, dat_file);
+            if (!ivars->dat_in) {
                 Err *error = (Err*)INCREF(Err_get_error());
                 DECREF(ix_file);
                 DECREF(dat_file);
@@ -181,16 +188,18 @@ DefDocReader_init(DefaultDocReader *self, Schema *schema, Folder *folder,
 void
 DefDocReader_read_record(DefaultDocReader *self, ByteBuf *buffer,
                          int32_t doc_id) {
+    DefaultDocReaderIVARS *const ivars = DefDocReader_IVARS(self);
+
     // Find start and length of variable length record.
-    InStream_Seek(self->ix_in, (int64_t)doc_id * 8);
-    int64_t start = InStream_Read_I64(self->ix_in);
-    int64_t end   = InStream_Read_I64(self->ix_in);
+    InStream_Seek(ivars->ix_in, (int64_t)doc_id * 8);
+    int64_t start = InStream_Read_I64(ivars->ix_in);
+    int64_t end   = InStream_Read_I64(ivars->ix_in);
     size_t size  = (size_t)(end - start);
 
     // Read in the record.
     char *buf = BB_Grow(buffer, size);
-    InStream_Seek(self->dat_in, start);
-    InStream_Read_Bytes(self->dat_in, buf, size);
+    InStream_Seek(ivars->dat_in, start);
+    InStream_Read_Bytes(ivars->dat_in, buf, size);
     BB_Set_Size(buffer, size);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/DocVector.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocVector.c b/core/Lucy/Index/DocVector.c
index 609c43b..131aaf4 100644
--- a/core/Lucy/Index/DocVector.c
+++ b/core/Lucy/Index/DocVector.c
@@ -41,62 +41,70 @@ DocVec_new() {
 
 DocVector*
 DocVec_init(DocVector *self) {
-    self->field_bufs    = Hash_new(0);
-    self->field_vectors = Hash_new(0);
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    ivars->field_bufs    = Hash_new(0);
+    ivars->field_vectors = Hash_new(0);
     return self;
 }
 
 void
 DocVec_serialize(DocVector *self, OutStream *outstream) {
-    Freezer_serialize_hash(self->field_bufs, outstream);
-    Freezer_serialize_hash(self->field_vectors, outstream);
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    Freezer_serialize_hash(ivars->field_bufs, outstream);
+    Freezer_serialize_hash(ivars->field_vectors, outstream);
 }
 
 DocVector*
 DocVec_deserialize(DocVector *self, InStream *instream) {
-    self->field_bufs    = Freezer_read_hash(instream);
-    self->field_vectors = Freezer_read_hash(instream);
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    ivars->field_bufs    = Freezer_read_hash(instream);
+    ivars->field_vectors = Freezer_read_hash(instream);
     return self;
 }
 
 void
 DocVec_destroy(DocVector *self) {
-    DECREF(self->field_bufs);
-    DECREF(self->field_vectors);
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    DECREF(ivars->field_bufs);
+    DECREF(ivars->field_vectors);
     SUPER_DESTROY(self, DOCVECTOR);
 }
 
 void
 DocVec_add_field_buf(DocVector *self, const CharBuf *field,
                      ByteBuf *field_buf) {
-    Hash_Store(self->field_bufs, (Obj*)field, INCREF(field_buf));
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    Hash_Store(ivars->field_bufs, (Obj*)field, INCREF(field_buf));
 }
 
 ByteBuf*
 DocVec_field_buf(DocVector *self, const CharBuf *field) {
-    return (ByteBuf*)Hash_Fetch(self->field_bufs, (Obj*)field);
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    return (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);
 }
 
 VArray*
 DocVec_field_names(DocVector *self) {
-    return Hash_Keys(self->field_bufs);
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    return Hash_Keys(ivars->field_bufs);
 }
 
 TermVector*
 DocVec_term_vector(DocVector *self, const CharBuf *field,
                    const CharBuf *term_text) {
-    Hash *field_vector = (Hash*)Hash_Fetch(self->field_vectors, (Obj*)field);
+    DocVectorIVARS *const ivars = DocVec_IVARS(self);
+    Hash *field_vector = (Hash*)Hash_Fetch(ivars->field_vectors, (Obj*)field);
 
     // If no cache hit, try to fill cache.
     if (field_vector == NULL) {
         ByteBuf *field_buf
-            = (ByteBuf*)Hash_Fetch(self->field_bufs, (Obj*)field);
+            = (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);
 
         // Bail if there's no content or the field isn't highlightable.
         if (field_buf == NULL) { return NULL; }
 
         field_vector = S_extract_tv_cache(field_buf);
-        Hash_Store(self->field_vectors, (Obj*)field, (Obj*)field_vector);
+        Hash_Store(ivars->field_vectors, (Obj*)field, (Obj*)field_vector);
     }
 
     // Get a buf for the term text or bail.

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/DocWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/DocWriter.c b/core/Lucy/Index/DocWriter.c
index 06355f0..0299de2 100644
--- a/core/Lucy/Index/DocWriter.c
+++ b/core/Lucy/Index/DocWriter.c
@@ -52,39 +52,42 @@ DocWriter_init(DocWriter *self, Schema *schema, Snapshot *snapshot,
 
 void
 DocWriter_destroy(DocWriter *self) {
-    DECREF(self->dat_out);
-    DECREF(self->ix_out);
+    DocWriterIVARS *const ivars = DocWriter_IVARS(self);
+    DECREF(ivars->dat_out);
+    DECREF(ivars->ix_out);
     SUPER_DESTROY(self, DOCWRITER);
 }
 
 static OutStream*
 S_lazy_init(DocWriter *self) {
-    if (!self->dat_out) {
-        Folder  *folder   = self->folder;
-        CharBuf *seg_name = Seg_Get_Name(self->segment);
+    DocWriterIVARS *const ivars = DocWriter_IVARS(self);
+    if (!ivars->dat_out) {
+        Folder  *folder   = ivars->folder;
+        CharBuf *seg_name = Seg_Get_Name(ivars->segment);
 
         // Get streams.
         CharBuf *ix_file = CB_newf("%o/documents.ix", seg_name);
-        self->ix_out = Folder_Open_Out(folder, ix_file);
+        ivars->ix_out = Folder_Open_Out(folder, ix_file);
         DECREF(ix_file);
-        if (!self->ix_out) { RETHROW(INCREF(Err_get_error())); }
+        if (!ivars->ix_out) { RETHROW(INCREF(Err_get_error())); }
         CharBuf *dat_file = CB_newf("%o/documents.dat", seg_name);
-        self->dat_out = Folder_Open_Out(folder, dat_file);
+        ivars->dat_out = Folder_Open_Out(folder, dat_file);
         DECREF(dat_file);
-        if (!self->dat_out) { RETHROW(INCREF(Err_get_error())); }
+        if (!ivars->dat_out) { RETHROW(INCREF(Err_get_error())); }
 
         // Go past non-doc #0.
-        OutStream_Write_I64(self->ix_out, 0);
+        OutStream_Write_I64(ivars->ix_out, 0);
     }
 
-    return self->dat_out;
+    return ivars->dat_out;
 }
 
 void
 DocWriter_add_inverted_doc(DocWriter *self, Inverter *inverter,
                            int32_t doc_id) {
+    DocWriterIVARS *const ivars = DocWriter_IVARS(self);
     OutStream *dat_out    = S_lazy_init(self);
-    OutStream *ix_out     = self->ix_out;
+    OutStream *ix_out     = ivars->ix_out;
     uint32_t   num_stored = 0;
     int64_t    start      = OutStream_Tell(dat_out);
     int64_t    expected   = OutStream_Tell(ix_out) / 8;
@@ -158,6 +161,7 @@ DocWriter_add_inverted_doc(DocWriter *self, Inverter *inverter,
 void
 DocWriter_add_segment(DocWriter *self, SegReader *reader,
                       I32Array *doc_map) {
+    DocWriterIVARS *const ivars = DocWriter_IVARS(self);
     int32_t doc_max = SegReader_Doc_Max(reader);
 
     if (doc_max == 0) {
@@ -166,7 +170,7 @@ DocWriter_add_segment(DocWriter *self, SegReader *reader,
     }
     else {
         OutStream *const dat_out = S_lazy_init(self);
-        OutStream *const ix_out  = self->ix_out;
+        OutStream *const ix_out  = ivars->ix_out;
         ByteBuf   *const buffer  = BB_new(0);
         DefaultDocReader *const doc_reader
             = (DefaultDocReader*)CERTIFY(
@@ -194,16 +198,17 @@ DocWriter_add_segment(DocWriter *self, SegReader *reader,
 
 void
 DocWriter_finish(DocWriter *self) {
-    if (self->dat_out) {
+    DocWriterIVARS *const ivars = DocWriter_IVARS(self);
+    if (ivars->dat_out) {
         // Write one final file pointer, so that we can derive the length of
         // the last record.
-        int64_t end = OutStream_Tell(self->dat_out);
-        OutStream_Write_I64(self->ix_out, end);
+        int64_t end = OutStream_Tell(ivars->dat_out);
+        OutStream_Write_I64(ivars->ix_out, end);
 
         // Close down output streams.
-        OutStream_Close(self->dat_out);
-        OutStream_Close(self->ix_out);
-        Seg_Store_Metadata_Str(self->segment, "documents", 9,
+        OutStream_Close(ivars->dat_out);
+        OutStream_Close(ivars->ix_out);
+        Seg_Store_Metadata_Str(ivars->segment, "documents", 9,
                                (Obj*)DocWriter_Metadata(self));
     }
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/FilePurger.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/FilePurger.c b/core/Lucy/Index/FilePurger.c
index 70e2ef8..35283ee 100644
--- a/core/Lucy/Index/FilePurger.c
+++ b/core/Lucy/Index/FilePurger.c
@@ -50,37 +50,40 @@ FilePurger_new(Folder *folder, Snapshot *snapshot, IndexManager *manager) {
 FilePurger*
 FilePurger_init(FilePurger *self, Folder *folder, Snapshot *snapshot,
                 IndexManager *manager) {
-    self->folder       = (Folder*)INCREF(folder);
-    self->snapshot     = (Snapshot*)INCREF(snapshot);
-    self->manager      = manager
+    FilePurgerIVARS *const ivars = FilePurger_IVARS(self);
+    ivars->folder       = (Folder*)INCREF(folder);
+    ivars->snapshot     = (Snapshot*)INCREF(snapshot);
+    ivars->manager      = manager
                          ? (IndexManager*)INCREF(manager)
                          : IxManager_new(NULL, NULL);
-    IxManager_Set_Folder(self->manager, folder);
+    IxManager_Set_Folder(ivars->manager, folder);
 
     // Don't allow the locks directory to be zapped.
-    self->disallowed = Hash_new(0);
-    Hash_Store_Str(self->disallowed, "locks", 5, (Obj*)CFISH_TRUE);
+    ivars->disallowed = Hash_new(0);
+    Hash_Store_Str(ivars->disallowed, "locks", 5, (Obj*)CFISH_TRUE);
 
     return self;
 }
 
 void
 FilePurger_destroy(FilePurger *self) {
-    DECREF(self->folder);
-    DECREF(self->snapshot);
-    DECREF(self->manager);
-    DECREF(self->disallowed);
+    FilePurgerIVARS *const ivars = FilePurger_IVARS(self);
+    DECREF(ivars->folder);
+    DECREF(ivars->snapshot);
+    DECREF(ivars->manager);
+    DECREF(ivars->disallowed);
     SUPER_DESTROY(self, FILEPURGER);
 }
 
 void
 FilePurger_purge(FilePurger *self) {
-    Lock *deletion_lock = IxManager_Make_Deletion_Lock(self->manager);
+    FilePurgerIVARS *const ivars = FilePurger_IVARS(self);
+    Lock *deletion_lock = IxManager_Make_Deletion_Lock(ivars->manager);
 
     // Obtain deletion lock, purge files, release deletion lock.
     Lock_Clear_Stale(deletion_lock);
     if (Lock_Obtain(deletion_lock)) {
-        Folder *folder   = self->folder;
+        Folder *folder   = ivars->folder;
         Hash   *failures = Hash_new(0);
         VArray *purgables;
         VArray *snapshots;
@@ -93,7 +96,7 @@ FilePurger_purge(FilePurger *self) {
         VA_Sort(purgables, NULL, NULL);
         for (uint32_t i = VA_Get_Size(purgables); i--;) {
             CharBuf *entry = (CharBuf*)VA_Fetch(purgables, i);
-            if (Hash_Fetch(self->disallowed, (Obj*)entry)) { continue; }
+            if (Hash_Fetch(ivars->disallowed, (Obj*)entry)) { continue; }
             if (!Folder_Delete(folder, entry)) {
                 if (Folder_Exists(folder, entry)) {
                     Hash_Store(failures, (Obj*)entry, (Obj*)CFISH_TRUE);
@@ -138,7 +141,8 @@ FilePurger_purge(FilePurger *self) {
 
 static void
 S_zap_dead_merge(FilePurger *self, Hash *candidates) {
-    IndexManager *manager    = self->manager;
+    FilePurgerIVARS *const ivars = FilePurger_IVARS(self);
+    IndexManager *manager    = ivars->manager;
     Lock         *merge_lock = IxManager_Make_Merge_Lock(manager);
 
     Lock_Clear_Stale(merge_lock);
@@ -150,9 +154,9 @@ S_zap_dead_merge(FilePurger *self, Hash *candidates) {
 
         if (cutoff) {
             CharBuf *cutoff_seg = Seg_num_to_name(Obj_To_I64(cutoff));
-            if (Folder_Exists(self->folder, cutoff_seg)) {
+            if (Folder_Exists(ivars->folder, cutoff_seg)) {
                 ZombieCharBuf *merge_json = ZCB_WRAP_STR("merge.json", 10);
-                DirHandle *dh = Folder_Open_Dir(self->folder, cutoff_seg);
+                DirHandle *dh = Folder_Open_Dir(ivars->folder, cutoff_seg);
                 CharBuf *entry = dh ? DH_Get_Entry(dh) : NULL;
                 CharBuf *filepath = CB_new(32);
 
@@ -183,7 +187,8 @@ S_zap_dead_merge(FilePurger *self, Hash *candidates) {
 static void
 S_discover_unused(FilePurger *self, VArray **purgables_ptr,
                   VArray **snapshots_ptr) {
-    Folder      *folder       = self->folder;
+    FilePurgerIVARS *const ivars = FilePurger_IVARS(self);
+    Folder      *folder       = ivars->folder;
     DirHandle   *dh           = Folder_Open_Dir(folder, NULL);
     if (!dh) { RETHROW(INCREF(Err_get_error())); }
     VArray      *spared       = VA_new(1);
@@ -191,13 +196,13 @@ S_discover_unused(FilePurger *self, VArray **purgables_ptr,
     CharBuf     *snapfile     = NULL;
 
     // Start off with the list of files in the current snapshot.
-    if (self->snapshot) {
-        VArray *entries    = Snapshot_List(self->snapshot);
+    if (ivars->snapshot) {
+        VArray *entries    = Snapshot_List(ivars->snapshot);
         VArray *referenced = S_find_all_referenced(folder, entries);
         VA_Push_VArray(spared, referenced);
         DECREF(entries);
         DECREF(referenced);
-        snapfile = Snapshot_Get_Path(self->snapshot);
+        snapfile = Snapshot_Get_Path(ivars->snapshot);
         if (snapfile) { VA_Push(spared, INCREF(snapfile)); }
     }
 
@@ -211,7 +216,7 @@ S_discover_unused(FilePurger *self, VArray **purgables_ptr,
             Snapshot *snapshot
                 = Snapshot_Read_File(Snapshot_new(), folder, entry);
             Lock *lock
-                = IxManager_Make_Snapshot_Read_Lock(self->manager, entry);
+                = IxManager_Make_Snapshot_Read_Lock(ivars->manager, entry);
             VArray *snap_list  = Snapshot_List(snapshot);
             VArray *referenced = S_find_all_referenced(folder, snap_list);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/HighlightReader.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightReader.c b/core/Lucy/Index/HighlightReader.c
index 8f4b1d6..655a5e4 100644
--- a/core/Lucy/Index/HighlightReader.c
+++ b/core/Lucy/Index/HighlightReader.c
@@ -58,42 +58,46 @@ PolyHighlightReader*
 PolyHLReader_init(PolyHighlightReader *self, VArray *readers,
                   I32Array *offsets) {
     HLReader_init((HighlightReader*)self, NULL, NULL, NULL, NULL, -1);
+    PolyHighlightReaderIVARS *const ivars = PolyHLReader_IVARS(self);
     for (uint32_t i = 0, max = VA_Get_Size(readers); i < max; i++) {
         CERTIFY(VA_Fetch(readers, i), HIGHLIGHTREADER);
     }
-    self->readers = (VArray*)INCREF(readers);
-    self->offsets = (I32Array*)INCREF(offsets);
+    ivars->readers = (VArray*)INCREF(readers);
+    ivars->offsets = (I32Array*)INCREF(offsets);
     return self;
 }
 
 void
 PolyHLReader_close(PolyHighlightReader *self) {
-    if (self->readers) {
-        for (uint32_t i = 0, max = VA_Get_Size(self->readers); i < max; i++) {
+    PolyHighlightReaderIVARS *const ivars = PolyHLReader_IVARS(self);
+    if (ivars->readers) {
+        for (uint32_t i = 0, max = VA_Get_Size(ivars->readers); i < max; i++) {
             HighlightReader *sub_reader
-                = (HighlightReader*)VA_Fetch(self->readers, i);
+                = (HighlightReader*)VA_Fetch(ivars->readers, i);
             if (sub_reader) { HLReader_Close(sub_reader); }
         }
-        DECREF(self->readers);
-        DECREF(self->offsets);
-        self->readers = NULL;
-        self->offsets = NULL;
+        DECREF(ivars->readers);
+        DECREF(ivars->offsets);
+        ivars->readers = NULL;
+        ivars->offsets = NULL;
     }
 }
 
 void
 PolyHLReader_destroy(PolyHighlightReader *self) {
-    DECREF(self->readers);
-    DECREF(self->offsets);
+    PolyHighlightReaderIVARS *const ivars = PolyHLReader_IVARS(self);
+    DECREF(ivars->readers);
+    DECREF(ivars->offsets);
     SUPER_DESTROY(self, POLYHIGHLIGHTREADER);
 }
 
 DocVector*
 PolyHLReader_fetch_doc_vec(PolyHighlightReader *self, int32_t doc_id) {
-    uint32_t seg_tick = PolyReader_sub_tick(self->offsets, doc_id);
-    int32_t  offset   = I32Arr_Get(self->offsets, seg_tick);
+    PolyHighlightReaderIVARS *const ivars = PolyHLReader_IVARS(self);
+    uint32_t seg_tick = PolyReader_sub_tick(ivars->offsets, doc_id);
+    int32_t  offset   = I32Arr_Get(ivars->offsets, seg_tick);
     HighlightReader *sub_reader
-        = (HighlightReader*)VA_Fetch(self->readers, seg_tick);
+        = (HighlightReader*)VA_Fetch(ivars->readers, seg_tick);
     if (!sub_reader) { THROW(ERR, "Invalid doc_id: %i32", doc_id); }
     return HLReader_Fetch_Doc_Vec(sub_reader, doc_id - offset);
 }
@@ -113,6 +117,7 @@ DefHLReader_init(DefaultHighlightReader *self, Schema *schema,
                  int32_t seg_tick) {
     HLReader_init((HighlightReader*)self, schema, folder, snapshot,
                   segments, seg_tick);
+    DefaultHighlightReaderIVARS *const ivars = DefHLReader_IVARS(self);
     Segment *segment    = DefHLReader_Get_Segment(self);
     Hash *metadata      = (Hash*)Seg_Fetch_Metadata_Str(segment, "highlight", 9);
     if (!metadata) {
@@ -136,16 +141,16 @@ DefHLReader_init(DefaultHighlightReader *self, Schema *schema,
     CharBuf *ix_file  = CB_newf("%o/highlight.ix", seg_name);
     CharBuf *dat_file = CB_newf("%o/highlight.dat", seg_name);
     if (Folder_Exists(folder, ix_file)) {
-        self->ix_in = Folder_Open_In(folder, ix_file);
-        if (!self->ix_in) {
+        ivars->ix_in = Folder_Open_In(folder, ix_file);
+        if (!ivars->ix_in) {
             Err *error = (Err*)INCREF(Err_get_error());
             DECREF(ix_file);
             DECREF(dat_file);
             DECREF(self);
             RETHROW(error);
         }
-        self->dat_in = Folder_Open_In(folder, dat_file);
-        if (!self->dat_in) {
+        ivars->dat_in = Folder_Open_In(folder, dat_file);
+        if (!ivars->dat_in) {
             Err *error = (Err*)INCREF(Err_get_error());
             DECREF(ix_file);
             DECREF(dat_file);
@@ -161,29 +166,32 @@ DefHLReader_init(DefaultHighlightReader *self, Schema *schema,
 
 void
 DefHLReader_close(DefaultHighlightReader *self) {
-    if (self->dat_in != NULL) {
-        InStream_Close(self->dat_in);
-        DECREF(self->dat_in);
-        self->dat_in = NULL;
+    DefaultHighlightReaderIVARS *const ivars = DefHLReader_IVARS(self);
+    if (ivars->dat_in != NULL) {
+        InStream_Close(ivars->dat_in);
+        DECREF(ivars->dat_in);
+        ivars->dat_in = NULL;
     }
-    if (self->ix_in != NULL) {
-        InStream_Close(self->ix_in);
-        DECREF(self->ix_in);
-        self->ix_in = NULL;
+    if (ivars->ix_in != NULL) {
+        InStream_Close(ivars->ix_in);
+        DECREF(ivars->ix_in);
+        ivars->ix_in = NULL;
     }
 }
 
 void
 DefHLReader_destroy(DefaultHighlightReader *self) {
-    DECREF(self->ix_in);
-    DECREF(self->dat_in);
+    DefaultHighlightReaderIVARS *const ivars = DefHLReader_IVARS(self);
+    DECREF(ivars->ix_in);
+    DECREF(ivars->dat_in);
     SUPER_DESTROY(self, DEFAULTHIGHLIGHTREADER);
 }
 
 DocVector*
 DefHLReader_fetch_doc_vec(DefaultHighlightReader *self, int32_t doc_id) {
-    InStream *const ix_in  = self->ix_in;
-    InStream *const dat_in = self->dat_in;
+    DefaultHighlightReaderIVARS *const ivars = DefHLReader_IVARS(self);
+    InStream *const ix_in  = ivars->ix_in;
+    InStream *const dat_in = ivars->dat_in;
     DocVector *doc_vec = DocVec_new();
 
     InStream_Seek(ix_in, doc_id * 8);
@@ -205,8 +213,9 @@ DefHLReader_fetch_doc_vec(DefaultHighlightReader *self, int32_t doc_id) {
 void
 DefHLReader_read_record(DefaultHighlightReader *self, int32_t doc_id,
                         ByteBuf *target) {
-    InStream *dat_in = self->dat_in;
-    InStream *ix_in  = self->ix_in;
+    DefaultHighlightReaderIVARS *const ivars = DefHLReader_IVARS(self);
+    InStream *dat_in = ivars->dat_in;
+    InStream *ix_in  = ivars->ix_in;
 
     InStream_Seek(ix_in, doc_id * 8);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/HighlightWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/HighlightWriter.c b/core/Lucy/Index/HighlightWriter.c
index 175e165..b398552 100644
--- a/core/Lucy/Index/HighlightWriter.c
+++ b/core/Lucy/Index/HighlightWriter.c
@@ -60,41 +60,44 @@ HLWriter_init(HighlightWriter *self, Schema *schema, Snapshot *snapshot,
 
 void
 HLWriter_destroy(HighlightWriter *self) {
-    DECREF(self->dat_out);
-    DECREF(self->ix_out);
+    HighlightWriterIVARS *const ivars = HLWriter_IVARS(self);
+    DECREF(ivars->dat_out);
+    DECREF(ivars->ix_out);
     SUPER_DESTROY(self, HIGHLIGHTWRITER);
 }
 
 static OutStream*
 S_lazy_init(HighlightWriter *self) {
-    if (!self->dat_out) {
-        Segment  *segment  = self->segment;
-        Folder   *folder   = self->folder;
+    HighlightWriterIVARS *const ivars = HLWriter_IVARS(self);
+    if (!ivars->dat_out) {
+        Segment  *segment  = ivars->segment;
+        Folder   *folder   = ivars->folder;
         CharBuf  *seg_name = Seg_Get_Name(segment);
 
         // Open outstreams.
         CharBuf *ix_file = CB_newf("%o/highlight.ix", seg_name);
-        self->ix_out = Folder_Open_Out(folder, ix_file);
+        ivars->ix_out = Folder_Open_Out(folder, ix_file);
         DECREF(ix_file);
-        if (!self->ix_out) { RETHROW(INCREF(Err_get_error())); }
+        if (!ivars->ix_out) { RETHROW(INCREF(Err_get_error())); }
 
         CharBuf *dat_file = CB_newf("%o/highlight.dat", seg_name);
-        self->dat_out = Folder_Open_Out(folder, dat_file);
+        ivars->dat_out = Folder_Open_Out(folder, dat_file);
         DECREF(dat_file);
-        if (!self->dat_out) { RETHROW(INCREF(Err_get_error())); }
+        if (!ivars->dat_out) { RETHROW(INCREF(Err_get_error())); }
 
         // Go past invalid doc 0.
-        OutStream_Write_I64(self->ix_out, 0);
+        OutStream_Write_I64(ivars->ix_out, 0);
     }
 
-    return self->dat_out;
+    return ivars->dat_out;
 }
 
 void
 HLWriter_add_inverted_doc(HighlightWriter *self, Inverter *inverter,
                           int32_t doc_id) {
+    HighlightWriterIVARS *const ivars = HLWriter_IVARS(self);
     OutStream *dat_out = S_lazy_init(self);
-    OutStream *ix_out  = self->ix_out;
+    OutStream *ix_out  = ivars->ix_out;
     int64_t    filepos = OutStream_Tell(dat_out);
     uint32_t num_highlightable = 0;
     int32_t expected = (int32_t)(OutStream_Tell(ix_out) / 8);
@@ -207,6 +210,7 @@ HLWriter_tv_buf(HighlightWriter *self, Inversion *inversion) {
 void
 HLWriter_add_segment(HighlightWriter *self, SegReader *reader,
                      I32Array *doc_map) {
+    HighlightWriterIVARS *const ivars = HLWriter_IVARS(self);
     int32_t doc_max = SegReader_Doc_Max(reader);
 
     if (doc_max == 0) {
@@ -219,7 +223,7 @@ HLWriter_add_segment(HighlightWriter *self, SegReader *reader,
                   SegReader_Obtain(reader, VTable_Get_Name(HIGHLIGHTREADER)),
                   DEFAULTHIGHLIGHTREADER);
         OutStream *dat_out = S_lazy_init(self);
-        OutStream *ix_out  = self->ix_out;
+        OutStream *ix_out  = ivars->ix_out;
         int32_t    orig;
         ByteBuf   *bb = BB_new(0);
 
@@ -244,16 +248,17 @@ HLWriter_add_segment(HighlightWriter *self, SegReader *reader,
 
 void
 HLWriter_finish(HighlightWriter *self) {
-    if (self->dat_out) {
+    HighlightWriterIVARS *const ivars = HLWriter_IVARS(self);
+    if (ivars->dat_out) {
         // Write one final file pointer, so that we can derive the length of
         // the last record.
-        int64_t end = OutStream_Tell(self->dat_out);
-        OutStream_Write_I64(self->ix_out, end);
+        int64_t end = OutStream_Tell(ivars->dat_out);
+        OutStream_Write_I64(ivars->ix_out, end);
 
         // Close down the output streams.
-        OutStream_Close(self->dat_out);
-        OutStream_Close(self->ix_out);
-        Seg_Store_Metadata_Str(self->segment, "highlight", 9,
+        OutStream_Close(ivars->dat_out);
+        OutStream_Close(ivars->ix_out);
+        Seg_Store_Metadata_Str(ivars->segment, "highlight", 9,
                                (Obj*)HLWriter_Metadata(self));
     }
 }

http://git-wip-us.apache.org/repos/asf/lucy/blob/7c23ce21/core/Lucy/Index/IndexManager.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/IndexManager.c b/core/Lucy/Index/IndexManager.c
index 61bb761..684e476 100644
--- a/core/Lucy/Index/IndexManager.c
+++ b/core/Lucy/Index/IndexManager.c
@@ -40,26 +40,28 @@ IxManager_new(const CharBuf *host, LockFactory *lock_factory) {
 IndexManager*
 IxManager_init(IndexManager *self, const CharBuf *host,
                LockFactory *lock_factory) {
-    self->host                = host
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
+    ivars->host                = host
                                 ? CB_Clone(host)
                                 : CB_new_from_trusted_utf8("", 0);
-    self->lock_factory        = (LockFactory*)INCREF(lock_factory);
-    self->folder              = NULL;
-    self->write_lock_timeout  = 1000;
-    self->write_lock_interval = 100;
-    self->merge_lock_timeout  = 0;
-    self->merge_lock_interval = 1000;
-    self->deletion_lock_timeout  = 1000;
-    self->deletion_lock_interval = 100;
+    ivars->lock_factory        = (LockFactory*)INCREF(lock_factory);
+    ivars->folder              = NULL;
+    ivars->write_lock_timeout  = 1000;
+    ivars->write_lock_interval = 100;
+    ivars->merge_lock_timeout  = 0;
+    ivars->merge_lock_interval = 1000;
+    ivars->deletion_lock_timeout  = 1000;
+    ivars->deletion_lock_interval = 100;
 
     return self;
 }
 
 void
 IxManager_destroy(IndexManager *self) {
-    DECREF(self->host);
-    DECREF(self->folder);
-    DECREF(self->lock_factory);
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
+    DECREF(ivars->host);
+    DECREF(ivars->folder);
+    DECREF(ivars->lock_factory);
     SUPER_DESTROY(self, INDEXMANAGER);
 }
 
@@ -81,7 +83,8 @@ IxManager_highest_seg_num(IndexManager *self, Snapshot *snapshot) {
 
 CharBuf*
 IxManager_make_snapshot_filename(IndexManager *self) {
-    Folder *folder = (Folder*)CERTIFY(self->folder, FOLDER);
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
+    Folder *folder = (Folder*)CERTIFY(ivars->folder, FOLDER);
     DirHandle *dh = Folder_Open_Dir(folder, NULL);
     uint64_t max_gen = 0;
 
@@ -216,49 +219,54 @@ IxManager_choose_sparse(IndexManager *self, I32Array *doc_counts) {
 
 static LockFactory*
 S_obtain_lock_factory(IndexManager *self) {
-    if (!self->lock_factory) {
-        if (!self->folder) {
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
+    if (!ivars->lock_factory) {
+        if (!ivars->folder) {
             THROW(ERR, "Can't create a LockFactory without a Folder");
         }
-        self->lock_factory = LockFact_new(self->folder, self->host);
+        ivars->lock_factory = LockFact_new(ivars->folder, ivars->host);
     }
-    return self->lock_factory;
+    return ivars->lock_factory;
 }
 
 Lock*
 IxManager_make_write_lock(IndexManager *self) {
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
     ZombieCharBuf *write_lock_name = ZCB_WRAP_STR("write", 5);
     LockFactory *lock_factory = S_obtain_lock_factory(self);
     return LockFact_Make_Lock(lock_factory, (CharBuf*)write_lock_name,
-                              self->write_lock_timeout,
-                              self->write_lock_interval);
+                              ivars->write_lock_timeout,
+                              ivars->write_lock_interval);
 }
 
 Lock*
 IxManager_make_deletion_lock(IndexManager *self) {
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
     ZombieCharBuf *lock_name = ZCB_WRAP_STR("deletion", 8);
     LockFactory *lock_factory = S_obtain_lock_factory(self);
     return LockFact_Make_Lock(lock_factory, (CharBuf*)lock_name,
-                              self->deletion_lock_timeout,
-                              self->deletion_lock_interval);
+                              ivars->deletion_lock_timeout,
+                              ivars->deletion_lock_interval);
 }
 
 Lock*
 IxManager_make_merge_lock(IndexManager *self) {
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
     ZombieCharBuf *merge_lock_name = ZCB_WRAP_STR("merge", 5);
     LockFactory *lock_factory = S_obtain_lock_factory(self);
     return LockFact_Make_Lock(lock_factory, (CharBuf*)merge_lock_name,
-                              self->merge_lock_timeout,
-                              self->merge_lock_interval);
+                              ivars->merge_lock_timeout,
+                              ivars->merge_lock_interval);
 }
 
 void
 IxManager_write_merge_data(IndexManager *self, int64_t cutoff) {
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
     ZombieCharBuf *merge_json = ZCB_WRAP_STR("merge.json", 10);
     Hash *data = Hash_new(1);
     bool success;
     Hash_Store_Str(data, "cutoff", 6, (Obj*)CB_newf("%i64", cutoff));
-    success = Json_spew_json((Obj*)data, self->folder, (CharBuf*)merge_json);
+    success = Json_spew_json((Obj*)data, ivars->folder, (CharBuf*)merge_json);
     DECREF(data);
     if (!success) {
         THROW(ERR, "Failed to write to %o", merge_json);
@@ -267,10 +275,11 @@ IxManager_write_merge_data(IndexManager *self, int64_t cutoff) {
 
 Hash*
 IxManager_read_merge_data(IndexManager *self) {
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
     ZombieCharBuf *merge_json = ZCB_WRAP_STR("merge.json", 10);
-    if (Folder_Exists(self->folder, (CharBuf*)merge_json)) {
+    if (Folder_Exists(ivars->folder, (CharBuf*)merge_json)) {
         Hash *stuff
-            = (Hash*)Json_slurp_json(self->folder, (CharBuf*)merge_json);
+            = (Hash*)Json_slurp_json(ivars->folder, (CharBuf*)merge_json);
         if (stuff) {
             CERTIFY(stuff, HASH);
             return stuff;
@@ -286,8 +295,9 @@ IxManager_read_merge_data(IndexManager *self) {
 
 bool
 IxManager_remove_merge_data(IndexManager *self) {
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
     ZombieCharBuf *merge_json = ZCB_WRAP_STR("merge.json", 10);
-    return Folder_Delete(self->folder, (CharBuf*)merge_json) != 0;
+    return Folder_Delete(ivars->folder, (CharBuf*)merge_json) != 0;
 }
 
 Lock*
@@ -310,78 +320,79 @@ IxManager_make_snapshot_read_lock(IndexManager *self,
 
 void
 IxManager_set_folder(IndexManager *self, Folder *folder) {
-    DECREF(self->folder);
-    self->folder = (Folder*)INCREF(folder);
+    IndexManagerIVARS *const ivars = IxManager_IVARS(self);
+    DECREF(ivars->folder);
+    ivars->folder = (Folder*)INCREF(folder);
 }
 
 Folder*
 IxManager_get_folder(IndexManager *self) {
-    return self->folder;
+    return IxManager_IVARS(self)->folder;
 }
 
 CharBuf*
 IxManager_get_host(IndexManager *self) {
-    return self->host;
+    return IxManager_IVARS(self)->host;
 }
 
 uint32_t
 IxManager_get_write_lock_timeout(IndexManager *self) {
-    return self->write_lock_timeout;
+    return IxManager_IVARS(self)->write_lock_timeout;
 }
 
 uint32_t
 IxManager_get_write_lock_interval(IndexManager *self) {
-    return self->write_lock_interval;
+    return IxManager_IVARS(self)->write_lock_interval;
 }
 
 uint32_t
 IxManager_get_merge_lock_timeout(IndexManager *self) {
-    return self->merge_lock_timeout;
+    return IxManager_IVARS(self)->merge_lock_timeout;
 }
 
 uint32_t
 IxManager_get_merge_lock_interval(IndexManager *self) {
-    return self->merge_lock_interval;
+    return IxManager_IVARS(self)->merge_lock_interval;
 }
 
 uint32_t
 IxManager_get_deletion_lock_timeout(IndexManager *self) {
-    return self->deletion_lock_timeout;
+    return IxManager_IVARS(self)->deletion_lock_timeout;
 }
 
 uint32_t
 IxManager_get_deletion_lock_interval(IndexManager *self) {
-    return self->deletion_lock_interval;
+    return IxManager_IVARS(self)->deletion_lock_interval;
 }
 
 void
 IxManager_set_write_lock_timeout(IndexManager *self, uint32_t timeout) {
-    self->write_lock_timeout = timeout;
+    IxManager_IVARS(self)->write_lock_timeout = timeout;
 }
 
 void
 IxManager_set_write_lock_interval(IndexManager *self, uint32_t interval) {
-    self->write_lock_interval = interval;
+    IxManager_IVARS(self)->write_lock_interval = interval;
 }
 
 void
 IxManager_set_merge_lock_timeout(IndexManager *self, uint32_t timeout) {
-    self->merge_lock_timeout = timeout;
+    IxManager_IVARS(self)->merge_lock_timeout = timeout;
 }
 
 void
 IxManager_set_merge_lock_interval(IndexManager *self, uint32_t interval) {
-    self->merge_lock_interval = interval;
+    IxManager_IVARS(self)->merge_lock_interval = interval;
 }
 
 void
 IxManager_set_deletion_lock_timeout(IndexManager *self, uint32_t timeout) {
-    self->deletion_lock_timeout = timeout;
+    IxManager_IVARS(self)->deletion_lock_timeout = timeout;
 }
 
 void
 IxManager_set_deletion_lock_interval(IndexManager *self, uint32_t interval) {
-    self->deletion_lock_interval = interval;
+    IxManager_IVARS(self)->deletion_lock_interval = interval;
 }
 
 


Mime
View raw message