Example #1
0
        public void Shutdown()
        {
            lock (_lock)
            {
                if (_shutdowndone == true)
                {
                    return;
                }

                InternalSave();
                if (_deleted != null)
                {
                    _deleted.SaveIndex();
                    _deleted.Shutdown();
                    _deleted = null;
                }

                if (_bitmaps != null)
                {
                    _bitmaps.Commit(Global.FreeBitmapMemoryOnSave);
                    _bitmaps.Shutdown();
                    _bitmaps = null;
                }

                if (_docMode)
                {
                    _docs.Shutdown();
                }

                _shutdowndone = true;
            }
        }
Example #2
0
        public Hoot(string IndexPath, string FileName, bool DocMode)
        {
            _Path     = IndexPath;
            _FileName = FileName;
            _docMode  = DocMode;
            if (_Path.EndsWith(Path.DirectorySeparatorChar.ToString()) == false)
            {
                _Path += Path.DirectorySeparatorChar;
            }
            Directory.CreateDirectory(IndexPath);

            _log.Debug("Starting hOOt....");
            _log.Debug("Storage Folder = " + _Path);

            if (DocMode)
            {
                _docs = new KeyStoreString(_Path + "files.docs", false);
                // read deleted
                _deleted    = new BoolIndex(_Path, "_deleted", ".hoot");
                _lastDocNum = (int)_docs.Count();
            }
            _bitmaps = new BitmapIndex(_Path, _FileName + "_hoot.bmp");
            // read words
            LoadWords();
        }
Example #3
0
        /// <summary>
        /// Construct a new object using configuration file and custom tokenizer
        /// </summary>
        /// <param name="config">Configuration file</param>
        /// <param name="tokenizer">Custom Tokenizer to parse text </param>
        public Hoot(IHootConfig config, ITokenizer tokenizer)
        {
            HootConfOptions = config;

            _tokenizer = (tokenizer != null) ? tokenizer : new tokenizer();

            if (!Directory.Exists(config.IndexPath))
            {
                Directory.CreateDirectory(config.IndexPath);
            }

            _log.Debug("Starting hOOt....");
            _log.Debug($"Storage Folder = {config.IndexPath}");

            _tokenizer.InitializeStopList(config.IndexPath);

            _log.Debug($"Stop List Words saved to {config.IndexPath}");

            if (config.DocMode)
            {
                _docs = new KeyStoreString(Path.Combine(config.IndexPath, $"files.docs"), false);
                //
                // read deleted
                //
                _deleted    = new BoolIndex(Path.Combine(config.IndexPath, $"_deleted.hoot"));
                _lastDocNum = (int)_docs.Count();
            }
            _bitmaps = new BitmapIndex(Path.Combine(config.IndexPath, $"{config.FileName}_hoot.bmp"));
            //
            // read words
            //
            LoadWords();
        }
Example #4
0
        public IndexFile(string filename, byte maxKeySize)//, ushort pageNodeCount)
        {
            _T = RDBDataType <T> .ByteHandler();

            if (typeof(T) == typeof(string) && Global.EnableOptimizedStringIndex)
            {
                _externalStrings = true;
                _maxKeySize      = 4;// blocknum:int
            }
            else
            {
                _maxKeySize = maxKeySize;
            }

            _PageNodeCount = Global.PageItemCount;// pageNodeCount;
            _rowSize       = (_maxKeySize + 1 + 4 + 4);

            _FileName = filename.Substring(0, filename.LastIndexOf('.'));
            string path = Path.GetDirectoryName(filename);

            Directory.CreateDirectory(path);
            if (File.Exists(filename))
            {
                // if file exists open and read header
                _file = File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                ReadFileHeader();
                if (_externalStrings == false)// if the file says different
                {
                    _rowSize = (_maxKeySize + 1 + 4 + 4);
                }
                // compute last page number from file length
                _PageLength     = (_BlockHeader.Length + _rowSize * (_PageNodeCount));
                _LastPageNumber = (int)((_file.Length - _FileHeader.Length) / _PageLength);
            }
            else
            {
                // else create new file
                _file = File.Open(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);

                _PageLength = (_BlockHeader.Length + _rowSize * (_PageNodeCount));

                CreateFileHeader(0);

                _LastPageNumber = (int)((_file.Length - _FileHeader.Length) / _PageLength);
            }
            if (_externalStrings)
            {
                _strings = new KeyStoreHF(path, Path.GetFileNameWithoutExtension(filename) + ".strings");
            }
            if (_LastPageNumber == 0)
            {
                _LastPageNumber = 1;
            }
            // bitmap duplicates
            if (_allowDups)
            {
                _bitmap = new BitmapIndex(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));
            }
        }
Example #5
0
        public Hoot(string IndexPath, string FileName, bool DocMode)
        {
            _Path = IndexPath;
            _FileName = FileName;
            _docMode = DocMode;
            if (_Path.EndsWith(Path.DirectorySeparatorChar.ToString()) == false) _Path += Path.DirectorySeparatorChar;
            Directory.CreateDirectory(IndexPath);

            _log.Debug("Starting hOOt....");
            _log.Debug("Storage Folder = " + _Path);

            if (DocMode)
            {
                _docs = new KeyStoreString(_Path + "files.docs", false);
                // read deleted
                _deleted = new BoolIndex(_Path, "_deleted" , ".hoot");
                _lastDocNum = (int)_docs.Count();
            }
            _bitmaps = new BitmapIndex(_Path, _FileName + "_hoot.bmp");
            // read words
            LoadWords();
        }
Example #6
0
        public IndexFile(string filename, byte maxKeySize, ushort pageNodeCount)
        {
            _T = RDBDataType <T> .ByteHandler();

            _maxKeySize    = maxKeySize;
            _PageNodeCount = pageNodeCount;
            _rowSize       = (_maxKeySize + 1 + 4 + 4);

            string path = Path.GetDirectoryName(filename);

            Directory.CreateDirectory(path);
            if (File.Exists(filename))
            {
                // if file exists open and read header
                _file = File.Open(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite);
                ReadFileHeader();
                // compute last page number from file length
                _PageLength     = (_BlockHeader.Length + _rowSize * (_PageNodeCount));
                _LastPageNumber = (int)((_file.Length - _FileHeader.Length) / _PageLength);
            }
            else
            {
                // else create new file
                _file = File.Open(filename, FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite);

                _PageLength = (_BlockHeader.Length + _rowSize * (_PageNodeCount));

                CreateFileHeader(0);

                _LastPageNumber = (int)((_file.Length - _FileHeader.Length) / _PageLength);
            }
            if (_LastPageNumber == 0)
            {
                _LastPageNumber = 1;
            }
            // bitmap duplicates
            _bitmap = new BitmapIndex(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));
        }
Example #7
0
 public L(BitmapIndex sc)
 {
     _sc = sc;
     _sc.CheckInternalOP();
 }
Example #8
0
 public L(BitmapIndex sc)
 {
     _sc = sc;
     _sc.CheckInternalOP();
 }
Example #9
0
        public void Shutdown()
        {
            lock (_lock)
            {
                InternalSave();
                if(_deleted!=null)
                {
                    _deleted.SaveIndex();
                    _deleted.Shutdown();
                }

                if (_bitmaps != null)
                {					
                    _bitmaps.Commit(Global.FreeBitmapMemoryOnSave);
                    _bitmaps.Shutdown();
                    _bitmaps = null;
                }

                if (_docMode)
                    _docs.Shutdown();
            }
        }