C# Class ScrewTurn.Wiki.SearchEngine.InMemoryIndexBase

Implements a base class for the search index.
All instance and static members are thread-safe.
Inheritance: IInMemoryIndex
Mostra file Open project: mono/ScrewTurnWiki Class Usage Examples

Protected Properties

Property Type Description
buildDocument BuildDocument
catalog Word>.Dictionary
stopWords string[]

Public Methods

Method Description
Clear ( object state ) : void

Completely clears the index (stop words are not affected).

InMemoryIndexBase ( ) : System

Initializes a new instance of the InMemoryIndexBase class.

InitializeData ( DumpedDocument documents, DumpedWord words, DumpedWordMapping mappings ) : void

Initializes index data by completely emptying the index catalog and storing the specified data.

The method does not check the consistency of the data passed as arguments.

RemoveDocument ( IDocument document, object state ) : void

Removes a document from the index.

Search ( SearchParameters parameters ) : SearchResultCollection

Performs a search in the index.

SetBuildDocumentDelegate ( BuildDocument buildDocument ) : void

Sets the delegate used for converting a DumpedDocument to an instance of a class implementing IDocument, while reading index data from a permanent storage.

This method must be called before invoking InitializeData.

StoreDocument ( IDocument document, string keywords, string content, object state ) : int

Stores a document in the index.

Indexing the content of the document is O(n), where n is the total number of words in the document. If the specified document was already in the index, all the old occurrences are deleted from the index.

Protected Methods

Method Description
OnIndexChange ( IDocument document, IndexChangeType change, DumpedChange changeData, object state ) : IndexStorerResult

Takes care of firing the IndexChanged event.

RemoveDocumentInternal ( IDocument document ) : DumpedChange

Removes a document from the index and generates the dumped change data.

StoreWord ( string wordText, IDocument document, ushort firstCharIndex, ushort wordIndex, WordLocation location, Word &newWord, DumpedWord &dumpedWord ) : DumpedWordMapping

Stores a word in the catalog.

Storing a word in the index is O(n log n), where n is the number of words already in the index.

Private Methods

Method Description
FindDocument ( string name ) : IDocument

Finds a document with a specified name.

Method Details

Clear() public method

Completely clears the index (stop words are not affected).
public Clear ( object state ) : void
state object A state object that is passed to the IndexStorer SaveDate/DeleteData function.
return void

InMemoryIndexBase() public method

Initializes a new instance of the InMemoryIndexBase class.
public InMemoryIndexBase ( ) : System
return System

InitializeData() public method

Initializes index data by completely emptying the index catalog and storing the specified data.
The method does not check the consistency of the data passed as arguments.
If , or are null. If was not called.
public InitializeData ( DumpedDocument documents, DumpedWord words, DumpedWordMapping mappings ) : void
documents DumpedDocument The documents.
words DumpedWord The words.
mappings DumpedWordMapping The mappings.
return void

OnIndexChange() protected method

Takes care of firing the IndexChanged event.
protected OnIndexChange ( IDocument document, IndexChangeType change, DumpedChange changeData, object state ) : IndexStorerResult
document IDocument The affected document.
change IndexChangeType The change performed.
changeData DumpedChange The dumped change data.
state object A state object that is passed to the IndexStorer SaveDate/DeleteData function.
return IndexStorerResult

RemoveDocument() public method

Removes a document from the index.
If is null.
public RemoveDocument ( IDocument document, object state ) : void
document IDocument The document to remove.
state object A state object that is passed to the IndexStorer SaveDate/DeleteData function.
return void

RemoveDocumentInternal() protected method

Removes a document from the index and generates the dumped change data.
protected RemoveDocumentInternal ( IDocument document ) : DumpedChange
document IDocument The document to remove.
return DumpedChange

Search() public method

Performs a search in the index.
If is null.
public Search ( SearchParameters parameters ) : SearchResultCollection
parameters SearchParameters The search parameters.
return SearchResultCollection

SetBuildDocumentDelegate() public method

Sets the delegate used for converting a DumpedDocument to an instance of a class implementing IDocument, while reading index data from a permanent storage.
This method must be called before invoking InitializeData.
If is null.
public SetBuildDocumentDelegate ( BuildDocument buildDocument ) : void
buildDocument BuildDocument The delegate (cannot be null).
return void

StoreDocument() public method

Stores a document in the index.
Indexing the content of the document is O(n), where n is the total number of words in the document. If the specified document was already in the index, all the old occurrences are deleted from the index.
If or are null.
public StoreDocument ( IDocument document, string keywords, string content, object state ) : int
document IDocument The document.
keywords string The document keywords, if any, an empty array or null otherwise.
content string The content of the document.
state object A state object that is passed to the IndexStorer SaveDate/DeleteData function.
return int

StoreWord() protected method

Stores a word in the catalog.
Storing a word in the index is O(n log n), where n is the number of words already in the index.
protected StoreWord ( string wordText, IDocument document, ushort firstCharIndex, ushort wordIndex, WordLocation location, Word &newWord, DumpedWord &dumpedWord ) : DumpedWordMapping
wordText string The word to store.
document IDocument The document the word occurs in.
firstCharIndex ushort The index of the first character of the word in the document the word occurs at.
wordIndex ushort The index of the word in the document.
location WordLocation The location of the word.
newWord Word The new word, or null.
dumpedWord DumpedWord The dumped word data, or null.
return DumpedWordMapping

Property Details

buildDocument protected_oe property

The BuildDocument delegate.
protected BuildDocument buildDocument
return BuildDocument

catalog protected_oe property

Contains the index catalog.
protected Dictionary catalog
return Word>.Dictionary

stopWords protected_oe property

The stop words to be used while indexing new content.
protected string[] stopWords
return string[]