You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2014/07/01 21:35:08 UTC

[3/8] git commit: refs/heads/master - Make SortFieldWriter#Refill obey the memory limit

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

Branch: refs/heads/master
Commit: 0cf86d1d79cc91723762f6abd34c034a25cb285b
Parents: efbc9ac
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Sep 26 02:04:42 2013 +0200
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Jun 18 21:22:59 2014 -0700

----------------------------------------------------------------------
 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/0cf86d1d/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 9fe71c0..8a372a3 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -92,7 +92,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;
@@ -450,19 +449,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) {
@@ -476,14 +466,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/0cf86d1d/core/Lucy/Index/SortFieldWriter.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.cfh b/core/Lucy/Index/SortFieldWriter.cfh
index 8f749cc..0128c61 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;