X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=TextCollection.h;h=2ea24ca57133e98350c758a9132b34118dbafe87;hb=ed61d2042a7ad7dd83bae32d7c31e69504dafa80;hp=a1d065dc28a2b9530808dca016b796cdb5f1f701;hpb=3c8e8e6146312f6f55046c451897234fed56608d;p=SXSI%2FTextCollection.git diff --git a/TextCollection.h b/TextCollection.h index a1d065d..2ea24ca 100644 --- a/TextCollection.h +++ b/TextCollection.h @@ -42,16 +42,18 @@ namespace SXSI // Type for text position (FIXME ulong or long?) typedef ulong TextPosition; + // mode flag: Default includes both the index and "naive" text + enum index_mode_t { index_mode_default, index_mode_text_only }; // index_mode_index_only + /** * Load from a file * * New samplerate can be given, otherwise will use the one specified in the save file! - * Note: This is not a static method; call InitTextCollection() first to get the object handle. * * Throws an exception if std::fread() fails. * */ - static TextCollection* Load(FILE *, unsigned samplerate = 0); + static TextCollection* Load(FILE *, index_mode_t = index_mode_default, unsigned samplerate = 0); /** * Save data structure into a file @@ -75,8 +77,22 @@ namespace SXSI * * Returns the i'th text in the collection. * The numbering starts from 0. + * + * Call DeleteText() for each pointer returned by GetText() + * to avoid possible memory leaks. */ virtual uchar* GetText(DocId) const = 0; + virtual void DeleteText(uchar *text) const = 0; + + /** + * Returns a pointer to the beginning of texts i, i+1, ..., j. + * Texts are separated by a '\0' byte. + * + * Call DeleteText() for each pointer returned by GetText() + * to avoid possible memory leaks. + */ + virtual uchar * GetText(DocId i, DocId j) const = 0; + /** * Returns substring [i, j] of k'th text * @@ -153,8 +169,8 @@ namespace SXSI virtual document_result Equal(uchar const *) const = 0; virtual document_result Contains(uchar const *) const = 0; virtual document_result LessThan(uchar const *) const = 0; - virtual document_result Kmismaches(uchar const *, unsigned) const = 0; - virtual document_result Kerrors(uchar const *, unsigned) const = 0; + virtual document_result KMismaches(uchar const *, unsigned) const = 0; + virtual document_result KErrors(uchar const *, unsigned) const = 0; /** * Document reporting queries for given DocId interval. @@ -176,13 +192,15 @@ namespace SXSI // Full reporting query for given DocId interval virtual full_result FullContains(uchar const *, DocId, DocId) const = 0; - virtual full_result FullKmismatches(uchar const *, unsigned) const = 0; - virtual full_result FullKerrors(uchar const *, unsigned) const = 0; + virtual full_result FullKMismatches(uchar const *, unsigned) const = 0; + virtual full_result FullKErrors(uchar const *, unsigned) const = 0; protected: // Protected constructor; use TextCollectionBuilder TextCollection() { }; +// index_mode_t indexMode; + // No copy constructor or assignment TextCollection(TextCollection const&); TextCollection& operator = (TextCollection const&);