OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StringOps_Namespace::StringOpInfo Struct Reference

#include <StringOpInfo.h>

Public Member Functions

 StringOpInfo (const SqlStringOpKind op_kind, const LiteralArgMap &literal_arg_map)
 
const SqlStringOpKindgetOpKind () const
 
const LiteralArgMapgetLiteralArgMap () const
 
size_t numLiterals () const
 
bool hasVarStringLiteral () const
 
bool intLiteralArgAtIdxExists (const size_t index) const
 
bool stringLiteralArgAtIdxExists (const size_t index) const
 
size_t numNonVariableLiterals () const
 
bool hasNullLiteralArg () const
 
std::string getStringLiteral (const size_t index) const
 
int64_t getIntLiteral (const size_t index) const
 
std::string toString () const
 

Static Private Member Functions

static bool isLiteralArgNull (const SQLTypes datum_type, const Datum &datum)
 
static size_t calcNumNullLiteralArgs (const LiteralArgMap &literal_arg_map)
 

Private Attributes

const SqlStringOpKind op_kind_
 
const LiteralArgMap literal_arg_map_
 
const size_t num_null_literals_
 

Friends

std::ostream & operator<< (std::ostream &stream, const StringOpInfo &string_op_info)
 

Detailed Description

Definition at line 32 of file StringOpInfo.h.

Constructor & Destructor Documentation

StringOps_Namespace::StringOpInfo::StringOpInfo ( const SqlStringOpKind  op_kind,
const LiteralArgMap literal_arg_map 
)
inline

Definition at line 34 of file StringOpInfo.h.

35  : op_kind_(op_kind)
36  , literal_arg_map_(literal_arg_map)
static size_t calcNumNullLiteralArgs(const LiteralArgMap &literal_arg_map)
const SqlStringOpKind op_kind_
Definition: StringOpInfo.h:71
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72

Member Function Documentation

size_t StringOps_Namespace::StringOpInfo::calcNumNullLiteralArgs ( const LiteralArgMap literal_arg_map)
staticprivate

Definition at line 158 of file StringOpInfo.cpp.

References isLiteralArgNull().

158  {
159  size_t num_null_literals{0UL};
160  for (const auto& literal_arg : literal_arg_map) {
161  const auto& datum_type = literal_arg.second.first;
162  const auto& datum = literal_arg.second.second;
163  num_null_literals += StringOpInfo::isLiteralArgNull(datum_type, datum) ? 1UL : 0UL;
164  }
165  return num_null_literals;
166 }
static bool isLiteralArgNull(const SQLTypes datum_type, const Datum &datum)

+ Here is the call graph for this function:

int64_t StringOps_Namespace::StringOpInfo::getIntLiteral ( const size_t  index) const

Definition at line 100 of file StringOpInfo.cpp.

References CHECK, extract_int_type_from_datum(), IS_INTEGER, isLiteralArgNull(), and literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

100  {
101  const auto literal_datum = literal_arg_map_.find(index);
102  CHECK(literal_datum != literal_arg_map_.end());
103  const auto& datum_type = literal_datum->second.first;
104  CHECK(IS_INTEGER(datum_type));
105  const auto& datum = literal_datum->second.second;
106  CHECK(!StringOpInfo::isLiteralArgNull(datum_type, datum));
107  const SQLTypeInfo ti(datum_type, false);
108  return extract_int_type_from_datum(datum, ti);
109 }
static bool isLiteralArgNull(const SQLTypes datum_type, const Datum &datum)
int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:455
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72
#define IS_INTEGER(T)
Definition: sqltypes.h:245
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const LiteralArgMap& StringOps_Namespace::StringOpInfo::getLiteralArgMap ( ) const
inline

Definition at line 41 of file StringOpInfo.h.

References literal_arg_map_.

41 { return literal_arg_map_; }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72
const SqlStringOpKind& StringOps_Namespace::StringOpInfo::getOpKind ( ) const
inline

Definition at line 39 of file StringOpInfo.h.

References op_kind_.

Referenced by StringOps_Namespace::gen_string_op(), and StringOps_Namespace::operator<<().

39 { return op_kind_; }
const SqlStringOpKind op_kind_
Definition: StringOpInfo.h:71

+ Here is the caller graph for this function:

std::string StringOps_Namespace::StringOpInfo::getStringLiteral ( const size_t  index) const

Definition at line 91 of file StringOpInfo.cpp.

References CHECK, IS_STRING, isLiteralArgNull(), and literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

91  {
92  const auto str_literal_datum = literal_arg_map_.find(index);
93  CHECK(str_literal_datum != literal_arg_map_.end());
94  CHECK(IS_STRING(str_literal_datum->second.first));
95  CHECK(!StringOpInfo::isLiteralArgNull(str_literal_datum->second.first,
96  str_literal_datum->second.second));
97  return *str_literal_datum->second.second.stringval;
98 }
static bool isLiteralArgNull(const SQLTypes datum_type, const Datum &datum)
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72
#define IS_STRING(T)
Definition: sqltypes.h:250
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool StringOps_Namespace::StringOpInfo::hasNullLiteralArg ( ) const
inline

Definition at line 55 of file StringOpInfo.h.

References num_null_literals_.

Referenced by StringOps_Namespace::apply_string_op_to_literals(), and StringOps_Namespace::gen_string_op().

55 { return num_null_literals_ > 0UL; }

+ Here is the caller graph for this function:

