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

#include <StringOpInfo.h>

+ Collaboration diagram for StringOps_Namespace::StringOpInfo:

Public Member Functions

 StringOpInfo (const SqlStringOpKind op_kind, const SQLTypeInfo &return_ti, 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
 
const SQLTypeInfogetReturnType () 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 SQLTypeInfo return_ti_
 
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 SQLTypeInfo return_ti,
const LiteralArgMap literal_arg_map 
)
inline

Definition at line 34 of file StringOpInfo.h.

37  : op_kind_(op_kind)
38  , return_ti_(return_ti)
39  , literal_arg_map_(literal_arg_map)
static size_t calcNumNullLiteralArgs(const LiteralArgMap &literal_arg_map)
const SqlStringOpKind op_kind_
Definition: StringOpInfo.h:76
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:78

Member Function Documentation

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

Definition at line 135 of file StringOpInfo.cpp.

References isLiteralArgNull().

135  {
136  size_t num_null_literals{0UL};
137  for (const auto& literal_arg : literal_arg_map) {
138  const auto& datum_type = literal_arg.second.first;
139  const auto& datum = literal_arg.second.second;
140  num_null_literals += StringOpInfo::isLiteralArgNull(datum_type, datum) ? 1UL : 0UL;
141  }
142  return num_null_literals;
143 }
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 103 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().

103  {
104  const auto literal_datum = literal_arg_map_.find(index);
105  CHECK(literal_datum != literal_arg_map_.end());
106  const auto& datum_type = literal_datum->second.first;
107  CHECK(IS_INTEGER(datum_type));
108  const auto& datum = literal_datum->second.second;
109  CHECK(!StringOpInfo::isLiteralArgNull(datum_type, datum));
110  const SQLTypeInfo ti(datum_type, false);
111  return extract_int_type_from_datum(datum, ti);
112 }
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:523
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:78
#define IS_INTEGER(T)
Definition: sqltypes.h:304
#define CHECK(condition)
Definition: Logger.h:291

+ 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 44 of file StringOpInfo.h.

References literal_arg_map_.

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

Definition at line 42 of file StringOpInfo.h.

References op_kind_.

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

42 { return op_kind_; }
const SqlStringOpKind op_kind_
Definition: StringOpInfo.h:76

+ Here is the caller graph for this function:

const SQLTypeInfo& StringOps_Namespace::StringOpInfo::getReturnType ( ) const
inline

Definition at line 58 of file StringOpInfo.h.

References return_ti_.

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

58 { return return_ti_; }

+ Here is the caller graph for this function:

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

Definition at line 94 of file StringOpInfo.cpp.

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

Referenced by StringOps_Namespace::gen_string_op().

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

+ 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 60 of file StringOpInfo.h.

References num_null_literals_.

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

60 { return num_null_literals_ > 0UL; }

+ Here is the caller graph for this function:

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

Definition at line 48 of file StringOpInfo.h.

References stringLiteralArgAtIdxExists().

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

48 { 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 76 of file StringOpInfo.cpp.

References CHECK, IS_INTEGER, and literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

76  {
77  const auto literal_itr = literal_arg_map_.find(index);
78  if (literal_itr == literal_arg_map_.end()) {
79  return false;
80  }
81  CHECK(IS_INTEGER(literal_itr->second.first));
82  return true;
83 }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:78
#define IS_INTEGER(T)
Definition: sqltypes.h:304
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

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

Definition at line 120 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<<().

120  {
121  if (datum_type == kNULLT) {
122  CHECK(datum.bigintval == 0);
123  return true;
124  }
125  if (IS_INTEGER(datum_type)) {
126  const SQLTypeInfo ti(datum_type, false);
127  return ti.is_null(datum);
128  }
129  CHECK(IS_STRING(datum_type));
130  // Currently null strings are empty strings
131  // Todo(todd): is this expressed centrally somewhere else in the codebase?
132  return datum.stringval == nullptr ? 1UL : 0UL;
133 }
int64_t bigintval
Definition: Datum.h:76
std::string * stringval
Definition: Datum.h:81
#define IS_INTEGER(T)
Definition: sqltypes.h:304
#define IS_STRING(T)
Definition: sqltypes.h:309
#define CHECK(condition)
Definition: Logger.h:291

+ 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 46 of file StringOpInfo.h.

References literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

46 { return literal_arg_map_.size(); }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:78

+ Here is the caller graph for this function:

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

Definition at line 54 of file StringOpInfo.h.

References hasVarStringLiteral(), and literal_arg_map_.

Referenced by StringOps_Namespace::gen_string_op().

54  {
55  return literal_arg_map_.size() - (hasVarStringLiteral() ? 1UL : 0UL);
56  }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:78

+ 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 85 of file StringOpInfo.cpp.

References CHECK, IS_STRING, and literal_arg_map_.

Referenced by hasVarStringLiteral().

85  {
86  const auto literal_itr = literal_arg_map_.find(index);
87  if (literal_itr == literal_arg_map_.end()) {
88  return false;
89  }
90  CHECK(IS_STRING(literal_itr->second.first));
91  return true;
92 }
const LiteralArgMap literal_arg_map_
Definition: StringOpInfo.h:78
#define IS_STRING(T)
Definition: sqltypes.h:309
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

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

Definition at line 114 of file StringOpInfo.cpp.

114  {
115  std::ostringstream oss;
116  oss << *this;
117  return oss.str();
118 }

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: " << string_op_info.getOpKind()
27  << "return_ti: " << toString(string_op_info.getReturnType().get_type())
28  << " dim: " << string_op_info.getReturnType().get_dimension()
29  << " scale: " << string_op_info.getReturnType().get_scale() << ", literals: [";
30  bool first_elem = true;
31  for (const auto& literal_arg : string_op_info.literal_arg_map_) {
32  if (!first_elem) {
33  stream << ", ";
34  }
35  first_elem = false;
36  const auto datum_type = literal_arg.second.first;
37  const auto& datum = literal_arg.second.second;
38  stream << "{slot: " << literal_arg.first /* slot/idx */ << ", type: "
39  << ::toString(datum_type) << ", value: ";
40  if (string_op_info.isLiteralArgNull(datum_type, literal_arg.second.second)) {
41  stream << "NULL";
42  } else if (IS_STRING(datum_type)) {
43  stream << *datum.stringval;
44  } else {
45  CHECK(IS_INTEGER(datum_type));
46  const SQLTypeInfo ti(datum_type, false);
47  stream << extract_int_type_from_datum(datum, ti);
48  }
49  stream << "}";
50  }
51  stream << "]";
52  return stream;
53 }
int64_t extract_int_type_from_datum(const Datum datum, const SQLTypeInfo &ti)
Definition: Datum.cpp:523
#define IS_INTEGER(T)
Definition: sqltypes.h:304
#define IS_STRING(T)
Definition: sqltypes.h:309
#define CHECK(condition)
Definition: Logger.h:291

Member Data Documentation

const size_t StringOps_Namespace::StringOpInfo::num_null_literals_
private

Definition at line 79 of file StringOpInfo.h.

Referenced by hasNullLiteralArg().

const SqlStringOpKind StringOps_Namespace::StringOpInfo::op_kind_
private

Definition at line 76 of file StringOpInfo.h.

Referenced by getOpKind().

const SQLTypeInfo StringOps_Namespace::StringOpInfo::return_ti_
private

Definition at line 77 of file StringOpInfo.h.

Referenced by getReturnType().


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