OmniSciDB  a5dc49c757
 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 #pragma once
17 
18 #include "QueryEngine/QueryHint.h"
19 
20 #include <boost/serialization/unordered_map.hpp>
21 #include <boost/serialization/vector.hpp>
22 
23 namespace boost {
24 namespace serialization {
25 
26 template <class Archive>
27 void serialize(Archive& ar, RegisteredQueryHint& query_hint, const unsigned int version) {
28  (ar & query_hint.cpu_mode);
29  (ar & query_hint.columnar_output);
30  (ar & query_hint.rowwise_output);
31  (ar & query_hint.bbox_intersect_bucket_threshold);
32  (ar & query_hint.bbox_intersect_max_size);
33  (ar & query_hint.bbox_intersect_allow_gpu_build);
34  (ar & query_hint.bbox_intersect_no_cache);
35  (ar & query_hint.bbox_intersect_keys_per_bin);
36  (ar & query_hint.keep_result);
37  (ar & query_hint.keep_table_function_result);
38  (ar & query_hint.aggregate_tree_fanout);
39  (ar & query_hint.cuda_block_size);
40  (ar & query_hint.cuda_grid_size_multiplier);
41  (ar & query_hint.opt_cuda_grid_and_block_size);
42  (ar & query_hint.watchdog);
43  (ar & query_hint.dynamic_watchdog);
44  (ar & query_hint.query_time_limit);
45  (ar & query_hint.use_loop_join);
46  (ar & query_hint.loop_join_inner_table_max_num_rows);
47  (ar & query_hint.max_join_hash_table_size);
48  (ar & query_hint.force_baseline_hash_join);
49  (ar & query_hint.force_one_to_many_hash_join);
51  (ar & query_hint.preflight_count_query_threshold);
52  (ar & query_hint.table_reordering_off);
53  (ar & query_hint.ndv_groups_estimator_multiplier);
54  (ar & query_hint.registered_hint);
55 }
56 
57 template <class Archive>
58 void serialize(Archive& ar, ExplainedQueryHint& query_hint, const unsigned int version) {
59  // need to split serialization into separate load/store methods since members are only
60  // accessible through getters/setters. See:
61  // https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/serialization.html#splitting
62  split_free(ar, query_hint, version);
63 }
64 
65 template <class Archive>
66 void save(Archive& ar, const ExplainedQueryHint& query_hint, const unsigned int version) {
67  ar << query_hint.getInteritPath();
68  ar << query_hint.getListOptions();
69  ar << query_hint.getKVOptions();
70 }
71 
72 template <class Archive>
73 void load(Archive& ar, ExplainedQueryHint& query_hint, const unsigned int version) {
74  std::vector<int> inherit_paths;
75  std::vector<std::string> list_options;
76  std::unordered_map<std::string, std::string> kv_options;
77  ar >> inherit_paths;
78  query_hint.setInheritPaths(inherit_paths);
79  ar >> list_options;
80  query_hint.setListOptions(list_options);
81  ar >> kv_options;
82  query_hint.setKVOptions(kv_options);
83 }
84 
85 template <class Archive>
86 inline void save_construct_data(Archive& ar,
87  const ExplainedQueryHint* query_hint,
88  const unsigned int version) {
89  ar << query_hint->getHint();
90  ar << query_hint->isGlobalHint();
91  ar << query_hint->hasOptions();
92  ar << query_hint->hasKvOptions();
93 }
94 
95 template <class Archive>
96 inline void load_construct_data(Archive& ar,
97  ExplainedQueryHint* query_hint,
98  const unsigned int version) {
99  QueryHint hint;
100  bool global_hint;
101  bool is_marker;
102  bool has_kv_type_options;
103  ar >> hint;
104  ar >> global_hint;
105  ar >> is_marker;
106  ar >> has_kv_type_options;
107  ::new (query_hint)
108  ExplainedQueryHint(hint, global_hint, is_marker, has_kv_type_options);
109 }
110 
111 } // namespace serialization
112 } // namespace boost
bool isGlobalHint() const
Definition: QueryHint.h:169
void load(Archive &ar, ExplainedQueryHint &query_hint, const unsigned int version)
double bbox_intersect_keys_per_bin
Definition: QueryHint.h:368
const std::vector< int > & getInteritPath() const
Definition: QueryHint.h:161
const std::unordered_map< std::string, std::string > & getKVOptions() const
Definition: QueryHint.h:163
void save(Archive &ar, const ExplainedQueryHint &query_hint, const unsigned int version)
void setListOptions(std::vector< std::string > &list_options)
Definition: QueryHint.h:147
std::optional< bool > dynamic_watchdog
Definition: QueryHint.h:347
double cuda_grid_size_multiplier
Definition: QueryHint.h:356
size_t cuda_block_size
Definition: QueryHint.h:355
std::vector< bool > registered_hint
Definition: QueryHint.h:377
void setKVOptions(std::unordered_map< std::string, std::string > &kv_options)
Definition: QueryHint.h:151
size_t max_join_hash_table_size
Definition: QueryHint.h:373
bool opt_cuda_grid_and_block_size
Definition: QueryHint.h:357
bool hasKvOptions() const
Definition: QueryHint.h:173
bool keep_table_function_result
Definition: QueryHint.h:345
size_t query_time_limit
Definition: QueryHint.h:348
string version
Definition: setup.in.py:73
double bbox_intersect_bucket_threshold
Definition: QueryHint.h:363
double ndv_groups_estimator_multiplier
Definition: QueryHint.h:352
bool hasOptions() const
Definition: QueryHint.h:171
size_t watchdog_max_projected_rows_per_device
Definition: QueryHint.h:349
std::optional< bool > watchdog
Definition: QueryHint.h:346
size_t preflight_count_query_threshold
Definition: QueryHint.h:350
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:365
bool force_baseline_hash_join
Definition: QueryHint.h:374
bool bbox_intersect_no_cache
Definition: QueryHint.h:367
std::optional< bool > use_loop_join
Definition: QueryHint.h:371
size_t loop_join_inner_table_max_num_rows
Definition: QueryHint.h:372
bool bbox_intersect_allow_gpu_build
Definition: QueryHint.h:366
size_t aggregate_tree_fanout
Definition: QueryHint.h:360
const QueryHint getHint() const
Definition: QueryHint.h:167
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:159
void setInheritPaths(std::vector< int > &interit_paths)
Definition: QueryHint.h:155
bool force_one_to_many_hash_join
Definition: QueryHint.h:375