C# Класс ScrewTurn.Wiki.SearchEngine.InMemoryIndexBase

Implements a base class for the search index.
All instance and static members are thread-safe.
Наследование: IInMemoryIndex
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
buildDocument BuildDocument
catalog Word>.Dictionary
stopWords string[]

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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.

Приватные методы

Метод Описание
FindDocument ( string name ) : IDocument

Finds a document with a specified name.

Описание методов

Clear() публичный Метод

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.
Результат void

InMemoryIndexBase() публичный Метод

Initializes a new instance of the InMemoryIndexBase class.
public InMemoryIndexBase ( ) : System
Результат System

InitializeData() публичный Метод

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.
Результат void

OnIndexChange() защищенный Метод

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.
Результат IndexStorerResult

RemoveDocument() публичный Метод

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.
Результат void

RemoveDocumentInternal() защищенный Метод

Removes a document from the index and generates the dumped change data.
protected RemoveDocumentInternal ( IDocument document ) : DumpedChange
document IDocument The document to remove.
Результат DumpedChange

Search() публичный Метод

Performs a search in the index.
If is null.
public Search ( SearchParameters parameters ) : SearchResultCollection
parameters SearchParameters The search parameters.
Результат SearchResultCollection

SetBuildDocumentDelegate() публичный Метод

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).
Результат void

StoreDocument() публичный Метод

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.
Результат int

StoreWord() защищенный Метод

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.
Результат DumpedWordMapping

Описание свойств

buildDocument защищенное свойство

The BuildDocument delegate.
protected BuildDocument buildDocument
Результат BuildDocument

catalog защищенное свойство

Contains the index catalog.
protected Dictionary catalog
Результат Word>.Dictionary

stopWords защищенное свойство

The stop words to be used while indexing new content.
protected string[] stopWords
Результат string[]