OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QueryHintSerializer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "QueryEngine/QueryHint.h"
20 
21 #include <boost/serialization/unordered_map.hpp>
22 #include <boost/serialization/vector.hpp>
23 
24 namespace boost {
25 namespace serialization {
26 
27 template <class Archive>
28 void serialize(Archive& ar, RegisteredQueryHint& query_hint, const unsigned int version) {
29  (ar & query_hint.cpu_mode);
30  (ar & query_hint.columnar_output);
31  (ar & query_hint.rowwise_output);
32  (ar & query_hint.keep_result);
33  (ar & query_hint.keep_table_function_result);
34  (ar & query_hint.watchdog);
35  (ar & query_hint.dynamic_watchdog);
36  (ar & query_hint.query_time_limit);
37  (ar & query_hint.cuda_block_size);
38  (ar & query_hint.cuda_grid_size_multiplier);
39  (ar & query_hint.aggregate_tree_fanout);
40  (ar & query_hint.bbox_intersect_bucket_threshold);
41  (ar & query_hint.bbox_intersect_max_size);
42  (ar & query_hint.bbox_intersect_allow_gpu_build);
43  (ar & query_hint.bbox_intersect_no_cache);
44  (ar & query_hint.bbox_intersect_keys_per_bin);
45  (ar & query_hint.use_loop_join);
46  (ar & query_hint.max_join_hash_table_size);
47  (ar & query_hint.loop_join_inner_table_max_num_rows);
48  (ar & query_hint.registered_hint);
49 }
50 
51 template <class Archive>
52 void serialize(Archive& ar, ExplainedQueryHint& query_hint, const unsigned int version) {
53  // need to split serialization into separate load/store methods since members are only
54  // accessible through getters/setters. See:
55  // https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/serialization.html#splitting
56  split_free(ar, query_hint, version);
57 }
58 
59 template <class Archive>
60 void save(Archive& ar, const ExplainedQueryHint& query_hint, const unsigned int version) {
61  ar << query_hint.getInteritPath();
62  ar << query_hint.getListOptions();
63  ar << query_hint.getKVOptions();
64 }
65 
66 template <class Archive>
67 void load(Archive& ar, ExplainedQueryHint& query_hint, const unsigned int version) {
68  std::vector<int> inherit_paths;
69  std::vector<std::string> list_options;
70  std::unordered_map<std::string, std::string> kv_options;
71  ar >> inherit_paths;
72  query_hint.setInheritPaths(inherit_paths);
73  ar >> list_options;
74  query_hint.setListOptions(list_options);
75  ar >> kv_options;
76  query_hint.setKVOptions(kv_options);
77 }
78 
79 template <class Archive>
80 inline void save_construct_data(Archive& ar,
81  const ExplainedQueryHint* query_hint,
82  const unsigned int version) {
83  ar << query_hint->getHint();
84  ar << query_hint->isGlobalHint();
85  ar << query_hint->hasOptions();
86  ar << query_hint->hasKvOptions();
87 }
88 
89 template <class Archive>
90 inline void load_construct_data(Archive& ar,
91  ExplainedQueryHint* query_hint,
92  const unsigned int version) {
93  QueryHint hint;
94  bool global_hint;
95  bool is_marker;
96  bool has_kv_type_options;
97  ar >> hint;
98  ar >> global_hint;
99  ar >> is_marker;
100  ar >> has_kv_type_options;
101  ::new (query_hint)
102  ExplainedQueryHint(hint, global_hint, is_marker, has_kv_type_options);
103 }
104 
105 } // namespace serialization
106 } // namespace boost
bool isGlobalHint() const
Definition: QueryHint.h:165
void load(Archive &ar, ExplainedQueryHint &query_hint, const unsigned int version)
double bbox_intersect_keys_per_bin
Definition: QueryHint.h:353
const std::vector< int > & getInteritPath() const
Definition: QueryHint.h:157
const std::unordered_map< std::string, std::string > & getKVOptions() const
Definition: QueryHint.h:159
void save(Archive &ar, const ExplainedQueryHint &query_hint, const unsigned int version)
void setListOptions(std::vector< std::string > &list_options)
Definition: QueryHint.h:143
std::optional< bool > dynamic_watchdog
Definition: QueryHint.h:334
double cuda_grid_size_multiplier
Definition: QueryHint.h:341
size_t cuda_block_size
Definition: QueryHint.h:340
std::vector< bool > registered_hint
Definition: QueryHint.h:362
void setKVOptions(std::unordered_map< std::string, std::string > &kv_options)
Definition: QueryHint.h:147
size_t max_join_hash_table_size
Definition: QueryHint.h:358
bool hasKvOptions() const
Definition: QueryHint.h:169
bool keep_table_function_result
Definition: QueryHint.h:332
size_t query_time_limit
Definition: QueryHint.h:335
string version
Definition: setup.in.py:73
double bbox_intersect_bucket_threshold
Definition: QueryHint.h:348
bool hasOptions() const
Definition: QueryHint.h:167
std::optional< bool > watchdog
Definition: QueryHint.h:333
void serialize(Archive &ar, RegisteredQueryHint &query_hint, const unsigned int version)
QueryHint
Definition: QueryHint.h:29
size_t bbox_intersect_max_size
Definition: QueryHint.h:350
bool bbox_intersect_no_cache
Definition: QueryHint.h:352
std::optional< bool > use_loop_join
Definition: QueryHint.h:356
size_t loop_join_inner_table_max_num_rows
Definition: QueryHint.h:357
bool bbox_intersect_allow_gpu_build
Definition: QueryHint.h:351
size_t aggregate_tree_fanout
Definition: QueryHint.h:345
const QueryHint getHint() const
Definition: QueryHint.h:163
void save_construct_data(Archive &ar, const ExplainedQueryHint *query_hint, const unsigned int version)
void load_construct_data(Archive &ar, ExplainedQueryHint *query_hint, const unsigned int version)
const std::vector< std::string > & getListOptions() const
Definition: QueryHint.h:155
void setInheritPaths(std::vector< int > &interit_paths)
Definition: QueryHint.h:151