lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mar...@apache.org
Subject [lucy-commits] [2/2] git commit: refs/heads/sortex_ptr_only - Change type for SortEx buffer.
Date Wed, 09 Jan 2013 01:14:35 GMT
Updated Branches:
  refs/heads/sortex_ptr_only 6384d8984 -> 8640ab5f6


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/8640ab5f
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/8640ab5f
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/8640ab5f

Branch: refs/heads/sortex_ptr_only
Commit: 8640ab5f60097305ff1e52afdc2e838cb7d3dc07
Parents: 2fb0098
Author: Marvin Humphrey <marvin@rectangular.com>
Authored: Tue Jan 8 17:11:59 2013 -0800
Committer: Marvin Humphrey <marvin@rectangular.com>
Committed: Tue Jan 8 17:11:59 2013 -0800

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


http://git-wip-us.apache.org/repos/asf/lucy/blob/8640ab5f/core/Lucy/Index/PostingPool.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/PostingPool.c b/core/Lucy/Index/PostingPool.c
index f8bf304..4895c6b 100644
--- a/core/Lucy/Index/PostingPool.c
+++ b/core/Lucy/Index/PostingPool.c
@@ -196,7 +196,7 @@ PostPool_flip(PostingPool *self) {
                            self->mem_pool, self->lex_temp_out,
                            self->post_temp_out, self->skip_out);
         PostPool_Grow_Cache(run, num_items);
