Added deltavector for non-indexed texts
[SXSI/TextCollection.git] / TCImplementation.h
index 65bf22c..f0a21cc 100644 (file)
 #   define W 32
 #endif
 #undef bitset
+#undef bitget
 
 #include "TextStorage.h"
+#include "ArrayDoc.h"
 #include <set>
 
 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;