Debug swcsa
[SXSI/TextCollection.git] / incbwt / rlcsa_builder.h
1 #ifndef RLCSA_BUILDER_H
2 #define RLCSA_BUILDER_H
3
4 #include "rlcsa.h"
5
6
7 namespace CSA
8 {
9
10
11 class RLCSABuilder
12 {
13   public:
14     RLCSABuilder(usint _block_size, usint _sample_rate, usint _buffer_size, usint _threads = 1);
15     ~RLCSABuilder();
16
17     void insertSequence(char* sequence, usint length, bool delete_sequence);
18
19     // Use this if you have already built an index for the file.
20     void insertFromFile(const std::string& base_name);
21
22     // User must free the index. Builder no longer contains it.
23     RLCSA* getRLCSA();
24
25     // User must free the BWT. length becomes the length of BWT.
26     char* getBWT(usint& length);
27
28     bool isOk();
29
30     // These times are not reset with the rest of the builder.
31     double getBuildTime();
32     double getSearchTime();
33     double getSortTime();
34     double getMergeTime();
35
36   private:
37     RLCSA* index;
38
39     usint block_size;
40     usint sample_rate;
41     usint buffer_size;
42
43     usint threads;
44
45     uchar* buffer;
46     usint chars;
47
48     bool ok;
49
50     double build_time;
51     double search_time;
52     double sort_time;
53     double merge_time;
54
55     void flush();
56     void addRLCSA(RLCSA* increment, uchar* sequence, usint length, bool delete_sequence);
57     void reset();
58
59     // These are not allowed.
60     RLCSABuilder();
61     RLCSABuilder(const RLCSABuilder&);
62     RLCSABuilder& operator = (const RLCSABuilder&);
63 };
64
65
66 } // namespace CSA
67
68
69 #endif // RLCSA_BUILDER_H