示例#1
0
        /// <summary>
        /// 创建hoot引擎
        /// </summary>
        /// <param name="IndexPath">索引地址目录,全路径</param>
        /// <param name="FileName">文件名(最好无后缀)</param>
        /// <param name="DocMode">是否文档模式</param>
        public HootEngine(string IndexPath, string FileName, bool DocMode)
        {
            _Path     = IndexPath;
            _FileName = FileName;
            _docMode  = DocMode;

            if (_Path.EndsWith(Path.DirectorySeparatorChar.ToString()) == false)
            {
                _Path += Path.DirectorySeparatorChar;
            }
            if (Directory.Exists(IndexPath))
            {
                Directory.CreateDirectory(IndexPath);
            }

            _log.Debug("hOOOOOOt Version:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
            _log.Debug("Starting hOOOOOOt....");
            _log.Debug("Storage Folder = " + _Path);

            if (DocMode)
            {
                _docs = new KeyStoreString(_Path, FileName, false);
                // read deleted
                _deleted    = new BoolIndex(_Path, FileName);
                _lastDocNum = (int)_docs.Count();//得到文档数,用于编号
            }
            _bitmaps = new BitmapIndex(_Path, _FileName);
            // read words
            LoadWords();
        }
示例#2
0
        public void Shutdown()
        {
            lock (_lock)
            {
                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();
                }
            }
        }
示例#3
0
        public IndexFile(string filename, byte maxKeySize)
        {
            _T = RDBDataType <T> .ByteHandler();

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

            _PageNodeCount = Global.PageItemCount;      // 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);
                this.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));

                this.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));
            }
        }
示例#4
0
 public L(BitmapIndex sc)
 {
     _sc = sc;
     _sc.CheckInternalOP();
 }