public override void Collect(int doc)
{
if (CurDocs == null)
{
// Cache was too large
CachedScorer.Score_Renamed = Scorer_Renamed.Score();
CachedScorer.Doc = doc;
Other.Collect(doc);
return;
}
// Allocate a bigger array or abort caching
if (Upto == CurDocs.Length)
{
@base += Upto;
// Compute next array length - don't allocate too big arrays
int nextLength = 8 * CurDocs.Length;
if (nextLength > MAX_ARRAY_SIZE)
{
nextLength = MAX_ARRAY_SIZE;
}
if (@base + nextLength > MaxDocsToCache)
{
// try to allocate a smaller array
nextLength = MaxDocsToCache - @base;
if (nextLength <= 0)
{
// Too many docs to collect -- clear cache
CurDocs = null;
CurScores = null;
CachedSegs.Clear();
CachedDocs.Clear();
CachedScores.Clear();
CachedScorer.Score_Renamed = Scorer_Renamed.Score();
CachedScorer.Doc = doc;
Other.Collect(doc);
return;
}
}
CurDocs = new int[nextLength];
CachedDocs.Add(CurDocs);
CurScores = new float[nextLength];
CachedScores.Add(CurScores);
Upto = 0;
}
CurDocs[Upto] = doc;
CachedScorer.Score_Renamed = CurScores[Upto] = Scorer_Renamed.Score();
Upto++;
CachedScorer.Doc = doc;
Other.Collect(doc);
}