Exemplo n.º 1
0
        // NOTE: removes any "all deleted" readers from mergeState.readers
        private int SetDocMaps()
        {
            int numReaders = mergeState.Readers.Count;

            // Remap docIDs
            mergeState.DocMaps = new MergeState.DocMap[numReaders];
            mergeState.DocBase = new int[numReaders];

            int docBase = 0;

            int i = 0;

            while (i < mergeState.Readers.Count)
            {
                AtomicReader reader = mergeState.Readers[i];

                mergeState.DocBase[i] = docBase;
                MergeState.DocMap docMap = MergeState.DocMap.Build(reader);
                mergeState.DocMaps[i] = docMap;
                docBase += docMap.NumDocs;

                i++;
            }

            return(docBase);
        }
Exemplo n.º 2
0
 private static bool Equals(MergeState.DocMap map1, MergeState.DocMap map2)
 {
     if (map1.MaxDoc != map2.MaxDoc)
     {
         return(false);
     }
     for (int i = 0; i < map1.MaxDoc; ++i)
     {
         if (map1.Get(i) != map2.Get(i))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        public virtual void TestBuildDocMap()
        {
            int         maxDoc         = TestUtil.NextInt(Random(), 1, 128);
            int         numDocs        = TestUtil.NextInt(Random(), 0, maxDoc);
            int         numDeletedDocs = maxDoc - numDocs;
            FixedBitSet liveDocs       = new FixedBitSet(maxDoc);

            for (int i = 0; i < numDocs; ++i)
            {
                while (true)
                {
                    int docID = Random().Next(maxDoc);
                    if (!liveDocs.Get(docID))
                    {
                        liveDocs.Set(docID);
                        break;
                    }
                }
            }

            MergeState.DocMap docMap = MergeState.DocMap.Build(maxDoc, liveDocs);

            Assert.AreEqual(maxDoc, docMap.MaxDoc);
            Assert.AreEqual(numDocs, docMap.NumDocs);
            Assert.AreEqual(numDeletedDocs, docMap.NumDeletedDocs);
            // assert the mapping is compact
            for (int i = 0, del = 0; i < maxDoc; ++i)
            {
                if (!liveDocs.Get(i))
                {
                    Assert.AreEqual(-1, docMap.Get(i));
                    ++del;
                }
                else
                {
                    Assert.AreEqual(i - del, docMap.Get(i));
                }
            }
        }