lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] [1/6] git commit: refs/heads/sortfieldwriter - Don't sort documents twice in SortFieldWriter#Refill
Date Sun, 13 Oct 2013 13:59:04 GMT
Updated Branches:
  refs/heads/sortfieldwriter [created] cf6cc5631


Don't sort documents twice in SortFieldWriter#Refill

The doc_ids are already sorted in S_lazy_init_sorted_ids. We only have
to make sure that S_lazy_init_sorted_ids uses the doc_id as secondary
sort key.


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

Branch: refs/heads/sortfieldwriter
Commit: 0e49ac6f6ca45860d5598060b89bdac3fbfed2db
Parents: 668e82a
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Thu Sep 26 01:25:52 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Sun Oct 13 15:09:33 2013 +0200

----------------------------------------------------------------------
 core/Lucy/Index/SortFieldWriter.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/0e49ac6f/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index e7d35cf..6ae42d1 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -340,7 +340,7 @@ SortFieldWriter_Compare_IMP(SortFieldWriter *self, void *va, void *vb)
{
     SFWriterElem *b = (SFWriterElem*)vb;
     int32_t comparison
         = FType_null_back_compare_values(ivars->type, a->value, b->value);
-    if (comparison == 0) { comparison = b->doc_id - a->doc_id; }
+    if (comparison == 0) { comparison = a->doc_id - b->doc_id; }
     return comparison;
 }
 
@@ -351,7 +351,9 @@ S_compare_doc_ids_by_ord_rev(void *context, const void *va, const void
*vb) {
     int32_t b = *(int32_t*)vb;
     int32_t ord_a = SortCache_Ordinal(sort_cache, a);
     int32_t ord_b = SortCache_Ordinal(sort_cache, b);
-    return ord_a - ord_b;
+    int32_t comparison = ord_a - ord_b;
+    if (comparison == 0) { comparison = a - b; }
+    return comparison;
 }
 
 static void
@@ -475,7 +477,6 @@ SortFieldWriter_Refill_IMP(SortFieldWriter *self) {
         ivars->run_tick++;
     }
     ivars->run_ord++;
-    SortFieldWriter_Sort_Cache(self);
 
     if (ivars->run_ord >= ivars->run_cardinality) {
         DECREF(ivars->sort_cache);


Mime
View raw message