public void createGlobalInvertedIndex(IndexRoot indexRoot)
 {
   Placement wordPlacement = new Placement(Lexicon.PlaceInDatabase, 2);
   BTreeSetOidShort<Word> wordSet = indexRoot.lexicon.WordSet;
   BTreeSet<Document> docSet = indexRoot.repository.documentSet;
   Word existingWord = null;
   foreach (Document doc in docSet)
   {
     if (doc.Indexed == false)
     {
       foreach (Word word in doc.WordSet)
       {
         WordHit wordHit = doc.WordHit[word];
         if (wordSet.TryGetKey(word, ref existingWord))
         {
           existingWord.GlobalCount = existingWord.GlobalCount + (uint)wordHit.Count;
         }
         else
         {
           existingWord = new WordGlobal(word.aWord, session, (uint)wordHit.Count);
           existingWord.Persist(wordPlacement, session);
           wordSet.Add(existingWord);
         }
         existingWord.DocumentHit.AddFast(doc);
       }
       doc.Indexed = true;
     }
   }
 }
Exemple #2
0
 static void createTopLevelInvertedIndex()
 {
   Console.WriteLine(DateTime.Now.ToString() + ", start creating top level inverted index");
   using (SessionNoServer session = new SessionNoServer(s_systemDir))
   {
     Placement wordPlacement = new Placement(Lexicon.PlaceInDatabase, 2, 1, 1000, 50000, true, false, UInt32.MaxValue, false);
     session.BeginUpdate();
     IndexRoot indexRoot = (IndexRoot)session.Open(Oid.Encode(IndexRoot.PlaceInDatabase, 1, 1));
     BTreeSetOidShort<Word> wordSet = indexRoot.lexicon.WordSet;
     BTreeSet<Document> documentSet = indexRoot.repository.documentSet;
     Word existingWord = null;
     foreach (Document doc in documentSet)
     {
       foreach (Word word in doc.WordSet)
       {
         WordHit wordHit = doc.WordHit[word];
         if (wordSet.TryGetKey(word, ref existingWord))
         {
           existingWord.GlobalCount = existingWord.GlobalCount + (uint)wordHit.Count;
         }
         else
         {
           existingWord = new WordGlobal(word.aWord, session, (uint)wordHit.Count);
           existingWord.Persist(wordPlacement, session);
           indexRoot.lexicon.WordSet.Add(existingWord);
         }
         existingWord.DocumentHit.AddFast(doc);
       }
       doc.Indexed = true;
     }
     session.Commit();
     Console.WriteLine(DateTime.Now.ToString() + ", done creating top level inverted index");
   }
 }