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