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; } }
private void Initialize(string filename, byte maxkeysize, bool AllowDuplicateKeys) { _MaxKeySize = RDBDataType <T> .GetByteSize(maxkeysize); _T = RDBDataType <T> .ByteHandler(); _Path = Path.GetDirectoryName(filename); Directory.CreateDirectory(_Path); _FileName = Path.GetFileNameWithoutExtension(filename); string db = _Path + Path.DirectorySeparatorChar + _FileName + _datExtension; string idx = _Path + Path.DirectorySeparatorChar + _FileName + _idxExtension; LogManager.Configure(_Path + Path.DirectorySeparatorChar + _FileName + ".txt", 500, false); _index = new MGIndex <T>(_Path, _FileName + _idxExtension, _MaxKeySize, Global.PageItemCount, AllowDuplicateKeys); _archive = new StorageFile <T>(db); _deleted = new BoolIndex(_Path, _FileName + "_deleted.idx"); _archive.SkipDateTime = true; log.Debug("Current Count = " + RecordCount().ToString("#,0")); CheckIndexState(); log.Debug("Starting save timer"); _savetimer = new System.Timers.Timer(); _savetimer.Elapsed += new System.Timers.ElapsedEventHandler(_savetimer_Elapsed); _savetimer.Interval = Global.SaveIndexToDiskTimerSeconds * 1000; _savetimer.AutoReset = true; _savetimer.Start(); }
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(); }
public void Shutdown() { lock (_shutdownlock) { if (_index != null) { log.Debug("Shutting down"); } else { return; } SaveIndex(); SaveLastRecord(); if (_deleted != null) { _deleted.Shutdown(); } if (_index != null) { _index.Shutdown(); } if (_archive != null) { _archive.Shutdown(); } _index = null; _archive = null; _deleted = null; log.Debug("Shutting down log"); LogManager.Shutdown(); } }
/// <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(); }
/// <summary> /// Initialize the Indexer /// </summary> /// <param name="config"></param> /// <param name="maxkeysize"></param> /// <param name="AllowDuplicateKeys"></param> private void Initialize(String filename, byte maxkeysize, bool AllowDuplicateKeys) { _MaxKeySize = RDBDataType <T> .GetByteSize(maxkeysize); _T = RDBDataType <T> .ByteHandler(); string db = Path.ChangeExtension(filename, _datExtension); string idx = Path.ChangeExtension(filename, _idxExtension); //LogManager.Configure(_Path + Path.DirectorySeparatorChar + _FileName + ".txt", 500, false); _index = new MGIndex <T>(idx, _MaxKeySize, /*Global.PageItemCount,*/ AllowDuplicateKeys); if (Global.SaveAsBinaryJSON) { _archive = new StorageFile <T>(db, SF_FORMAT.BSON, false); } else { _archive = new StorageFile <T>(db, SF_FORMAT.JSON, false); } _deleted = new BoolIndex(Path.Combine(Path.GetDirectoryName(filename), "_deleted.idx")); log.Debug("Current Count = " + RecordCount().ToString("#,0")); CheckIndexState(); log.Debug("Starting save timer"); _savetimer = new System.Timers.Timer(); _savetimer.Elapsed += new System.Timers.ElapsedEventHandler(_savetimer_Elapsed); _savetimer.Interval = Global.SaveIndexToDiskTimerSeconds * 1000; _savetimer.AutoReset = true; _savetimer.Start(); }
/// <summary> /// Shut down the KeyStorage Indexer /// </summary> public void Shutdown() { lock (_shutdownlock) { if (_index != null) { log.Debug("Shutting down"); _savetimer.Enabled = false; SaveIndex(); SaveLastRecord(); if (_deleted != null) { _deleted.Shutdown(); } if (_index != null) { _index.Shutdown(); } if (_archive != null) { _archive.Shutdown(); } _index = null; _archive = null; _deleted = null; } } }
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(); }