cvsimport
[beagle.git] / beagled / Lucene.Net / Search / FieldCache.cs
blob896766b1b34405a050cd99f908de08db9accb1d4
1 /*
2 * Copyright 2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using System;
18 using IndexReader = Lucene.Net.Index.IndexReader;
20 namespace Lucene.Net.Search
23 /// <summary> Expert: Maintains caches of term values.
24 ///
25 /// <p>Created: May 19, 2004 11:13:14 AM
26 ///
27 /// </summary>
28 /// <author> Tim Jones (Nacimiento Software)
29 /// </author>
30 /// <since> lucene 1.4
31 /// </since>
32 /// <version> $Id: FieldCache.cs,v 1.3 2006/10/02 17:09:02 joeshaw Exp $
33 /// </version>
34 /// <summary>Expert: Stores term text values and document ordering data. </summary>
35 public class StringIndex
38 /// <summary>All the term values, in natural order. </summary>
39 public System.String[] lookup;
41 /// <summary>For each document, an index into the lookup array. </summary>
42 public int[] order;
44 /// <summary>Creates one of these objects </summary>
45 public StringIndex(int[] values, System.String[] lookup)
47 this.order = values;
48 this.lookup = lookup;
51 public struct FieldCache_Fields
53 /// <summary>Indicator for StringIndex values in the cache. </summary>
54 // NOTE: the value assigned to this constant must not be
55 // the same as any of those in SortField!!
56 public readonly static int STRING_INDEX = - 1;
57 /// <summary>Expert: The cache used internally by sorting and range query classes. </summary>
58 public readonly static FieldCache DEFAULT;
59 static FieldCache_Fields()
61 DEFAULT = new FieldCacheImpl();
64 public interface FieldCache
68 /// <summary>Checks the internal cache for an appropriate entry, and if none is
69 /// found, reads the terms in <code>field</code> as integers and returns an array
70 /// of size <code>reader.maxDoc()</code> of the value each document
71 /// has in the given field.
72 /// </summary>
73 /// <param name="reader"> Used to get field values.
74 /// </param>
75 /// <param name="field"> Which field contains the integers.
76 /// </param>
77 /// <returns> The values in the given field for each document.
78 /// </returns>
79 /// <throws> IOException If any error occurs. </throws>
80 int[] GetInts(IndexReader reader, System.String field);
82 /// <summary>Checks the internal cache for an appropriate entry, and if none is found,
83 /// reads the terms in <code>field</code> as integers and returns an array of
84 /// size <code>reader.maxDoc()</code> of the value each document has in the
85 /// given field.
86 /// </summary>
87 /// <param name="reader"> Used to get field values.
88 /// </param>
89 /// <param name="field"> Which field contains the integers.
90 /// </param>
91 /// <param name="parser"> Computes integer for string values.
92 /// </param>
93 /// <returns> The values in the given field for each document.
94 /// </returns>
95 /// <throws> IOException If any error occurs. </throws>
96 int[] GetInts(IndexReader reader, System.String field, IntParser parser);
98 /// <summary>Checks the internal cache for an appropriate entry, and if
99 /// none is found, reads the terms in <code>field</code> as floats and returns an array
100 /// of size <code>reader.maxDoc()</code> of the value each document
101 /// has in the given field.
102 /// </summary>
103 /// <param name="reader"> Used to get field values.
104 /// </param>
105 /// <param name="field"> Which field contains the floats.
106 /// </param>
107 /// <returns> The values in the given field for each document.
108 /// </returns>
109 /// <throws> IOException If any error occurs. </throws>
110 float[] GetFloats(IndexReader reader, System.String field);
112 /// <summary>Checks the internal cache for an appropriate entry, and if
113 /// none is found, reads the terms in <code>field</code> as floats and returns an array
114 /// of size <code>reader.maxDoc()</code> of the value each document
115 /// has in the given field.
116 /// </summary>
117 /// <param name="reader"> Used to get field values.
118 /// </param>
119 /// <param name="field"> Which field contains the floats.
120 /// </param>
121 /// <param name="parser"> Computes float for string values.
122 /// </param>
123 /// <returns> The values in the given field for each document.
124 /// </returns>
125 /// <throws> IOException If any error occurs. </throws>
126 float[] GetFloats(IndexReader reader, System.String field, FloatParser parser);
128 /// <summary>Checks the internal cache for an appropriate entry, and if none
129 /// is found, reads the term values in <code>field</code> and returns an array
130 /// of size <code>reader.maxDoc()</code> containing the value each document
131 /// has in the given field.
132 /// </summary>
133 /// <param name="reader"> Used to get field values.
134 /// </param>
135 /// <param name="field"> Which field contains the strings.
136 /// </param>
137 /// <returns> The values in the given field for each document.
138 /// </returns>
139 /// <throws> IOException If any error occurs. </throws>
140 System.String[] GetStrings(IndexReader reader, System.String field);
142 /// <summary>Checks the internal cache for an appropriate entry, and if none
143 /// is found reads the term values in <code>field</code> and returns
144 /// an array of them in natural order, along with an array telling
145 /// which element in the term array each document uses.
146 /// </summary>
147 /// <param name="reader"> Used to get field values.
148 /// </param>
149 /// <param name="field"> Which field contains the strings.
150 /// </param>
151 /// <returns> Array of terms and index into the array for each document.
152 /// </returns>
153 /// <throws> IOException If any error occurs. </throws>
154 StringIndex GetStringIndex(IndexReader reader, System.String field);
156 /// <summary>Checks the internal cache for an appropriate entry, and if
157 /// none is found reads <code>field</code> to see if it contains integers, floats
158 /// or strings, and then calls one of the other methods in this class to get the
159 /// values. For string values, a StringIndex is returned. After
160 /// calling this method, there is an entry in the cache for both
161 /// type <code>AUTO</code> and the actual found type.
162 /// </summary>
163 /// <param name="reader"> Used to get field values.
164 /// </param>
165 /// <param name="field"> Which field contains the values.
166 /// </param>
167 /// <returns> int[], float[] or StringIndex.
168 /// </returns>
169 /// <throws> IOException If any error occurs. </throws>
170 System.Object GetAuto(IndexReader reader, System.String field);
172 /// <summary>Checks the internal cache for an appropriate entry, and if none
173 /// is found reads the terms out of <code>field</code> and calls the given SortComparator
174 /// to get the sort values. A hit in the cache will happen if <code>reader</code>,
175 /// <code>field</code>, and <code>comparator</code> are the same (using <code>equals()</code>)
176 /// as a previous call to this method.
177 /// </summary>
178 /// <param name="reader"> Used to get field values.
179 /// </param>
180 /// <param name="field"> Which field contains the values.
181 /// </param>
182 /// <param name="comparator">Used to convert terms into something to sort by.
183 /// </param>
184 /// <returns> Array of sort objects, one for each document.
185 /// </returns>
186 /// <throws> IOException If any error occurs. </throws>
187 System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator);
190 /// <summary>Interface to parse ints from document fields.</summary>
191 /// <seealso cref="GetInts(IndexReader, String, IntParser)">
192 /// </seealso>
193 public interface IntParser
195 /// <summary>Return an integer representation of this field's value. </summary>
196 int ParseInt(System.String string_Renamed);
199 /// <summary>Interface to parse floats from document fields.</summary>
200 /// <seealso cref="GetFloats(IndexReader, String, FloatParser)">
201 /// </seealso>
202 public interface FloatParser
204 /// <summary>Return an float representation of this field's value. </summary>
205 float ParseFloat(System.String string_Renamed);