OmniSciDB  a5dc49c757
 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 1330 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 1499 of file heavydbTypes.h.

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

1499  {
1500  if (n_ != 1) {
1501 #ifndef __CUDACC__
1502  throw std::runtime_error(::typeName(this) +
1503  " extend failed: expected single index, got " +
1504  ::toString(n_));
1505 #endif
1506  }
1507  FlatBufferManager::Status status{};
1509  if (assign) {
1510  status = m.setItem(index_[0], data, size);
1511  if (status != FlatBufferManager::Status::Success) {
1512 #ifndef __CUDACC__
1513  throw std::runtime_error(
1514  ::typeName(this) +
1515  " extend failed: setItem failed with: " + ::toString(status));
1516 #endif
1517  }
1518  } else {
1519  status = m.concatItem(index_[0], data, size);
1520  if (status != FlatBufferManager::Status::Success) {
1521 #ifndef __CUDACC__
1522  throw std::runtime_error(
1523  ::typeName(this) +
1524  " extend failed: concatItem failed with: " + ::toString(status));
1525 #endif
1526  }
1527  }
1528  }
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 1530 of file heavydbTypes.h.

1530  {
1531  // TODO: check flatbuffer_ equality
1532  if (n_ != 1) {
1533 #ifndef __CUDACC__
1534  throw std::runtime_error(::typeName(this) +
1535  "extend failed: expected single index, got " +
1536  ::toString(n_));
1537 #endif
1538  }
1539  FlatBufferManager other_m{other.flatbuffer_};
1541  auto status = other_m.getItem<NESTED_ARRAY_NDIM>(other.index_, other.n_, item);
1542  if (status != FlatBufferManager::Status::Success) {
1543 #ifndef __CUDACC__
1544  throw std::runtime_error(::typeName(this) + " extend failed: getItem raised " +
1545  ::toString(status));
1546 #endif
1547  } else {
1549  if (assign) {
1550  status = this_m.setItem<NESTED_ARRAY_NDIM>(index_[0], item);
1551  if (status != FlatBufferManager::Status::Success) {
1552 #ifndef __CUDACC__
1553  throw std::runtime_error(::typeName(this) + " extend failed: setItem raised " +
1554  ::toString(status));
1555 #endif
1556  }
1557  } else {
1558  status = this_m.concatItem<NESTED_ARRAY_NDIM>(index_[0], item);
1559  if (status != FlatBufferManager::Status::Success) {
1560 #ifndef __CUDACC__
1561  throw std::runtime_error(::typeName(this) +
1562  " extend failed: concatItem raised " +
1563  ::toString(status));
1564 #endif
1565  }
1566  }
1567  }
1568  }
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:452
template<typename ItemType>
const ItemType flatbuffer::NestedArray< ItemType >::getItem ( const int64_t  index) const
inline

Definition at line 1450 of file heavydbTypes.h.

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

1450  {
1451  if constexpr (IS_VALUE_TYPE(ItemType)) {
1452  return getValue(index);
1453  } else {
1454  ItemType result{flatbuffer_, {}, n_ + 1};
1455  for (size_t i = 0; i < n_; i++) {
1456  result.index_[i] = index_[i];
1457  }
1458  result.index_[n_] = index;
1459  return result;
1460  }
1461  }
#define IS_VALUE_TYPE(T)
Definition: heavydbTypes.h:454
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 1372 of file heavydbTypes.h.

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

1376  {
1377  values = nullptr;
1378  nof_values = 0;
1379  is_null = true;
1380  value_size = 0;
1381  if constexpr (!IS_VALUE_TYPE(ItemType)) {
1382 #ifndef __CUDACC__
1383  ItemType item{};
1384  throw std::runtime_error(::typeName(this) +
1385  " getValuesBuffer failed: expected scalar type but got " +
1386  ::typeName(&item));
1387 #endif
1388  } else {
1389  FlatBufferManager::Status status{};
1392  status = m.getItem<NESTED_ARRAY_NDIM>(index_, n_, item);
1393  if (status != FlatBufferManager::Status::Success) {
1394 #ifndef __CUDACC__
1395  throw std::runtime_error(::typeName(this) +
1396  " getValuesBuffer failed: getItem returned " +
1397  ::toString(status));
1398 #endif
1399  }
1400  if (require_1d_item && item.nof_sizes != 0) {
1401 #ifndef __CUDACC__
1402  throw std::runtime_error(::typeName(this) +
1403  " &getValuesBuffer failed: expected 1-D item");
1404 #endif
1405  }
1406  values = item.values;
1407  nof_values = item.nof_values;
1408  is_null = item.is_null;
1409  value_size = m.getValueSize();
1410  }
1411  }
#define IS_VALUE_TYPE(T)
Definition: heavydbTypes.h:454
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:452

