コード例 #1
0
 private void LoadWords()
 {
     lock (_lock)
     {
         if (_words == null)
         {
             _words = new SafeDictionary <string, int>();
         }
         //  new SafeSortedList<string, int>();
         if (File.Exists(_Path + _FileName + ".words") == false)
         {
             return;
         }
         // load words
         using (FileStream words = new FileStream(_Path + _FileName + ".words", FileMode.Open))
         {
             if (words.Length == 0)
             {
                 return;
             }
             using (BinaryReader br = new BinaryReader(words, Encoding.UTF8))
             {
                 string s = br.ReadString();
                 while (s != "")
                 {
                     int off = br.ReadInt32();
                     _words.Add(s, off);
                     try
                     {
                         s = br.ReadString();
                     }
                     catch { s = ""; }
                 }
             }
         }
         //byte[] b = File.ReadAllBytes(_Path + _FileName + ".words");
         //if (b.Length == 0)
         //    return;
         //MemoryStream ms = new MemoryStream(b);
         //BinaryReader br = new BinaryReader(ms, Encoding.UTF8);
         //string s = br.ReadString();
         //while (s != "")
         //{
         //    int off = br.ReadInt32();
         //    _words.Add(s, off);
         //    try
         //    {
         //        s = br.ReadString();
         //    }
         //    catch { s = ""; }
         //}
         _log.Debug("Word Count = " + _words.Count());
         _wordschanged = true;
     }
 }
コード例 #2
0
 public WAHBitArray()
 {
     _state = TYPE.Indexes;
     if (Global.UseLessMemoryStructures)
     {
         _offsets = new SafeSortedList <uint, bool>();
     }
     else
     {
         _offsets = new SafeDictionary <uint, bool>();
     }
 }
コード例 #3
0
 public void Commit(bool freeMemory)
 {
     foreach (KeyValuePair <int, WAHBitArray> kv in _cache)
     {
         if (kv.Value.isDirty)
         {
             SaveBitmap(kv.Key, kv.Value);
             kv.Value.FreeMemory();
             kv.Value.isDirty = false;
         }
     }
     Flush();
     if (freeMemory)
     {
         _cache = new SafeDictionary <int, WAHBitArray>();
     }
 }
コード例 #4
0
        /// <summary>
        /// Load Words
        /// </summary>
        private void LoadWords()
        {
            lock (_lock)
            {
                if (_words == null)
                {
                    _words = new SafeDictionary <string, int>();
                }

                // new SafeSortedList<string, int>();

                if (!File.Exists(Path.Combine(HootConfOptions.IndexPath, $"{HootConfOptions.FileName}.words")) == false)
                {
                    // load words
                    using (FileStream words = new FileStream(Path.Combine(HootConfOptions.IndexPath, $"{HootConfOptions.FileName}.words"), FileMode.Open))
                    {
                        if (words.Length == 0)
                        {
                            return;
                        }

                        using (BinaryReader br = new BinaryReader(words, Encoding.UTF8))
                        {
                            string s = br.ReadString();

                            while (s != "")
                            {
                                int off = br.ReadInt32();
                                _words.Add(s, off);
                                try
                                {
                                    s = br.ReadString();
                                }
                                catch { s = ""; }
                            }
                        }
                    }
                    _log.Debug("Word Count = " + _words.Count());
                    _wordschanged = true;
                }
            }
        }
コード例 #5
0
        public void Commit(bool freeMemory)
        {
            List <int> keys = new List <int>(_cache.Keys());

            foreach (int k in keys)
            {
                var bmp = _cache[k];
                if (bmp.isDirty)
                {
                    SaveBitmap(k, bmp);
                    bmp.FreeMemory();
                    bmp.isDirty = false;
                }
            }
            Flush();
            if (freeMemory)
            {
                _cache = new SafeDictionary <int, WAHBitArray>();
            }
        }
コード例 #6
0
        public BitmapIndex(string path, string filename)
        {
            if (Global.UseLessMemoryStructures)
            {
                _cache = new SafeSortedList <int, WAHBitArray>();
            }
            else
            {
                _cache = new SafeDictionary <int, WAHBitArray>();
            }

            _FileName = Path.GetFileNameWithoutExtension(filename);
            _Path     = path;
            if (_Path.EndsWith(Path.DirectorySeparatorChar.ToString()) == false)
            {
                _Path += Path.DirectorySeparatorChar.ToString();
            }

            Initialize();
        }
コード例 #7
0
        public void Commit(bool freeMemory)
        {
            using (new L(this))
            {
                int[] keys = _cache.Keys();
                Array.Sort(keys);

                foreach (int k in keys)
                {
                    var bmp = _cache[k];
                    if (bmp.isDirty)
                    {
                        SaveBitmap(k, bmp);
                        bmp.FreeMemory();
                        bmp.isDirty = false;
                    }
                }
                Flush();
                if (freeMemory)
                {
                    _cache = new SafeDictionary <int, WAHBitArray>();
                }
            }
        }
コード例 #8
0
ファイル: Hoot.cs プロジェクト: nhaberl/hOOt
 private void LoadWords()
 {
     lock (_lock)
     {
         if (_words == null)
         {
             _words = //new SafeSortedList<string, int>();
                      new SafeDictionary <string, int>();
         }
         if (File.Exists(_Path + _FileName + ".words") == false)
         {
             return;
         }
         // load words
         byte[] b = File.ReadAllBytes(_Path + _FileName + ".words");
         if (b.Length == 0)
         {
             return;
         }
         MemoryStream ms = new MemoryStream(b);
         BinaryReader br = new BinaryReader(ms, Encoding.UTF8);
         string       s  = br.ReadString();
         while (s != "")
         {
             int off = br.ReadInt32();
             _words.Add(s, off);
             try
             {
                 s = br.ReadString();
             }
             catch { s = ""; }
         }
         _log.Debug("Word Count = " + _words.Count);
         _wordschanged = true;
     }
 }