Previous: WordList CONFIGURATION, Up: WordList   [Contents][Index]


10.9.5 WordList METHODS

inline WordContext* GetContext()

Return a pointer to the WordContext object used to create this instance.

inline const WordContext* GetContext() const

Return a pointer to the WordContext object used to create this instance as a const.

virtual inline int Override(const WordReference& wordRef)

Insert wordRef in index. If the Key() part of the wordRef exists in the index, override it. Returns OK on success, NOTOK on error.

virtual int Exists(const WordReference& wordRef)

Returns OK if wordRef exists in the index, NOTOK otherwise.

inline int Exists(const String& word)

Returns OK if word exists in the index, NOTOK otherwise.

virtual int WalkDelete(const WordReference& wordRef)

Delete all entries in the index whose key matches the Key() part of wordRef , using the Walk method. Returns the number of entries successfully deleted.

virtual int Delete(const WordReference& wordRef)

Delete the entry in the index that exactly matches the Key() part of wordRef. Returns OK if deletion is successfull, NOTOK otherwise.

virtual int Open(const String& filename, int mode)

Open inverted index filename. mode may be O_RDONLY or O_RDWR. If mode is O_RDWR it can be or’ed with O_TRUNC to reset the content of an existing inverted index. Return OK on success, NOTOK otherwise.

virtual int Close()

Close inverted index. Return OK on success, NOTOK otherwise.

virtual unsigned int Size() const

Return the size of the index in pages.

virtual int Pagesize() const

Return the page size

virtual WordDict *Dict()

Return a pointer to the inverted index dictionnary.

const String& Filename() const

Return the filename given to the last call to Open.

int Flags() const

Return the mode given to the last call to Open.

inline List *Find(const WordReference& wordRef)

Returns the list of word occurrences exactly matching the Key() part of wordRef. The List returned contains pointers to WordReference objects. It is the responsibility of the caller to free the list. See List.h header for usage.

inline List *FindWord(const String& word)

Returns the list of word occurrences exactly matching the word. The List returned contains pointers to WordReference objects. It is the responsibility of the caller to free the list. See List.h header for usage.

virtual List *operator [] (const WordReference& wordRef)

Alias to the Find method.

inline List *operator [] (const String& word)

Alias to the FindWord method.

virtual List *Prefix (const WordReference& prefix)

Returns the list of word occurrences matching the Key() part of wordRef. In the Key() , the string (accessed with GetWord() ) matches any string that begins with it. The List returned contains pointers to WordReference objects. It is the responsibility of the caller to free the list.

inline List *Prefix (const String& prefix)

Returns the list of word occurrences matching the word. In the Key() , the string (accessed with GetWord() ) matches any string that begins with it. The List returned contains pointers to WordReference objects. It is the responsibility of the caller to free the list.

virtual List *Words()

Returns a list of all unique words contained in the inverted index. The List returned contains pointers to String objects. It is the responsibility of the caller to free the list. See List.h header for usage.

virtual List *WordRefs()

Returns a list of all entries contained in the inverted index. The List returned contains pointers to WordReference objects. It is the responsibility of the caller to free the list. See List.h header for usage.

virtual WordCursor *Cursor(wordlist_walk_callback_t callback, Object *callback_data)

Create a cursor that searches all the occurrences in the inverted index and call ncallback with ncallback_data for every match.

virtual WordCursor *Cursor(const WordKey &searchKey, int action = HTDIG_WORDLIST_WALKER)

Create a cursor that searches all the occurrences in the inverted index and that match nsearchKey. If naction is set to HTDIG_WORDLIST_WALKER calls searchKey.callback with searchKey.callback_data for every match. If naction is set to HTDIG_WORDLIST_COLLECT push each match in searchKey.collectRes data member as a WordReference object. It is the responsibility of the caller to free the searchKey.collectRes list.

virtual WordCursor *Cursor(const WordKey &searchKey, wordlist_walk_callback_t callback, Object * callback_data)

Create a cursor that searches all the occurrences in the inverted index and that match nsearchKey and calls ncallback with ncallback_data for every match.

virtual WordKey Key(const String& bufferin)

Create a WordKey object and return it. The bufferin argument is used to initialize the key, as in the WordKey::Set method. The first component of bufferin must be a word that is translated to the corresponding numerical id using the WordDict::Serial method.

virtual WordReference Word(const String& bufferin, int exists = 0)

Create a WordReference object and return it. The bufferin argument is used to initialize the structure, as in the WordReference::Set method. The first component of bufferin must be a word that is translated to the corresponding numerical id using the WordDict::Serial method. If the exists argument is set to 1, the method WordDict::SerialExists is used instead, that is no serial is assigned to the word if it does not already have one. Before translation the word is normalized using the WordType::Normalize method. The word is saved using the WordReference::SetWord method.

virtual WordReference WordExists(const String& bufferin)

Alias for Word(bufferin, 1).

virtual void BatchStart()

Accelerate bulk insertions in the inverted index. All insertion done with the Override method are batched instead of being updating the inverted index immediately. No update of the inverted index file is done before the BatchEnd method is called.

virtual void BatchEnd()

Terminate a bulk insertion started with a call to the BatchStart method. When all insertions are done the AllRef method is called to restore statistics.

virtual int Noccurrence(const String& key, unsigned int& noccurrence) const

Return in noccurrence the number of occurrences of the string contained in the GetWord() part of key. Returns OK on success, NOTOK otherwise.

virtual int Write(FILE* f)

Write on file descriptor f an ASCII description of the index. Each line of the file contains a WordReference ASCII description. Return OK on success, NOTOK otherwise.

virtual int WriteDict(FILE* f)

Write on file descriptor f the complete dictionnary with statistics. Return OK on success, NOTOK otherwise.

virtual int Read(FILE* f)

Read WordReference ASCII descriptions from f , returns the number of inserted WordReference or < 0 if an error occurs. Invalid descriptions are ignored as well as empty lines.


Previous: WordList CONFIGURATION, Up: WordList   [Contents][Index]