lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [47/54] [abbrv] git commit: refs/heads/sortex_ptr_only - Change type for SortEx buffer.
Date Sat, 26 Apr 2014 23:12:17 GMT
Change type for SortEx buffer.

Change buffer for SortExternal to an array of objects instead of
addresses.


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

Branch: refs/heads/sortex_ptr_only
Commit: c09c1dcab745ed5ecdaa66e1e1c1a276263e418f
Parents: 7392ca1
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Jan 8 17:11:59 2013 -0800
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Sat Apr 26 13:48:18 2014 -0700

----------------------------------------------------------------------
 core/Lucy/Index/PostingPool.c   |  9 ++++-----
 core/Lucy/Util/BBSortEx.c       |  7 +++----
 core/Lucy/Util/SortExternal.c   | 23 ++++++++++-------------
 core/Lucy/Util/SortExternal.cfh |  4 ++--
 4 files changed, 19 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/c09c1dca/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index 6628fc3..55eecc9 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -202,7 +202,7 @@ PostPool_Flip_IMP(PostingPool *self) {
         PostPool_Grow_Cache(run, num_items);
         PostingPoolIVARS *const run_ivars = PostPool_IVARS(run);
 
-        memcpy(run_ivars->cache, ((Obj**)ivars->cache) + ivars->cache_tick,
+        memcpy(run_ivars->cache, (ivars->cache) + ivars->cache_tick,
                num_items * sizeof(Obj*));
         run_ivars->cache_max = num_items;
         PostPool_Add_Run(self, (SortExternal*)run);
@@ -266,10 +266,10 @@ PostPool_Shrink_IMP(PostingPool *self) {
         size_t cache_count = PostPool_Cache_Count(self);
         size_t size        = cache_count * sizeof(Obj*);
         if (ivars->cache_tick > 0) {
-            Obj **start = ((Obj**)ivars->cache) + ivars->cache_tick;
+            Obj **start = ivars->cache + ivars->cache_tick;
             memmove(ivars->cache, start, size);
         }
-        ivars->cache      = (uint8_t*)REALLOCATE(ivars->cache, size);
+        ivars->cache      = (Obj**)REALLOCATE(ivars->cache, size);
         ivars->cache_tick = 0;
         ivars->cache_max  = cache_count;
         ivars->cache_cap  = cache_count;
@@ -549,8 +549,7 @@ PostPool_Refill_IMP(PostingPool *self) {
             size_t new_cap = Memory_oversize(num_elems + 1, sizeof(Obj*));
             PostPool_Grow_Cache(self, new_cap);
         }
-        Obj **cache = (Obj**)ivars->cache;
-        cache[num_elems] = (Obj*)rawpost;
+        ivars->cache[num_elems] = (Obj*)rawpost;
         num_elems++;
     }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/c09c1dca/core/Lucy/Util/BBSortEx.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/BBSortEx.c b/core/Lucy/Util/BBSortEx.c
index fb50522..40238cf 100644
--- a/core/Lucy/Util/BBSortEx.c
+++ b/core/Lucy/Util/BBSortEx.c
@@ -52,7 +52,7 @@ BBSortEx_Destroy_IMP(BBSortEx *self) {
 void
 BBSortEx_Clear_Cache_IMP(BBSortEx *self) {
     BBSortExIVARS *const ivars = BBSortEx_IVARS(self);
-    Obj **const cache = (Obj**)ivars->cache;
+    Obj **const cache = ivars->cache;
     for (uint32_t i = ivars->cache_tick, max = ivars->cache_max; i < max; i++) {
         DECREF(cache[i]);
     }
@@ -81,7 +81,7 @@ void
 BBSortEx_Flush_IMP(BBSortEx *self) {
     BBSortExIVARS *const ivars = BBSortEx_IVARS(self);
     uint32_t     cache_count = ivars->cache_max - ivars->cache_tick;
-    Obj        **cache = (Obj**)ivars->cache;
+    Obj        **cache = ivars->cache;
     VArray      *elems;
 
     if (!cache_count) { return; }
@@ -136,8 +136,7 @@ BBSortEx_Refill_IMP(BBSortEx *self) {
                                 Memory_oversize(ivars->cache_max + 1,
                                                 sizeof(Obj*)));
         }
-        Obj **cache = (Obj**)ivars->cache;
-        cache[ivars->cache_max++] = INCREF(elem);
+        ivars->cache[ivars->cache_max++] = INCREF(elem);
     }
 
     return ivars->cache_max;

http://git-wip-us.apache.org/repos/asf/lucy/blob/c09c1dca/core/Lucy/Util/SortExternal.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.c b/core/Lucy/Util/SortExternal.c
index 3aa3334..434c34d 100644
--- a/core/Lucy/Util/SortExternal.c
+++ b/core/Lucy/Util/SortExternal.c
@@ -89,8 +89,7 @@ SortEx_Feed_IMP(SortExternal *self, Obj *item) {
         size_t amount = Memory_oversize(ivars->cache_max + 1, sizeof(Obj*));
         SortEx_Grow_Cache(self, amount);
     }
-    Obj **elems = (Obj**)ivars->cache;
-    elems[ivars->cache_max] = item;
+    ivars->cache[ivars->cache_max] = item;
     ivars->cache_max++;
 }
 
@@ -101,8 +100,7 @@ SI_peek(SortExternal *self, SortExternalIVARS *ivars) {
     }
 
     if (ivars->cache_max > 0) {
-        Obj **elems = (Obj**)ivars->cache;
-        return elems[ivars->cache_tick];
+        return ivars->cache[ivars->cache_tick];
     }
     else {
         return NULL;
@@ -159,8 +157,7 @@ SortEx_Add_Run_IMP(SortExternal *self, SortExternal *run) {
         = (uint32_t*)REALLOCATE(ivars->slice_sizes,
                                 num_runs * sizeof(uint32_t));
     ivars->slice_starts
-        = (Obj**)REALLOCATE(ivars->slice_starts,
-                                num_runs * sizeof(Obj*));
+        = (Obj***)REALLOCATE(ivars->slice_starts, num_runs * sizeof(Obj**));
 }
 
 static void
@@ -203,7 +200,7 @@ S_find_endpost(SortExternal *self, SortExternalIVARS *ivars) {
         else {
             // Cache item with the highest sort value currently held in memory
             // by the run.
-            Obj **candidate = (Obj**)run_ivars->cache + tick;
+            Obj **candidate = run_ivars->cache + tick;
 
             // If it's the first run, item is automatically the new endpost.
             if (i == 0) {
@@ -223,7 +220,7 @@ static void
 S_absorb_slices(SortExternal *self, SortExternalIVARS *ivars,
                 Obj **endpost) {
     uint32_t    num_runs     = VA_Get_Size(ivars->runs);
-    Obj       **slice_starts = ivars->slice_starts;
+    Obj      ***slice_starts = ivars->slice_starts;
     uint32_t   *slice_sizes  = ivars->slice_sizes;
     VTable     *vtable       = SortEx_Get_VTable(self);
     CFISH_Sort_Compare_t compare
@@ -244,8 +241,8 @@ S_absorb_slices(SortExternal *self, SortExternalIVARS *ivars,
                                              sizeof(Obj*));
                 SortEx_Grow_Cache(self, cap);
             }
-            memcpy(ivars->cache + ivars->cache_max * sizeof(Obj*),
-                   run_ivars->cache + run_ivars->cache_tick * sizeof(Obj*),
+            memcpy(ivars->cache + ivars->cache_max,
+                   run_ivars->cache + run_ivars->cache_tick,
                    slice_size * sizeof(Obj*));
             run_ivars->cache_tick += slice_size;
             ivars->cache_max += slice_size;
@@ -258,7 +255,7 @@ S_absorb_slices(SortExternal *self, SortExternalIVARS *ivars,
     // Transform slice starts from ticks to pointers.
     uint32_t total = 0;
     for (uint32_t i = 0; i < ivars->num_slices; i++) {
-        slice_starts[i] = (Obj*)(ivars->cache + total * sizeof(Obj*));
+        slice_starts[i] = ivars->cache + total;
         total += slice_sizes[i];
     }
 
@@ -307,7 +304,7 @@ void
 SortEx_Grow_Cache_IMP(SortExternal *self, uint32_t size) {
     SortExternalIVARS *const ivars = SortEx_IVARS(self);
     if (size > ivars->cache_cap) {
-        ivars->cache = (uint8_t*)REALLOCATE(ivars->cache, size * sizeof(Obj*));
+        ivars->cache = (Obj**)REALLOCATE(ivars->cache, size * sizeof(Obj*));
         ivars->cache_cap = size;
     }
 }
@@ -317,7 +314,7 @@ S_find_slice_size(SortExternal *self, SortExternalIVARS *ivars,
                   Obj **endpost) {
     int32_t          lo      = ivars->cache_tick - 1;
     int32_t          hi      = ivars->cache_max;
-    Obj            **cache   = (Obj**)ivars->cache;
+    Obj            **cache   = ivars->cache;
     SortEx_Compare_t compare
         = METHOD_PTR(SortEx_Get_VTable(self), LUCY_SortEx_Compare);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/c09c1dca/core/Lucy/Util/SortExternal.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.cfh b/core/Lucy/Util/SortExternal.cfh
index b1af4ad..13d3009 100644
--- a/core/Lucy/Util/SortExternal.cfh
+++ b/core/Lucy/Util/SortExternal.cfh
@@ -49,7 +49,7 @@ __END_C__
 abstract class Lucy::Util::SortExternal nickname SortEx
     inherits Clownfish::Obj {
 
-    uint8_t       *cache;
+    Obj          **cache;
     uint32_t       cache_cap;
     uint32_t       cache_max;
     uint32_t       cache_tick;
@@ -57,7 +57,7 @@ abstract class Lucy::Util::SortExternal nickname SortEx
     uint32_t       scratch_cap;
     VArray        *runs;
     uint32_t       num_slices;
-    Obj          **slice_starts;
+    Obj         ***slice_starts;
     uint32_t      *slice_sizes;
     uint32_t       mem_thresh;
     bool           flipped;


Mime
View raw message