Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FieldCache.cs « Search « core « src - github.com/mono/Lucene.Net.Light.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e0ac588b501cb084eb42499f7e34a9c245dbc943 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
/* 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using System;
using System.IO;
using Lucene.Net.Support;
using Double = Lucene.Net.Support.Double;
using NumericTokenStream = Lucene.Net.Analysis.NumericTokenStream;
using NumericField = Lucene.Net.Documents.NumericField;
using IndexReader = Lucene.Net.Index.IndexReader;
using NumericUtils = Lucene.Net.Util.NumericUtils;
using RamUsageEstimator = Lucene.Net.Util.RamUsageEstimator;
using Single = Lucene.Net.Support.Single;

namespace Lucene.Net.Search
{

    /// <summary> Expert: Maintains caches of term values.
    /// 
    /// <p/>Created: May 19, 2004 11:13:14 AM
    /// 
    /// </summary>
    /// <since>   lucene 1.4
    /// </since>
    /// <version>  $Id: FieldCache.java 807841 2009-08-25 22:27:31Z markrmiller $
    /// </version>
    /// <seealso cref="Lucene.Net.Util.FieldCacheSanityChecker">
    /// </seealso>
    public sealed class CreationPlaceholder
    {
        internal System.Object value_Renamed;
    }
    /// <summary>Expert: Stores term text values and document ordering data. </summary>
    public class StringIndex
    {

        public virtual int BinarySearchLookup(System.String key)
        {
            // this special case is the reason that Arrays.binarySearch() isn't useful.
            if (key == null)
                return 0;

            int low = 1;
            int high = lookup.Length - 1;

            while (low <= high)
            {
                int mid = Number.URShift((low + high), 1);
                int cmp = String.CompareOrdinal(lookup[mid], key);

                if (cmp < 0)
                    low = mid + 1;
                else if (cmp > 0)
                    high = mid - 1;
                else
                    return mid; // key found
            }
            return -(low + 1); // key not found.
        }

        /// <summary>All the term values, in natural order. </summary>
        public System.String[] lookup;

        /// <summary>For each document, an index into the lookup array. </summary>
        public int[] order;

        /// <summary>Creates one of these objects </summary>
        public StringIndex(int[] values, System.String[] lookup)
        {
            this.order = values;
            this.lookup = lookup;
        }
    }
    /// <summary> EXPERT: A unique Identifier/Description for each item in the FieldCache. 
    /// Can be useful for logging/debugging.
    /// <p/>
    /// <b>EXPERIMENTAL API:</b> This API is considered extremely advanced 
    /// and experimental.  It may be removed or altered w/o warning in future 
    /// releases 
    /// of Lucene.
    /// <p/>
    /// </summary>
    public abstract class CacheEntry
    {
        public abstract object ReaderKey { get; }
        public abstract string FieldName { get; }
        public abstract Type CacheType { get; }
        public abstract object Custom { get; }
        public abstract object Value { get; }

        /// <seealso cref="EstimateSize(RamUsageEstimator)">
        /// </seealso>
        public virtual void EstimateSize()
        {
            EstimateSize(new RamUsageEstimator(false)); // doesn't check for interned
        }
        /// <summary> Computes (and stores) the estimated size of the cache Value </summary>
        /// <seealso cref="EstimatedSize">
        /// </seealso>
        public virtual void EstimateSize(RamUsageEstimator ramCalc)
        {
            long size = ramCalc.EstimateRamUsage(Value);
            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#
        }

        /// <summary> The most recently estimated size of the value, null unless 
        /// estimateSize has been called.
        /// </summary>
        public string EstimatedSize { get; protected internal set; }


        public override System.String ToString()
        {
            var b = new System.Text.StringBuilder();
            b.Append("'").Append(ReaderKey).Append("'=>");
            b.Append("'").Append(FieldName).Append("',");
            b.Append(CacheType).Append(",").Append(Custom);
            b.Append("=>").Append(Value.GetType().FullName).Append("#");
            b.Append(Value.GetHashCode());

            System.String s = EstimatedSize;
            if (null != s)
            {
                b.Append(" (size =~ ").Append(s).Append(')');
            }

            return b.ToString();
        }
    }
    public struct FieldCache_Fields
    {
        /// <summary>Indicator for StringIndex values in the cache. </summary>
        // NOTE: the value assigned to this constant must not be
        // the same as any of those in SortField!!
        public readonly static int STRING_INDEX = -1;
        /// <summary>Expert: The cache used internally by sorting and range query classes. </summary>
        public readonly static FieldCache DEFAULT;
        /// <summary>The default parser for byte values, which are encoded by <see cref="byte.ToString()" /> </summary>
        public readonly static ByteParser DEFAULT_BYTE_PARSER;
        /// <summary>The default parser for short values, which are encoded by <see cref="short.ToString()" /> </summary>
        public readonly static ShortParser DEFAULT_SHORT_PARSER;
        /// <summary>The default parser for int values, which are encoded by <see cref="int.ToString()" /> </summary>
        public readonly static IntParser DEFAULT_INT_PARSER;
        /// <summary>The default parser for float values, which are encoded by <see cref="float.ToString()" /> </summary>
        public readonly static FloatParser DEFAULT_FLOAT_PARSER;
        /// <summary>The default parser for long values, which are encoded by <see cref="long.ToString()" /> </summary>
        public readonly static LongParser DEFAULT_LONG_PARSER;
        /// <summary>The default parser for double values, which are encoded by <see cref="double.ToString()" /> </summary>
        public readonly static DoubleParser DEFAULT_DOUBLE_PARSER;
        /// <summary> A parser instance for int values encoded by <see cref="NumericUtils.IntToPrefixCoded(int)" />, e.g. when indexed
        /// via <see cref="NumericField" />/<see cref="NumericTokenStream" />.
        /// </summary>
        public readonly static IntParser NUMERIC_UTILS_INT_PARSER;
        /// <summary> A parser instance for float values encoded with <see cref="NumericUtils" />, e.g. when indexed
        /// via <see cref="NumericField" />/<see cref="NumericTokenStream" />.
        /// </summary>
        public readonly static FloatParser NUMERIC_UTILS_FLOAT_PARSER;
        /// <summary> A parser instance for long values encoded by <see cref="NumericUtils.LongToPrefixCoded(long)" />, e.g. when indexed
        /// via <see cref="NumericField" />/<see cref="NumericTokenStream" />.
        /// </summary>
        public readonly static LongParser NUMERIC_UTILS_LONG_PARSER;
        /// <summary> A parser instance for double values encoded with <see cref="NumericUtils" />, e.g. when indexed
        /// via <see cref="NumericField" />/<see cref="NumericTokenStream" />.
        /// </summary>
        public readonly static DoubleParser NUMERIC_UTILS_DOUBLE_PARSER;
        static FieldCache_Fields()
        {
            DEFAULT = new FieldCacheImpl();
            DEFAULT_BYTE_PARSER = new AnonymousClassByteParser();
            DEFAULT_SHORT_PARSER = new AnonymousClassShortParser();
            DEFAULT_INT_PARSER = new AnonymousClassIntParser();
            DEFAULT_FLOAT_PARSER = new AnonymousClassFloatParser();
            DEFAULT_LONG_PARSER = new AnonymousClassLongParser();
            DEFAULT_DOUBLE_PARSER = new AnonymousClassDoubleParser();
            NUMERIC_UTILS_INT_PARSER = new AnonymousClassIntParser1();
            NUMERIC_UTILS_FLOAT_PARSER = new AnonymousClassFloatParser1();
            NUMERIC_UTILS_LONG_PARSER = new AnonymousClassLongParser1();
            NUMERIC_UTILS_DOUBLE_PARSER = new AnonymousClassDoubleParser1();
        }
    }

    [Serializable]
    class AnonymousClassByteParser : ByteParser
    {
        public virtual sbyte ParseByte(System.String value_Renamed)
        {
            return System.SByte.Parse(value_Renamed);
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.DEFAULT_BYTE_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".DEFAULT_BYTE_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassShortParser : ShortParser
    {
        public virtual short ParseShort(System.String value_Renamed)
        {
            return System.Int16.Parse(value_Renamed);
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.DEFAULT_SHORT_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".DEFAULT_SHORT_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassIntParser : IntParser
    {
        public virtual int ParseInt(System.String value_Renamed)
        {
            return System.Int32.Parse(value_Renamed);
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.DEFAULT_INT_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".DEFAULT_INT_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassFloatParser : FloatParser
    {
        public virtual float ParseFloat(System.String value_Renamed)
        {
            try
            {
                return Single.Parse(value_Renamed);
            }
            catch (System.OverflowException)
            {
                return value_Renamed.StartsWith("-") ? float.PositiveInfinity : float.NegativeInfinity;
            }
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.DEFAULT_FLOAT_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".DEFAULT_FLOAT_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassLongParser : LongParser
    {
        public virtual long ParseLong(System.String value_Renamed)
        {
            return System.Int64.Parse(value_Renamed);
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.DEFAULT_LONG_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".DEFAULT_LONG_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassDoubleParser : DoubleParser
    {
        public virtual double ParseDouble(System.String value_Renamed)
        {
            return Double.Parse(value_Renamed);
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.DEFAULT_DOUBLE_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".DEFAULT_DOUBLE_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassIntParser1 : IntParser
    {
        public virtual int ParseInt(System.String val)
        {
            int shift = val[0] - NumericUtils.SHIFT_START_INT;
            if (shift > 0 && shift <= 31)
                throw new FieldCacheImpl.StopFillCacheException();
            return NumericUtils.PrefixCodedToInt(val);
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_INT_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".NUMERIC_UTILS_INT_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassFloatParser1 : FloatParser
    {
        public virtual float ParseFloat(System.String val)
        {
            int shift = val[0] - NumericUtils.SHIFT_START_INT;
            if (shift > 0 && shift <= 31)
                throw new FieldCacheImpl.StopFillCacheException();
            return NumericUtils.SortableIntToFloat(NumericUtils.PrefixCodedToInt(val));
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_FLOAT_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".NUMERIC_UTILS_FLOAT_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassLongParser1 : LongParser
    {
        public virtual long ParseLong(System.String val)
        {
            int shift = val[0] - NumericUtils.SHIFT_START_LONG;
            if (shift > 0 && shift <= 63)
                throw new FieldCacheImpl.StopFillCacheException();
            return NumericUtils.PrefixCodedToLong(val);
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_LONG_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".NUMERIC_UTILS_LONG_PARSER";
        }
    }
    [Serializable]
    class AnonymousClassDoubleParser1 : DoubleParser
    {
        public virtual double ParseDouble(System.String val)
        {
            int shift = val[0] - NumericUtils.SHIFT_START_LONG;
            if (shift > 0 && shift <= 63)
                throw new FieldCacheImpl.StopFillCacheException();
            return NumericUtils.SortableLongToDouble(NumericUtils.PrefixCodedToLong(val));
        }
        protected internal virtual System.Object ReadResolve()
        {
            return Lucene.Net.Search.FieldCache_Fields.NUMERIC_UTILS_DOUBLE_PARSER;
        }
        public override System.String ToString()
        {
            return typeof(FieldCache).FullName + ".NUMERIC_UTILS_DOUBLE_PARSER";
        }
    }

    public interface FieldCache
    {

        /// <summary>Checks the internal cache for an appropriate entry, and if none is
        /// found, reads the terms in <c>field</c> as a single byte and returns an array
        /// of size <c>reader.MaxDoc</c> of the value each document
        /// has in the given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the single byte values.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        sbyte[] GetBytes(IndexReader reader, System.String field);

        /// <summary>Checks the internal cache for an appropriate entry, and if none is found,
        /// reads the terms in <c>field</c> as bytes and returns an array of
        /// size <c>reader.MaxDoc</c> of the value each document has in the
        /// given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the bytes.
        /// </param>
        /// <param name="parser"> Computes byte for string values.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        sbyte[] GetBytes(IndexReader reader, System.String field, ByteParser parser);

        /// <summary>Checks the internal cache for an appropriate entry, and if none is
        /// found, reads the terms in <c>field</c> as shorts and returns an array
        /// of size <c>reader.MaxDoc</c> of the value each document
        /// has in the given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the shorts.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        short[] GetShorts(IndexReader reader, System.String field);

        /// <summary>Checks the internal cache for an appropriate entry, and if none is found,
        /// reads the terms in <c>field</c> as shorts and returns an array of
        /// size <c>reader.MaxDoc</c> of the value each document has in the
        /// given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the shorts.
        /// </param>
        /// <param name="parser"> Computes short for string values.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        short[] GetShorts(IndexReader reader, System.String field, ShortParser parser);

        /// <summary>Checks the internal cache for an appropriate entry, and if none is
        /// found, reads the terms in <c>field</c> as integers and returns an array
        /// of size <c>reader.MaxDoc</c> of the value each document
        /// has in the given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the integers.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        int[] GetInts(IndexReader reader, System.String field);

        /// <summary>Checks the internal cache for an appropriate entry, and if none is found,
        /// reads the terms in <c>field</c> as integers and returns an array of
        /// size <c>reader.MaxDoc</c> of the value each document has in the
        /// given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the integers.
        /// </param>
        /// <param name="parser"> Computes integer for string values.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        int[] GetInts(IndexReader reader, System.String field, IntParser parser);

        /// <summary>Checks the internal cache for an appropriate entry, and if
        /// none is found, reads the terms in <c>field</c> as floats and returns an array
        /// of size <c>reader.MaxDoc</c> of the value each document
        /// has in the given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the floats.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        float[] GetFloats(IndexReader reader, System.String field);

        /// <summary>Checks the internal cache for an appropriate entry, and if
        /// none is found, reads the terms in <c>field</c> as floats and returns an array
        /// of size <c>reader.MaxDoc</c> of the value each document
        /// has in the given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the floats.
        /// </param>
        /// <param name="parser"> Computes float for string values.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        float[] GetFloats(IndexReader reader, System.String field, FloatParser parser);

        /// <summary> Checks the internal cache for an appropriate entry, and if none is
        /// found, reads the terms in <c>field</c> as longs and returns an array
        /// of size <c>reader.MaxDoc</c> of the value each document
        /// has in the given field.
        /// 
        /// </summary>
        /// <param name="reader">Used to get field values.
        /// </param>
        /// <param name="field"> Which field contains the longs.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  java.io.IOException If any error occurs. </throws>
        long[] GetLongs(IndexReader reader, System.String field);

        /// <summary> Checks the internal cache for an appropriate entry, and if none is found,
        /// reads the terms in <c>field</c> as longs and returns an array of
        /// size <c>reader.MaxDoc</c> of the value each document has in the
        /// given field.
        /// 
        /// </summary>
        /// <param name="reader">Used to get field values.
        /// </param>
        /// <param name="field"> Which field contains the longs.
        /// </param>
        /// <param name="parser">Computes integer for string values.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException If any error occurs. </throws>
        long[] GetLongs(IndexReader reader, System.String field, LongParser parser);


        /// <summary> Checks the internal cache for an appropriate entry, and if none is
        /// found, reads the terms in <c>field</c> as integers and returns an array
        /// of size <c>reader.MaxDoc</c> of the value each document
        /// has in the given field.
        /// 
        /// </summary>
        /// <param name="reader">Used to get field values.
        /// </param>
        /// <param name="field"> Which field contains the doubles.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException If any error occurs. </throws>
        double[] GetDoubles(IndexReader reader, System.String field);

        /// <summary> Checks the internal cache for an appropriate entry, and if none is found,
        /// reads the terms in <c>field</c> as doubles and returns an array of
        /// size <c>reader.MaxDoc</c> of the value each document has in the
        /// given field.
        /// 
        /// </summary>
        /// <param name="reader">Used to get field values.
        /// </param>
        /// <param name="field"> Which field contains the doubles.
        /// </param>
        /// <param name="parser">Computes integer for string values.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException If any error occurs. </throws>
        double[] GetDoubles(IndexReader reader, System.String field, DoubleParser parser);

        /// <summary>Checks the internal cache for an appropriate entry, and if none
        /// is found, reads the term values in <c>field</c> and returns an array
        /// of size <c>reader.MaxDoc</c> containing the value each document
        /// has in the given field.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the strings.
        /// </param>
        /// <returns> The values in the given field for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        System.String[] GetStrings(IndexReader reader, System.String field);

        /// <summary>Checks the internal cache for an appropriate entry, and if none
        /// is found reads the term values in <c>field</c> and returns
        /// an array of them in natural order, along with an array telling
        /// which element in the term array each document uses.
        /// </summary>
        /// <param name="reader"> Used to get field values.
        /// </param>
        /// <param name="field">  Which field contains the strings.
        /// </param>
        /// <returns> Array of terms and index into the array for each document.
        /// </returns>
        /// <throws>  IOException  If any error occurs. </throws>
        StringIndex GetStringIndex(IndexReader reader, System.String field);

        /// <summary> EXPERT: Generates an array of CacheEntry objects representing all items 
        /// currently in the FieldCache.
        /// <p/>
        /// NOTE: These CacheEntry objects maintain a strong refrence to the 
        /// Cached Values.  Maintaining refrences to a CacheEntry the IndexReader 
        /// associated with it has garbage collected will prevent the Value itself
        /// from being garbage collected when the Cache drops the WeakRefrence.
        /// <p/>
        /// <p/>
        /// <b>EXPERIMENTAL API:</b> This API is considered extremely advanced 
        /// and experimental.  It may be removed or altered w/o warning in future 
        /// releases 
        /// of Lucene.
        /// <p/>
        /// </summary>
        CacheEntry[] GetCacheEntries();

        /// <summary> <p/>
        /// EXPERT: Instructs the FieldCache to forcibly expunge all entries 
        /// from the underlying caches.  This is intended only to be used for 
        /// test methods as a way to ensure a known base state of the Cache 
        /// (with out needing to rely on GC to free WeakReferences).  
        /// It should not be relied on for "Cache maintenance" in general 
        /// application code.
        /// <p/>
        /// <p/>
        /// <b>EXPERIMENTAL API:</b> This API is considered extremely advanced 
        /// and experimental.  It may be removed or altered w/o warning in future 
        /// releases 
        /// of Lucene.
        /// <p/>
        /// </summary>
        void PurgeAllCaches();

        /// <summary>
        /// Expert: drops all cache entries associated with this
        /// reader.  NOTE: this reader must precisely match the
        /// reader that the cache entry is keyed on. If you pass a
        /// top-level reader, it usually will have no effect as
        /// Lucene now caches at the segment reader level.
        /// </summary>
        void Purge(IndexReader r);

        /// <summary> Gets or sets the InfoStream for this FieldCache.
        /// <para>If non-null, FieldCacheImpl will warn whenever
        /// entries are created that are not sane according to
        /// <see cref="Lucene.Net.Util.FieldCacheSanityChecker" />.
        /// </para>
        /// </summary>
        StreamWriter InfoStream { get; set; }
    }

    /// <summary> Marker interface as super-interface to all parsers. It
    /// is used to specify a custom parser to <see cref="SortField(String, Parser)" />.
    /// </summary>
    public interface Parser
    {
    }

    /// <summary>Interface to parse bytes from document fields.</summary>
    /// <seealso cref="FieldCache.GetBytes(IndexReader, String, ByteParser)">
    /// </seealso>
    public interface ByteParser : Parser
    {
        /// <summary>Return a single Byte representation of this field's value. </summary>
        sbyte ParseByte(System.String string_Renamed);
    }

    /// <summary>Interface to parse shorts from document fields.</summary>
    /// <seealso cref="FieldCache.GetShorts(IndexReader, String, ShortParser)">
    /// </seealso>
    public interface ShortParser : Parser
    {
        /// <summary>Return a short representation of this field's value. </summary>
        short ParseShort(System.String string_Renamed);
    }

    /// <summary>Interface to parse ints from document fields.</summary>
    /// <seealso cref="FieldCache.GetInts(IndexReader, String, IntParser)">
    /// </seealso>
    public interface IntParser : Parser
    {
        /// <summary>Return an integer representation of this field's value. </summary>
        int ParseInt(System.String string_Renamed);
    }

    /// <summary>Interface to parse floats from document fields.</summary>
    /// <seealso cref="FieldCache.GetFloats(IndexReader, String, FloatParser)">
    /// </seealso>
    public interface FloatParser : Parser
    {
        /// <summary>Return an float representation of this field's value. </summary>
        float ParseFloat(System.String string_Renamed);
    }

    /// <summary>Interface to parse long from document fields.</summary>
    /// <seealso cref="FieldCache.GetLongs(IndexReader, String, LongParser)">
    /// </seealso>
    /// <deprecated> Use <see cref="LongParser" />, this will be removed in Lucene 3.0 
    /// </deprecated>
    public interface LongParser : Parser
    {
        /// <summary>Return an long representation of this field's value. </summary>
        long ParseLong(System.String string_Renamed);
    }

    /// <summary>Interface to parse doubles from document fields.</summary>
    /// <seealso cref="FieldCache.GetDoubles(IndexReader, String, DoubleParser)">
    /// </seealso>
    /// <deprecated> Use <see cref="DoubleParser" />, this will be removed in Lucene 3.0 
    /// </deprecated>
    public interface DoubleParser : Parser
    {
        /// <summary>Return an long representation of this field's value. </summary>
        double ParseDouble(System.String string_Renamed);
    }
}