OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Codec.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 #ifndef QUERYENGINE_CODEC_H
18 #define QUERYENGINE_CODEC_H
19 
20 #include <llvm/IR/IRBuilder.h>
21 #include <llvm/IR/Module.h>
22 #include <llvm/IR/Value.h>
23 
24 #include "../Shared/sqltypes.h"
25 
26 class Decoder {
27  public:
28  virtual llvm::Instruction* codegenDecode(llvm::Value* byte_stream,
29  llvm::Value* pos,
30  llvm::Module* llvm_module) const = 0;
31  virtual ~Decoder() {}
32 };
33 
34 class FixedWidthInt : public Decoder {
35  public:
36  FixedWidthInt(const size_t byte_width);
37  llvm::Instruction* codegenDecode(llvm::Value* byte_stream,
38  llvm::Value* pos,
39  llvm::Module* llvm_module) const override;
40 
41  private:
42  const size_t byte_width_;
43 };
44 
45 class FixedWidthUnsigned : public Decoder {
46  public:
47  FixedWidthUnsigned(const size_t byte_width);
48  llvm::Instruction* codegenDecode(llvm::Value* byte_stream,
49  llvm::Value* pos,
50  llvm::Module* llvm_module) const override;
51 
52  private:
53  const size_t byte_width_;
54 };
55 
56 class DiffFixedWidthInt : public Decoder {
57  public:
58  DiffFixedWidthInt(const size_t byte_width, const int64_t baseline);
59  llvm::Instruction* codegenDecode(llvm::Value* byte_stream,
60  llvm::Value* pos,
61  llvm::Module* llvm_module) const override;
62 
63  private:
64  const size_t byte_width_;
65  const int64_t baseline_;
66 };
67 
68 class FixedWidthReal : public Decoder {
69  public:
70  FixedWidthReal(const bool is_double);
71  llvm::Instruction* codegenDecode(llvm::Value* byte_stream,
72  llvm::Value* pos,
73  llvm::Module* llvm_module) const override;
74 
75  private:
76  const bool is_double_;
77 };
78 
79 class FixedWidthSmallDate : public Decoder {
80  public:
81  FixedWidthSmallDate(const size_t byte_width);
82  llvm::Instruction* codegenDecode(llvm::Value* byte_stream,
83  llvm::Value* pos,
84  llvm::Module* llvm_module) const override;
85 
86  private:
87  const size_t byte_width_;
88  const int32_t null_val_;
89  static constexpr int64_t ret_null_val_ = NULL_BIGINT;
90 };
91 
92 #endif // QUERYENGINE_CODEC_H
FixedWidthUnsigned(const size_t byte_width)
Definition: Codec.cpp:41
llvm::Instruction * codegenDecode(llvm::Value *byte_stream, llvm::Value *pos, llvm::Module *llvm_module) const override
Definition: Codec.cpp:28
const size_t byte_width_
Definition: Codec.h:42
llvm::Instruction * codegenDecode(llvm::Value *byte_stream, llvm::Value *pos, llvm::Module *llvm_module) const override
Definition: Codec.cpp:44
#define NULL_BIGINT
FixedWidthSmallDate(const size_t byte_width)
Definition: Codec.cpp:86
FixedWidthReal(const bool is_double)
Definition: Codec.cpp:74
DiffFixedWidthInt(const size_t byte_width, const int64_t baseline)
Definition: Codec.cpp:57
llvm::Instruction * codegenDecode(llvm::Value *byte_stream, llvm::Value *pos, llvm::Module *llvm_module) const override
Definition: Codec.cpp:76
virtual ~Decoder()
Definition: Codec.h:31
FixedWidthInt(const size_t byte_width)
Definition: Codec.cpp:26
const int64_t baseline_
Definition: Codec.h:65
const int32_t null_val_
Definition: Codec.h:88
Definition: Codec.h:26
llvm::Instruction * codegenDecode(llvm::Value *byte_stream, llvm::Value *pos, llvm::Module *llvm_module) const override
Definition: Codec.cpp:60
llvm::Instruction * codegenDecode(llvm::Value *byte_stream, llvm::Value *pos, llvm::Module *llvm_module) const override
Definition: Codec.cpp:89
const size_t byte_width_
Definition: Codec.h:53
virtual llvm::Instruction * codegenDecode(llvm::Value *byte_stream, llvm::Value *pos, llvm::Module *llvm_module) const =0
const bool is_double_
Definition: Codec.h:76
static constexpr int64_t ret_null_val_
Definition: Codec.h:89
const size_t byte_width_
Definition: Codec.h:64
const size_t byte_width_
Definition: Codec.h:87