Thumbnail file hits. Based on a patch from D Bera
[beagle.git] / beagled / Lucene.Net / Search / FieldCache.cs
blobdade3f509d33c9fd3a1e70a08db5e974008d576c
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.
16 using System;
17 using IndexReader = Lucene.Net.Index.IndexReader;
18 namespace Lucene.Net.Search
21 /// <summary> Expert: Maintains caches of term values.
22 ///
23 /// <p>Created: May 19, 2004 11:13:14 AM
24 ///
25 /// </summary>
26 /// <author> Tim Jones (Nacimiento Software)
27 /// </author>
28 /// <since> lucene 1.4
29 /// </since>
30 /// <version> $Id: FieldCache.cs,v 1.1 2005/01/17 19:54:30 joeshaw Exp $
31 /// </version>
32 /// <summary>Expert: Stores term text values and document ordering data. </summary>
33 public class StringIndex
36 /// <summary>All the term values, in natural order. </summary>
37 public System.String[] lookup;
39 /// <summary>For each document, an index into the lookup array. </summary>
40 public int[] order;
42 /// <summary>Creates one of these objects </summary>
43 public StringIndex(int[] values, System.String[] lookup)
45 this.order = values;
46 this.lookup = lookup;
49 public struct FieldCache_Fields
51 /// <summary>Indicator for StringIndex values in the cache. </summary>
52 // NOTE: the value assigned to this constant must not be
53 // the same as any of those in SortField!!
54 public readonly static int STRING_INDEX = - 1;
55 /// <summary>Expert: The cache used internally by sorting and range query classes. </summary>
56 public readonly static FieldCache DEFAULT;
57 static FieldCache_Fields()
59 DEFAULT = new FieldCacheImpl();
62 public interface FieldCache
66 /// <summary>Checks the internal cache for an appropriate entry, and if none is
67 /// found, reads the terms in <code>Field</code> as integers and returns an array
68 /// of size <code>reader.maxDoc()</code> of the value each document
69 /// has in the given Field.
70 /// </summary>
71 /// <param name="reader"> Used to get Field values.
72 /// </param>
73 /// <param name="Field"> Which Field contains the integers.
74 /// </param>
75 /// <returns> The values in the given Field for each document.
76 /// </returns>
77 /// <throws> IOException If any error occurs. </throws>
78 int[] GetInts(IndexReader reader, System.String field);
80 /// <summary>Checks the internal cache for an appropriate entry, and if
81 /// none is found, reads the terms in <code>Field</code> as floats and returns an array
82 /// of size <code>reader.maxDoc()</code> of the value each document
83 /// has in the given Field.
84 /// </summary>
85 /// <param name="reader"> Used to get Field values.
86 /// </param>
87 /// <param name="Field"> Which Field contains the floats.
88 /// </param>
89 /// <returns> The values in the given Field for each document.
90 /// </returns>
91 /// <throws> IOException If any error occurs. </throws>
92 float[] GetFloats(IndexReader reader, System.String field);
94 /// <summary>Checks the internal cache for an appropriate entry, and if none
95 /// is found, reads the term values in <code>Field</code> and returns an array
96 /// of size <code>reader.maxDoc()</code> containing the value each document
97 /// has in the given Field.
98 /// </summary>
99 /// <param name="reader"> Used to get Field values.
100 /// </param>
101 /// <param name="Field"> Which Field contains the strings.
102 /// </param>
103 /// <returns> The values in the given Field for each document.
104 /// </returns>
105 /// <throws> IOException If any error occurs. </throws>
106 System.String[] GetStrings(IndexReader reader, System.String field);
108 /// <summary>Checks the internal cache for an appropriate entry, and if none
109 /// is found reads the term values in <code>Field</code> and returns
110 /// an array of them in natural order, along with an array telling
111 /// which element in the term array each document uses.
112 /// </summary>
113 /// <param name="reader"> Used to get Field values.
114 /// </param>
115 /// <param name="Field"> Which Field contains the strings.
116 /// </param>
117 /// <returns> Array of terms and index into the array for each document.
118 /// </returns>
119 /// <throws> IOException If any error occurs. </throws>
120 StringIndex GetStringIndex(IndexReader reader, System.String field);
122 /// <summary>Checks the internal cache for an appropriate entry, and if
123 /// none is found reads <code>Field</code> to see if it contains integers, floats
124 /// or strings, and then calls one of the other methods in this class to get the
125 /// values. For string values, a StringIndex is returned. After
126 /// calling this method, there is an entry in the cache for both
127 /// type <code>AUTO</code> and the actual found type.
128 /// </summary>
129 /// <param name="reader"> Used to get Field values.
130 /// </param>
131 /// <param name="Field"> Which Field contains the values.
132 /// </param>
133 /// <returns> int[], float[] or StringIndex.
134 /// </returns>
135 /// <throws> IOException If any error occurs. </throws>
136 System.Object GetAuto(IndexReader reader, System.String field);
138 /// <summary>Checks the internal cache for an appropriate entry, and if none
139 /// is found reads the terms out of <code>Field</code> and calls the given SortComparator
140 /// to get the sort values. A hit in the cache will happen if <code>reader</code>,
141 /// <code>Field</code>, and <code>comparator</code> are the same (using <code>equals()</code>)
142 /// as a previous call to this method.
143 /// </summary>
144 /// <param name="reader"> Used to get Field values.
145 /// </param>
146 /// <param name="Field"> Which Field contains the values.
147 /// </param>
148 /// <param name="comparator">Used to convert terms into something to sort by.
149 /// </param>
150 /// <returns> Array of sort objects, one for each document.
151 /// </returns>
152 /// <throws> IOException If any error occurs. </throws>
153 System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator);