diff --git a/src/Lucene.Net/Search/FieldCacheImpl.cs b/src/Lucene.Net/Search/FieldCacheImpl.cs index f5bb0dda88..08d933a21d 100644 --- a/src/Lucene.Net/Search/FieldCacheImpl.cs +++ b/src/Lucene.Net/Search/FieldCacheImpl.cs @@ -589,7 +589,7 @@ public virtual FieldCache.Bytes GetBytes(AtomicReader reader, string field, Fiel { // Not cached here by FieldCacheImpl (cached instead // per-thread by SegmentReader): - return new FieldCache_BytesAnonymousInnerClassHelper(this, valuesIn); + return new FieldCache.Bytes(get: (docID) => (byte)valuesIn.Get(docID)); } else { @@ -613,24 +613,6 @@ public virtual FieldCache.Bytes GetBytes(AtomicReader reader, string field, Fiel } } - private class FieldCache_BytesAnonymousInnerClassHelper : FieldCache.Bytes - { - private readonly FieldCacheImpl outerInstance; - - private NumericDocValues valuesIn; - - public FieldCache_BytesAnonymousInnerClassHelper(FieldCacheImpl outerInstance, NumericDocValues valuesIn) - { - this.outerInstance = outerInstance; - this.valuesIn = valuesIn; - } - - public override byte Get(int docID) - { - return (byte)valuesIn.Get(docID); - } - } - internal class BytesFromArray : FieldCache.Bytes { private readonly sbyte[] values; @@ -765,7 +747,7 @@ public virtual FieldCache.Int16s GetInt16s(AtomicReader reader, string field, Fi { // Not cached here by FieldCacheImpl (cached instead // per-thread by SegmentReader): - return new FieldCache_Int16sAnonymousInnerClassHelper(this, valuesIn); + return new FieldCache.Int16s(get: (docID) => (short)valuesIn.Get(docID)); } else { @@ -787,24 +769,6 @@ public virtual FieldCache.Int16s GetInt16s(AtomicReader reader, string field, Fi } } - private class FieldCache_Int16sAnonymousInnerClassHelper : FieldCache.Int16s - { - private readonly FieldCacheImpl outerInstance; - - private NumericDocValues valuesIn; - - public FieldCache_Int16sAnonymousInnerClassHelper(FieldCacheImpl outerInstance, NumericDocValues valuesIn) - { - this.outerInstance = outerInstance; - this.valuesIn = valuesIn; - } - - public override short Get(int docID) - { - return (short)valuesIn.Get(docID); - } - } - /// /// NOTE: This was ShortsFromArray in Lucene /// @@ -943,7 +907,7 @@ public virtual FieldCache.Int32s GetInt32s(AtomicReader reader, string field, Fi { // Not cached here by FieldCacheImpl (cached instead // per-thread by SegmentReader): - return new FieldCache_Int32sAnonymousInnerClassHelper(this, valuesIn); + return new FieldCache.Int32s(get: (docID) => (int)valuesIn.Get(docID)); } else { @@ -965,24 +929,6 @@ public virtual FieldCache.Int32s GetInt32s(AtomicReader reader, string field, Fi } } - private class FieldCache_Int32sAnonymousInnerClassHelper : FieldCache.Int32s - { - private readonly FieldCacheImpl outerInstance; - - private NumericDocValues valuesIn; - - public FieldCache_Int32sAnonymousInnerClassHelper(FieldCacheImpl outerInstance, NumericDocValues valuesIn) - { - this.outerInstance = outerInstance; - this.valuesIn = valuesIn; - } - - public override int Get(int docID) - { - return (int)valuesIn.Get(docID); - } - } - /// /// NOTE: This was IntsFromArray in Lucene /// @@ -1244,7 +1190,7 @@ public virtual FieldCache.Singles GetSingles(AtomicReader reader, string field, { // Not cached here by FieldCacheImpl (cached instead // per-thread by SegmentReader): - return new FieldCache_SinglesAnonymousInnerClassHelper(this, valuesIn); + return new FieldCache.Singles(get: (docID) => J2N.BitConversion.Int32BitsToSingle((int)valuesIn.Get(docID))); } else { @@ -1266,24 +1212,6 @@ public virtual FieldCache.Singles GetSingles(AtomicReader reader, string field, } } - private class FieldCache_SinglesAnonymousInnerClassHelper : FieldCache.Singles - { - private readonly FieldCacheImpl outerInstance; - - private NumericDocValues valuesIn; - - public FieldCache_SinglesAnonymousInnerClassHelper(FieldCacheImpl outerInstance, NumericDocValues valuesIn) - { - this.outerInstance = outerInstance; - this.valuesIn = valuesIn; - } - - public override float Get(int docID) - { - return J2N.BitConversion.Int32BitsToSingle((int)valuesIn.Get(docID)); - } - } - /// /// NOTE: This was FloatsFromArray in Lucene /// @@ -1416,7 +1344,7 @@ public virtual FieldCache.Int64s GetInt64s(AtomicReader reader, string field, Fi { // Not cached here by FieldCacheImpl (cached instead // per-thread by SegmentReader): - return new FieldCache_Int64sAnonymousInnerClassHelper(this, valuesIn); + return new FieldCache.Int64s(get: (docID) => valuesIn.Get(docID)); } else { @@ -1438,24 +1366,6 @@ public virtual FieldCache.Int64s GetInt64s(AtomicReader reader, string field, Fi } } - private class FieldCache_Int64sAnonymousInnerClassHelper : FieldCache.Int64s - { - private readonly FieldCacheImpl outerInstance; - - private NumericDocValues valuesIn; - - public FieldCache_Int64sAnonymousInnerClassHelper(FieldCacheImpl outerInstance, NumericDocValues valuesIn) - { - this.outerInstance = outerInstance; - this.valuesIn = valuesIn; - } - - public override long Get(int docID) - { - return valuesIn.Get(docID); - } - } - /// /// NOTE: This was LongsFromArray in Lucene /// @@ -1600,7 +1510,7 @@ public virtual FieldCache.Doubles GetDoubles(AtomicReader reader, string field, { // Not cached here by FieldCacheImpl (cached instead // per-thread by SegmentReader): - return new FieldCache_DoublesAnonymousInnerClassHelper(this, valuesIn); + return new FieldCache.Doubles(get: (docID) => J2N.BitConversion.Int64BitsToDouble(valuesIn.Get(docID))); } else { @@ -1622,24 +1532,6 @@ public virtual FieldCache.Doubles GetDoubles(AtomicReader reader, string field, } } - private class FieldCache_DoublesAnonymousInnerClassHelper : FieldCache.Doubles - { - private readonly FieldCacheImpl outerInstance; - - private NumericDocValues valuesIn; - - public FieldCache_DoublesAnonymousInnerClassHelper(FieldCacheImpl outerInstance, NumericDocValues valuesIn) - { - this.outerInstance = outerInstance; - this.valuesIn = valuesIn; - } - - public override double Get(int docID) - { - return J2N.BitConversion.Int64BitsToDouble(valuesIn.Get(docID)); - } - } - internal class DoublesFromArray : FieldCache.Doubles { private readonly double[] values;