-
Notifications
You must be signed in to change notification settings - Fork 2
/
kwage.h
77 lines (63 loc) · 1.88 KB
/
kwage.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
#ifndef __KWAGE
#define __KWAGE
#define KWAGE_VERSION "0.4d"
#define INVENTORY_VERSION "0.7"
#define MAESTRO_VERSION "0.9"
#include <cstdint> // uint32_t
#include <fstream>
#include "hash.h"
// Needed to supress compiler wanings on g++
#include "binary_io.h"
// The currently allowed compression levels
enum {
NO_COMPRESSION,
RLE_COMPRESSION,
RLE_HUFFMAN_COMPRESSION
};
#define KWAGE_MAGIC_NUMBER 0x20191025
#define CURRENT_DBFILE_VERSION 2
// MPI Messages
#define INFO_BUFFER 1001
#define INFO_LEN 1002
// The file header for the KWAGE database files
struct DBFileHeader
{
// Use X Macros (https://en.wikipedia.org/wiki/X_Macro) to
// ensure that structure variable are correctly serialized
#define DBFILEHEADER_MEMBERS \
VARIABLE(uint32_t, magic) \
VARIABLE(uint32_t, version) \
VARIABLE(uint32_t, crc32) \
VARIABLE(uint32_t, kmer_len) \
VARIABLE(uint32_t, num_hash) \
VARIABLE(uint32_t, log_2_filter_len) \
VARIABLE(uint32_t, num_filter) \
VARIABLE(HashFunction, hash_func) \
VARIABLE(uint32_t, compression) \
VARIABLE(uint64_t, info_start)
#define VARIABLE(A, B) A B;
DBFILEHEADER_MEMBERS
#undef VARIABLE
DBFileHeader()
{
// Initialize all variables to zero (which will work until
// we add a member variable that can not be assigned to zero).
#define VARIABLE(A, B) B = 0;
DBFILEHEADER_MEMBERS
#undef VARIABLE
magic = KWAGE_MAGIC_NUMBER;
version = CURRENT_DBFILE_VERSION;
};
// Return a size_t to allow for very large Bloom filters
inline size_t filter_len() const
{
return (size_t(1) << log_2_filter_len);
};
template<class T> friend void binary_write(std::ostream &m_out,
const T &m_obj);
template<class T> friend void binary_read(std::istream &m_in,
T &m_obj);
};
template<> void binary_write(std::ostream &m_out, const DBFileHeader &m_obj);
template<> void binary_read(std::istream &m_in, DBFileHeader &m_obj);
#endif // __KWAGE