-
Notifications
You must be signed in to change notification settings - Fork 0
/
SuffixNodeStoreDisk.h
85 lines (69 loc) · 2.19 KB
/
SuffixNodeStoreDisk.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* -
* Copyright (c) 2012 Nava Whiteford <[email protected]>
* suffixcore - core suffixtree algorithms
*
* A license to use this software is granted to users given access to the git repository at: https://github.com/sgenomics/suffixcore
* A complete copy of this license is located in the license.txt file of this package.
*
* In Summary this software:
*
* Can be used for creating unlimited applications.
* Can be distributed in binary or object form only.
* Commercial use is allowed.
* Can modify source-code but cannot distribute modifications (derivative works).
*/
#ifndef SUFFIXNODESTOREDISK
#define SUFFIXNODESTOREDISK
#include <vector>
#include <map>
#include <algorithm>
#include "tialloc.h"
#include <stdio.h>
#include <omp.h>
#include <zlib.h>
class SuffixNode;
using namespace std;
#include <stdint.h>
class SuffixNodeStoreDisk {
public:
SuffixNodeStoreDisk() {}
SuffixNodeStoreDisk(string filename,bool compress=false);
void set_compactmode(bool compact_mode);
size_t push_back_norm();
size_t push_back_end();
size_t push_back(SuffixNode &s,int resize=-1);
void push_back_nort(SuffixNode &s);
SuffixNode get(uint32_t idx);
void set(uint32_t idx, SuffixNode &s);
uint32_t size();
uint32_t next_idx(uint32_t i);
uint32_t last_idx();
void stats();
void force_compact();
void compact();
FILE *get_data_filehandle_uc(uint32_t i);
gzFile get_data_filehandle_gz(uint32_t i);
template<class copying_type>
void copy(copying_type &other) {
//#pragma omp parallel for
for(uint32_t n=0;n<other.size();n++) {
push_back_nort(other.get(n));
}
close();
}
uint64_t push_idx_entry(uint16_t filenum,uint32_t index);
void get_idx_entry(uint32_t idx,uint16_t &filenum,uint32_t &index);
void *read_data(uint16_t filenum,uint32_t index);
void write_data(void *data,uint16_t filenum,uint32_t index);
uint32_t push_data(uint16_t filenum, void *data);
void close();
vector<gzFile> data_filehandle_gz;
vector<FILE *> data_filehandle_uc;
vector<omp_lock_t> data_filehandle_lock;
gzFile index_filehandle_gz;
FILE *index_filehandle_uc;
omp_lock_t index_filehandle_lock;
string basefilename;
bool m_compress;
};
#endif