public HashtableSearcher(string dataFileFullName, NormlizeTextFunction normlizeTextFunction = null) { if (dataFileFullName.IsEmptyOrNull()) { throw (new ArgumentNullException("dataFileFullName")); } var indexFileFullName = IndexFileHelper.GetIndexFileFullName(dataFileFullName); this.IndexHeader = HashtableIndexer.GetIndexHeaderByIndexFile(indexFileFullName); if (!this.IndexHeader.IsSignValid()) { throw (new DiskSearchEngineException("Invalid sign of index file: '" + indexFileFullName + "'.")); } if (!this.IndexHeader.IsCorrectSizeAndModifyTime(dataFileFullName)) { throw (new DiskSearchEngineException("Data file was modify after last indexing.")); } this._DataFileTextLineReader = new TextLineReader ( dataFileFullName, this.IndexHeader.DataFileEncoding, this.IndexHeader.DataRecordMaxBytesLenght + this.IndexHeader.DataFileEncoding.GetMaxByteCount(10) ); this._IndexFileBinaryReader = IndexFileHelper.CreateBinaryReaderRandomAccess(indexFileFullName); this._DiskSlotReadBuffer = new ReadBuffer <DiskSlot>(); this._DiskTagReadBuffer = new ReadBuffer <DiskTag>(); this._DiskSlotInt32ReadBuffer = new ReadBuffer <DiskSlotInt32>(); this._DiskTagInt32ReadBuffer = new ReadBuffer <DiskTagInt32>(); this._NormlizeTextFunction = normlizeTextFunction; switch (this.IndexHeader.HashtableSlotType) { case HashtableIndexFileHeader.SlotType.Int64: this._IsExistsFunction = IsExistsDiskRoutine; break; case HashtableIndexFileHeader.SlotType.Int32: this._IsExistsFunction = IsExistsDiskRoutineIn32; break; default: throw (new ArgumentException("this.IndexHeader.HashtableSlotType")); } }
public static HashtableIndexFileHeader GetIndexHeaderByDataFile(string dataFileFullName) { return(GetIndexHeaderByIndexFile(IndexFileHelper.GetIndexFileFullName(dataFileFullName))); }