OmniSciDB  f17484ade4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flatbuffer::NestedArray< ItemType > Struct Template Reference

#include <heavydbTypes.h>

+ Inheritance diagram for flatbuffer::NestedArray< ItemType >:

Public Member Functions

size_t size () const
 
size_t size (const int64_t index) const
 
void getValuesBuffer (ItemType *&values, int64_t &nof_values, bool &is_null, bool require_1d_item=true) const
 
void getRawBuffer (int8_t *&values, int64_t &nof_values, size_t &value_size, bool &is_null, bool require_1d_item=true) const
 
ItemType & getValue (const int64_t index) const
 
const ItemType operator[] (const int64_t index) const
 
const ItemType getItem (const int64_t index) const
 
bool isNull () const
 
bool isNull (int64_t index) const
 
DEVICE void extend (const int8_t *data, const int32_t size, bool assign=false)
 
void extend (const NestedArray< ItemType > &other, bool assign=false)
 
NestedArray< ItemType > & operator= (const NestedArray< ItemType > &other)
 
NestedArray< ItemType > & operator+= (const NestedArray< ItemType > &other)
 
const SQLTypeInfoLitegetTypeInfo () const
 
std::string toString () const
 

Public Attributes

int8_t * flatbuffer_
 
int64_t index_ [NESTED_ARRAY_NDIM]
 
size_t n_ {0}
 

Detailed Description

template<typename ItemType>
struct flatbuffer::NestedArray< ItemType >

Definition at line 1323 of file heavydbTypes.h.

Member Function Documentation

template<typename ItemType>
DEVICE void flatbuffer::NestedArray< ItemType >::extend ( const int8_t *  data,
const int32_t  size,
bool  assign = false 
)
inline

Definition at line 1492 of file heavydbTypes.h.

Referenced by flatbuffer::NestedArray< char >::operator+=(), and flatbuffer::NestedArray< char >::operator=().

1492  {
1493  if (n_ != 1) {
1494 #ifndef __CUDACC__
1495  throw std::runtime_error(::typeName(this) +
1496  " extend failed: expected single index, got " +
1497  ::toString(n_));
1498 #endif
1499  }
1500  FlatBufferManager::Status status{};
1502  if (assign) {
1503  status = m.setItem(index_[0], data, size);
1504  if (status != FlatBufferManager::Status::Success) {
1505 #ifndef __CUDACC__
1506  throw std::runtime_error(
1507  ::typeName(this) +
1508  " extend failed: setItem failed with: " + ::toString(status));
1509 #endif
1510  }
1511  } else {
1512  status = m.concatItem(index_[0], data, size);
1513  if (status != FlatBufferManager::Status::Success) {
1514 #ifndef __CUDACC__
1515  throw std::runtime_error(
1516  ::typeName(this) +
1517  " extend failed: concatItem failed with: " + ::toString(status));
1518 #endif
1519  }
1520  }
1521  }
int64_t index_[NESTED_ARRAY_NDIM]
size_t size() const
std::string typeName(const T *v)
Definition: toString.h:106
std::string toString() const

+ Here is the caller graph for this function:

template<typename ItemType>
void flatbuffer::NestedArray< ItemType >::extend ( const NestedArray< ItemType > &  other,
bool  assign = false 
)
inline

Definition at line 1523 of file heavydbTypes.h.

1523  {
1524  // TODO: check flatbuffer_ equality
1525  if (n_ != 1) {
1526 #ifndef __CUDACC__
1527  throw std::runtime_error(::typeName(this) +
1528  "extend failed: expected single index, got " +
1529  ::toString(n_));
1530 #endif
1531  }
1532  FlatBufferManager other_m{other.flatbuffer_};
1534  auto status = other_m.getItem<NESTED_ARRAY_NDIM>(other.index_, other.n_, item);
1535  if (status != FlatBufferManager::Status::Success) {
1536 #ifndef __CUDACC__
1537  throw std::runtime_error(::typeName(this) + " extend failed: getItem raised " +
1538  ::toString(status));
1539 #endif
1540  } else {
1542  if (assign) {
1543  status = this_m.setItem<NESTED_ARRAY_NDIM>(index_[0], item);
1544  if (status != FlatBufferManager::Status::Success) {
1545 #ifndef __CUDACC__
1546  throw std::runtime_error(::typeName(this) + " extend failed: setItem raised " +
1547  ::toString(status));
1548 #endif
1549  }
1550  } else {
1551  status = this_m.concatItem<NESTED_ARRAY_NDIM>(index_[0], item);
1552  if (status != FlatBufferManager::Status::Success) {
1553 #ifndef __CUDACC__
1554  throw std::runtime_error(::typeName(this) +
1555  " extend failed: concatItem raised " +
1556  ::toString(status));
1557 #endif
1558  }
1559  }
1560  }
1561  }
int64_t index_[NESTED_ARRAY_NDIM]
std::string typeName(const T *v)
Definition: toString.h:106
std::string toString() const
#define NESTED_ARRAY_NDIM
Definition: heavydbTypes.h:450
template<typename ItemType>
const ItemType flatbuffer::NestedArray< ItemType >::getItem ( const int64_t  index) const
inline

