Jouni's Incremental BWT integrated into TextCollection
[SXSI/TextCollection.git] / incbwt / rlcsa_builder.h
1 #ifndef RLCSA_BUILDER_H
2 #define RLCSA_BUILDER_H
3
4 #include <cstdlib>
5 #include "rlcsa.h"
6
7
8 namespace CSA
9 {
10
11
12 class RLCSABuilder
13 {
14   public:
15     RLCSABuilder(usint _block_size, usint _sample_rate, usint _buffer_size);
16     ~RLCSABuilder();
17
18     void insertSequence(char* sequence, usint length, bool delete_sequence);
19
20     // User must free the index. Builder no longer contains it.
21     RLCSA* getRLCSA();
22
23     // User must free the BWT. length becomes the length of BWT.
24     char* getBWT(usint& length);
25
26     bool isOk();
27
28     // These times are not reset with the rest of the builder.
29     double getBuildTime();
30     double getSearchTime();
31     double getMergeTime();
32
33   private:
34     RLCSA* index;
35
36     usint block_size;
37     usint sample_rate;
38     usint buffer_size;
39
40     uchar* buffer;
41     usint chars;
42
43     bool ok;
44
45     clock_t build_time;
46     clock_t search_time;
47     clock_t merge_time;
48
49     void flush();
50     void addRLCSA(RLCSA* increment, uchar* sequence, usint length, bool delete_sequence);
51     void reset();
52 };
53
54
55 } // namespace CSA
56
57
58 #endif // RLCSA_BUILDER_H