2 * Copyright 2004 The Apache Software Foundation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 IndexReader
= Lucene
.Net
.Index
.IndexReader
;
18 namespace Lucene
.Net
.Search
21 /// <summary> Expert: Maintains caches of term values.
23 /// <p>Created: May 19, 2004 11:13:14 AM
26 /// <author> Tim Jones (Nacimiento Software)
28 /// <since> lucene 1.4
30 /// <version> $Id: FieldCache.cs,v 1.1 2005/01/17 19:54:30 joeshaw Exp $
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>
42 /// <summary>Creates one of these objects </summary>
43 public StringIndex(int[] values
, System
.String
[] 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.
71 /// <param name="reader"> Used to get Field values.
73 /// <param name="Field"> Which Field contains the integers.
75 /// <returns> The values in the given Field for each document.
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.
85 /// <param name="reader"> Used to get Field values.
87 /// <param name="Field"> Which Field contains the floats.
89 /// <returns> The values in the given Field for each document.
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.
99 /// <param name="reader"> Used to get Field values.
101 /// <param name="Field"> Which Field contains the strings.
103 /// <returns> The values in the given Field for each document.
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.
113 /// <param name="reader"> Used to get Field values.
115 /// <param name="Field"> Which Field contains the strings.
117 /// <returns> Array of terms and index into the array for each document.
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.
129 /// <param name="reader"> Used to get Field values.
131 /// <param name="Field"> Which Field contains the values.
133 /// <returns> int[], float[] or StringIndex.
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.
144 /// <param name="reader"> Used to get Field values.
146 /// <param name="Field"> Which Field contains the values.
148 /// <param name="comparator">Used to convert terms into something to sort by.
150 /// <returns> Array of sort objects, one for each document.
152 /// <throws> IOException If any error occurs. </throws>
153 System
.IComparable
[] GetCustom(IndexReader reader
, System
.String field
, SortComparator comparator
);