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:09 UTC
[4/8] git commit: refs/heads/master - Don't sort documents twice in
SortFieldWriter#Refill
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/efbc9ace
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/efbc9ace
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/efbc9ace
Branch: refs/heads/master
Commit: efbc9acef7a97463b9d98404e6add8362fcf5e4c
Parents: 4d500c5
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Sep 26 01:25:52 2013 +0200
Committer: Marvin Humphrey <ma...@rectangular.com>
Committed: Wed Jun 18 21:22:59 2014 -0700
----------------------------------------------------------------------
core/Lucy/Index/SortFieldWriter.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy/blob/efbc9ace/core/Lucy/Index/SortFieldWriter.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Index/SortFieldWriter.c b/core/Lucy/Index/SortFieldWriter.c
index 381f9ad..9fe71c0 100644
--- a/core/Lucy/Index/SortFieldWriter.c
+++ b/core/Lucy/Index/SortFieldWriter.c
@@ -345,7 +345,7 @@ SortFieldWriter_Compare_IMP(SortFieldWriter *self, void *va, void *vb) {
SFWriterElemIVARS *b = SFWriterElem_IVARS(*(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;
}
@@ -356,7 +356,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
@@ -480,7 +482,6 @@ SortFieldWriter_Refill_IMP(SortFieldWriter *self) {
ivars->run_tick++;
}
ivars->run_ord++;
- SortFieldWriter_Sort_Buffer(self);
if (ivars->run_ord >= ivars->run_cardinality) {
DECREF(ivars->sort_cache);