-
Notifications
You must be signed in to change notification settings - Fork 4
/
QueryLoader.h
42 lines (33 loc) · 1.1 KB
/
QueryLoader.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
#ifndef SPEEDPPR_QUERYLOADER_H
#define SPEEDPPR_QUERYLOADER_H
#include <vector>
#include <string>
#include <fstream>
#include "BasicDefinition.h"
#include "HelperFunctions.h"
class QueryLoader {
std::vector<VertexIdType> vertices;
public:
QueryLoader(const std::string &_query_file_name, const uint32_t &_query_size) {
std::ifstream file(_query_file_name.c_str());
if (file.good() == false) {
printf("Query File Not Exists.\n");
exit(1);
}
for (VertexIdType sid; (file >> sid) && vertices.size() < _query_size;) {
vertices.emplace_back(sid);
}
if (vertices.empty()) {
printf("Error in QueryLoader::QueryLoader. Empty Query File\n");
} else if (vertices.size() > _query_size) {
printf("Error in QueryLoader::QueryLoader.\n");
} else {
printf("The number of query points loaded: %zu\n", vertices.size());
}
file.close();
}
const std::vector<VertexIdType> &source_vertices() const {
return vertices;
}
};
#endif //SPEEDPPR_QUERYLOADER_H