From 58198c299cd88fecacf3bfdbfbfb7f4aef7694b7 Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Thu, 6 Mar 2014 17:03:56 +0000 Subject: [PATCH] LUCENE-5493: fix precommit git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5493@1574962 13f79535-47bb-0310-9956-ffa450edef68 --- .../index/sorter/BlockJoinComparatorSource.java | 15 +++++++++++---- .../lucene/index/sorter/SortingAtomicReader.java | 10 +++++----- 2 files changed, 16 insertions(+), 9 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 c2a2a476b28..3029bcab656 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 @@ -31,7 +31,16 @@ import org.apache.lucene.util.FixedBitSet; /** * Helper class to sort readers that contain blocks of documents. + *

+ * Note that this currently has some limitations: + *

+ * Its intended to be used with {@link SortingMergePolicy}. */ +// TODO: can/should we clean this thing up (e.g. return a proper sort value) +// and move to the join/ module? public class BlockJoinComparatorSource extends FieldComparatorSource { final Filter parentsFilter; final Sort parentSort; @@ -84,8 +93,8 @@ public class BlockJoinComparatorSource extends FieldComparatorSource { childComparators[i] = childFields[i].getComparator(1, i); } - // NOTE: not quite right i guess, really our sort "value" is more complex... - // but at the moment you really should only use this at indexing time. + // NOTE: we could return parent ID as value but really our sort "value" is more complex... + // So we throw UOE for now. At the moment you really should only use this at indexing time. return new FieldComparator() { int bottomParent; int bottomChild; @@ -171,7 +180,6 @@ public class BlockJoinComparatorSource extends FieldComparatorSource { int compare(int docID1, int parent1, int docID2, int parent2) throws IOException { if (parent1 == parent2) { // both are in the same block - // nocommit: should not be needed? if (docID1 == parent1 || docID2 == parent2) { // keep parents at the end of blocks return docID1 - docID2; @@ -180,7 +188,6 @@ public class BlockJoinComparatorSource extends FieldComparatorSource { } } else { int cmp = compare(parent1, parent2, parentComparators, parentReverseMul); - // nocommit: should not be needed? if (cmp == 0) { return parent1 - parent2; } else { diff --git a/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java b/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java index 55693434459..1ecde39d9e2 100644 --- a/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java +++ b/lucene/misc/src/java/org/apache/lucene/index/sorter/SortingAtomicReader.java @@ -49,13 +49,13 @@ import org.apache.lucene.util.automaton.CompiledAutomaton; /** * An {@link AtomicReader} which supports sorting documents by a given - * {@link Sorter}. You can use this class to sort an index as follows: + * {@link Sort}. You can use this class to sort an index as follows: * *
  * IndexWriter writer; // writer to which the sorted index will be added
  * DirectoryReader reader; // reader on the input index
- * Sorter sorter; // determines how the documents are sorted
- * AtomicReader sortingReader = SortingAtomicReader.wrap(SlowCompositeReaderWrapper.wrap(reader), sorter);
+ * Sort sort; // determines how the documents are sorted
+ * AtomicReader sortingReader = SortingAtomicReader.wrap(SlowCompositeReaderWrapper.wrap(reader), sort);
  * writer.addIndexes(reader);
  * writer.close();
  * reader.close();
@@ -481,7 +481,7 @@ public class SortingAtomicReader extends FilterAtomicReader {
   static class SortingDocsAndPositionsEnum extends FilterDocsAndPositionsEnum {
     
     /**
-     * A {@link Sorter} which sorts two parallel arrays of doc IDs and
+     * A {@link TimSorter} which sorts two parallel arrays of doc IDs and
      * offsets in one go. Everytime a doc ID is 'swapped', its correponding offset
      * is swapped too.
      */
@@ -709,7 +709,7 @@ public class SortingAtomicReader extends FilterAtomicReader {
   }
 
   /** Return a sorted view of reader according to the order
-   *  defined by sorter. If the reader is already sorted, this
+   *  defined by sort. If the reader is already sorted, this
    *  method might return the reader as-is. */
   public static AtomicReader wrap(AtomicReader reader, Sort sort) throws IOException {
     return wrap(reader, new Sorter(sort).sort(reader));