C# Class ScrewTurn.Wiki.IndexStorer

Stores index data to disk.
Instance and static members are thread-safe.
Inheritance: ScrewTurn.Wiki.SearchEngine.IndexStorerBase
显示文件 Open project: mono/ScrewTurnWiki

Public Methods

Method Description
IndexStorer ( string documentsFile, string wordsFile, string mappingsFile, IInMemoryIndex index ) : System

Initializes a new instance of the IndexStorer class.

Protected Methods

Method Description
DeleteData ( DumpedChange data, object state ) : void

Deletes data from the data storage.

InitDataStore ( object state ) : void

Initializes the data storage.

LoadIndexInternal ( DumpedDocument &documents, DumpedWord &words, DumpedWordMapping &mappings ) : void

Loads the index from the data store the first time.

SaveData ( DumpedChange data, object state ) : IndexStorerResult

Stores new data into the data storage.

When saving a new document, the document ID in data.Mappings must be replaced with the currect document ID, generated by the concrete implementation of this method. data.Words should have IDs numbered from uint.MaxValue downwards. The method re-numbers the words appropriately.

Private Methods

Method Description
EqualDumpedDocument ( DumpedDocument d1, DumpedDocument d2 ) : bool

Determines whether two DumpedDocuments are equal.

GetTempFile ( string file ) : string

Gets a tempDumpedWord file name given an original name.

InitFiles ( ) : void

Initializes the data files, if needed.

ReadCount ( FileStream fs ) : int

Reads the count in a FileStream.

The caller must properly seek the stream after calling the method.

ReadDumpedDocument ( BinaryReader reader ) : DumpedDocument

Reads a DumpedDocument from a BinaryReader.

ReadDumpedWord ( BinaryReader reader ) : DumpedWord

Reads a DumpedWord from a BinaryReader.

ReadDumpedWordMapping ( BinaryReader reader ) : DumpedWordMapping

Reads a DumpedWordMapping from a BinaryReader.

ReadReserved ( BinaryReader reader ) : bool

Reads the reserved bytes.

WriteDumpedDocument ( BinaryWriter writer, DumpedDocument document ) : void

Writes a DumpedDocument to a BinaryWriter.

WriteDumpedWord ( BinaryWriter writer, DumpedWord word ) : void

Writes a DumpedWord to a BinaryWriter.

WriteDumpedWordMapping ( BinaryWriter writer, DumpedWordMapping mapping ) : void

Writes a DumpedWordMapping to a BinaryWriter.

WriteHeader ( BinaryWriter writer ) : void

Writes the binary file header.

Method Details

DeleteData() protected method

Deletes data from the data storage.
protected DeleteData ( DumpedChange data, object state ) : void
data ScrewTurn.Wiki.SearchEngine.DumpedChange The data to delete.
state object A state object passed from the index.
return void

IndexStorer() public method

Initializes a new instance of the IndexStorer class.
public IndexStorer ( string documentsFile, string wordsFile, string mappingsFile, IInMemoryIndex index ) : System
documentsFile string The file that contains the documents list.
wordsFile string The file that contains the words list.
mappingsFile string The file that contains the index mappings data.
index IInMemoryIndex The index to manage.
return System

InitDataStore() protected method

Initializes the data storage.
protected InitDataStore ( object state ) : void
state object A state object passed from the index.
return void

LoadIndexInternal() protected method

Loads the index from the data store the first time.
protected LoadIndexInternal ( DumpedDocument &documents, DumpedWord &words, DumpedWordMapping &mappings ) : void
documents ScrewTurn.Wiki.SearchEngine.DumpedDocument The dumped documents.
words ScrewTurn.Wiki.SearchEngine.DumpedWord The dumped words.
mappings ScrewTurn.Wiki.SearchEngine.DumpedWordMapping The dumped word mappings.
return void

SaveData() protected method

Stores new data into the data storage.
When saving a new document, the document ID in data.Mappings must be replaced with the currect document ID, generated by the concrete implementation of this method. data.Words should have IDs numbered from uint.MaxValue downwards. The method re-numbers the words appropriately.
protected SaveData ( DumpedChange data, object state ) : IndexStorerResult
data ScrewTurn.Wiki.SearchEngine.DumpedChange The data to store.
state object A state object passed from the index.
return ScrewTurn.Wiki.SearchEngine.IndexStorerResult