-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph_query.h
123 lines (110 loc) · 5.41 KB
/
graph_query.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/**
* TODO: Some boost definitions (functions, classes, structs) that I overrode
* for extracting all the isomorphism maps, use camel casing and I have retained that
* for consistency with the corresponding boost definitions. But we are using snake case
* in the rest of our codebase, so maybe convert all of those overriden defs to snake_case.
*/
#ifndef GRAPH_QUERY_H_ // NOLINT
#define GRAPH_QUERY_H_
#include <iostream>
#include <unordered_map>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <future>
#include <tuple>
#include <unordered_set>
#include "query_conditions.h"
#include "google/cloud/storage/client.h"
#include "opentelemetry/proto/trace/v1/trace.pb.h"
#include <boost/algorithm/string.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/vf2_sub_graph_iso.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include "get_traces_by_structure.h"
#include "indices/folders_index_query.h"
#include "indices/query_bloom_index.h"
#include "common.h"
const int BRUTE_FORCE_BATCH_SIZE = 1000;
typedef std::map<int, std::map<int, std::string>> iso_to_span_id; // iso_map_index to (node_id_index to span_id)
std::vector<std::string> query(
trace_structure query_trace, int start_time, int end_time,
std::vector<query_condition> conditions, return_value ret, bool verbose, gcs::Client* client);
// ****************** conditions-related ********************************
// Service name to span data for return.
typedef std::unordered_map<
std::string,
opentelemetry::proto::trace::v1::TracesData> ret_req_data;
struct fetched_data {
std::string structural_object;
std::unordered_map<std::string, opentelemetry::proto::trace::v1::TracesData> service_name_to_span_data;
};
std::string get_service_name_for_node_index(
traces_by_structure& structural_results, int iso_map_index, int node_index
);
fetched_data fetch_data_per_batch(
traces_by_structure& structs_result,
std::string batch_name,
const std::vector<std::string> trace_ids,
std::vector<query_condition> &conditions,
gcs::Client* client
);
StatusOr<std::tuple<index_type, time_t>> is_indexed(const query_condition *condition, gcs::Client* client);
bool does_span_satisfy_condition(
const std::string &span_id, const std::string &service_name,
const query_condition &condition, fetched_data& evaluation_data
);
std::map<int, std::map<int, std::string>> get_iso_maps_indices_for_which_trace_satifies_curr_condition(
const std::string &trace_id, std::vector<query_condition>& conditions,
int curr_cond_ind, fetched_data& evaluation_data, traces_by_structure& structural_results, const return_value &ret
);
StatusOr<objname_to_matching_trace_ids> get_traces_by_indexed_condition(
int start_time, int end_time, const query_condition *condition, const index_type ind_type, gcs::Client* client);
std::tuple<objname_to_matching_trace_ids, std::map<std::string, iso_to_span_id>> filter_based_on_conditions(
objname_to_matching_trace_ids &intersection,
traces_by_structure &structural_results,
std::vector<query_condition> &conditions,
struct fetched_data &fetched,
return_value &ret
);
std::tuple<std::vector<std::string>, std::map<std::string, iso_to_span_id>> filter_batch_data_based_on_conditions(
const std::vector<std::string>& trace_ids,
traces_by_structure &structural_results,
std::vector<query_condition> &conditions,
struct fetched_data &fetched,
const return_value &ret
);
std::map<int, std::map<int, std::string>> does_trace_satisfy_conditions(
const std::string& trace_id,
std::vector<query_condition> &conditions, fetched_data& evaluation_data,
traces_by_structure &structural_results, const return_value& ret
);
// ***************** query-related ******************************************
ret_req_data fetch_return_data(
const std::tuple<std::vector<std::string>, std::map<std::string, iso_to_span_id>> &filtered,
const return_value &ret, fetched_data &data, trace_structure &query_trace, std::string batch_name,
traces_by_structure struct_results,
gcs::Client* client
);
std::vector<std::string> get_return_value(
std::tuple<std::vector<std::string>, std::map<std::string, iso_to_span_id>> &filtered,
const return_value &ret, fetched_data &data, trace_structure &query_trace,
ret_req_data &return_data, traces_by_structure &struct_results, gcs::Client* client
);
objname_to_matching_trace_ids intersect_index_results(
std::vector<objname_to_matching_trace_ids> &index_results,
traces_by_structure &structural_results, time_t last_indexed, bool verbose);
objname_to_matching_trace_ids morph_struct_result_to_objname_to_matching_trace_ids(
traces_by_structure struct_results);
std::map<std::string, iso_to_span_id> get_iso_map_to_span_id_info(
traces_by_structure struct_results, int return_node_index, gcs::Client* client);
std::vector<std::string> brute_force_per_batch(std::string batch_name,
std::vector<std::string> trace_ids,
traces_by_structure struct_results,
std::vector<query_condition> conditions,
return_value ret,
trace_structure query_trace,
gcs::Client* client);
int dummy_tests();
#endif // GRAPH_QUERY_H_ // NOLINT