OmniSciDB  b28c0d5765
 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:381
void set_compression(EncodingType c)
Definition: sqltypes.h:501
void set_size(int s)
Definition: sqltypes.h:498
HOST DEVICE int get_size() const
Definition: sqltypes.h:390
SQLTypes
Definition: sqltypes.h:53
void load(Archive &ar, ExplainedQueryHint &query_hint, const unsigned int version)
HOST DEVICE int get_scale() const
Definition: sqltypes.h:385
void save(Archive &ar, const ExplainedQueryHint &query_hint, const unsigned int version)
HOST DEVICE void set_subtype(SQLTypes st)
Definition: sqltypes.h:491
Constants for Builtin SQL Types supported by HEAVY.AI.
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:380
EncodingType
Definition: sqltypes.h:228
string version
Definition: setup.in.py:73
void set_scale(int s)
Definition: sqltypes.h:495
bool is_dict_intersection() const
Definition: sqltypes.h:645
void set_comp_param(int p)
Definition: sqltypes.h:502
void serialize(Archive &ar, RegisteredQueryHint &query_hint, const unsigned int version)
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:388
void set_dimension(int d)
Definition: sqltypes.h:492
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:382
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:389
void set_dict_intersection()
Definition: sqltypes.h:500
void set_notnull(bool n)
Definition: sqltypes.h:497
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:387
HOST DEVICE void set_type(SQLTypes t)
Definition: sqltypes.h:490