OmniSciDB  343343d194
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 Importer_NS::anonymous_namespace{Importer.cpp}::double_value_at ( const TypedImportBuffer &  import_buffer,
const size_t  index 
)

Definition at line 2389 of file Importer.cpp.

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

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

2389  {
2390  const auto& ti = import_buffer.getTypeInfo();
2391  CHECK_EQ(kDOUBLE, ti.get_type());
2392  const auto values_buffer = import_buffer.getAsBytes();
2393  return reinterpret_cast<const double*>(may_alias_ptr(values_buffer))[index];
2394 }
#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 Importer_NS::anonymous_namespace{Importer.cpp}::float_value_at ( const TypedImportBuffer &  import_buffer,
const size_t  index 
)

Definition at line 2382 of file Importer.cpp.

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

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

2382  {
2383  const auto& ti = import_buffer.getTypeInfo();
2384  CHECK_EQ(kFLOAT, ti.get_type());
2385  const auto values_buffer = import_buffer.getAsBytes();
2386  return reinterpret_cast<const float*>(may_alias_ptr(values_buffer))[index];
2387 }
#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:

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 4151 of file Importer.cpp.

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

4153  {
4154  // get layer with specified name, or default to first layer
4155  OGRLayer* poLayer = nullptr;
4156  if (geo_layer_name.size()) {
4157  poLayer = poDS->GetLayerByName(geo_layer_name.c_str());
4158  if (poLayer == nullptr) {
4159  throw std::runtime_error("Layer '" + geo_layer_name + "' not found in " +
4160  file_name);
4161  }
4162  } else {
4163  poLayer = poDS->GetLayer(0);
4164  if (poLayer == nullptr) {
4165  throw std::runtime_error("No layers found in " + file_name);
4166  }
4167  }
4168  return *poLayer;
4169 }

+ Here is the caller graph for this function:

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

Definition at line 2351 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().

2351  {
2352  const auto& ti = import_buffer.getTypeInfo();
2353  const int8_t* values_buffer{nullptr};
2354  if (ti.is_string()) {
2355  CHECK_EQ(kENCODING_DICT, ti.get_compression());
2356  values_buffer = import_buffer.getStringDictBuffer();
2357  } else {
2358  values_buffer = import_buffer.getAsBytes();
2359  }
2360  CHECK(values_buffer);
2361  const int logical_size = ti.is_string() ? ti.get_size() : ti.get_logical_size();
2362  switch (logical_size) {
2363  case 1: {
2364  return values_buffer[index];
2365  }
2366  case 2: {
2367  return reinterpret_cast<const int16_t*>(values_buffer)[index];
2368  }
2369  case 4: {
2370  return reinterpret_cast<const int32_t*>(values_buffer)[index];
2371  }
2372  case 8: {
2373  return reinterpret_cast<const int64_t*>(values_buffer)[index];
2374  }
2375  default:
2376  LOG(FATAL) << "Unexpected size for shard key: " << logical_size;
2377  }
2378  UNREACHABLE();
2379  return 0;
2380 }
#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: