OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SortFieldSerializer.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/RelAlgDag.h"
20 
21 namespace boost {
22 namespace serialization {
23 
24 template <class Archive>
25 void serialize(Archive&, SortField&, const unsigned int) {
26  // We will not serialize anything directly from SortField instances and instead
27  // serialize constructor data. This is handled in the save/load_construct_data functions
28  // below below. See:
29  // https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/serialization.html#constructors
30  // for more.
31  // We still need to provide this no-op method for compilation tho.
32 }
33 
34 template <class Archive>
35 inline void save_construct_data(Archive& ar,
36  const SortField* sort_field,
37  const unsigned int version) {
38  ar << sort_field->getField();
39  ar << sort_field->getSortDir();
40  ar << sort_field->getNullsPosition();
41 }
42 
43 template <class Archive>
44 inline void load_construct_data(Archive& ar,
45  SortField* sort_field,
46  const unsigned int version) {
47  size_t field;
48  SortDirection sort_dir;
49  NullSortedPosition nulls_pos;
50  ar >> field;
51  ar >> sort_dir;
52  ar >> nulls_pos;
53  ::new (sort_field) SortField(field, sort_dir, nulls_pos);
54 }
55 
56 } // namespace serialization
57 } // namespace boost
SortDirection getSortDir() const
Definition: RelAlgDag.h:549
SortDirection
Definition: RelAlgDag.h:531
size_t getField() const
Definition: RelAlgDag.h:547
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:33
NullSortedPosition getNullsPosition() const
Definition: RelAlgDag.h:551
string version
Definition: setup.in.py:73
void serialize(Archive &ar, RegisteredQueryHint &query_hint, const unsigned int version)
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)
NullSortedPosition
Definition: RelAlgDag.h:533