OmniSciDB  6686921089
 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 367 of file ArrowImporter.h.

Member Typedef Documentation

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

Definition at line 368 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 369 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 373 of file ArrowImporter.h.

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

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

+ Here is the call graph for this function:


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