|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sort | Line # 94 | 23 | 16 | 59.5% |
0.5952381
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (25) | |||
| Result | |||
|
0.5
|
org.apache.lucene.search.TestSort.testNormalizedScores
org.apache.lucene.search.TestSort.testNormalizedScores
|
1 PASS | |
|
0.4047619
|
org.apache.lucene.search.TestSort.testParallelMultiSort
org.apache.lucene.search.TestSort.testParallelMultiSort
|
1 PASS | |
|
0.4047619
|
org.apache.lucene.search.TestSort.testRemoteSort
org.apache.lucene.search.TestSort.testRemoteSort
|
1 PASS | |
|
0.4047619
|
org.apache.lucene.search.TestSort.testMultiSort
org.apache.lucene.search.TestSort.testMultiSort
|
1 PASS | |
|
0.35714287
|
org.apache.lucene.search.TestFilteredQuery.testFilteredQuery
org.apache.lucene.search.TestFilteredQuery.testFilteredQuery
|
1 PASS | |
|
0.23809524
|
org.apache.lucene.search.TestMultiSearcher.testNormalization10
org.apache.lucene.search.TestMultiSearcher.testNormalization10
|
1 PASS | |
|
0.23809524
|
org.apache.lucene.search.TestBoolean2.testRandomQueries
org.apache.lucene.search.TestBoolean2.testRandomQueries
|
1 PASS | |
|
0.23809524
|
org.apache.lucene.search.TestCustomSearcherSort.testFieldSortCustomSearcher
org.apache.lucene.search.TestCustomSearcherSort.testFieldSortCustomSearcher
|
1 PASS | |
|
0.23809524
|
org.apache.lucene.search.TestSort.testSortCombos
org.apache.lucene.search.TestSort.testSortCombos
|
1 PASS | |
|
0.23809524
|
org.apache.lucene.search.TestRemoteSearchable.testTermQuery
org.apache.lucene.search.TestRemoteSearchable.testTermQuery
|
1 PASS | |
|
0.23809524
|
org.apache.lucene.search.TestMultiSearcher.testNormalization10
org.apache.lucene.search.TestMultiSearcher.testNormalization10
|
1 PASS | |
|
0.21428572
|
org.apache.lucene.search.TestSort.testEmptyFieldSort
org.apache.lucene.search.TestSort.testEmptyFieldSort
|
1 PASS | |
|
0.1904762
|
org.apache.lucene.search.TestSort.testEmptyIndex
org.apache.lucene.search.TestSort.testEmptyIndex
|
1 PASS | |
|
0.1904762
|
org.apache.lucene.search.TestSort.testBuiltInSorts
org.apache.lucene.search.TestSort.testBuiltInSorts
|
1 PASS | |
|
0.16666667
|
org.apache.lucene.search.TestSort.testReverseSort
org.apache.lucene.search.TestSort.testReverseSort
|
1 PASS | |
|
0.14285715
|
org.apache.lucene.search.TestSort.testTopDocsScores
org.apache.lucene.search.TestSort.testTopDocsScores
|
1 PASS | |
|
0.11904762
|
org.apache.lucene.search.TestSort.testAutoSort
org.apache.lucene.search.TestSort.testAutoSort
|
1 PASS | |
|
0.0952381
|
org.apache.lucene.search.TestCustomSearcherSort.testFieldSortMultiCustomSearcher
org.apache.lucene.search.TestCustomSearcherSort.testFieldSortMultiCustomSearcher
|
1 PASS | |
|
0.0952381
|
org.apache.lucene.search.TestCustomSearcherSort.testFieldSortSingleSearcher
org.apache.lucene.search.TestCustomSearcherSort.testFieldSortSingleSearcher
|
1 PASS | |
|
0.04761905
|
org.apache.lucene.search.TestSort.testCustomSorts
org.apache.lucene.search.TestSort.testCustomSorts
|
1 PASS | |
|
0.04761905
|
org.apache.lucene.search.TestSort.testRemoteCustomSort
org.apache.lucene.search.TestSort.testRemoteCustomSort
|
1 PASS | |
|
0.04761905
|
org.apache.lucene.search.TestSort.testInternationalMultiSearcherSort
org.apache.lucene.search.TestSort.testInternationalMultiSearcherSort
|
1 PASS | |
|
0.04761905
|
org.apache.lucene.search.TestSort.testInternationalSort
org.apache.lucene.search.TestSort.testInternationalSort
|
1 PASS | |
|
0.04761905
|
org.apache.lucene.search.TestSort.testTypedSort
org.apache.lucene.search.TestSort.testTypedSort
|
1 PASS | |
|
0.04761905
|
org.apache.lucene.search.TestSort.testLocaleSort
org.apache.lucene.search.TestSort.testLocaleSort
|
1 PASS | |
| 1 | package org.apache.lucene.search; | |
| 2 | ||
| 3 | /** | |
| 4 | * Copyright 2004 The Apache Software Foundation | |
| 5 | * | |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 7 | * you may not use this file except in compliance with the License. | |
| 8 | * You may obtain a copy of the License at | |
| 9 | * | |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 11 | * | |
| 12 | * Unless required by applicable law or agreed to in writing, software | |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 15 | * See the License for the specific language governing permissions and | |
| 16 | * limitations under the License. | |
| 17 | */ | |
| 18 | ||
| 19 | import java.io.Serializable; | |
| 20 | ||
| 21 | ||
| 22 | /** | |
| 23 | * Encapsulates sort criteria for returned hits. | |
| 24 | * | |
| 25 | * <p>The fields used to determine sort order must be carefully chosen. | |
| 26 | * Documents must contain a single term in such a field, | |
| 27 | * and the value of the term should indicate the document's relative position in | |
| 28 | * a given sort order. The field must be indexed, but should not be tokenized, | |
| 29 | * and does not need to be stored (unless you happen to want it back with the | |
| 30 | * rest of your document data). In other words: | |
| 31 | * | |
| 32 | * <p><code>document.add (new Fieldable ("byNumber", Integer.toString(x), Fieldable.Store.NO, Fieldable.Index.UN_TOKENIZED));</code></p> | |
| 33 | * | |
| 34 | * | |
| 35 | * <p><h3>Valid Types of Values</h3> | |
| 36 | * | |
| 37 | * <p>There are three possible kinds of term values which may be put into | |
| 38 | * sorting fields: Integers, Floats, or Strings. Unless | |
| 39 | * {@link SortField SortField} objects are specified, the type of value | |
| 40 | * in the field is determined by parsing the first term in the field. | |
| 41 | * | |
| 42 | * <p>Integer term values should contain only digits and an optional | |
| 43 | * preceeding negative sign. Values must be base 10 and in the range | |
| 44 | * <code>Integer.MIN_VALUE</code> and <code>Integer.MAX_VALUE</code> inclusive. | |
| 45 | * Documents which should appear first in the sort | |
| 46 | * should have low value integers, later documents high values | |
| 47 | * (i.e. the documents should be numbered <code>1..n</code> where | |
| 48 | * <code>1</code> is the first and <code>n</code> the last). | |
| 49 | * | |
| 50 | * <p>Float term values should conform to values accepted by | |
| 51 | * {@link Float Float.valueOf(String)} (except that <code>NaN</code> | |
| 52 | * and <code>Infinity</code> are not supported). | |
| 53 | * Documents which should appear first in the sort | |
| 54 | * should have low values, later documents high values. | |
| 55 | * | |
| 56 | * <p>String term values can contain any valid String, but should | |
| 57 | * not be tokenized. The values are sorted according to their | |
| 58 | * {@link Comparable natural order}. Note that using this type | |
| 59 | * of term value has higher memory requirements than the other | |
| 60 | * two types. | |
| 61 | * | |
| 62 | * <p><h3>Object Reuse</h3> | |
| 63 | * | |
| 64 | * <p>One of these objects can be | |
| 65 | * used multiple times and the sort order changed between usages. | |
| 66 | * | |
| 67 | * <p>This class is thread safe. | |
| 68 | * | |
| 69 | * <p><h3>Memory Usage</h3> | |
| 70 | * | |
| 71 | * <p>Sorting uses of caches of term values maintained by the | |
| 72 | * internal HitQueue(s). The cache is static and contains an integer | |
| 73 | * or float array of length <code>IndexReader.maxDoc()</code> for each field | |
| 74 | * name for which a sort is performed. In other words, the size of the | |
| 75 | * cache in bytes is: | |
| 76 | * | |
| 77 | * <p><code>4 * IndexReader.maxDoc() * (# of different fields actually used to sort)</code> | |
| 78 | * | |
| 79 | * <p>For String fields, the cache is larger: in addition to the | |
| 80 | * above array, the value of every term in the field is kept in memory. | |
| 81 | * If there are many unique terms in the field, this could | |
| 82 | * be quite large. | |
| 83 | * | |
| 84 | * <p>Note that the size of the cache is not affected by how many | |
| 85 | * fields are in the index and <i>might</i> be used to sort - only by | |
| 86 | * the ones actually used to sort a result set. | |
| 87 | * | |
| 88 | * <p>Created: Feb 12, 2004 10:53:57 AM | |
| 89 | * | |
| 90 | * @author Tim Jones (Nacimiento Software) | |
| 91 | * @since lucene 1.4 | |
| 92 | * @version $Id: Sort.java 470109 2006-11-01 21:35:32Z yonik $ | |
| 93 | */ | |
| 94 | public class Sort | |
| 95 | implements Serializable { | |
| 96 | ||
| 97 | /** | |
| 98 | * Represents sorting by computed relevance. Using this sort criteria returns | |
| 99 | * the same results as calling | |
| 100 | * {@link Searcher#search(Query) Searcher#search()}without a sort criteria, | |
| 101 | * only with slightly more overhead. | |
| 102 | */ | |
| 103 | public static final Sort RELEVANCE = new Sort(); | |
| 104 | ||
| 105 | /** Represents sorting by index order. */ | |
| 106 | public static final Sort INDEXORDER = new Sort(SortField.FIELD_DOC); | |
| 107 | ||
| 108 | // internal representation of the sort criteria | |
| 109 | SortField[] fields; | |
| 110 | ||
| 111 | /** | |
| 112 | * Sorts by computed relevance. This is the same sort criteria as calling | |
| 113 | * {@link Searcher#search(Query) Searcher#search()}without a sort criteria, | |
| 114 | * only with slightly more overhead. | |
| 115 | */ | |
| 116 | 28 |
public Sort() { |
| 117 | 28 | this(new SortField[] { SortField.FIELD_SCORE, SortField.FIELD_DOC }); |
| 118 | } | |
| 119 | ||
| 120 | /** | |
| 121 | * Sorts by the terms in <code>field</code> then by index order (document | |
| 122 | * number). The type of value in <code>field</code> is determined | |
| 123 | * automatically. | |
| 124 | * | |
| 125 | * @see SortField#AUTO | |
| 126 | */ | |
| 127 | 1 |
public Sort(String field) { |
| 128 | 1 | setSort(field, false); |
| 129 | } | |
| 130 | ||
| 131 | /** | |
| 132 | * Sorts possibly in reverse by the terms in <code>field</code> then by | |
| 133 | * index order (document number). The type of value in <code>field</code> is | |
| 134 | ||