OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SQLTypeInfoSerializer.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 "Shared/sqltypes.h"
20 
21 namespace boost {
22 namespace serialization {
23 
24 // Serialize/deserialize SQLTypeInfo instances. These are split into separate save
25 // (serialize) / load (deserialize) methods to adhere to existing API. They could not be
26 // combined into a single serialize template since data members (i.e.
27 // type/subtype/dimension etc.) are not publicly accessible. They are only accessible with
28 // getters/setters.
29 
30 template <class Archive>
31 void serialize(Archive& ar, SQLTypeInfo& type_info, const unsigned int version) {
32  // need to split serialization of type_info into separate load/store methods defined
33  // above. See 'Splitting Free Functions' section of
34  // https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/serialization.html#splitting
35  split_free(ar, type_info, version);
36 }
37 
38 template <class Archive>
39 void save(Archive& ar, const SQLTypeInfo& type_info, const unsigned int version) {
40  ar << type_info.get_type();
41  ar << type_info.get_subtype();
42  ar << type_info.get_dimension();
43  ar << type_info.get_scale();
44  ar << type_info.get_notnull();
45  ar << type_info.get_compression();
46  ar << type_info.get_comp_param();
47  ar << type_info.get_size();
48  ar << type_info.is_dict_intersection();
49 }
50 
51 template <class Archive>
52 void load(Archive& ar, SQLTypeInfo& type_info, const unsigned int version) {
53  SQLTypes type;
54  SQLTypes subtype;
55  int dimension{0};
56  int scale{0};
57  bool notnull{false};
58  EncodingType compression;
59  int comp_param{0};
60  int size{0};
61  bool is_dict_intersection{false};
62 
63  ar >> type;
64  type_info.set_type(type);
65  ar >> subtype;
66  type_info.set_subtype(subtype);
67  ar >> dimension;
68  type_info.set_dimension(dimension);
69  ar >> scale;
70  type_info.set_scale(scale);
71  ar >> notnull;
72  type_info.set_notnull(notnull);
73  ar >> compression;
74  type_info.set_compression(compression);
75  ar >> comp_param;
76  type_info.set_comp_param(comp_param);
77  ar >> size;
78  type_info.set_size(size);
79  ar >> is_dict_intersection;
80  if (is_dict_intersection) {
81  type_info.set_dict_intersection();
82  }
83 }
84 
85 } // namespace serialization
86 } // namespace boost
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:392
void set_compression(EncodingType c)
Definition: sqltypes.h:479
void set_size(int s)
Definition: sqltypes.h:476
HOST DEVICE int get_size() const
Definition: sqltypes.h:403
SQLTypes
Definition: sqltypes.h:65
void load(Archive &ar, ExplainedQueryHint &query_hint, const unsigned int version)
HOST DEVICE int get_scale() const
Definition: sqltypes.h:396
void save(Archive &ar, const ExplainedQueryHint &query_hint, const unsigned int version)
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:469
Constants for Builtin SQL Types supported by HEAVY.AI.
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
EncodingType
Definition: sqltypes.h:240
string version
Definition: setup.in.py:73
void set_scale(int s)
Definition: sqltypes.h:473
bool is_dict_intersection() const
Definition: sqltypes.h:658
void set_comp_param(int p)
Definition: sqltypes.h:480
void serialize(Archive &ar, RegisteredQueryHint &query_hint, const unsigned int version)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399
void set_dimension(int d)
Definition: sqltypes.h:470
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:393
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:402
void set_dict_intersection()
Definition: sqltypes.h:478
void set_notnull(bool n)
Definition: sqltypes.h:475
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398
HOST DEVICE void set_type(SQLTypes t)
Definition: sqltypes.h:468