OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{ResultSetIteration.cpp}::GeoQueryOutputFetchHandler Struct Reference

Static Public Member Functions

static auto yieldGpuPtrFetcher ()
 
static auto yieldGpuDatumFetcher (Data_Namespace::DataMgr *data_mgr_ptr, const int device_id)
 
static auto yieldCpuDatumFetcher ()
 
template<typename... T>
static auto fetch (const SQLTypeInfo &geo_ti, const ResultSet::GeoReturnType return_type, Data_Namespace::DataMgr *data_mgr, const bool fetch_data_from_gpu, const int device_id, T &&...vals)
 

Detailed Description

Definition at line 940 of file ResultSetIteration.cpp.

Member Function Documentation

template<typename... T>
static auto anonymous_namespace{ResultSetIteration.cpp}::GeoQueryOutputFetchHandler::fetch ( const SQLTypeInfo geo_ti,
const ResultSet::GeoReturnType  return_type,
Data_Namespace::DataMgr data_mgr,
const bool  fetch_data_from_gpu,
const int  device_id,
T &&...  vals 
)
inlinestatic

Definition at line 964 of file ResultSetIteration.cpp.

References CHECK, ResultSet::GeoTargetValueGpuPtr, SQLTypeInfo::get_notnull(), SQLTypeInfo::get_type(), is_null(), Geospatial::is_null_point(), kARRAY, kDOUBLE, kENCODING_NONE, and kPOINT.

969  {
970  auto ad_arr_generator = [&](auto datum_fetcher) {
971  constexpr int num_vals = sizeof...(vals);
972  static_assert(
973  num_vals % 2 == 0,
974  "Must have consistent pointer/size pairs for lazy fetch of geo target values.");
975  const auto vals_vector = std::vector<int64_t>{vals...};
976 
977  std::array<VarlenDatumPtr, num_vals / 2> ad_arr;
978  size_t ctr = 0;
979  for (size_t i = 0; i < vals_vector.size(); i += 2, ctr++) {
980  if (vals_vector[i] == 0) {
981  // projected null
982  CHECK(!geo_ti.get_notnull());
983  ad_arr[ctr] = std::make_unique<ArrayDatum>(0, nullptr, true);
984  continue;
985  }
986  ad_arr[ctr] = datum_fetcher(vals_vector[i], vals_vector[i + 1]);
987  // All fetched datums come in with is_null set to false
988  if (!geo_ti.get_notnull()) {
989  bool is_null = false;
990  // Now need to set the nullness
991  if (ad_arr[ctr]->length == 0 || ad_arr[ctr]->pointer == NULL) {
992  is_null = true;
993  } else if (geo_ti.get_type() == kPOINT && ctr == 0 &&
994  is_null_point(geo_ti, ad_arr[ctr]->pointer, ad_arr[ctr]->length)) {
995  is_null = true; // recognizes compressed and uncompressed points
996  } else if (ad_arr[ctr]->length == 4 * sizeof(double)) {
997  // Bounds
998  auto dti = SQLTypeInfo(kARRAY, 0, 0, false, kENCODING_NONE, 0, kDOUBLE);
999  is_null = dti.is_null_fixlen_array(ad_arr[ctr]->pointer, ad_arr[ctr]->length);
1000  }
1001  ad_arr[ctr]->is_null = is_null;
1002  }
1003  }
1004  return ad_arr;
1005  };
1006 
1007  if (fetch_data_from_gpu) {
1009  return ad_arr_generator(yieldGpuPtrFetcher());
1010  } else {
1011  return ad_arr_generator(yieldGpuDatumFetcher(data_mgr, device_id));
1012  }
1013  } else {
1014  return ad_arr_generator(yieldCpuDatumFetcher());
1015  }
1016  }
bool is_null_point(const SQLTypeInfo &geo_ti, const int8_t *coords, const size_t coords_sz)
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
CONSTEXPR DEVICE bool is_null(const T &value)
static auto yieldGpuDatumFetcher(Data_Namespace::DataMgr *data_mgr_ptr, const int device_id)
#define CHECK(condition)
Definition: Logger.h:291
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398
std::unique_ptr< VarlenDatum > VarlenDatumPtr
std::unique_ptr< ArrayDatum > fetch_data_from_gpu(int64_t varlen_ptr, const int64_t length, Data_Namespace::DataMgr *data_mgr, const int device_id)

+ Here is the call graph for this function:

static auto anonymous_namespace{ResultSetIteration.cpp}::GeoQueryOutputFetchHandler::yieldCpuDatumFetcher ( )
inlinestatic

Definition at line 956 of file ResultSetIteration.cpp.

956  {
957  return [](const int64_t ptr, const int64_t length) -> VarlenDatumPtr {
958  // Just fetching the data from gpu, not checking geo nullness
959  return std::make_unique<VarlenDatum>(length, reinterpret_cast<int8_t*>(ptr), false);
960  };
961  }
std::unique_ptr< VarlenDatum > VarlenDatumPtr
static auto anonymous_namespace{ResultSetIteration.cpp}::GeoQueryOutputFetchHandler::yieldGpuDatumFetcher ( Data_Namespace::DataMgr data_mgr_ptr,
const int  device_id 
)
inlinestatic

Definition at line 948 of file ResultSetIteration.cpp.

References anonymous_namespace{ResultSetIteration.cpp}::fetch_data_from_gpu().

949  {
950  return [data_mgr_ptr, device_id](const int64_t ptr,
951  const int64_t length) -> VarlenDatumPtr {
952  return fetch_data_from_gpu(ptr, length, data_mgr_ptr, device_id);
953  };
954  }
std::unique_ptr< VarlenDatum > VarlenDatumPtr
std::unique_ptr< ArrayDatum > fetch_data_from_gpu(int64_t varlen_ptr, const int64_t length, Data_Namespace::DataMgr *data_mgr, const int device_id)

+ Here is the call graph for this function:

static auto anonymous_namespace{ResultSetIteration.cpp}::GeoQueryOutputFetchHandler::yieldGpuPtrFetcher ( )
inlinestatic

Definition at line 941 of file ResultSetIteration.cpp.

941  {
942  return [](const int64_t ptr, const int64_t length) -> VarlenDatumPtr {
943  // Just fetching the data from gpu, not checking geo nullness
944  return std::make_unique<VarlenDatum>(length, reinterpret_cast<int8_t*>(ptr), false);
945  };
946  }
std::unique_ptr< VarlenDatum > VarlenDatumPtr

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