mirror of https://github.com/apache/lucene.git
LUCENE-5493: fix precommit
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene5493@1574962 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4244ad3747
commit
58198c299c
|
@ -31,7 +31,16 @@ import org.apache.lucene.util.FixedBitSet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper class to sort readers that contain blocks of documents.
|
* Helper class to sort readers that contain blocks of documents.
|
||||||
|
* <p>
|
||||||
|
* Note that this currently has some limitations:
|
||||||
|
* <ul>
|
||||||
|
* <li>Cannot yet be used with IndexSearcher.searchAfter
|
||||||
|
* <li>Filling sort value fields is not yet supported.
|
||||||
|
* </ul>
|
||||||
|
* 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 {
|
public class BlockJoinComparatorSource extends FieldComparatorSource {
|
||||||
final Filter parentsFilter;
|
final Filter parentsFilter;
|
||||||
final Sort parentSort;
|
final Sort parentSort;
|
||||||
|
@ -84,8 +93,8 @@ public class BlockJoinComparatorSource extends FieldComparatorSource {
|
||||||
childComparators[i] = childFields[i].getComparator(1, i);
|
childComparators[i] = childFields[i].getComparator(1, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: not quite right i guess, really our sort "value" is more complex...
|
// NOTE: we could return parent ID as value but really our sort "value" is more complex...
|
||||||
// but at the moment you really should only use this at indexing time.
|
// So we throw UOE for now. At the moment you really should only use this at indexing time.
|
||||||
return new FieldComparator<Integer>() {
|
return new FieldComparator<Integer>() {
|
||||||
int bottomParent;
|
int bottomParent;
|
||||||
int bottomChild;
|
int bottomChild;
|
||||||
|
@ -171,7 +180,6 @@ public class BlockJoinComparatorSource extends FieldComparatorSource {
|
||||||
|
|
||||||
int compare(int docID1, int parent1, int docID2, int parent2) throws IOException {
|
int compare(int docID1, int parent1, int docID2, int parent2) throws IOException {
|
||||||
if (parent1 == parent2) { // both are in the same block
|
if (parent1 == parent2) { // both are in the same block
|
||||||
// nocommit: should not be needed?
|
|
||||||
if (docID1 == parent1 || docID2 == parent2) {
|
if (docID1 == parent1 || docID2 == parent2) {
|
||||||
// keep parents at the end of blocks
|
// keep parents at the end of blocks
|
||||||
return docID1 - docID2;
|
return docID1 - docID2;
|
||||||
|
@ -180,7 +188,6 @@ public class BlockJoinComparatorSource extends FieldComparatorSource {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int cmp = compare(parent1, parent2, parentComparators, parentReverseMul);
|
int cmp = compare(parent1, parent2, parentComparators, parentReverseMul);
|
||||||
// nocommit: should not be needed?
|
|
||||||
if (cmp == 0) {
|
if (cmp == 0) {
|
||||||
return parent1 - parent2;
|
return parent1 - parent2;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -49,13 +49,13 @@ import org.apache.lucene.util.automaton.CompiledAutomaton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link AtomicReader} which supports sorting documents by a given
|
* 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:
|
||||||
*
|
*
|
||||||
* <pre class="prettyprint">
|
* <pre class="prettyprint">
|
||||||
* IndexWriter writer; // writer to which the sorted index will be added
|
* IndexWriter writer; // writer to which the sorted index will be added
|
||||||
* DirectoryReader reader; // reader on the input index
|
* DirectoryReader reader; // reader on the input index
|
||||||
* Sorter sorter; // determines how the documents are sorted
|
* Sort sort; // determines how the documents are sorted
|
||||||
* AtomicReader sortingReader = SortingAtomicReader.wrap(SlowCompositeReaderWrapper.wrap(reader), sorter);
|
* AtomicReader sortingReader = SortingAtomicReader.wrap(SlowCompositeReaderWrapper.wrap(reader), sort);
|
||||||
* writer.addIndexes(reader);
|
* writer.addIndexes(reader);
|
||||||
* writer.close();
|
* writer.close();
|
||||||
* reader.close();
|
* reader.close();
|
||||||
|
@ -481,7 +481,7 @@ public class SortingAtomicReader extends FilterAtomicReader {
|
||||||
static class SortingDocsAndPositionsEnum extends FilterDocsAndPositionsEnum {
|
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
|
* offsets in one go. Everytime a doc ID is 'swapped', its correponding offset
|
||||||
* is swapped too.
|
* is swapped too.
|
||||||
*/
|
*/
|
||||||
|
@ -709,7 +709,7 @@ public class SortingAtomicReader extends FilterAtomicReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a sorted view of <code>reader</code> according to the order
|
/** Return a sorted view of <code>reader</code> according to the order
|
||||||
* defined by <code>sorter</code>. If the reader is already sorted, this
|
* defined by <code>sort</code>. If the reader is already sorted, this
|
||||||
* method might return the reader as-is. */
|
* method might return the reader as-is. */
|
||||||
public static AtomicReader wrap(AtomicReader reader, Sort sort) throws IOException {
|
public static AtomicReader wrap(AtomicReader reader, Sort sort) throws IOException {
|
||||||
return wrap(reader, new Sorter(sort).sort(reader));
|
return wrap(reader, new Sorter(sort).sort(reader));
|
||||||
|
|
Loading…
Reference in New Issue