-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfile_manager.h
67 lines (55 loc) · 1.84 KB
/
file_manager.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
#ifndef file_manager_H
#define file_manager_H
#include <string>
#include <iostream>
#include <vector>
#include <unordered_map>
#include "bloom_filter.h"
#include "bloom_tree.h"
//----------
//
// classes in this module--
//
//----------
struct BitVectorInfo
{
std::string name;
std::uint32_t compressor; // compressor identifier (one of bvcomp_xxx)
size_t offset; // offset (into file) of bloom filter's data
size_t numBytes; // number of bytes of data; zero means unknown
};
class FileManager
{
public:
FileManager(BloomTree* root, bool validateConsistency=false);
virtual ~FileManager();
virtual void preload_content(const std::string& filename);
virtual void load_content(const std::string& filename,const std::string& whichNodeName="");
public:
bool reportLoad = false;
static bool trackMemory;
static bool dbgContentLoad;
public:
BloomFilter* modelBf;
std::unordered_map<std::string,BloomTree*> nameToNode; // hash table
// .. mapping a node name to the associated
// .. bloom tree node
std::unordered_map<std::string,std::vector<std::string>*> filenameToNames;
// hash table mapping a filename to the
// .. list of names of nodes to be loaded
// .. from that file
std::unordered_map<std::string,bool> alreadyPreloaded; // hash table mapping
// .. a filename to the to true if the file
// .. has already been preloaded, false if
// .. not
public:
static bool reportOpenClose;
static std::ifstream* open_file (const std::string& filename,
std::ios_base::openmode mode=std::ios::in,
bool positionAtStart=false);
static void close_file (std::ifstream* in=nullptr, bool really=false);
public:
static std::string openedFilename;
static std::ifstream* openedFile;
};
#endif // file_manager_H