~slub.team/goobi-indexserver/3.x

« back to all changes in this revision

Viewing changes to solr/core/src/java/org/apache/solr/search/DocList.java

  • Committer: Sebastian Meyer
  • Date: 2012-08-03 09:12:40 UTC
  • Revision ID: sebastian.meyer@slub-dresden.de-20120803091240-x6861b0vabq1xror
Remove Lucene and Solr source code and add patches instead
Fix Bug #985487: Auto-suggestion for the search interface

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
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
8
 
 *
9
 
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 
 *
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.
16
 
 */
17
 
 
18
 
package org.apache.solr.search;
19
 
 
20
 
 
21
 
/**
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>.
25
 
 *
26
 
 * @version $Id: DocList.java 555343 2007-07-11 17:46:25Z hossman $
27
 
 * @since solr 0.9
28
 
 */
29
 
public interface DocList extends DocSet {
30
 
 
31
 
  /**
32
 
   * Returns the zero based offset of this list within the total ordered list of matches to the query.
33
 
   */
34
 
  public int offset();
35
 
 
36
 
  /**
37
 
   * Returns the number of ids in this list.
38
 
   */
39
 
  public int size();
40
 
 
41
 
  /**
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 &amp; any filters)
47
 
   */
48
 
  public int matches();
49
 
 
50
 
 
51
 
  /***
52
 
  public int getDoc(int pos);
53
 
  ***/
54
 
 
55
 
  // hmmm, what if a different slice could be generated from an existing DocSet
56
 
  // (and was before)...
57
 
 
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?
62
 
 
63
 
  /**
64
 
   * Get a subset of an existing DocList.
65
 
   * Returns null if not possible.
66
 
   */
67
 
  public DocList subset(int offset, int len);
68
 
 
69
 
  /**
70
 
   * Returns an iterator that may be used to iterate over the documents in this DocList
71
 
   *
72
 
   * <p>
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.
76
 
   * </p>
77
 
   * @see #hasScores
78
 
   */
79
 
  public DocIterator iterator();
80
 
    
81
 
  /** True if scores were retained */
82
 
  public boolean hasScores();
83
 
 
84
 
  /** The maximum score for the search... only valid if
85
 
   * scores were retained (if hasScores()==true)
86
 
   */
87
 
  public float maxScore();
88
 
}
89
 
 
90
 
 
91
 
/****  Maybe do this at a higher level (more efficient)
92
 
 
93
 
class SmartDocSet implements DocSet {
94
 
  static int INITIAL_SIZE=10;
95
 
  static int TRANSITION_SIZE=10;
96
 
 
97
 
  protected BitSet bits;
98
 
  int size;
99
 
 
100
 
  protected int[] arr;     // keep small set as an array, or as a hash?
101
 
  protected int arrsize;
102
 
 
103
 
  public SmartDocSet() {
104
 
    if (INITIAL_SIZE>0) {
105
 
      arr=new int[INITIAL_SIZE];
106
 
    } else {
107
 
      bits=new BitSet();
108
 
    }
109
 
  }
110
 
 
111
 
 
112
 
  public void addUnique(int doc) {
113
 
    size++;
114
 
    if (bits != null) {
115
 
      bits.set(doc);
116
 
    }
117
 
    else {
118
 
      if (arrsize<10) {
119
 
        arr[arrsize++]=doc;
120
 
      } else  {
121
 
        // TODO: transition to bit set
122
 
      }
123
 
    }
124
 
  };
125
 
 
126
 
  public int size() {
127
 
    return size;
128
 
  }
129
 
  public boolean exists(int docid) {
130
 
    return false;
131
 
  }
132
 
  public DocSet intersection(DocSet other) {
133
 
    return null;
134
 
 
135
 
  }
136
 
  public DocSet union(DocSet other) {
137
 
    return null;
138
 
  }
139
 
}
140
 
***/