OmniSciDB  4201147b46
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t > Struct Template Reference

#include <ArrowImporter.h>

+ Inheritance diagram for anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >:
+ Collaboration diagram for anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >:

Public Types

using VALUE_TYPE = int64_t
 

Public Member Functions

 ArrowValue (const DataBufferBase &data, const VALUE_TYPE &v)
 
template<typename DATA_TYPE >
 operator DATA_TYPE () const
 
- Public Member Functions inherited from anonymous_namespace{ArrowImporter.h}::ArrowValueBase< int64_t >
 ArrowValueBase (const DataBufferBase &data, const int64_t &v)
 
int64_t resolve_time (const int64_t &v, std::enable_if_t< enabled > *=0) const
 
int64_t resolve_time (const int64_t &v, std::enable_if_t<!enabled > *=0) const
 

Additional Inherited Members

- Public Attributes inherited from anonymous_namespace{ArrowImporter.h}::ArrowValueBase< int64_t >
const DataBufferBasedata
 
const int64_t v
 
const int32_t dimension
 

Detailed Description

template<>
struct anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >

Definition at line 368 of file ArrowImporter.h.

Member Typedef Documentation

using anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::VALUE_TYPE = int64_t

Definition at line 369 of file ArrowImporter.h.

Constructor & Destructor Documentation

anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::ArrowValue ( const DataBufferBase data,
const VALUE_TYPE v 
)
inline

Definition at line 370 of file ArrowImporter.h.

Member Function Documentation

template<typename DATA_TYPE >
anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::operator DATA_TYPE ( ) const
inlineexplicit

Definition at line 374 of file ArrowImporter.h.

References anonymous_namespace{ArrowImporter.h}::_precision_scale_lookup, Datum::bigintval, DatumToString(), kDATE, kTIMESTAMP, run_benchmark_import::result, and to_string().

374  {
375  if constexpr (std::is_integral<DATA_TYPE>::value) { // NOLINT
376  int64_t v = this->v;
377  if (std::is_same<int64_t, DATA_TYPE>::value) {
378  } else if (std::numeric_limits<DATA_TYPE>::lowest() < v &&
379  v <= std::numeric_limits<DATA_TYPE>::max()) {
380  } else {
381  data_conversion_error<DATA_TYPE>(v, data.cd, data.bad_rows_tracker);
382  }
383  if (data.cd->columnType.is_time()) {
384  v = this->resolve_time(v);
385  }
386  return v;
387  } else if constexpr (std::is_floating_point<DATA_TYPE>::value) { // NOLINT
388  return v;
389  } else if constexpr (std::is_same<DATA_TYPE, std::string>::value) { // NOLINT
390  const auto& type_id = data.arrow_type.id();
391  if (type_id == arrow::Type::DATE32 || type_id == arrow::Type::DATE64) {
392  auto& date_type = static_cast<const arrow::DateType&>(data.arrow_type);
393  SQLTypeInfo ti(kDATE);
394  Datum datum;
395  datum.bigintval =
396  date_type.unit() == arrow::DateUnit::MILLI ? v / kMicrosecondsInSecond : v;
397  return DatumToString(datum, ti);
398  } else if (type_id == arrow::Type::TIME32 || type_id == arrow::Type::TIME64 ||
399  type_id == arrow::Type::TIMESTAMP) {
400  auto& time_type = static_cast<const arrow::TimeType&>(data.arrow_type);
401  const auto result =
402  _precision_scale_lookup.find(std::make_pair(0, time_type.unit()));
403  int64_t divisor{1};
404  if (result != _precision_scale_lookup.end()) {
405  divisor = result->second.second;
406  }
408  Datum datum;
409  datum.bigintval = v / divisor;
410  auto time_str = DatumToString(datum, ti);
411  if (divisor != 1 && v % divisor) {
412  time_str += "." + std::to_string(v % divisor);
413  }
414  return time_str;
415  }
416  return std::to_string(v);
417  }
418  }
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:392
bool is_time() const
Definition: sqltypes.h:516
std::string to_string(char const *&&v)
static const std::map< std::pair< int32_t, arrow::TimeUnit::type >, std::pair< SQLOps, int64_t > > _precision_scale_lookup
int64_t bigintval
Definition: sqltypes.h:215
import_export::BadRowsTracker *const bad_rows_tracker
Definition: sqltypes.h:53
int64_t resolve_time(const int64_t &v, std::enable_if_t< enabled > *=0) const
SQLTypeInfo columnType

+ Here is the call graph for this function:


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