2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
18
package org.apache.solr.search;
22
* <code>DocList</code> represents the result of a query: an ordered list of document ids with optional score.
23
* This list contains a subset of the complete list of documents actually matched: <code>size()</code>
24
* document ids starting at <code>offset()</code>.
26
* @version $Id: DocList.java 555343 2007-07-11 17:46:25Z hossman $
29
public interface DocList extends DocSet {
32
* Returns the zero based offset of this list within the total ordered list of matches to the query.
37
* Returns the number of ids in this list.
42
* Returns the total number of matches for the search
43
* (as opposed to just the number collected according
44
* to <code>offset()</code> and <code>size()</code>).
45
* Hence it's always true that matches() >= size()
46
* @return number of matches for the search(query & any filters)
52
public int getDoc(int pos);
55
// hmmm, what if a different slice could be generated from an existing DocSet
56
// (and was before)...
58
// how to distinguish cached values from logical values?
59
// docSet could represent docs 10-20, but actually contain 0-100
60
// should the big slice be cached independently, and a new class called
61
// DocListSubset be created to refer to a range within the DocList?
64
* Get a subset of an existing DocList.
65
* Returns null if not possible.
67
public DocList subset(int offset, int len);
70
* Returns an iterator that may be used to iterate over the documents in this DocList
73
* The order of the documents returned by this iterator is based on the
74
* Sort order of the search that produced it. The Scoring information
75
* is meaningful only if <code>hasScores()</code> returns true.
79
public DocIterator iterator();
81
/** True if scores were retained */
82
public boolean hasScores();
84
/** The maximum score for the search... only valid if
85
* scores were retained (if hasScores()==true)
87
public float maxScore();
91
/**** Maybe do this at a higher level (more efficient)
93
class SmartDocSet implements DocSet {
94
static int INITIAL_SIZE=10;
95
static int TRANSITION_SIZE=10;
97
protected BitSet bits;
100
protected int[] arr; // keep small set as an array, or as a hash?
101
protected int arrsize;
103
public SmartDocSet() {
104
if (INITIAL_SIZE>0) {
105
arr=new int[INITIAL_SIZE];
112
public void addUnique(int doc) {
121
// TODO: transition to bit set
129
public boolean exists(int docid) {
132
public DocSet intersection(DocSet other) {
136
public DocSet union(DocSet other) {