GetBitmap() public method

public GetBitmap ( ) : WAHBitArray
return WAHBitArray
Ejemplo n.º 1
0
 private static WAHBitArray DoBitOperation(WAHBitArray bits, Cache c, Cache.OPERATION op)
 {
     if (bits != null)
     {
         bits = c.Op(bits, op);
     }
     else
     {
         bits = c.GetBitmap();
         bits = op == Cache.OPERATION.ANDNOT ? bits.Not() : bits;
     }
     return(bits);
 }
Ejemplo n.º 2
0
        public IndexResult UpdateExistingIndex(int recnum, string text)
        {
            Log("UpdateExistingIndex started");
            LogIndex();
            Log(string.Format("text size = {0}", text.Length));
            Dictionary <string, int> wordFrequencies = GenerateWordFreq(text);

            Log(string.Format("word count = {0}", wordFrequencies.Count));
            var result = new IndexResult {
                DocNumber = recnum
            };

            using (var bmp = CreateBitmapStream())
            {
                foreach (KeyValuePair <string, Cache> vc in _index)
                {
                    string indexedWord = vc.Key;
                    Cache  cache       = vc.Value;
                    LoadCacheIfNotLoaded(cache, bmp);
                    bool isWordIndexed = cache.GetBitmap().Get(recnum);
                    bool isWordInText  = wordFrequencies.ContainsKey(indexedWord);
                    if (isWordIndexed && isWordInText)
                    {
                        wordFrequencies.Remove(indexedWord);
                    }
                    else if (isWordIndexed)
                    {
                        result.WordsRemoved.Add(indexedWord);
                        cache.SetBit(recnum, false);
                    }
                    else if (isWordInText)
                    {
                        result.WordsAdded.Add(indexedWord, wordFrequencies[indexedWord]);
                        wordFrequencies.Remove(indexedWord);
                        cache.SetBit(recnum, true);
                    }
                }
            }
            foreach (var wordFrequency in wordFrequencies)
            {
                result.WordsAdded.Add(wordFrequency.Key, wordFrequency.Value);
                var cache = new Cache {
                    isLoaded = true
                };
                cache.SetBit(recnum, true);
                _index.Add(wordFrequency.Key, cache);
            }
            LogIndex();
            Log("UpdateExistingIndex ended");
            return(result);
        }
Ejemplo n.º 3
0
 public IndexData GetExistingIndex(int recnum)
 {
     LogIndex();
     using (var bmp = CreateBitmapStream())
     {
         var words = new List <string>();
         foreach (KeyValuePair <string, Cache> vc in _index)
         {
             string indexedWord = vc.Key;
             Cache  cache       = vc.Value;
             LoadCacheIfNotLoaded(cache, bmp);
             bool isWordIndexed = cache.GetBitmap().Get(recnum);
             if (isWordIndexed)
             {
                 words.Add(indexedWord);
             }
         }
         return(new IndexData
         {
             DocNumber = recnum,
             Words = words
         });
     }
 }