-        memcpy(run->cache, ((Obj**)self->cache) + self->cache_tick,
+        memcpy(run->cache, (self->cache + self->cache_tick),
                num_items * sizeof(Obj*));
         run->cache_max = num_items;
         PostPool_Add_Run(self, (SortExternal*)run);
@@ -257,10 +257,10 @@ PostPool_shrink(PostingPool *self) {
         size_t cache_count = PostPool_Cache_Count(self);
         size_t size        = cache_count * sizeof(Obj*);
         if (self->cache_tick > 0) {
-            Obj **start = ((Obj**)self->cache) + self->cache_tick;
+            Obj **start = self->cache + self->cache_tick;
             memmove(self->cache, start, size);
         }
-        self->cache      = (uint8_t*)REALLOCATE(self->cache, size);
+        self->cache      = (Obj**)REALLOCATE(self->cache, size);
         self->cache_tick = 0;
         self->cache_max  = cache_count;
         self->cache_cap  = cache_count;
@@ -525,8 +525,7 @@ PostPool_refill(PostingPool *self) {
             size_t new_cap = Memory_oversize(num_elems + 1, sizeof(Obj*));
             PostPool_Grow_Cache(self, new_cap);
         }
-        Obj **cache = (Obj**)self->cache;
-        cache[num_elems] = (Obj*)raw_posting;
+        self->cache[num_elems] = (Obj*)raw_posting;
         num_elems++;
     }
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/8640ab5f/core/Lucy/Test/Util/BBSortEx.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Test/Util/BBSortEx.c b/core/Lucy/Test/Util/BBSortEx.c
index f586733..0a6fc28 100644
--- a/core/Lucy/Test/Util/BBSortEx.c
+++ b/core/Lucy/Test/Util/BBSortEx.c
@@ -48,7 +48,7 @@ BBSortEx_destroy(BBSortEx *self) {
 
 void
 BBSortEx_clear_cache(BBSortEx *self) {
-    Obj **const cache = (Obj**)self->cache;
+    Obj **const cache = self->cache;
     for (uint32_t i = self->cache_tick, max = self->cache_max; i < max; i++) {
         DECREF(cache[i]);
     }
@@ -75,7 +75,7 @@ BBSortEx_feed(BBSortEx *self, Obj *item) {
 void
 BBSortEx_flush(BBSortEx *self) {
     uint32_t     cache_count = self->cache_max - self->cache_tick;
-    Obj        **cache = (Obj**)self->cache;
+    Obj        **cache = self->cache;
     VArray      *elems;
 
     if (!cache_count) { return; }
@@ -128,8 +128,7 @@ BBSortEx_refill(BBSortEx *self) {
                                 Memory_oversize(self->cache_max + 1,
                                                 sizeof(Obj*)));
         }
-        Obj **cache = (Obj**)self->cache;
-        cache[self->cache_max++] = INCREF(elem);
+        self->cache[self->cache_max++] = INCREF(elem);
     }
 
     return self->cache_max;

http://git-wip-us.apache.org/repos/asf/lucy/blob/8640ab5f/core/Lucy/Util/SortExternal.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.c b/core/Lucy/Util/SortExternal.c
index 2634add..a5b885d 100644
--- a/core/Lucy/Util/SortExternal.c
+++ b/core/Lucy/Util/SortExternal.c
@@ -82,8 +82,7 @@ SortEx_feed(SortExternal *self, Obj *item) {
         size_t amount = Memory_oversize(self->cache_max + 1, sizeof(Obj*));
         SortEx_Grow_Cache(self, amount);
     }
-    Obj **elems = (Obj**)self->cache;
-    elems[self->cache_max] = item;
+    self->cache[self->cache_max] = item;
     self->cache_max++;
 }
 
@@ -94,8 +93,7 @@ SI_peek(SortExternal *self) {
     }
 
     if (self->cache_max > 0) {
-        Obj **elems = (Obj**)self->cache;
-        return elems[self->cache_tick];
+        return self->cache[self->cache_tick];
     }
     else {
         return NULL;
@@ -147,9 +145,9 @@ SortEx_add_run(SortExternal *self, SortExternal *run) {
     self->slice_sizes = (uint32_t*)REALLOCATE(
                             self->slice_sizes,
                             num_runs * sizeof(uint32_t));
-    self->slice_starts = (Obj**)REALLOCATE(
+    self->slice_starts = (Obj***)REALLOCATE(
                              self->slice_starts,
-                             num_runs * sizeof(Obj*));
+                             num_runs * sizeof(Obj**));
 }
 
 static void
@@ -191,7 +189,7 @@ S_find_endpost(SortExternal *self) {
         else {
             // Cache item with the highest sort value currently held in memory
             // by the run.
-            Obj **candidate = (Obj**)run->cache + tick;
+            Obj **candidate = run->cache + tick;
 
             // If it's the first run, item is automatically the new endpost.
             if (i == 0) {
@@ -210,7 +208,7 @@ S_find_endpost(SortExternal *self) {
 static void
 S_absorb_slices(SortExternal *self, Obj **endpost) {
     uint32_t    num_runs     = VA_Get_Size(self->runs);
-    Obj       **slice_starts = self->slice_starts;
+    Obj      ***slice_starts = self->slice_starts;
     uint32_t   *slice_sizes  = self->slice_sizes;
     VTable     *vtable       = SortEx_Get_VTable(self);
     Lucy_Sort_Compare_t compare
@@ -230,8 +228,8 @@ S_absorb_slices(SortExternal *self, Obj **endpost) {
                                              sizeof(Obj*));
                 SortEx_Grow_Cache(self, cap);
             }
-            memcpy(self->cache + self->cache_max * sizeof(Obj*),
-                   run->cache + run->cache_tick * sizeof(Obj*),
+            memcpy(self->cache + self->cache_max,
+                   run->cache + run->cache_tick,
                    slice_size * sizeof(Obj*));
             run->cache_tick += slice_size;
             self->cache_max += slice_size;
@@ -244,7 +242,7 @@ S_absorb_slices(SortExternal *self, Obj **endpost) {
     // Transform slice starts from ticks to pointers.
     uint32_t total = 0;
     for (uint32_t i = 0; i < self->num_slices; i++) {
-        slice_starts[i] = (Obj*)(self->cache + total * sizeof(Obj*));
+        slice_starts[i] = self->cache + total;
         total += slice_sizes[i];
     }
 
@@ -292,7 +290,7 @@ S_absorb_slices(SortExternal *self, Obj **endpost) {
 void
 SortEx_grow_cache(SortExternal *self, uint32_t size) {
     if (size > self->cache_cap) {
-        self->cache = (uint8_t*)REALLOCATE(self->cache, size * sizeof(Obj*));
+        self->cache = (Obj**)REALLOCATE(self->cache, size * sizeof(Obj*));
         self->cache_cap = size;
     }
 }
@@ -301,7 +299,7 @@ static uint32_t
 S_find_slice_size(SortExternal *self, Obj **endpost) {
     int32_t          lo      = self->cache_tick - 1;
     int32_t          hi      = self->cache_max;
-    Obj            **cache   = (Obj**)self->cache;
+    Obj            **cache   = self->cache;
     SortEx_Compare_t compare
         = METHOD_PTR(SortEx_Get_VTable(self), Lucy_SortEx_Compare);
 

http://git-wip-us.apache.org/repos/asf/lucy/blob/8640ab5f/core/Lucy/Util/SortExternal.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Util/SortExternal.cfh b/core/Lucy/Util/SortExternal.cfh
index eb9a2b0..99c4bf1 100644
--- a/core/Lucy/Util/SortExternal.cfh
+++ b/core/Lucy/Util/SortExternal.cfh
@@ -49,7 +49,7 @@ __END_C__
 abstract class Lucy::Util::SortExternal cnick 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 cnick 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