OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 , typename = enable_if_integral<DATA_TYPE>>
 operator const DATA_TYPE () const
 
template<typename DATA_TYPE , typename = enable_if_floating<DATA_TYPE>>
 operator DATA_TYPE () const
 
 operator const std::string () 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 359 of file ArrowImporter.h.

Member Typedef Documentation

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

Definition at line 360 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 361 of file ArrowImporter.h.

Member Function Documentation

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

Definition at line 364 of file ArrowImporter.h.

364  {
365  int64_t v = this->v;
366  if (std::is_same<int64_t, DATA_TYPE>::value) {
367  } else if (std::numeric_limits<DATA_TYPE>::lowest() < v &&
368  v <= std::numeric_limits<DATA_TYPE>::max()) {
369  } else {
370  data_conversion_error<DATA_TYPE>(v, data.cd, data.bad_rows_tracker);
371  }
372  if (data.cd->columnType.is_time()) {
373  v = this->resolve_time(v);
374  }
375  return v;
376  }
bool is_time() const
Definition: sqltypes.h:493
import_export::BadRowsTracker *const bad_rows_tracker
int64_t resolve_time(const int64_t &v, std::enable_if_t< enabled > *=0) const
SQLTypeInfo columnType
anonymous_namespace{ArrowImporter.h}::ArrowValue< int64_t >::operator const std::string ( ) const
inlineexplicit

Definition at line 381 of file ArrowImporter.h.

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

381  {
382  const auto& type_id = data.arrow_type.id();
383  if (type_id == arrow::Type::DATE32 || type_id == arrow::Type::DATE64) {
384  auto& date_type = static_cast<const arrow::DateType&>(data.arrow_type);
385  SQLTypeInfo ti(kDATE);
386  Datum datum{.bigintval = date_type.unit() == arrow::DateUnit::MILLI
388  : v};
389  return DatumToString(datum, ti);
390  } else if (type_id == arrow::Type::TIME32 || type_id == arrow::Type::TIME64 ||
391  type_id == arrow::Type::TIMESTAMP) {
392  auto& time_type = static_cast<const arrow::TimeType&>(data.arrow_type);
393  const auto result =
394  _precision_scale_lookup.find(std::make_pair(0, time_type.unit()));
395  int64_t divisor{1};
396  if (result != _precision_scale_lookup.end()) {
397  divisor = result->second.second;
398  }
400  Datum datum{.bigintval = v / divisor};
401  auto time_str = DatumToString(datum, ti);
402  if (divisor != 1 && v % divisor) {
403  time_str += "." + std::to_string(v % divisor);
404  }
405  return time_str;
406  }
407  return std::to_string(v);
408  }
std::string DatumToString(Datum d, const SQLTypeInfo &ti)
Definition: Datum.cpp:239
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:209
Definition: sqltypes.h:55

+ Here is the call graph for this function:

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

Definition at line 378 of file ArrowImporter.h.

378  {
379  return v;
380  }

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