From f39f4f66c1cb3f830de2e4161b522274a156387d Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 6 Mar 2014 15:49:18 +0000 Subject: [PATCH] LUCENE-5493: minor cleanups/opto git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5493@1574928 13f79535-47bb-0310-9956-ffa450edef68 --- .../index/sorter/BlockJoinComparatorSource.java | 15 ++++++++++----- .../apache/lucene/index/sorter/SortSorter.java | 8 +++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/lucene/misc/src/java/org/apache/lucene/index/sorter/BlockJoinComparatorSource.java b/lucene/misc/src/java/org/apache/lucene/index/sorter/BlockJoinComparatorSource.java index ab29e74a428..c2a2a476b28 100644 --- a/lucene/misc/src/java/org/apache/lucene/index/sorter/BlockJoinComparatorSource.java +++ b/lucene/misc/src/java/org/apache/lucene/index/sorter/BlockJoinComparatorSource.java @@ -73,7 +73,7 @@ public class BlockJoinComparatorSource extends FieldComparatorSource { final FieldComparator parentComparators[] = new FieldComparator[parentFields.length]; for (int i = 0; i < parentFields.length; i++) { parentReverseMul[i] = parentFields[i].getReverse() ? -1 : 1; - parentComparators[i] = parentFields[i].getComparator(2, i); + parentComparators[i] = parentFields[i].getComparator(1, i); } SortField childFields[] = childSort.getSort(); @@ -81,7 +81,7 @@ public class BlockJoinComparatorSource extends FieldComparatorSource { final FieldComparator childComparators[] = new FieldComparator[childFields.length]; for (int i = 0; i < childFields.length; i++) { childReverseMul[i] = childFields[i].getReverse() ? -1 : 1; - childComparators[i] = childFields[i].getComparator(2, i); + childComparators[i] = childFields[i].getComparator(1, i); } // NOTE: not quite right i guess, really our sort "value" is more complex... @@ -191,9 +191,11 @@ public class BlockJoinComparatorSource extends FieldComparatorSource { int compare(int docID1, int docID2, FieldComparator comparators[], int reverseMul[]) throws IOException { for (int i = 0; i < comparators.length; i++) { + // TODO: would be better if copy() didnt cause a term lookup in TermOrdVal & co, + // the segments are always the same here... comparators[i].copy(0, docID1); - comparators[i].copy(1, docID2); - int comp = reverseMul[i] * comparators[i].compare(0, 1); + comparators[i].setBottom(0); + int comp = reverseMul[i] * comparators[i].compareBottom(docID2); if (comp != 0) { return comp; } @@ -203,5 +205,8 @@ public class BlockJoinComparatorSource extends FieldComparatorSource { }; } - + @Override + public String toString() { + return "blockJoin(parentSort=" + parentSort + ",childSort=" + childSort + ")"; + } } diff --git a/lucene/misc/src/java/org/apache/lucene/index/sorter/SortSorter.java b/lucene/misc/src/java/org/apache/lucene/index/sorter/SortSorter.java index 5ec5cd8f025..52c3c849b5c 100644 --- a/lucene/misc/src/java/org/apache/lucene/index/sorter/SortSorter.java +++ b/lucene/misc/src/java/org/apache/lucene/index/sorter/SortSorter.java @@ -41,7 +41,7 @@ class SortSorter extends Sorter { for (int i = 0; i < fields.length; i++) { reverseMul[i] = fields[i].getReverse() ? -1 : 1; - comparators[i] = fields[i].getComparator(2, i); + comparators[i] = fields[i].getComparator(1, i); comparators[i].setNextReader(reader.getContext()); comparators[i].setScorer(FAKESCORER); } @@ -50,9 +50,11 @@ class SortSorter extends Sorter { public int compare(int docID1, int docID2) { try { for (int i = 0; i < comparators.length; i++) { + // TODO: would be better if copy() didnt cause a term lookup in TermOrdVal & co, + // the segments are always the same here... comparators[i].copy(0, docID1); - comparators[i].copy(1, docID2); - int comp = reverseMul[i] * comparators[i].compare(0, 1); + comparators[i].setBottom(0); + int comp = reverseMul[i] * comparators[i].compareBottom(docID2); if (comp != 0) { return comp; }