Skip to content

Commit

Permalink
Lucene.Net.Search.FieldCacheImpl: Removed field value types and decla…
Browse files Browse the repository at this point in the history
…red Get methods inline using delegate methods
  • Loading branch information
NightOwl888 committed Sep 23, 2020
1 parent 197d5db commit 34758c1
Showing 1 changed file with 6 additions and 114 deletions.
120 changes: 6 additions & 114 deletions src/Lucene.Net/Search/FieldCacheImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down Expand Up @@ -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
{
Expand All @@ -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);
}
}

/// <summary>
/// NOTE: This was ShortsFromArray in Lucene
/// </summary>
Expand Down Expand Up @@ -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
{
Expand All @@ -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);
}
}

/// <summary>
/// NOTE: This was IntsFromArray in Lucene
/// </summary>
Expand Down Expand Up @@ -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
{
Expand All @@ -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));
}
}

/// <summary>
/// NOTE: This was FloatsFromArray in Lucene
/// </summary>
Expand Down Expand Up @@ -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
{
Expand All @@ -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);
}
}

/// <summary>
/// NOTE: This was LongsFromArray in Lucene
/// </summary>
Expand Down Expand Up @@ -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
{
Expand All @@ -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;
Expand Down

0 comments on commit 34758c1

Please sign in to comment.