38 #include <tbb/parallel_for.h>
42 const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos) {
43 for (
const auto& string_op_info : string_op_infos) {
44 if (string_op_info.hasNullLiteralArg()) {
54 const bool translate_intersection_only,
56 const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos,
58 const int device_count,
61 const bool delay_translation)
62 : source_string_dict_key_(source_string_dict_key)
63 , dest_string_dict_key_(dest_string_dict_key)
88 const std::vector<StringOps_Namespace::StringOpInfo>& string_op_infos,
90 const int device_count,
93 const bool delay_translation)
94 : source_string_dict_key_(source_string_dict_key)
95 , dest_string_dict_key_({-1, -1})
111 const auto& last_string_op_info = string_op_infos.back();
112 CHECK(!last_string_op_info.getReturnType().is_string());
114 buildTranslationMap();
115 createKernelBuffers();
128 host_translation_map_ =
executor_->getStringProxyTranslationMap(
149 const size_t translation_map_size_bytes =
mapSize();
150 for (
int device_id = 0; device_id <
device_count_; ++device_id) {
152 data_mgr_, translation_map_size_bytes, device_id));
156 reinterpret_cast<CUdeviceptr>(device_buffer),
158 translation_map_size_bytes,
173 const bool add_nullcheck,
211 auto cgen_state_ptr =
executor_->getCgenStatePtr();
220 return static_cast<llvm::Value*
>(
executor_->cgen_state_->inlineIntNull(null_ti));
223 std::vector<std::shared_ptr<const Analyzer::Constant>> constants_owned;
224 std::vector<const Analyzer::Constant*> constants;
226 const int64_t translation_map_handle =
227 reinterpret_cast<int64_t
>(kernel_translation_map);
228 const auto translation_map_handle_literal =
231 CHECK(translation_map_handle_literal);
233 translation_map_handle_literal->get_type_info().get_compression());
234 constants_owned.push_back(translation_map_handle_literal);
235 constants.push_back(translation_map_handle_literal.get());
242 const auto translation_map_handle_lvs =
244 ? code_generator.codegenHoistedConstants(constants,
kENCODING_NONE, {})
245 : code_generator.codegen(constants[0],
false, co);
246 CHECK_EQ(
size_t(1), translation_map_handle_lvs.size());
248 std::unique_ptr<CodeGenerator::NullCheckCodegen> nullcheck_codegen;
251 if (add_nullcheck && is_nullable) {
252 nullcheck_codegen = std::make_unique<CodeGenerator::NullCheckCodegen>(
257 "dict_encoded_str_cast_nullcheck");
261 ret = cgen_state_ptr->emitCall(
262 "map_string_dict_id",
264 cgen_state_ptr->castToTypeIn(translation_map_handle_lvs.front(), 64),
267 std::string fn_call =
"map_string_to_datum_";
292 throw std::runtime_error(
"Unimplemented type for string-to-numeric translation");
295 ret = cgen_state_ptr->emitCall(
298 cgen_state_ptr->castToTypeIn(translation_map_handle_lvs.front(), 64),
302 if (nullcheck_codegen) {
303 ret = nullcheck_codegen->finalize(cgen_state_ptr->inlineNull(
output_ti_), ret);
310 return host_translation_map_ && !host_translation_map_->empty();
319 return reinterpret_cast<const int8_t*
>(host_translation_map_->data());
338 ? host_translation_map_->getVectorMap().size()
340 const size_t elem_size =
342 return num_elems * elem_size;
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_
void buildTranslationMap()
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t intval)
~StringDictionaryTranslationMgr()
int32_t domainStart() const
bool one_or_more_string_ops_is_null(const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
Data_Namespace::DataMgr * data_mgr_
const bool dest_type_is_string_
HOST DEVICE SQLTypes get_type() const
const StringDictionaryProxy::TranslationMap< Datum > * host_numeric_translation_map_
const SQLTypeInfo output_ti_
Classes representing a parse tree.
int get_logical_size() const
string_op_infos_(string_op_infos)
const bool has_null_string_op_
bool g_enable_smem_group_by true
std::string toString(const Executor::ExtModuleKinds &kind)
const shared::StringDictKey dest_string_dict_key_
int32_t minSourceStringId() const
ExecutorDeviceType device_type
dest_type_is_string_(false)
std::vector< const int8_t * > kernel_translation_maps_
const int8_t * data() const
static Data_Namespace::AbstractBuffer * allocGpuAbstractBuffer(Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
std::vector< T > const & getVectorMap() const
translate_intersection_only_(true)
const bool translate_intersection_only_
void copy_to_nvidia_gpu(Data_Namespace::DataMgr *data_mgr, CUdeviceptr dst, const void *src, const size_t num_bytes, const int device_id)
std::vector< Data_Namespace::AbstractBuffer * > device_buffers_
device_count_(device_count)
Allocate GPU memory using GpuBuffers via DataMgr.
void free(AbstractBuffer *buffer)
HOST DEVICE bool get_notnull() const
llvm::Value * codegen(llvm::Value *str_id_input, const SQLTypeInfo &input_ti, const bool add_nullcheck, const CompilationOptions &co) const
void createKernelBuffers()
has_null_string_op_(one_or_more_string_ops_is_null(string_op_infos))
const shared::StringDictKey source_string_dict_key_
const std::vector< StringOps_Namespace::StringOpInfo > string_op_infos_
memory_level_(memory_level)