lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] git commit: refs/heads/cfish-string-prep1 - Fix changes to SortFieldWriter
Date Wed, 18 Sep 2013 11:27:46 GMT
Updated Branches:
  refs/heads/cfish-string-prep1 fde94c411 -> 80b15686a


Fix changes to SortFieldWriter

Now I realized that the objects which have previously be Mimiced were
keys of a ZombieKeyedHash allocated from a MemoryPool. As a temporary
fix, Clone the last Fetched value when the hash is cleared.

With immutable strings, I think we can get rid of ZombieKeyedHash and
use a normal Hash instead. Then this fix can be reverted.


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

Branch: refs/heads/cfish-string-prep1
Commit: 80b15686ae1cde8238fa707a809ece5ee8e7b30c
Parents: fde94c4
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Wed Sep 18 13:21:36 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Wed Sep 18 13:21:36 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Index/SortFieldWriter.c   | 17 ++++++++++++-----
 core/Lucy/Index/SortFieldWriter.cfh |  1 +
 2 files changed, 13 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/80b15686/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index bf08089..18ace6a 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -94,6 +94,7 @@ SortFieldWriter_init(SortFieldWriter *self, Schema *schema,
     ivars->run_ord         = 0;
     ivars->run_tick        = 0;
     ivars->ord_width       = 0;
+    ivars->last_val        = NULL;
 
     // Assign.
     ivars->field        = Str_Clone(field);
@@ -128,6 +129,11 @@ void
 SortFieldWriter_Clear_Cache_IMP(SortFieldWriter *self) {
     SortFieldWriterIVARS *const ivars = SortFieldWriter_IVARS(self);
     if (ivars->uniq_vals) {
+        if (ivars->last_val) {
+            Obj *clone = Obj_Clone(ivars->last_val);
+            DECREF(ivars->last_val);
+            ivars->last_val = clone;
+        }
         Hash_Clear(ivars->uniq_vals);
     }
     SortFieldWriter_Clear_Cache_t super_clear_cache
@@ -552,24 +558,25 @@ S_write_files(SortFieldWriter *self, OutStream *ord_out, OutStream *ix_out,
     ords[0] = 0;
 
     // Build array of ords, write non-NULL sorted values.
-    Obj *val = INCREF(elem->value);
+    ivars->last_val = INCREF(elem->value);
     Obj *last_val_address = elem->value;
     S_write_val(elem->value, prim_id, ix_out, dat_out, dat_start);
     while (NULL != (elem = (SFWriterElem*)SortFieldWriter_Fetch(self))) {
         if (elem->value != last_val_address) {
             int32_t comparison
-                = FType_Compare_Values(ivars->type, elem->value, val);
+                = FType_Compare_Values(ivars->type, elem->value, ivars->last_val);
             if (comparison != 0) {
                 ord++;
                 S_write_val(elem->value, prim_id, ix_out, dat_out, dat_start);
-                DECREF(val);
-                val = INCREF(elem->value);
+                DECREF(ivars->last_val);
+                ivars->last_val = INCREF(elem->value);
             }
             last_val_address = elem->value;
         }
         ords[elem->doc_id] = ord;
     }
-    DECREF(val);
+    DECREF(ivars->last_val);
+    ivars->last_val = NULL;
 
     // If there are NULL values, write one now and record the NULL ord.
     if (has_nulls) {

http://git-wip-us.apache.org/repos/asf/lucy/blob/80b15686/core/Lucy/Index/SortFieldWriter.cfh
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.cfh b/core/Lucy/Index/SortFieldWriter.cfh
index 3f6301b..274961c 100644
--- a/core/Lucy/Index/SortFieldWriter.cfh
+++ b/core/Lucy/Index/SortFieldWriter.cfh
@@ -51,6 +51,7 @@ class Lucy::Index::SortFieldWriter
     int32_t     run_ord;
     int32_t     run_tick;
     int32_t     ord_width;
+    Obj        *last_val;
 
     inert incremented SortFieldWriter*
     new(Schema *schema, Snapshot *snapshot, Segment *segment,


Mime
View raw message