OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StringDictionaryTranslationMgr.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 
23 #pragma once
24 
25 #include "DataMgr/MemoryLevel.h"
26 #include "Shared/DbObjectKeys.h"
27 #include "StringOps/StringOpInfo.h"
28 
29 #include <vector>
30 
32 struct StringDictionaryProxyTranslationMgr;
33 struct CompilationOptions;
34 
35 namespace Data_Namespace {
36 class DataMgr;
37 class AbstractBuffer;
38 } // namespace Data_Namespace
39 
40 class Executor;
41 namespace llvm {
42 class Value;
43 }
44 
45 namespace StringFunctors {
46 enum StringFunctorType : unsigned int;
47 }
49  public:
51  const shared::StringDictKey& source_string_dict_key,
52  const shared::StringDictKey& dest_string_dict_key,
53  const bool translate_intersection_only,
54  const SQLTypeInfo& output_ti,
55  const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos,
56  const Data_Namespace::MemoryLevel memory_level,
57  const int device_count,
58  Executor* executor,
59  Data_Namespace::DataMgr* data_mgr,
60  const bool delay_translation);
61 
63  const shared::StringDictKey& source_string_dict_key,
64  const SQLTypeInfo& output_ti,
65  const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos,
66  const Data_Namespace::MemoryLevel memory_level,
67  const int device_count,
68  Executor* executor,
69  Data_Namespace::DataMgr* data_mgr,
70  const bool delay_translation);
71 
73  void buildTranslationMap();
74  void createKernelBuffers();
75  llvm::Value* codegen(llvm::Value* str_id_input,
76  const SQLTypeInfo& input_ti,
77  const bool add_nullcheck,
78  const CompilationOptions& co) const;
79 
80  bool isMapValid() const;
81  const int8_t* data() const;
82  int32_t minSourceStringId() const;
83  size_t mapSize() const;
84 
85  private:
90  const std::vector<StringOps_Namespace::StringOpInfo> string_op_infos_;
91  const bool has_null_string_op_;
93  const int device_count_;
97  const StringDictionaryProxy::IdMap* host_translation_map_{nullptr};
99  nullptr};
100  std::vector<const int8_t*> kernel_translation_maps_;
101  std::vector<Data_Namespace::AbstractBuffer*> device_buffers_;
102 };
StringDictionaryTranslationMgr(const shared::StringDictKey &source_string_dict_key, const shared::StringDictKey &dest_string_dict_key, const bool translate_intersection_only, const SQLTypeInfo &output_ti, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos, const Data_Namespace::MemoryLevel memory_level, const int device_count, Executor *executor, Data_Namespace::DataMgr *data_mgr, const bool delay_translation)
const Data_Namespace::MemoryLevel memory_level_
const StringDictionaryProxy::TranslationMap< Datum > * host_numeric_translation_map_
const shared::StringDictKey dest_string_dict_key_
std::vector< const int8_t * > kernel_translation_maps_
std::vector< Data_Namespace::AbstractBuffer * > device_buffers_
llvm::Value * codegen(llvm::Value *str_id_input, const SQLTypeInfo &input_ti, const bool add_nullcheck, const CompilationOptions &co) const
const shared::StringDictKey source_string_dict_key_
const std::vector< StringOps_Namespace::StringOpInfo > string_op_infos_