OmniSciDB  04ee39c94c
anonymous_namespace{ArrowResultSetConverter.cpp} Namespace Reference

Functions

SQLTypes get_dict_index_type (const SQLTypeInfo &ti)
 
SQLTypeInfo get_dict_index_type_info (const SQLTypeInfo &ti)
 
SQLTypes get_physical_type (const SQLTypeInfo &ti)
 
template<typename TYPE , typename C_TYPE >
void create_or_append_value (const ScalarTargetValue &val_cty, std::shared_ptr< ValueArray > &values, const size_t max_size)
 
template<typename TYPE >
void create_or_append_validity (const ScalarTargetValue &value, const SQLTypeInfo &col_type, std::shared_ptr< std::vector< bool >> &null_bitmap, const size_t max_size)
 

Function Documentation

◆ create_or_append_validity()

template<typename TYPE >
void anonymous_namespace{ArrowResultSetConverter.cpp}::create_or_append_validity ( const ScalarTargetValue value,
const SQLTypeInfo col_type,
std::shared_ptr< std::vector< bool >> &  null_bitmap,
const size_t  max_size 
)

Definition at line 120 of file ArrowResultSetConverter.cpp.

References CHECK, SQLTypeInfoCore< TYPE_FACET_PACK >::get_notnull(), inline_fp_null_val(), inline_int_null_val(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_boolean(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_dict_encoded_string(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_fp(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_integer(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_time(), and UNREACHABLE.

123  {
124  if (col_type.get_notnull()) {
125  CHECK(!null_bitmap);
126  return;
127  }
128  auto pvalue = boost::get<TYPE>(&value);
129  CHECK(pvalue);
130  bool is_valid = false;
131  if (col_type.is_boolean()) {
132  is_valid = inline_int_null_val(col_type) != static_cast<int8_t>(*pvalue);
133  } else if (col_type.is_dict_encoded_string()) {
134  is_valid = inline_int_null_val(col_type) != static_cast<int32_t>(*pvalue);
135  } else if (col_type.is_integer() || col_type.is_time()) {
136  is_valid = inline_int_null_val(col_type) != static_cast<int64_t>(*pvalue);
137  } else if (col_type.is_fp()) {
138  is_valid = inline_fp_null_val(col_type) != static_cast<double>(*pvalue);
139  } else {
140  UNREACHABLE();
141  }
142 
143  if (!null_bitmap) {
144  null_bitmap = std::make_shared<std::vector<bool>>();
145  null_bitmap->reserve(max_size);
146  }
147  CHECK(null_bitmap);
148  null_bitmap->push_back(is_valid);
149 }
bool is_time() const
Definition: sqltypes.h:456
bool is_fp() const
Definition: sqltypes.h:454
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:330
#define UNREACHABLE()
Definition: Logger.h:231
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
bool is_integer() const
Definition: sqltypes.h:452
bool is_dict_encoded_string() const
Definition: sqltypes.h:476
bool is_boolean() const
Definition: sqltypes.h:457
#define CHECK(condition)
Definition: Logger.h:187
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
+ Here is the call graph for this function:

◆ create_or_append_value()

template<typename TYPE , typename C_TYPE >
void anonymous_namespace{ArrowResultSetConverter.cpp}::create_or_append_value ( const ScalarTargetValue val_cty,
std::shared_ptr< ValueArray > &  values,
const size_t  max_size 
)

Definition at line 103 of file ArrowResultSetConverter.cpp.

References CHECK.

105  {
106  auto pval_cty = boost::get<C_TYPE>(&val_cty);
107  CHECK(pval_cty);
108  auto val_ty = static_cast<TYPE>(*pval_cty);
109  if (!values) {
110  values = std::make_shared<ValueArray>(std::vector<TYPE>());
111  boost::get<std::vector<TYPE>>(*values).reserve(max_size);
112  }
113  CHECK(values);
114  auto values_ty = boost::get<std::vector<TYPE>>(values.get());
115  CHECK(values_ty);
116  values_ty->push_back(val_ty);
117 }
#define CHECK(condition)
Definition: Logger.h:187

◆ get_dict_index_type()

SQLTypes anonymous_namespace{ArrowResultSetConverter.cpp}::get_dict_index_type ( const SQLTypeInfo ti)
inline

Definition at line 49 of file ArrowResultSetConverter.cpp.

References CHECK, SQLTypeInfoCore< TYPE_FACET_PACK >::get_size(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_dict_encoded_string(), kBIGINT, kINT, kSMALLINT, and kTINYINT.

Referenced by ArrowResultSetConverter::initializeColumnBuilder().

49  {
51  switch (ti.get_size()) {
52  case 1:
53  return kTINYINT;
54  case 2:
55  return kSMALLINT;
56  case 4:
57  return kINT;
58  case 8:
59  return kBIGINT;
60  default:
61  CHECK(false);
62  }
63  return ti.get_type();
64 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:333
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
bool is_dict_encoded_string() const
Definition: sqltypes.h:476
#define CHECK(condition)
Definition: Logger.h:187
Definition: sqltypes.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_dict_index_type_info()

SQLTypeInfo anonymous_namespace{ArrowResultSetConverter.cpp}::get_dict_index_type_info ( const SQLTypeInfo ti)
inline

Definition at line 66 of file ArrowResultSetConverter.cpp.

References CHECK, SQLTypeInfoCore< TYPE_FACET_PACK >::get_notnull(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_size(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_dict_encoded_string(), kBIGINT, kINT, kSMALLINT, and kTINYINT.

Referenced by ArrowResultSetConverter::getArrowType().

66  {
68  switch (ti.get_size()) {
69  case 1:
70  return SQLTypeInfo(kTINYINT, ti.get_notnull());
71  case 2:
72  return SQLTypeInfo(kSMALLINT, ti.get_notnull());
73  case 4:
74  return SQLTypeInfo(kINT, ti.get_notnull());
75  case 8:
76  return SQLTypeInfo(kBIGINT, ti.get_notnull());
77  default:
78  CHECK(false);
79  }
80  return ti;
81 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:333
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:330
bool is_dict_encoded_string() const
Definition: sqltypes.h:476
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
#define CHECK(condition)
Definition: Logger.h:187
Definition: sqltypes.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_physical_type()

SQLTypes anonymous_namespace{ArrowResultSetConverter.cpp}::get_physical_type ( const SQLTypeInfo ti)
inline

Definition at line 83 of file ArrowResultSetConverter.cpp.

References CHECK, SQLTypeInfoCore< TYPE_FACET_PACK >::get_size(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), IS_INTEGER, kBIGINT, kINT, kSMALLINT, and kTINYINT.

Referenced by ArrowResultSetConverter::getArrowType(), and ArrowResultSetConverter::initializeColumnBuilder().

83  {
84  auto logical_type = ti.get_type();
85  if (IS_INTEGER(logical_type)) {
86  switch (ti.get_size()) {
87  case 1:
88  return kTINYINT;
89  case 2:
90  return kSMALLINT;
91  case 4:
92  return kINT;
93  case 8:
94  return kBIGINT;
95  default:
96  CHECK(false);
97  }
98  }
99  return logical_type;
100 }
HOST DEVICE int get_size() const
Definition: sqltypes.h:333
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
#define IS_INTEGER(T)
Definition: sqltypes.h:158
#define CHECK(condition)
Definition: Logger.h:187
Definition: sqltypes.h:47
+ Here is the call graph for this function:
+ Here is the caller graph for this function: