LZ index support
[SXSI/TextCollection.git] / TCImplementation.h
index d9ac063..75f1d40 100644 (file)
@@ -39,6 +39,7 @@
 #   define W 32
 #endif
 #undef bitset
+#undef bitget
 
 #include "TextStorage.h"
 #include <set>
@@ -53,31 +54,30 @@ namespace SXSI
  */
 class TCImplementation : public SXSI::TextCollection {
 public:
-    TCImplementation(uchar *, ulong, unsigned, unsigned, 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 +117,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 +129,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);
@@ -165,7 +165,7 @@ private:
     // Following methods are not part of the public API
     uchar * BWT(uchar *);
     void makewavelet(uchar *);
-    void maketables();
+    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;