+ Here is the caller graph for this function:

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

Definition at line 1583 of file heavydbTypes.h.

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

1583  {
1585  const auto* ti = reinterpret_cast<const SQLTypeInfoLite*>(m.get_user_data_buffer());
1586  if (ti == nullptr) {
1587 #ifndef __CUDACC__
1588  throw std::runtime_error(::typeName(this) +
1589  " getTypeInfo failed: user data buffer is null");
1590 #endif
1591  }
1592  return ti;
1593  }
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 1415 of file heavydbTypes.h.

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

1415  {
1416  if constexpr (!IS_VALUE_TYPE(ItemType)) {
1417 #ifndef __CUDACC__
1418  ItemType item{};
1419  throw std::runtime_error(::typeName(this) +
1420  " &getValue failed: expected scalar type but got " +
1421  ::typeName(&item));
1422 #endif
1423  }
1424  ItemType* values;
1425  int64_t nof_values;
1426  bool is_null;
1427  getValuesBuffer(values, nof_values, is_null);
1428  if (is_null) {
1429 #ifndef __CUDACC__
1430  throw std::runtime_error(::typeName(this) +
1431  " &getValue failed: expected non-null item ");
1432 #endif
1433  }
1434  if (index < 0 || index >= nof_values) {
1435 #ifndef __CUDACC__
1436  throw std::runtime_error(
1437  ::typeName(this) + " &getValue failed: index (=" + std::to_string(index) +
1438  ") is out of range, expected 0 <= index < " + std::to_string(nof_values));
1439 #endif
1440  }
1441  return values[index];
1442  }
#define IS_VALUE_TYPE(T)
Definition: heavydbTypes.h:454
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 1362 of file heavydbTypes.h.

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

1365  {
1366  int8_t* _values;
1367  size_t value_size;
1368  getRawBuffer(_values, nof_values, value_size, is_null, require_1d_item);
1369  values = reinterpret_cast<ItemType*>(_values);
1370  }
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 1464 of file heavydbTypes.h.

1464  {
1466  bool is_null = false;
1467  auto status = m.isNull(index_[0], is_null);
1468 #ifndef __CUDACC__
1469  if (status != FlatBufferManager::Status::Success) {
1470  throw std::runtime_error(::typeName(this) + "isNull failed: isNull returned " +
1471  ::toString(status));
1472  }
1473 #endif
1474  return is_null;
1475  }
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 1478 of file heavydbTypes.h.

1478  {
1480  bool is_null = false;
1481  int64_t tmp_index[NESTED_ARRAY_NDIM];
1482  for (size_t i = 0; i < n_; i++) {
1483  tmp_index[i] = index_[i];
1484  }
1485  tmp_index[n_] = index;
1486  auto status =
1487  m.isNull<NESTED_ARRAY_NDIM>(tmp_index, static_cast<size_t>(n_ + 1), is_null);
1488 #ifndef __CUDACC__
1489  if (status != FlatBufferManager::Status::Success) {
1490  throw std::runtime_error(::typeName(this) +
1491  "isNull(index) failed: isNull returned " +
1492  ::toString(status));
1493  }
1494 #endif
1495  return is_null;
1496  }
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:452
template<typename ItemType>
NestedArray<ItemType>& flatbuffer::NestedArray< ItemType >::operator+= ( const NestedArray< ItemType > &  other)
inline

Definition at line 1578 of file heavydbTypes.h.

1578  {
1579  extend(other, /*assign=*/false);
1580  return *this;
1581  }
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 1571 of file heavydbTypes.h.

1571  {
1572  extend(other, /*assign=*/true);
1573  return *this;
1574  }
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 1445 of file heavydbTypes.h.

1445  {
1446  return getItem(index);
1447  }
const ItemType getItem(const int64_t index) const
template<typename ItemType>
size_t flatbuffer::NestedArray< ItemType >::size ( ) const
inline

Definition at line 1343 of file heavydbTypes.h.

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

1343  {
1345  size_t length;
1346  FlatBufferManager::Status status = FlatBufferManager::Status::NotImplementedError;
1347  status = m.getLength<NESTED_ARRAY_NDIM>(index_, n_, length);
1348  if (status != FlatBufferManager::Status::Success) {
1349 #ifndef __CUDACC__
1350  throw std::runtime_error(::typeName(this) + " size failed: getLength failed with " +
1351  ::toString(status));
1352 #endif
1353  return 0;
1354  }
1355  return length;
1356  }
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:452

+ 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 1358 of file heavydbTypes.h.

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

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

1596  {
1597  std::string result = ::typeName(this) + "(..., {";
1598  for (size_t i = 0; i < n_; i++) {
1599  result += std::to_string(index_[i]) + ", ";
1600  }
1601  result += "}, " + std::to_string(n_) + ")";
1602  return result;
1603  }
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: