OmniSciDB  04ee39c94c
JoinHashTableInterface.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 #ifndef QUERYENGINE_JOINHASHTABLEINTERFACE_H
17 #define QUERYENGINE_JOINHASHTABLEINTERFACE_H
18 
19 #include <llvm/IR/Value.h>
20 #include <cstdint>
21 #include "CompilationOptions.h"
22 
23 class TooManyHashEntries : public std::runtime_error {
24  public:
26  : std::runtime_error("Hash tables with more than 2B entries not supported yet") {}
27 };
28 
29 class TableMustBeReplicated : public std::runtime_error {
30  public:
31  TableMustBeReplicated(const std::string& table_name)
32  : std::runtime_error("Hash join failed: Table '" + table_name +
33  "' must be replicated.") {}
34 };
35 
36 class HashJoinFail : public std::runtime_error {
37  public:
38  HashJoinFail(const std::string& reason) : std::runtime_error(reason) {}
39 };
40 
42  public:
44  : HashJoinFail("Not enough memory for columns involvde in join") {}
45 };
46 
48  public:
49  FailedToJoinOnVirtualColumn() : HashJoinFail("Cannot join on rowid") {}
50 };
51 
53  llvm::Value* elements;
54  llvm::Value* count;
55  llvm::Value* slot;
56 };
57 
58 using InnerOuter = std::pair<const Analyzer::ColumnVar*, const Analyzer::Expr*>;
59 
61  public:
62  virtual int64_t getJoinHashBuffer(const ExecutorDeviceType device_type,
63  const int device_id) noexcept = 0;
64 
65  virtual llvm::Value* codegenSlot(const CompilationOptions&, const size_t) = 0;
66 
67  virtual HashJoinMatchingSet codegenMatchingSet(const CompilationOptions&,
68  const size_t) = 0;
69 
70  virtual int getInnerTableId() const noexcept = 0;
71 
72  virtual int getInnerTableRteIdx() const noexcept = 0;
73 
74  enum class HashType { OneToOne, OneToMany };
75 
76  virtual HashType getHashType() const noexcept = 0;
77 
78  virtual size_t offsetBufferOff() const noexcept = 0;
79 
80  virtual size_t countBufferOff() const noexcept = 0;
81 
82  virtual size_t payloadBufferOff() const noexcept = 0;
83 };
84 
85 #endif // QUERYENGINE_JOINHASHTABLEINTERFACE_H
ExecutorDeviceType
TableMustBeReplicated(const std::string &table_name)
std::pair< const Analyzer::ColumnVar *, const Analyzer::Expr * > InnerOuter
HashJoinFail(const std::string &reason)