Definition at line 1443 of file heavydbTypes.h.

Referenced by flatbuffer::NestedArray< char >::operator[](), flatbuffer::NestedArray< char >::size(), and Geo::GeoNestedArray< Point2D >::toCoordsWorker().

1443  {
1444  if constexpr (IS_VALUE_TYPE(ItemType)) {
1445  return getValue(index);
1446  } else {
1447  ItemType result{flatbuffer_, {}, n_ + 1};
1448  for (size_t i = 0; i < n_; i++) {
1449  result.index_[i] = index_[i];
1450  }
1451  result.index_[n_] = index;
1452  return result;
1453  }
1454  }
#define IS_VALUE_TYPE(T)
Definition: heavydbTypes.h:452
int64_t index_[NESTED_ARRAY_NDIM]
ItemType & getValue(const int64_t index) const

+ Here is the caller graph for this function:

template<typename ItemType>
void flatbuffer::NestedArray< ItemType >::getRawBuffer ( int8_t *&  values,
int64_t &  nof_values,
size_t &  value_size,
bool &  is_null,
bool  require_1d_item = true 
) const
inline

Definition at line 1365 of file heavydbTypes.h.

Referenced by Geo::GeoNestedArray< Point2D >::getPoint(), flatbuffer::NestedArray< char >::getValuesBuffer(), and Geo::GeoNestedArray< Point2D >::toCoordsWorker().

1369  {
1370  values = nullptr;
1371  nof_values = 0;
1372  is_null = true;
1373  value_size = 0;
1374  if constexpr (!IS_VALUE_TYPE(ItemType)) {
1375 #ifndef __CUDACC__
1376  ItemType item{};
1377  throw std::runtime_error(::typeName(this) +
1378  " getValuesBuffer failed: expected scalar type but got " +
1379  ::typeName(&item));
1380 #endif
1381  } else {
1382  FlatBufferManager::Status status{};
1385  status = m.getItem<NESTED_ARRAY_NDIM>(index_, n_, item);
1386  if (status != FlatBufferManager::Status::Success) {
1387 #ifndef __CUDACC__
1388  throw std::runtime_error(::typeName(this) +
1389  " getValuesBuffer failed: getItem returned " +
1390  ::toString(status));
1391 #endif
1392  }
1393  if (require_1d_item && item.nof_sizes != 0) {
1394 #ifndef __CUDACC__
1395  throw std::runtime_error(::typeName(this) +
1396  " &getValuesBuffer failed: expected 1-D item");
1397 #endif
1398  }
1399  values = item.values;
1400  nof_values = item.nof_values;
1401  is_null = item.is_null;
1402  value_size = m.getValueSize();
1403  }
1404  }
#define IS_VALUE_TYPE(T)
Definition: heavydbTypes.h:452
int64_t index_[NESTED_ARRAY_NDIM]
CONSTEXPR DEVICE bool is_null(const T &value)
std::string typeName(const T *v)
Definition: toString.h:106
std::string toString() const
#define NESTED_ARRAY_NDIM
Definition: heavydbTypes.h:450

+ Here is the caller graph for this function:

template<typename ItemType>
const SQLTypeInfoLite* flatbuffer::NestedArray< ItemType >::getTypeInfo ( ) const
inline

Definition at line 1576 of file heavydbTypes.h.

Referenced by Geo::GeoNestedArray< Point2D >::fromCoordsWorker(), Geo::GeoNestedArray< Point2D >::getPoint(), and Geo::GeoNestedArray< Point2D >::toCoordsWorker().

1576  {
1578  const auto* ti = reinterpret_cast<const SQLTypeInfoLite*>(m.get_user_data_buffer());
1579  if (ti == nullptr) {
1580 #ifndef __CUDACC__
1581  throw std::runtime_error(::typeName(this) +
1582  " getTypeInfo failed: user data buffer is null");
1583 #endif
1584  }
1585  return ti;
1586  }
std::string typeName(const T *v)
Definition: toString.h:106

+ Here is the caller graph for this function:

template<typename ItemType>
ItemType& flatbuffer::NestedArray< ItemType >::getValue ( const int64_t  index) const
inline

Definition at line 1408 of file heavydbTypes.h.

Referenced by flatbuffer::NestedArray< char >::getItem().

1408  {
1409  if constexpr (!IS_VALUE_TYPE(ItemType)) {
1410 #ifndef __CUDACC__
1411  ItemType item{};
1412  throw std::runtime_error(::typeName(this) +
1413  " &getValue failed: expected scalar type but got " +
1414  ::typeName(&item));
1415 #endif
1416  }
1417  ItemType* values;
1418  int64_t nof_values;
1419  bool is_null;
1420  getValuesBuffer(values, nof_values, is_null);
1421  if (is_null) {
1422 #ifndef __CUDACC__
1423  throw std::runtime_error(::typeName(this) +
1424  " &getValue failed: expected non-null item ");
1425 #endif
1426  }
1427  if (index < 0 || index >= nof_values) {
1428 #ifndef __CUDACC__
1429  throw std::runtime_error(
1430  ::typeName(this) + " &getValue failed: index (=" + std::to_string(index) +
1431  ") is out of range, expected 0 <= index < " + std::to_string(nof_values));
1432 #endif
1433  }
1434  return values[index];
1435  }
#define IS_VALUE_TYPE(T)
Definition: heavydbTypes.h:452
std::string to_string(char const *&&v)
CONSTEXPR DEVICE bool is_null(const T &value)
std::string typeName(const T *v)
Definition: toString.h:106
void getValuesBuffer(ItemType *&values, int64_t &nof_values, bool &is_null, bool require_1d_item=true) const

+ Here is the caller graph for this function:

template<typename ItemType>
void flatbuffer::NestedArray< ItemType >::getValuesBuffer ( ItemType *&  values,
int64_t &  nof_values,
bool &  is_null,
bool  require_1d_item = true 
) const
inline

Definition at line 1355 of file heavydbTypes.h.

Referenced by flatbuffer::NestedArray< char >::getValue().

1358  {
1359  int8_t* _values;
1360  size_t value_size;
1361  getRawBuffer(_values, nof_values, value_size, is_null, require_1d_item);
1362  values = reinterpret_cast<ItemType*>(_values);
1363  }
void getRawBuffer(int8_t *&values, int64_t &nof_values, size_t &value_size, bool &is_null, bool require_1d_item=true) const
CONSTEXPR DEVICE bool is_null(const T &value)

+ Here is the caller graph for this function:

template<typename ItemType>
bool flatbuffer::NestedArray< ItemType >::isNull ( ) const
inline

Definition at line 1457 of file heavydbTypes.h.

1457  {
1459  bool is_null = false;
1460  auto status = m.isNull(index_[0], is_null);
1461 #ifndef __CUDACC__
1462  if (status != FlatBufferManager::Status::Success) {
1463  throw std::runtime_error(::typeName(this) + "isNull failed: isNull returned " +
1464  ::toString(status));
1465  }
1466 #endif
1467  return is_null;
1468  }
int64_t index_[NESTED_ARRAY_NDIM]
CONSTEXPR DEVICE bool is_null(const T &value)
std::string typeName(const T *v)
Definition: toString.h:106
std::string toString() const
template<typename ItemType>
bool flatbuffer::NestedArray< ItemType >::isNull ( int64_t  index) const
inline

Definition at line 1471 of file heavydbTypes.h.

1471  {
1473  bool is_null = false;
1474  int64_t tmp_index[NESTED_ARRAY_NDIM];
1475  for (size_t i = 0; i < n_; i++) {
1476  tmp_index[i] = index_[i];
1477  }
1478  tmp_index[n_] = index;
1479  auto status =
1480  m.isNull<NESTED_ARRAY_NDIM>(tmp_index, static_cast<size_t>(n_ + 1), is_null);
1481 #ifndef __CUDACC__
1482  if (status != FlatBufferManager::Status::Success) {
1483  throw std::runtime_error(::typeName(this) +
1484  "isNull(index) failed: isNull returned " +
1485  ::toString(status));
1486  }
1487 #endif
1488  return is_null;
1489  }
int64_t index_[NESTED_ARRAY_NDIM]
CONSTEXPR DEVICE bool is_null(const T &value)
std::string typeName(const T *v)
Definition: toString.h:106
std::string toString() const
#define NESTED_ARRAY_NDIM
Definition: heavydbTypes.h:450
template<typename ItemType>
NestedArray<ItemType>& flatbuffer::NestedArray< ItemType >::operator+= ( const NestedArray< ItemType > &  other)
inline

Definition at line 1571 of file heavydbTypes.h.

1571  {
1572  extend(other, /*assign=*/false);
1573  return *this;
1574  }
DEVICE void extend(const int8_t *data, const int32_t size, bool assign=false)
template<typename ItemType>
NestedArray<ItemType>& flatbuffer::NestedArray< ItemType >::operator= ( const NestedArray< ItemType > &  other)
inline

Definition at line 1564 of file heavydbTypes.h.

1564  {
1565  extend(other, /*assign=*/true);
1566  return *this;
1567  }
DEVICE void extend(const int8_t *data, const int32_t size, bool assign=false)
template<typename ItemType>
const ItemType flatbuffer::NestedArray< ItemType >::operator[] ( const int64_t  index) const
inline

Definition at line 1438 of file heavydbTypes.h.

1438  {
1439  return getItem(index);
1440  }
const ItemType getItem(const int64_t index) const
template<typename ItemType>
size_t flatbuffer::NestedArray< ItemType >::size ( ) const
inline

Definition at line 1336 of file heavydbTypes.h.

Referenced by ct_make_multipolygon__cpu_(), ct_make_polygon3__cpu_(), and Geo::GeoNestedArray< Point2D >::toCoordsWorker().

1336  {
1338  size_t length;
1339  FlatBufferManager::Status status = FlatBufferManager::Status::NotImplementedError;
1340  status = m.getLength<NESTED_ARRAY_NDIM>(index_, n_, length);
1341  if (status != FlatBufferManager::Status::Success) {
1342 #ifndef __CUDACC__
1343  throw std::runtime_error(::typeName(this) + " size failed: getLength failed with " +
1344  ::toString(status));
1345 #endif
1346  return 0;
1347  }
1348  return length;
1349  }
int64_t index_[NESTED_ARRAY_NDIM]
std::string typeName(const T *v)
Definition: toString.h:106
std::string toString() const
#define NESTED_ARRAY_NDIM
Definition: heavydbTypes.h:450

+ Here is the caller graph for this function:

template<typename ItemType>
size_t flatbuffer::NestedArray< ItemType >::size ( const int64_t  index) const
inline

Definition at line 1351 of file heavydbTypes.h.

1351  {
1352  return getItem(index).size();
1353  }
const ItemType getItem(const int64_t index) const
template<typename ItemType>
std::string flatbuffer::NestedArray< ItemType >::toString ( ) const
inline

Definition at line 1589 of file heavydbTypes.h.

Referenced by flatbuffer::NestedArray< char >::extend(), Geo::GeoNestedArray< Point2D >::fromCoordsWorker(), flatbuffer::NestedArray< char >::getRawBuffer(), flatbuffer::NestedArray< char >::isNull(), and flatbuffer::NestedArray< char >::size().

1589  {
1590  std::string result = ::typeName(this) + "(..., {";
1591  for (size_t i = 0; i < n_; i++) {
1592  result += std::to_string(index_[i]) + ", ";
1593  }
1594  result += "}, " + std::to_string(n_) + ")";
1595  return result;
1596  }
int64_t index_[NESTED_ARRAY_NDIM]
std::string to_string(char const *&&v)
std::string typeName(const T *v)
Definition: toString.h:106

+ Here is the caller graph for this function:

Member Data Documentation


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