OmniSciDB  471d68cefb
 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 938 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 962 of file ResultSetIteration.cpp.

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

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

954  {
955  return [](const int64_t ptr, const int64_t length) -> VarlenDatumPtr {
956  // Just fetching the data from gpu, not checking geo nullness
957  return std::make_unique<VarlenDatum>(length, reinterpret_cast<int8_t*>(ptr), false);
958  };
959  }
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 946 of file ResultSetIteration.cpp.

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

947  {
948  return [data_mgr_ptr, device_id](const int64_t ptr,
949  const int64_t length) -> VarlenDatumPtr {
950  return fetch_data_from_gpu(ptr, length, data_mgr_ptr, device_id);
951  };
952  }
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 939 of file ResultSetIteration.cpp.

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

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