OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
InputDescriptors.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, 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 #ifndef QUERYENGINE_INPUTDESCRIPTORS_H
18 #define QUERYENGINE_INPUTDESCRIPTORS_H
19 
20 #include "../Catalog/TableDescriptor.h"
21 #include "Shared/Logger.h"
22 
23 #include <memory>
24 
25 enum class InputSourceType { TABLE, RESULT };
26 
28  public:
29  InputDescriptor(const int table_id, const int nest_level)
30  : table_id_(table_id), nest_level_(nest_level) {}
31 
32  bool operator==(const InputDescriptor& that) const {
33  return table_id_ == that.table_id_ && nest_level_ == that.nest_level_;
34  }
35 
36  int getTableId() const { return table_id_; }
37 
38  int getNestLevel() const { return nest_level_; }
39 
42  }
43 
44  private:
45  int table_id_;
47 };
48 
49 namespace std {
50 template <>
51 struct hash<InputDescriptor> {
52  size_t operator()(const InputDescriptor& input_desc) const {
53  return input_desc.getTableId() ^ input_desc.getNestLevel();
54  }
55 };
56 } // namespace std
57 
59  public:
60  InputColDescriptor(const int col_id, const int table_id, const int nest_level)
61  : col_id_(col_id), input_desc_(table_id, nest_level) {}
62 
63  bool operator==(const InputColDescriptor& that) const {
64  return col_id_ == that.col_id_ && input_desc_ == that.input_desc_;
65  }
66 
67  int getColId() const { return col_id_; }
68 
69  const InputDescriptor& getScanDesc() const { return input_desc_; }
70 
71  virtual ~InputColDescriptor() {}
72 
73  private:
74  const int col_id_;
76 };
77 
78 namespace std {
79 template <>
80 struct hash<InputColDescriptor> {
81  size_t operator()(const InputColDescriptor& input_col_desc) const {
82  hash<InputDescriptor> input_col_desc_hasher;
83  return input_col_desc_hasher(input_col_desc.getScanDesc()) ^
84  static_cast<size_t>(input_col_desc.getColId());
85  }
86 };
87 
88 template <>
89 struct hash<const InputColDescriptor*> {
90  size_t operator()(const InputColDescriptor* input_col_desc) const {
91  hash<InputColDescriptor> input_col_desc_hasher;
92  CHECK(input_col_desc);
93  return input_col_desc_hasher(*input_col_desc);
94  }
95 };
96 
97 template <>
98 struct equal_to<shared_ptr<const InputColDescriptor>> {
99  bool operator()(shared_ptr<const InputColDescriptor> const& lhs,
100  shared_ptr<const InputColDescriptor> const& rhs) const {
101  CHECK(lhs && rhs);
102  return *lhs == *rhs;
103  }
104 };
105 } // namespace std
106 
107 #endif // QUERYENGINE_INPUTDESCRIPTORS_H
InputColDescriptor(const int col_id, const int table_id, const int nest_level)
size_t operator()(const InputColDescriptor *input_col_desc) const
size_t operator()(const InputDescriptor &input_desc) const
CHECK(cgen_state)
virtual ~InputColDescriptor()
int getColId() const
size_t operator()(const InputColDescriptor &input_col_desc) const
int getTableId() const
InputDescriptor(const int table_id, const int nest_level)
InputSourceType getSourceType() const
bool operator==(const InputColDescriptor &that) const
bool operator==(const InputDescriptor &that) const
const InputDescriptor input_desc_
InputSourceType
int getNestLevel() const
const InputDescriptor & getScanDesc() const
bool operator()(shared_ptr< const InputColDescriptor > const &lhs, shared_ptr< const InputColDescriptor > const &rhs) const