bool StringOps_Namespace::StringOpInfo::hasVarStringLiteral ( ) const
inline

Definition at line 45 of file StringOpInfo.h.

References stringLiteralArgAtIdxExists().

Referenced by StringOps_Namespace::apply_string_op_to_literals(), StringOps_Namespace::gen_string_op(), and numNonVariableLiterals().

45 { return stringLiteralArgAtIdxExists(0); }
bool stringLiteralArgAtIdxExists(const size_t index) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool StringOps_Namespace::StringOpInfo::intLiteralArgAtIdxExists ( const size_t  index) const

Definition at line 73 of file StringOpInfo.cpp.

References CHECK, IS_INTEGER, and literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

73  {
74  const auto literal_itr = literal_arg_map_.find(index);
75  if (literal_itr == literal_arg_map_.end()) {
76  return false;
77  }
78  CHECK(IS_INTEGER(literal_itr->second.first));
79  return true;
80 }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72
#define IS_INTEGER(T)
Definition: sqltypes.h:245
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

bool StringOps_Namespace::StringOpInfo::isLiteralArgNull ( const SQLTypes  datum_type,
const Datum datum 
)
staticprivate

Definition at line 143 of file StringOpInfo.cpp.

References Datum::bigintval, CHECK, IS_INTEGER, SQLTypeInfo::is_null(), IS_STRING, kNULLT, and Datum::stringval.

Referenced by calcNumNullLiteralArgs(), getIntLiteral(), getStringLiteral(), and StringOps_Namespace::operator<<().

143  {
144  if (datum_type == kNULLT) {
145  CHECK(datum.bigintval == 0);
146  return true;
147  }
148  if (IS_INTEGER(datum_type)) {
149  const SQLTypeInfo ti(datum_type, false);
150  return ti.is_null(datum);
151  }
152  CHECK(IS_STRING(datum_type));
153  // Currently null strings are empty strings
154  // Todo(todd): is this expressed centrally somewhere else in the codebase?
155  return datum.stringval == nullptr ? 1UL : 0UL;
156 }
int64_t bigintval
Definition: sqltypes.h:215
std::string * stringval
Definition: sqltypes.h:220
#define IS_INTEGER(T)
Definition: sqltypes.h:245
#define IS_STRING(T)
Definition: sqltypes.h:250
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t StringOps_Namespace::StringOpInfo::numLiterals ( ) const
inline

Definition at line 43 of file StringOpInfo.h.

References literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

43 { return literal_arg_map_.size(); }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72

+ Here is the caller graph for this function:

size_t StringOps_Namespace::StringOpInfo::numNonVariableLiterals ( ) const
inline

Definition at line 51 of file StringOpInfo.h.

References hasVarStringLiteral(), and literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

51  {
52  return literal_arg_map_.size() - (hasVarStringLiteral() ? 1UL : 0UL);
53  }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool StringOps_Namespace::StringOpInfo::stringLiteralArgAtIdxExists ( const size_t  index) const

Definition at line 82 of file StringOpInfo.cpp.

References CHECK, IS_STRING, and literal_arg_map_.

Referenced by hasVarStringLiteral().

82  {
83  const auto literal_itr = literal_arg_map_.find(index);
84  if (literal_itr == literal_arg_map_.end()) {
85  return false;
86  }
87  CHECK(IS_STRING(literal_itr->second.first));
88  return true;
89 }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:72
#define IS_STRING(T)
Definition: sqltypes.h:250
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

std::string StringOps_Namespace::StringOpInfo::toString ( ) const

Definition at line 111 of file StringOpInfo.cpp.

111  {
112  std::ostringstream oss;
113  oss << *this;
114  return oss.str();
115 }

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const StringOpInfo string_op_info 
)
friend

Definition at line 24 of file StringOpInfo.cpp.

24  {
25  stream << "StringOp("
26  << "operator: " << ::toString(string_op_info.getOpKind()) << ", literals: [";
27  bool first_elem = true;
28  for (const auto& literal_arg : string_op_info.literal_arg_map_) {
29  if (!first_elem) {
30  stream << ", ";
31  }
32  first_elem = false;
33  const auto datum_type = literal_arg.second.first;
34  const auto& datum = literal_arg.second.second;
35  stream << "{slot: " << literal_arg.first /* slot/idx */ << ", type: "
36  << ::toString(datum_type) << ", value: ";
37  if (string_op_info.isLiteralArgNull(datum_type, literal_arg.second.second)) {
38  stream << "NULL";
39  } else if (IS_STRING(datum_type)) {
40  stream << *datum.stringval;
41  } else {
42  CHECK(IS_INTEGER(datum_type));
43  const SQLTypeInfo ti(datum_type, false);
44  stream << extract_int_type_from_datum(datum, ti);
45  }
46  stream << "}";
47  }
48  stream << "]";
49  return stream;
50 }
int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:455
#define IS_INTEGER(T)
Definition: sqltypes.h:245
#define IS_STRING(T)
Definition: sqltypes.h:250
#define CHECK(condition)
Definition: Logger.h:222

Member Data Documentation

const size_t StringOps_Namespace::StringOpInfo::num_null_literals_
private

Definition at line 73 of file StringOpInfo.h.

Referenced by hasNullLiteralArg().

const SqlStringOpKind StringOps_Namespace::StringOpInfo::op_kind_
private

Definition at line 71 of file StringOpInfo.h.

Referenced by getOpKind().


The documentation for this struct was generated from the following files: