X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=TCImplementation.h;h=f0a21cc91e17729d161816138f69ca099538d283;hb=47be601752d3cd9d24c831a16621cd6d4ced6670;hp=65bf22c030b350333b429feaf8cc1feab63a90f9;hpb=e59bd57d53c2d9e5db4c22f2501a9789f62f46c1;p=SXSI%2FTextCollection.git diff --git a/TCImplementation.h b/TCImplementation.h index 65bf22c..f0a21cc 100644 --- a/TCImplementation.h +++ b/TCImplementation.h @@ -39,8 +39,10 @@ # define W 32 #endif #undef bitset +#undef bitget #include "TextStorage.h" +#include "ArrayDoc.h" #include namespace SXSI @@ -53,31 +55,30 @@ namespace SXSI */ class TCImplementation : public SXSI::TextCollection { public: - TCImplementation(uchar *, ulong, unsigned, unsigned, ulong, ulong); + TCImplementation(uchar *, ulong, unsigned, unsigned, ulong, ulong, char); ~TCImplementation(); bool EmptyText(DocId) const; /** - * Returns a pointer to the original text. + * Extracting one text. * - * Do *not* try to free the array. - * (However, this implementation is suspect to change.) - * - * See TextStorage.h for details. + * Call DeleteText() for each pointer returned by GetText() + * to avoid possible memory leaks. */ uchar * GetText(DocId) const; + void DeleteText(uchar *text) const + { textStorage->DeleteText(text); } /** * Returns a pointer to the beginning of texts i, i+1, ..., j. * Texts are separated by a '\0' byte. * - * Do *not* try to free the array. - * (However, this implementation is suspect to change.) - * - * See TextStorage.h for details. + * Call DeleteText() for each pointer returned by GetText() + * to avoid possible memory leaks. */ - uchar * GetText(DocId i, DocId j) const; + uchar * GetText(DocId i, DocId j) const + { return textStorage->GetText(i, j); } /** * Returns a substring of given text ID. @@ -117,8 +118,8 @@ public: document_result Equal(uchar const *) const; document_result Contains(uchar const *) const; document_result LessThan(uchar const *) const; - document_result Kmismaches(uchar const *, unsigned) const; - document_result Kerrors(uchar const *, unsigned) const; + document_result KMismaches(uchar const *, unsigned) const; + document_result KErrors(uchar const *, unsigned) const; document_result Prefix(uchar const *, DocId, DocId) const; document_result Suffix(uchar const *, DocId, DocId) const; @@ -129,8 +130,8 @@ public: // Definition of full_result is inherited from SXSI::TextCollection. full_result FullContains(uchar const *) const; full_result FullContains(uchar const *, DocId, DocId) const; - full_result FullKmismatches(uchar const *, unsigned) const; - full_result FullKerrors(uchar const *, unsigned) const; + full_result FullKMismatches(uchar const *, unsigned) const; + full_result FullKErrors(uchar const *, unsigned) const; // Index from/to disk TCImplementation(FILE *, unsigned); @@ -157,7 +158,8 @@ private: ulong maxTextLength; // Array of document id's in the order of end-markers in BWT - static_sequence *Doc; +// static_sequence *Doc; + ArrayDoc *Doc; // Text storage for fast extraction TextStorage * textStorage; @@ -165,7 +167,7 @@ private: // Following methods are not part of the public API uchar * BWT(uchar *); void makewavelet(uchar *); - void maketables(ulong); + void maketables(ulong, char); DocId DocIdAtTextPos(BlockArray*, TextPosition) const; ulong Search(uchar const *, TextPosition, TextPosition *, TextPosition *) const; ulong Search(uchar const *, TextPosition, TextPosition *, TextPosition *, DocId, DocId) const;