OmniSciDB  04ee39c94c
Importer_NS::anonymous_namespace{Importer.cpp} Namespace Reference

Functions

int64_t int_value_at (const TypedImportBuffer &import_buffer, const size_t index)
 
float float_value_at (const TypedImportBuffer &import_buffer, const size_t index)
 
double double_value_at (const TypedImportBuffer &import_buffer, const size_t index)
 
OGRLayer & getLayerWithSpecifiedName (const std::string &geo_layer_name, const OGRDataSourceUqPtr &poDS, const std::string &file_name)
 

Function Documentation

◆ double_value_at()

double Importer_NS::anonymous_namespace{Importer.cpp}::double_value_at ( const TypedImportBuffer import_buffer,
const size_t  index 
)

Definition at line 2337 of file Importer.cpp.

References CHECK_EQ, Importer_NS::TypedImportBuffer::getAsBytes(), Importer_NS::TypedImportBuffer::getTypeInfo(), and kDOUBLE.

Referenced by Importer_NS::Loader::distributeToShards().

2337  {
2338  const auto& ti = import_buffer.getTypeInfo();
2339  CHECK_EQ(kDOUBLE, ti.get_type());
2340  const auto values_buffer = import_buffer.getAsBytes();
2341  return reinterpret_cast<const double*>(may_alias_ptr(values_buffer))[index];
2342 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ float_value_at()

float Importer_NS::anonymous_namespace{Importer.cpp}::float_value_at ( const TypedImportBuffer import_buffer,
const size_t  index 
)

Definition at line 2330 of file Importer.cpp.

References CHECK_EQ, Importer_NS::TypedImportBuffer::getAsBytes(), Importer_NS::TypedImportBuffer::getTypeInfo(), and kFLOAT.

Referenced by Importer_NS::Loader::distributeToShards().

2330  {
2331  const auto& ti = import_buffer.getTypeInfo();
2332  CHECK_EQ(kFLOAT, ti.get_type());
2333  const auto values_buffer = import_buffer.getAsBytes();
2334  return reinterpret_cast<const float*>(may_alias_ptr(values_buffer))[index];
2335 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLayerWithSpecifiedName()

OGRLayer& Importer_NS::anonymous_namespace{Importer.cpp}::getLayerWithSpecifiedName ( const std::string &  geo_layer_name,
const OGRDataSourceUqPtr &  poDS,
const std::string &  file_name 
)

Definition at line 4121 of file Importer.cpp.

Referenced by Importer_NS::Importer::gdalToColumnDescriptors(), Importer_NS::Importer::importGDAL(), and Importer_NS::Importer::readMetadataSampleGDAL().

4123  {
4124  // get layer with specified name, or default to first layer
4125  OGRLayer* poLayer = nullptr;
4126  if (geo_layer_name.size()) {
4127  poLayer = poDS->GetLayerByName(geo_layer_name.c_str());
4128  if (poLayer == nullptr) {
4129  throw std::runtime_error("Layer '" + geo_layer_name + "' not found in " +
4130  file_name);
4131  }
4132  } else {
4133  poLayer = poDS->GetLayer(0);
4134  if (poLayer == nullptr) {
4135  throw std::runtime_error("No layers found in " + file_name);
4136  }
4137  }
4138  return *poLayer;
4139 }
+ Here is the caller graph for this function:

◆ int_value_at()

int64_t Importer_NS::anonymous_namespace{Importer.cpp}::int_value_at ( const TypedImportBuffer import_buffer,
const size_t  index 
)

Definition at line 2299 of file Importer.cpp.

References CHECK, CHECK_EQ, logger::FATAL, Importer_NS::TypedImportBuffer::getAsBytes(), Importer_NS::TypedImportBuffer::getStringDictBuffer(), Importer_NS::TypedImportBuffer::getTypeInfo(), kENCODING_DICT, LOG, and UNREACHABLE.

Referenced by Importer_NS::Loader::distributeToShards().

2299  {
2300  const auto& ti = import_buffer.getTypeInfo();
2301  const int8_t* values_buffer{nullptr};
2302  if (ti.is_string()) {
2303  CHECK_EQ(kENCODING_DICT, ti.get_compression());
2304  values_buffer = import_buffer.getStringDictBuffer();
2305  } else {
2306  values_buffer = import_buffer.getAsBytes();
2307  }
2308  CHECK(values_buffer);
2309  const int logical_size = ti.is_string() ? ti.get_size() : ti.get_logical_size();
2310  switch (logical_size) {
2311  case 1: {
2312  return values_buffer[index];
2313  }
2314  case 2: {
2315  return reinterpret_cast<const int16_t*>(values_buffer)[index];
2316  }
2317  case 4: {
2318  return reinterpret_cast<const int32_t*>(values_buffer)[index];
2319  }
2320  case 8: {
2321  return reinterpret_cast<const int64_t*>(values_buffer)[index];
2322  }
2323  default:
2324  LOG(FATAL) << "Unexpected size for shard key: " << logical_size;
2325  }
2326  UNREACHABLE();
2327  return 0;
2328 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define LOG(tag)
Definition: Logger.h:182
#define UNREACHABLE()
Definition: Logger.h:231
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:
+ Here is the caller graph for this function: