Get() public method

public Get ( int index ) : bool
index int
return bool
 protected override void FillDocsAndScores(FixedBitSet matchingDocs, Bits acceptDocs,
     TermsEnum termsEnum)
 {
     BytesRef spare = new BytesRef();
     DocsEnum docsEnum = null;
     for (int i = 0; i < outerInstance._terms.Size(); i++)
     {
         if (termsEnum.SeekExact(outerInstance._terms.Get(outerInstance._ords[i], spare)))
         {
             docsEnum = termsEnum.Docs(acceptDocs, docsEnum, FLAG_NONE);
             float score = outerInstance._scores[outerInstance._ords[i]];
             for (int doc = docsEnum.NextDoc();
                 doc != NO_MORE_DOCS;
                 doc = docsEnum.NextDoc())
             {
                 // I prefer this:
                 /*if (scores[doc] < score) {
                   scores[doc] = score;
                   matchingDocs.set(doc);
                 }*/
                 // But this behaves the same as MVInnerScorer and only then the tests will pass:
                 if (!matchingDocs.Get(doc))
                 {
                     scores[doc] = score;
                     matchingDocs.Set(doc);
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Useful from an assert. </summary>
 internal virtual bool IsConsistent(int maxDoc)
 {
     FixedBitSet targets = new FixedBitSet(maxDoc);
     for (int i = 0; i < maxDoc; ++i)
     {
         int target = Map(i);
         if (target < 0 || target >= maxDoc)
         {
             Debug.Assert(false, "out of range: " + target + " not in [0-" + maxDoc + "[");
             return false;
         }
         else if (targets.Get(target))
         {
             Debug.Assert(false, target + " is already taken (" + i + ")");
             return false;
         }
     }
     return true;
 }
Exemplo n.º 3
0
 internal Bits RandomLiveDocs(int maxDoc)
 {
     if (Rarely())
     {
         if (Random().nextBoolean())
         {
             return null;
         }
         else
         {
             return new Bits_MatchNoBits(maxDoc);
         }
     }
     FixedBitSet bits = new FixedBitSet(maxDoc);
     int bitsSet = TestUtil.NextInt(Random(), 1, maxDoc - 1);
     for (int i = 0; i < bitsSet; ++i)
     {
         while (true)
         {
             int index = Random().nextInt(maxDoc);
             if (!bits.Get(index))
             {
                 bits.Set(index);
                 break;
             }
         }
     }
     return bits;
 }