public virtual void AddTerm(Term term, int docIDUpto)
{
int? current;
Terms.TryGetValue(term, out current);
if (current != null && docIDUpto < current)
{
// Only record the new number if it's greater than the
// current one. this is important because if multiple
// threads are replacing the same doc at nearly the
// same time, it's possible that one thread that got a
// higher docID is scheduled before the other
// threads. If we blindly replace than we can
// incorrectly get both docs indexed.
return;
}
Terms[term] = Convert.ToInt32(docIDUpto);
// note that if current != null then it means there's already a buffered
// delete on that term, therefore we seem to over-count. this over-counting
// is done to respect IndexWriterConfig.setMaxBufferedDeleteTerms.
NumTermDeletes.IncrementAndGet();
if (current == null)
{
BytesUsed.AddAndGet(BYTES_PER_DEL_TERM + term.Bytes_Renamed.Length + (RamUsageEstimator.NUM_BYTES_CHAR * term.Field().Length));
}
}