Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / tools / monkeydoc / Lucene.Net / Lucene.Net / Search / FieldCache.cs
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 using System;
19
20 using NumericTokenStream = Mono.Lucene.Net.Analysis.NumericTokenStream;
21 using NumericField = Mono.Lucene.Net.Documents.NumericField;
22 using IndexReader = Mono.Lucene.Net.Index.IndexReader;
23 using NumericUtils = Mono.Lucene.Net.Util.NumericUtils;
24 using RamUsageEstimator = Mono.Lucene.Net.Util.RamUsageEstimator;
25
26 namespace Mono.Lucene.Net.Search
27 {
28         
29         /// <summary> Expert: Maintains caches of term values.
30         /// 
31         /// <p/>Created: May 19, 2004 11:13:14 AM
32         /// 
33         /// </summary>
34         /// <since>   lucene 1.4
35         /// </since>
36         /// <version>  $Id: FieldCache.java 807841 2009-08-25 22:27:31Z markrmiller $
37         /// </version>
38         /// <seealso cref="Mono.Lucene.Net.Util.FieldCacheSanityChecker">
39         /// </seealso>
40         public sealed class CreationPlaceholder
41         {
42                 internal System.Object value_Renamed;
43         }
44         /// <summary>Expert: Stores term text values and document ordering data. </summary>
45         public class StringIndex
46         {
47                 
48                 public virtual int BinarySearchLookup(System.String key)
49                 {
50                         // this special case is the reason that Arrays.binarySearch() isn't useful.
51                         if (key == null)
52                                 return 0;
53                         
54                         int low = 1;
55                         int high = lookup.Length - 1;
56                         
57                         while (low <= high)
58                         {
59                                 int mid = SupportClass.Number.URShift((low + high), 1);
60                                 int cmp = String.CompareOrdinal(lookup[mid], key);
61                                 
62                                 if (cmp < 0)
63                                         low = mid + 1;
64                                 else if (cmp > 0)
65                                         high = mid - 1;
66                                 else
67                                         return mid; // key found
68                         }
69                         return - (low + 1); // key not found.
70                 }
71                 
72                 /// <summary>All the term values, in natural order. </summary>
73                 public System.String[] lookup;
74                 
75                 /// <summary>For each document, an index into the lookup array. </summary>
76                 public int[] order;
77                 
78                 /// <summary>Creates one of these objects </summary>
79                 public StringIndex(int[] values, System.String[] lookup)
80                 {
81                         this.order = values;
82                         this.lookup = lookup;
83                 }
84         }
85         /// <summary> EXPERT: A unique Identifier/Description for each item in the FieldCache. 
86         /// Can be useful for logging/debugging.
87         /// <p/>
88         /// <b>EXPERIMENTAL API:</b> This API is considered extremely advanced 
89         /// and experimental.  It may be removed or altered w/o warning in future 
90         /// releases 
91         /// of Lucene.
92         /// <p/>
93         /// </summary>
94         public abstract class CacheEntry
95         {
96                 public abstract System.Object GetReaderKey();
97                 public abstract System.String GetFieldName();
98                 public abstract System.Type GetCacheType();
99                 public abstract System.Object GetCustom();
100                 public abstract System.Object GetValue();
101                 private System.String size = null;
102                 protected internal void  SetEstimatedSize(System.String size)
103                 {
104                         this.size = size;
105                 }
106                 /// <seealso cref="EstimateSize(RamUsageEstimator)">
107                 /// </seealso>
108                 public virtual void  EstimateSize()
109                 {
110                         EstimateSize(new RamUsageEstimator(false)); // doesn't check for interned
111                 }
112                 /// <summary> Computes (and stores) the estimated size of the cache Value </summary>
113                 /// <seealso cref="getEstimatedSize">
114                 /// </seealso>
115                 public virtual void  EstimateSize(RamUsageEstimator ramCalc)
116                 {
117                         long size = ramCalc.EstimateRamUsage(GetValue());
118             SetEstimatedSize(RamUsageEstimator.HumanReadableUnits(size, new System.Globalization.NumberFormatInfo()));  // {{Aroush-2.9}} in Java, the formater is set to "0.#", so we need to do the same in C#
119                 }
120                 /// <summary> The most recently estimated size of the value, null unless 
121                 /// estimateSize has been called.
122                 /// </summary>
123                 public System.String GetEstimatedSize()
124                 {
125                         return size;
126                 }
127                 
128                 
129                 public override System.String ToString()
130                 {
131                         System.Text.StringBuilder b = new System.Text.StringBuilder();
132                         b.Append("'").Append(GetReaderKey()).Append("'=>");
133                         b.Append("'").Append(GetFieldName()).Append("',");
134                         b.Append(GetCacheType()).Append(",").Append(GetCustom());
135                         b.Append("=>").Append(GetValue().GetType().FullName).Append("#");
136                         b.Append(GetValue().GetHashCode());
137                         
138                         System.String s = GetEstimatedSize();
139                         if (null != s)
140                         {
141                                 b.Append(" (size =~ ").Append(s).Append(')');
142                         }
143                         
144                         return b.ToString();
145                 }
146         }
147         public struct FieldCache_Fields{
148                 /// <summary>Indicator for StringIndex values in the cache. </summary>
149                 // NOTE: the value assigned to this constant must not be
150                 // the same as any of those in SortField!!
151                 public readonly static int STRING_INDEX = - 1;
152                 /// <summary>Expert: The cache used internally by sorting and range query classes. </summary>
153                 public readonly static FieldCache DEFAULT;
154                 /// <summary>The default parser for byte values, which are encoded by {@link Byte#toString(byte)} </summary>
155                 public readonly static ByteParser DEFAULT_BYTE_PARSER;
156                 /// <summary>The default parser for short values, which are encoded by {@link Short#toString(short)} </summary>
157                 public readonly static ShortParser DEFAULT_SHORT_PARSER;
158                 /// <summary>The default parser for int values, which are encoded by {@link Integer#toString(int)} </summary>
159                 public readonly static IntParser DEFAULT_INT_PARSER;
160                 /// <summary>The default parser for float values, which are encoded by {@link Float#toString(float)} </summary>
161                 public readonly static FloatParser DEFAULT_FLOAT_PARSER;
162                 /// <summary>The default parser for long values, which are encoded by {@link Long#toString(long)} </summary>
163                 public readonly static LongParser DEFAULT_LONG_PARSER;
164                 /// <summary>The default parser for double values, which are encoded by {@link Double#toString(double)} </summary>
165                 public readonly static DoubleParser DEFAULT_DOUBLE_PARSER;
166                 /// <summary> A parser instance for int values encoded by {@link NumericUtils#IntToPrefixCoded(int)}, e.g. when indexed
167                 /// via {@link NumericField}/{@link NumericTokenStream}.
168                 /// </summary>
169                 public readonly static IntParser NUMERIC_UTILS_INT_PARSER;
170                 /// <summary> A parser instance for float values encoded with {@link NumericUtils}, e.g. when indexed
171                 /// via {@link NumericField}/{@link NumericTokenStream}.
172                 /// </summary>
173                 public readonly static FloatParser NUMERIC_UTILS_FLOAT_PARSER;
174                 /// <summary> A parser instance for long values encoded by {@link NumericUtils#LongToPrefixCoded(long)}, e.g. when indexed
175                 /// via {@link NumericField}/{@link NumericTokenStream}.
176                 /// </summary>
177                 public readonly static LongParser NUMERIC_UTILS_LONG_PARSER;
178                 /// <summary> A parser instance for double values encoded with {@link NumericUtils}, e.g. when indexed
179                 /// via {@link NumericField}/{@link NumericTokenStream}.
180                 /// </summary>
181                 public readonly static DoubleParser NUMERIC_UTILS_DOUBLE_PARSER;
182                 static FieldCache_Fields()
183                 {
184                         DEFAULT = new FieldCacheImpl();
185                         DEFAULT_BYTE_PARSER = new AnonymousClassByteParser();
186                         DEFAULT_SHORT_PARSER = new AnonymousClassShortParser();
187                         DEFAULT_INT_PARSER = new AnonymousClassIntParser();
188                         DEFAULT_FLOAT_PARSER = new AnonymousClassFloatParser();
189                         DEFAULT_LONG_PARSER = new AnonymousClassLongParser();
190                         DEFAULT_DOUBLE_PARSER = new AnonymousClassDoubleParser();
191                         NUMERIC_UTILS_INT_PARSER = new AnonymousClassIntParser1();
192                         NUMERIC_UTILS_FLOAT_PARSER = new AnonymousClassFloatParser1();
193                         NUMERIC_UTILS_LONG_PARSER = new AnonymousClassLongParser1();
194                         NUMERIC_UTILS_DOUBLE_PARSER = new AnonymousClassDoubleParser1();
195                 }
196         }
197     
198         [Serializable]
199         class AnonymousClassByteParser : ByteParser
200         {
201                 public virtual sbyte ParseByte(System.String value_Renamed)
202                 {
203             return System.SByte.Parse(value_Renamed);
204                 }
205                 protected internal virtual System.Object ReadResolve()
206                 {
207                         return Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_BYTE_PARSER;
208                 }
209                 public override System.String ToString()
210                 {
211                         return typeof(FieldCache).FullName + ".DEFAULT_BYTE_PARSER";
212                 }
213         }
214         [Serializable]
215         class AnonymousClassShortParser : ShortParser
216         {
217                 public virtual short ParseShort(System.String value_Renamed)
218                 {
219                         return System.Int16.Parse(value_Renamed);
220                 }
221                 protected internal virtual System.Object ReadResolve()
222                 {
223                         return Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_SHORT_PARSER;
224                 }
225                 public override System.String ToString()
226                 {
227                         return typeof(FieldCache).FullName + ".DEFAULT_SHORT_PARSER";
228                 }
229         }
230         [Serializable]
231         class AnonymousClassIntParser : IntParser
232         {
233                 public virtual int ParseInt(System.String value_Renamed)
234                 {
235                         return System.Int32.Parse(value_Renamed);
236                 }
237                 protected internal virtual System.Object ReadResolve()
238                 {
239                         return Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_INT_PARSER;
240                 }
241                 public override System.String ToString()
242                 {
243                         return typeof(FieldCache).FullName + ".DEFAULT_INT_PARSER";
244                 }
245         }
246         [Serializable]
247         class AnonymousClassFloatParser : FloatParser
248         {
249                 public virtual float ParseFloat(System.String value_Renamed)
250                 {
251             try
252             {
253                 return SupportClass.Single.Parse(value_Renamed);
254             }
255             catch (System.OverflowException)
256             {
257                 return value_Renamed.StartsWith("-") ? float.PositiveInfinity : float.NegativeInfinity;
258             }
259                 }
260                 protected internal virtual System.Object ReadResolve()
261                 {
262                         return Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_FLOAT_PARSER;
263                 }
264                 public override System.String ToString()
265                 {
266                         return typeof(FieldCache).FullName + ".DEFAULT_FLOAT_PARSER";
267                 }
268         }
269         [Serializable]
270         class AnonymousClassLongParser : LongParser
271         {
272                 public virtual long ParseLong(System.String value_Renamed)
273                 {
274                         return System.Int64.Parse(value_Renamed);
275                 }
276                 protected internal virtual System.Object ReadResolve()
277                 {
278                         return Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_LONG_PARSER;
279                 }
280                 public override System.String ToString()
281                 {
282                         return typeof(FieldCache).FullName + ".DEFAULT_LONG_PARSER";
283                 }
284         }
285         [Serializable]
286         class AnonymousClassDoubleParser : DoubleParser
287         {
288                 public virtual double ParseDouble(System.String value_Renamed)
289                 {
290                         return SupportClass.Double.Parse(value_Renamed);
291                 }
292                 protected internal virtual System.Object ReadResolve()
293                 {
294                         return Mono.Lucene.Net.Search.FieldCache_Fields.DEFAULT_DOUBLE_PARSER;
295                 }
296                 public override System.String ToString()
297                 {
298                         return typeof(FieldCache).FullName + ".DEFAULT_DOUBLE_PARSER";
299                 }
300         }
301         [Serializable]
302         class AnonymousClassIntParser1 : IntParser
303         {
304                 public virtual int ParseInt(System.String val)
305                 {
306                         int shift = val[0] - NumericUtils.SHIFT_START_INT;
307                         if (shift > 0 && shift <= 31)
308                                 throw new FieldCacheImpl.StopFillCacheException();
309                         return NumericUtils.PrefixCodedToInt(val);
310                 }
311                 protected internal virtual System.Object ReadResolve()
312                 {
313                         return Mono.Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_INT_PARSER;
314                 }
315                 public override System.String ToString()
316                 {
317                         return typeof(FieldCache).FullName + ".NUMERIC_UTILS_INT_PARSER";
318                 }
319         }
320         [Serializable]
321         class AnonymousClassFloatParser1 : FloatParser
322         {
323                 public virtual float ParseFloat(System.String val)
324                 {
325                         int shift = val[0] - NumericUtils.SHIFT_START_INT;
326                         if (shift > 0 && shift <= 31)
327                                 throw new FieldCacheImpl.StopFillCacheException();
328                         return NumericUtils.SortableIntToFloat(NumericUtils.PrefixCodedToInt(val));
329                 }
330                 protected internal virtual System.Object ReadResolve()
331                 {
332                         return Mono.Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_FLOAT_PARSER;
333                 }
334                 public override System.String ToString()
335                 {
336                         return typeof(FieldCache).FullName + ".NUMERIC_UTILS_FLOAT_PARSER";
337                 }
338         }
339         [Serializable]
340         class AnonymousClassLongParser1 : LongParser
341         {
342                 public virtual long ParseLong(System.String val)
343                 {
344                         int shift = val[0] - NumericUtils.SHIFT_START_LONG;
345                         if (shift > 0 && shift <= 63)
346                                 throw new FieldCacheImpl.StopFillCacheException();
347                         return NumericUtils.PrefixCodedToLong(val);
348                 }
349                 protected internal virtual System.Object ReadResolve()
350                 {
351                         return Mono.Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_LONG_PARSER;
352                 }
353                 public override System.String ToString()
354                 {
355                         return typeof(FieldCache).FullName + ".NUMERIC_UTILS_LONG_PARSER";
356                 }
357         }
358         [Serializable]
359         class AnonymousClassDoubleParser1 : DoubleParser
360         {
361                 public virtual double ParseDouble(System.String val)
362                 {
363                         int shift = val[0] - NumericUtils.SHIFT_START_LONG;
364                         if (shift > 0 && shift <= 63)
365                                 throw new FieldCacheImpl.StopFillCacheException();
366                         return NumericUtils.SortableLongToDouble(NumericUtils.PrefixCodedToLong(val));
367                 }
368                 protected internal virtual System.Object ReadResolve()
369                 {
370                         return Mono.Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_DOUBLE_PARSER;
371                 }
372                 public override System.String ToString()
373                 {
374                         return typeof(FieldCache).FullName + ".NUMERIC_UTILS_DOUBLE_PARSER";
375                 }
376         }
377         public interface FieldCache
378         {
379                 
380                 /// <summary>Checks the internal cache for an appropriate entry, and if none is
381                 /// found, reads the terms in <code>field</code> as a single byte and returns an array
382                 /// of size <code>reader.maxDoc()</code> of the value each document
383                 /// has in the given field.
384                 /// </summary>
385                 /// <param name="reader"> Used to get field values.
386                 /// </param>
387                 /// <param name="field">  Which field contains the single byte values.
388                 /// </param>
389                 /// <returns> The values in the given field for each document.
390                 /// </returns>
391                 /// <throws>  IOException  If any error occurs. </throws>
392                 sbyte[] GetBytes(IndexReader reader, System.String field);
393                 
394                 /// <summary>Checks the internal cache for an appropriate entry, and if none is found,
395                 /// reads the terms in <code>field</code> as bytes and returns an array of
396                 /// size <code>reader.maxDoc()</code> of the value each document has in the
397                 /// given field.
398                 /// </summary>
399                 /// <param name="reader"> Used to get field values.
400                 /// </param>
401                 /// <param name="field">  Which field contains the bytes.
402                 /// </param>
403                 /// <param name="parser"> Computes byte for string values.
404                 /// </param>
405                 /// <returns> The values in the given field for each document.
406                 /// </returns>
407                 /// <throws>  IOException  If any error occurs. </throws>
408                 sbyte[] GetBytes(IndexReader reader, System.String field, ByteParser parser);
409                 
410                 /// <summary>Checks the internal cache for an appropriate entry, and if none is
411                 /// found, reads the terms in <code>field</code> as shorts and returns an array
412                 /// of size <code>reader.maxDoc()</code> of the value each document
413                 /// has in the given field.
414                 /// </summary>
415                 /// <param name="reader"> Used to get field values.
416                 /// </param>
417                 /// <param name="field">  Which field contains the shorts.
418                 /// </param>
419                 /// <returns> The values in the given field for each document.
420                 /// </returns>
421                 /// <throws>  IOException  If any error occurs. </throws>
422                 short[] GetShorts(IndexReader reader, System.String field);
423                 
424                 /// <summary>Checks the internal cache for an appropriate entry, and if none is found,
425                 /// reads the terms in <code>field</code> as shorts and returns an array of
426                 /// size <code>reader.maxDoc()</code> of the value each document has in the
427                 /// given field.
428                 /// </summary>
429                 /// <param name="reader"> Used to get field values.
430                 /// </param>
431                 /// <param name="field">  Which field contains the shorts.
432                 /// </param>
433                 /// <param name="parser"> Computes short for string values.
434                 /// </param>
435                 /// <returns> The values in the given field for each document.
436                 /// </returns>
437                 /// <throws>  IOException  If any error occurs. </throws>
438                 short[] GetShorts(IndexReader reader, System.String field, ShortParser parser);
439                 
440                 /// <summary>Checks the internal cache for an appropriate entry, and if none is
441                 /// found, reads the terms in <code>field</code> as integers and returns an array
442                 /// of size <code>reader.maxDoc()</code> of the value each document
443                 /// has in the given field.
444                 /// </summary>
445                 /// <param name="reader"> Used to get field values.
446                 /// </param>
447                 /// <param name="field">  Which field contains the integers.
448                 /// </param>
449                 /// <returns> The values in the given field for each document.
450                 /// </returns>
451                 /// <throws>  IOException  If any error occurs. </throws>
452                 int[] GetInts(IndexReader reader, System.String field);
453                 
454                 /// <summary>Checks the internal cache for an appropriate entry, and if none is found,
455                 /// reads the terms in <code>field</code> as integers and returns an array of
456                 /// size <code>reader.maxDoc()</code> of the value each document has in the
457                 /// given field.
458                 /// </summary>
459                 /// <param name="reader"> Used to get field values.
460                 /// </param>
461                 /// <param name="field">  Which field contains the integers.
462                 /// </param>
463                 /// <param name="parser"> Computes integer for string values.
464                 /// </param>
465                 /// <returns> The values in the given field for each document.
466                 /// </returns>
467                 /// <throws>  IOException  If any error occurs. </throws>
468                 int[] GetInts(IndexReader reader, System.String field, IntParser parser);
469                 
470                 /// <summary>Checks the internal cache for an appropriate entry, and if
471                 /// none is found, reads the terms in <code>field</code> as floats and returns an array
472                 /// of size <code>reader.maxDoc()</code> of the value each document
473                 /// has in the given field.
474                 /// </summary>
475                 /// <param name="reader"> Used to get field values.
476                 /// </param>
477                 /// <param name="field">  Which field contains the floats.
478                 /// </param>
479                 /// <returns> The values in the given field for each document.
480                 /// </returns>
481                 /// <throws>  IOException  If any error occurs. </throws>
482                 float[] GetFloats(IndexReader reader, System.String field);
483                 
484                 /// <summary>Checks the internal cache for an appropriate entry, and if
485                 /// none is found, reads the terms in <code>field</code> as floats and returns an array
486                 /// of size <code>reader.maxDoc()</code> of the value each document
487                 /// has in the given field.
488                 /// </summary>
489                 /// <param name="reader"> Used to get field values.
490                 /// </param>
491                 /// <param name="field">  Which field contains the floats.
492                 /// </param>
493                 /// <param name="parser"> Computes float for string values.
494                 /// </param>
495                 /// <returns> The values in the given field for each document.
496                 /// </returns>
497                 /// <throws>  IOException  If any error occurs. </throws>
498                 float[] GetFloats(IndexReader reader, System.String field, FloatParser parser);
499                 
500                 /// <summary> Checks the internal cache for an appropriate entry, and if none is
501                 /// found, reads the terms in <code>field</code> as longs and returns an array
502                 /// of size <code>reader.maxDoc()</code> of the value each document
503                 /// has in the given field.
504                 /// 
505                 /// </summary>
506                 /// <param name="reader">Used to get field values.
507                 /// </param>
508                 /// <param name="field"> Which field contains the longs.
509                 /// </param>
510                 /// <returns> The values in the given field for each document.
511                 /// </returns>
512                 /// <throws>  java.io.IOException If any error occurs. </throws>
513                 long[] GetLongs(IndexReader reader, System.String field);
514                 
515                 /// <summary> Checks the internal cache for an appropriate entry, and if none is found,
516                 /// reads the terms in <code>field</code> as longs and returns an array of
517                 /// size <code>reader.maxDoc()</code> of the value each document has in the
518                 /// given field.
519                 /// 
520                 /// </summary>
521                 /// <param name="reader">Used to get field values.
522                 /// </param>
523                 /// <param name="field"> Which field contains the longs.
524                 /// </param>
525                 /// <param name="parser">Computes integer for string values.
526                 /// </param>
527                 /// <returns> The values in the given field for each document.
528                 /// </returns>
529                 /// <throws>  IOException If any error occurs. </throws>
530                 long[] GetLongs(IndexReader reader, System.String field, LongParser parser);
531                 
532                 
533                 /// <summary> Checks the internal cache for an appropriate entry, and if none is
534                 /// found, reads the terms in <code>field</code> as integers and returns an array
535                 /// of size <code>reader.maxDoc()</code> of the value each document
536                 /// has in the given field.
537                 /// 
538                 /// </summary>
539                 /// <param name="reader">Used to get field values.
540                 /// </param>
541                 /// <param name="field"> Which field contains the doubles.
542                 /// </param>
543                 /// <returns> The values in the given field for each document.
544                 /// </returns>
545                 /// <throws>  IOException If any error occurs. </throws>
546                 double[] GetDoubles(IndexReader reader, System.String field);
547                 
548                 /// <summary> Checks the internal cache for an appropriate entry, and if none is found,
549                 /// reads the terms in <code>field</code> as doubles and returns an array of
550                 /// size <code>reader.maxDoc()</code> of the value each document has in the
551                 /// given field.
552                 /// 
553                 /// </summary>
554                 /// <param name="reader">Used to get field values.
555                 /// </param>
556                 /// <param name="field"> Which field contains the doubles.
557                 /// </param>
558                 /// <param name="parser">Computes integer for string values.
559                 /// </param>
560                 /// <returns> The values in the given field for each document.
561                 /// </returns>
562                 /// <throws>  IOException If any error occurs. </throws>
563                 double[] GetDoubles(IndexReader reader, System.String field, DoubleParser parser);
564                 
565                 /// <summary>Checks the internal cache for an appropriate entry, and if none
566                 /// is found, reads the term values in <code>field</code> and returns an array
567                 /// of size <code>reader.maxDoc()</code> containing the value each document
568                 /// has in the given field.
569                 /// </summary>
570                 /// <param name="reader"> Used to get field values.
571                 /// </param>
572                 /// <param name="field">  Which field contains the strings.
573                 /// </param>
574                 /// <returns> The values in the given field for each document.
575                 /// </returns>
576                 /// <throws>  IOException  If any error occurs. </throws>
577                 System.String[] GetStrings(IndexReader reader, System.String field);
578                 
579                 /// <summary>Checks the internal cache for an appropriate entry, and if none
580                 /// is found reads the term values in <code>field</code> and returns
581                 /// an array of them in natural order, along with an array telling
582                 /// which element in the term array each document uses.
583                 /// </summary>
584                 /// <param name="reader"> Used to get field values.
585                 /// </param>
586                 /// <param name="field">  Which field contains the strings.
587                 /// </param>
588                 /// <returns> Array of terms and index into the array for each document.
589                 /// </returns>
590                 /// <throws>  IOException  If any error occurs. </throws>
591                 StringIndex GetStringIndex(IndexReader reader, System.String field);
592                 
593                 /// <summary>Checks the internal cache for an appropriate entry, and if
594                 /// none is found reads <code>field</code> to see if it contains integers, longs, floats
595                 /// or strings, and then calls one of the other methods in this class to get the
596                 /// values.  For string values, a StringIndex is returned.  After
597                 /// calling this method, there is an entry in the cache for both
598                 /// type <code>AUTO</code> and the actual found type.
599                 /// </summary>
600                 /// <param name="reader"> Used to get field values.
601                 /// </param>
602                 /// <param name="field">  Which field contains the values.
603                 /// </param>
604                 /// <returns> int[], long[], float[] or StringIndex.
605                 /// </returns>
606                 /// <throws>  IOException  If any error occurs. </throws>
607                 /// <deprecated> Please specify the exact type, instead.
608                 /// Especially, guessing does <b>not</b> work with the new
609                 /// {@link NumericField} type.
610                 /// </deprecated>
611         [Obsolete("Please specify the exact type, instead. Especially, guessing does not work with the new NumericField type.")]
612                 System.Object GetAuto(IndexReader reader, System.String field);
613                 
614                 /// <summary>Checks the internal cache for an appropriate entry, and if none
615                 /// is found reads the terms out of <code>field</code> and calls the given SortComparator
616                 /// to get the sort values.  A hit in the cache will happen if <code>reader</code>,
617                 /// <code>field</code>, and <code>comparator</code> are the same (using <code>equals()</code>)
618                 /// as a previous call to this method.
619                 /// </summary>
620                 /// <param name="reader"> Used to get field values.
621                 /// </param>
622                 /// <param name="field">  Which field contains the values.
623                 /// </param>
624                 /// <param name="comparator">Used to convert terms into something to sort by.
625                 /// </param>
626                 /// <returns> Array of sort objects, one for each document.
627                 /// </returns>
628                 /// <throws>  IOException  If any error occurs. </throws>
629                 /// <deprecated> Please implement {@link
630                 /// FieldComparatorSource} directly, instead.
631                 /// </deprecated>
632         [Obsolete("Please implement FieldComparatorSource directly, instead.")]
633                 System.IComparable[] GetCustom(IndexReader reader, System.String field, SortComparator comparator);
634                 
635                 /// <summary> EXPERT: Generates an array of CacheEntry objects representing all items 
636                 /// currently in the FieldCache.
637                 /// <p/>
638                 /// NOTE: These CacheEntry objects maintain a strong refrence to the 
639                 /// Cached Values.  Maintaining refrences to a CacheEntry the IndexReader 
640                 /// associated with it has garbage collected will prevent the Value itself
641                 /// from being garbage collected when the Cache drops the WeakRefrence.
642                 /// <p/>
643                 /// <p/>
644                 /// <b>EXPERIMENTAL API:</b> This API is considered extremely advanced 
645                 /// and experimental.  It may be removed or altered w/o warning in future 
646                 /// releases 
647                 /// of Lucene.
648                 /// <p/>
649                 /// </summary>
650                 CacheEntry[] GetCacheEntries();
651                 
652                 /// <summary> <p/>
653                 /// EXPERT: Instructs the FieldCache to forcibly expunge all entries 
654                 /// from the underlying caches.  This is intended only to be used for 
655                 /// test methods as a way to ensure a known base state of the Cache 
656                 /// (with out needing to rely on GC to free WeakReferences).  
657                 /// It should not be relied on for "Cache maintenance" in general 
658                 /// application code.
659                 /// <p/>
660                 /// <p/>
661                 /// <b>EXPERIMENTAL API:</b> This API is considered extremely advanced 
662                 /// and experimental.  It may be removed or altered w/o warning in future 
663                 /// releases 
664                 /// of Lucene.
665                 /// <p/>
666                 /// </summary>
667                 void  PurgeAllCaches();
668
669         /// <summary>
670         /// Expert: drops all cache entries associated with this
671         /// reader.  NOTE: this reader must precisely match the
672         /// reader that the cache entry is keyed on. If you pass a
673         /// top-level reader, it usually will have no effect as
674         /// Lucene now caches at the segment reader level.
675         /// </summary>
676         void Purge(IndexReader r);
677                 
678                 /// <summary> If non-null, FieldCacheImpl will warn whenever
679                 /// entries are created that are not sane according to
680                 /// {@link Mono.Lucene.Net.Util.FieldCacheSanityChecker}.
681                 /// </summary>
682                 void  SetInfoStream(System.IO.StreamWriter stream);
683                 
684                 /// <summary>counterpart of {@link #SetInfoStream(PrintStream)} </summary>
685                 System.IO.StreamWriter GetInfoStream();
686         }
687         
688         /// <summary> Marker interface as super-interface to all parsers. It
689         /// is used to specify a custom parser to {@link
690         /// SortField#SortField(String, FieldCache.Parser)}.
691         /// </summary>
692         public interface Parser
693         {
694         }
695         
696         /// <summary>Interface to parse bytes from document fields.</summary>
697         /// <seealso cref="FieldCache.GetBytes(IndexReader, String, FieldCache.ByteParser)">
698         /// </seealso>
699         public interface ByteParser:Parser
700         {
701                 /// <summary>Return a single Byte representation of this field's value. </summary>
702                 sbyte ParseByte(System.String string_Renamed);
703         }
704         
705         /// <summary>Interface to parse shorts from document fields.</summary>
706         /// <seealso cref="FieldCache.GetShorts(IndexReader, String, FieldCache.ShortParser)">
707         /// </seealso>
708         public interface ShortParser:Parser
709         {
710                 /// <summary>Return a short representation of this field's value. </summary>
711                 short ParseShort(System.String string_Renamed);
712         }
713         
714         /// <summary>Interface to parse ints from document fields.</summary>
715         /// <seealso cref="FieldCache.GetInts(IndexReader, String, FieldCache.IntParser)">
716         /// </seealso>
717         public interface IntParser:Parser
718         {
719                 /// <summary>Return an integer representation of this field's value. </summary>
720                 int ParseInt(System.String string_Renamed);
721         }
722         
723         /// <summary>Interface to parse floats from document fields.</summary>
724         /// <seealso cref="FieldCache.GetFloats(IndexReader, String, FieldCache.FloatParser)">
725         /// </seealso>
726         public interface FloatParser:Parser
727         {
728                 /// <summary>Return an float representation of this field's value. </summary>
729                 float ParseFloat(System.String string_Renamed);
730         }
731         
732         /// <summary>Interface to parse long from document fields.</summary>
733         /// <seealso cref="FieldCache.GetLongs(IndexReader, String, FieldCache.LongParser)">
734         /// </seealso>
735         /// <deprecated> Use {@link FieldCache.LongParser}, this will be removed in Lucene 3.0 
736         /// </deprecated>
737     [Obsolete("Use FieldCache.LongParser, this will be removed in Lucene 3.0")]
738         public interface LongParser:Parser
739         {
740                 /// <summary>Return an long representation of this field's value. </summary>
741                 long ParseLong(System.String string_Renamed);
742         }
743         
744         /// <summary>Interface to parse doubles from document fields.</summary>
745         /// <seealso cref="FieldCache.GetDoubles(IndexReader, String, FieldCache.DoubleParser)">
746         /// </seealso>
747         /// <deprecated> Use {@link FieldCache.DoubleParser}, this will be removed in Lucene 3.0 
748         /// </deprecated>
749     [Obsolete("Use FieldCache.DoubleParser, this will be removed in Lucene 3.0 ")]
750         public interface DoubleParser:Parser
751         {
752                 /// <summary>Return an long representation of this field's value. </summary>
753                 double ParseDouble(System.String string_Renamed);
754         }
755 }