lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [2/6] git commit: refs/heads/sortfieldwriter - Make SortFieldWriter#Refill obey the memory limit
Date Sun, 13 Oct 2013 13:59:05 GMT
Make SortFieldWriter#Refill obey the memory limit

The old logic was broken.


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

Branch: refs/heads/sortfieldwriter
Commit: a5aa40a93d0b2542dc04afd387619b015cf273b5
Parents: 0e49ac6
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Thu Sep 26 02:04:42 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Oct 13 15:10:09 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Index/SortFieldWriter.c   | 20 +++-----------------
 core/Lucy/Index/SortFieldWriter.cfh |  1 -
 2 files changed, 3 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/a5aa40a9/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 6ae42d1..7c698e6 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -91,7 +91,6 @@ SortFieldWriter_init(SortFieldWriter *self, Schema *schema,
     ivars->sort_cache      = NULL;
     ivars->doc_map         = NULL;
     ivars->sorted_ids      = NULL;
-    ivars->run_ord         = 0;
     ivars->run_tick        = 0;
     ivars->ord_width       = 0;
     ivars->last_val        = NULL;
@@ -445,19 +444,10 @@ SortFieldWriter_Refill_IMP(SortFieldWriter *self) {
     I32Array *const  doc_map    = ivars->doc_map;
     SortCache *const sort_cache = ivars->sort_cache;
 
-    while (ivars->run_ord < ivars->run_cardinality
+    uint32_t count = 0;
+    while (ivars->run_tick <= ivars->run_max
            && MemPool_Get_Consumed(ivars->mem_pool) < ivars->mem_thresh
           ) {
-        Obj *val = SortCache_Value(sort_cache, ivars->run_ord);
-        if (val) {
-            Hash_Store(uniq_vals, val, (Obj*)CFISH_TRUE);
-            DECREF(val);
-            break;
-        }
-        ivars->run_ord++;
-    }
-    uint32_t count = 0;
-    while (ivars->run_tick <= ivars->run_max) {
         int32_t raw_doc_id = ivars->sorted_ids[ivars->run_tick];
         int32_t ord = SortCache_Ordinal(sort_cache, raw_doc_id);
         if (ord != null_ord) {
@@ -471,14 +461,10 @@ SortFieldWriter_Refill_IMP(SortFieldWriter *self) {
                 DECREF(val);
             }
         }
-        else if (ord > ivars->run_ord) {
-            break;
-        }
         ivars->run_tick++;
     }
-    ivars->run_ord++;
 
-    if (ivars->run_ord >= ivars->run_cardinality) {
+    if (ivars->run_tick > ivars->run_max) {
         DECREF(ivars->sort_cache);
         ivars->sort_cache = NULL;
     }

http://git-wip-us.apache.org/repos/asf/lucy/blob/a5aa40a9/core/Lucy/Index/SortFieldWriter.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.cfh b/core/Lucy/Index/SortFieldWriter.cfh
index ac25515..cdb9c8e 100644
--- a/core/Lucy/Index/SortFieldWriter.cfh
+++ b/core/Lucy/Index/SortFieldWriter.cfh
@@ -48,7 +48,6 @@ class Lucy::Index::SortFieldWriter
     int32_t     run_max;
     bool        var_width;
     int32_t    *sorted_ids;
-    int32_t     run_ord;
     int32_t     run_tick;
     int32_t     ord_width;
     Obj        *last_val;


Mime
View raw message