OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TransientStringLiteralsVisitor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, 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 #pragma once
18 
19 #include "Logger/Logger.h"
21 
23  public:
25 
26  void* visitConstant(const Analyzer::Constant* constant) const override {
27  if (constant->get_type_info().is_string() && !constant->get_is_null()) {
28  CHECK(constant->get_constval().stringval);
30  }
31  return nullptr;
32  }
33 
34  protected:
35  void* defaultResult() const override { return nullptr; }
36 
37  private:
39 };
40 
42  public:
43  int visitUOper(const Analyzer::UOper* uoper) const override {
44  const auto& expr_ti = uoper->get_type_info();
45  if (uoper->get_optype() == kCAST && expr_ti.is_string() &&
46  expr_ti.get_compression() == kENCODING_DICT) {
47  return expr_ti.get_comp_param();
48  }
49  return defaultResult();
50  }
51 
52  int visitCaseExpr(const Analyzer::CaseExpr* case_expr) const override {
53  const auto& expr_ti = case_expr->get_type_info();
54  if (expr_ti.is_string() && expr_ti.get_compression() == kENCODING_DICT) {
55  return expr_ti.get_comp_param();
56  }
57  return defaultResult();
58  }
59 
60  protected:
61  int defaultResult() const override { return -1; }
62 };
int visitCaseExpr(const Analyzer::CaseExpr *case_expr) const override
bool get_is_null() const
Definition: Analyzer.h:333
int visitUOper(const Analyzer::UOper *uoper) const override
Definition: sqldefs.h:49
void * visitConstant(const Analyzer::Constant *constant) const override
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
std::string * stringval
Definition: sqltypes.h:220
TransientStringLiteralsVisitor(StringDictionaryProxy *sdp)
Datum get_constval() const
Definition: Analyzer.h:334
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338
#define CHECK(condition)
Definition: Logger.h:209
int32_t getOrAddTransient(const std::string &str)
bool is_string() const
Definition: sqltypes.h:509
SQLOps get_optype() const
Definition: Analyzer.h:369