OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FlatBufferManager Struct Reference

#include <FlatBuffer.h>

Classes

struct  BaseWorker
 
struct  GeoPoint
 
struct  GeoPointWorker
 
struct  NestedArray
 
struct  NestedArrayItem
 
struct  NestedArrayWorker
 

Public Types

enum  ValueType {
  Bool8, Int8, Int16, Int32,
  Int64, UInt8, UInt16, UInt32,
  UInt64, Float32, Float64, PointInt32,
  PointFloat64
}
 
enum  Status {
  Success = 0, IndexError, SubIndexError, SizeError,
  FlatbufferSizeError, ItemAlreadySpecifiedError, ItemUnspecifiedError, UnexpectedNullItemError,
  ValuesBufferTooSmallError, SizesBufferTooSmallError, CompressedIndices2BufferTooSmallError, MemoryError,
  NotImplementedError, NotSupportedFormatError, InvalidUserDataError, DimensionalityError,
  TypeError, UserDataError, InconsistentSizesError, UnknownFormatError
}
 
typedef int32_t sizes_t
 
typedef int64_t offsets_t
 

Public Member Functions

int64_t getBufferSize () const
 
HOST DEVICE bool isNestedArray () const
 
HOST DEVICE size_t getValueSize () const
 
HOST DEVICE size_t getValuesBufferSize () const
 
HOST DEVICE const int8_t * getValuesBuffer () const
 
size_t getValuesCount () const
 
HOST DEVICE FlatBufferFormat format () const
 
HOST DEVICE int64_t itemsCount () const
 
HOST DEVICE int64_t valueByteSize () const
 
HOST DEVICE int64_t dtypeSize () const
 
HOST DEVICE BaseWorkergetBaseWorker ()
 
HOST DEVICE const BaseWorkergetBaseWorker () const
 
 FLATBUFFER_MANAGER_FORMAT_TOOLS (GeoPoint)
 
 FLATBUFFER_MANAGER_FORMAT_TOOLS (NestedArray)
 
Status initializeNestedArray (int64_t ndims, int64_t total_items_count, int64_t total_sizes_count, int64_t total_values_count, ValueType value_type, const int8_t *null_value_ptr, const int8_t *user_data_ptr, size_t user_data_size)
 
void initialize (FlatBufferFormat format_id, const int8_t *format_metadata_ptr)
 
HOST DEVICE size_t getNDims () const
 
int64_t get_max_nof_values () const
 
HOST DEVICE int64_t & get_storage_count ()
 
const int64_t & get_storage_count () const
 
int64_t get_values_buffer_size () const
 
HOST DEVICE int8_t * get_values ()
 
HOST DEVICE const int8_t * get_values () const
 
 FLATBUFFER_GET_BUFFER_METHODS (user_data_buffer, int8_t)
 
 FLATBUFFER_GET_BUFFER_METHODS (values_buffer, int8_t)
 
 FLATBUFFER_GET_BUFFER_METHODS (sizes_buffer, sizes_t)
 
 FLATBUFFER_GET_BUFFER_METHODS (values_offsets, offsets_t)
 
 FLATBUFFER_GET_BUFFER_METHODS (sizes_offsets, offsets_t)
 
HOST DEVICE const int8_t * getNullValuePtr () const
 
HOST DEVICE bool containsNullValue (const int8_t *value_ptr) const
 
HOST DEVICE sizes_tget_storage_indices ()
 
HOST DEVICE const sizes_tget_storage_indices () const
 
HOST DEVICE sizes_t get_storage_index (const int64_t index) const
 
template<size_t NDIM>
HOST DEVICE Status isNull (const int64_t index[NDIM], const size_t n, bool &is_null)
 
template<size_t NDIM = 1>
HOST DEVICE Status getLength (const int64_t index, size_t &length)
 
template<size_t NDIM>
HOST DEVICE Status getLength (const int64_t index[NDIM], const size_t n, size_t &length) const
 
template<size_t NDIM>
HOST DEVICE Status getItemWorker (const int64_t index[NDIM], const size_t n, int8_t *&values, int32_t &nof_values, int32_t *sizes_buffers[NDIM], int32_t sizes_lengths[NDIM], int32_t &nof_sizes, bool &is_null)
 
template<size_t NDIM>
HOST DEVICE Status getItem (const int64_t index, NestedArrayItem< NDIM > &result)
 
template<size_t NDIM>
HOST DEVICE Status getItem (const int64_t index[NDIM], const size_t n, NestedArrayItem< NDIM > &result)
 
template<size_t NDIM, bool check_sizes = true>
HOST DEVICE Status setItemWorker (const int64_t index, const int8_t *values, const int32_t nof_values, const int32_t *const sizes_buffers[NDIM], const int32_t sizes_lengths[NDIM], const int32_t nof_sizes)
 
template<size_t NDIM, bool check_sizes = true>
HOST DEVICE Status concatItemWorker (const int64_t index, const int8_t *values, const int32_t nof_values, const int32_t *const sizes_buffers[NDIM], const int32_t sizes_lengths[NDIM], const int32_t nof_sizes)
 
template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status setItem (const int64_t index, const int8_t *values_buf, const int32_t nof_values)
 
template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status setItem (const int64_t index, const int8_t *values_buf, const int32_t nof_values, const int32_t *sizes_buf, const int32_t nof_sizes)
 
template<size_t NDIM = 2, bool check_sizes = true>
HOST DEVICE Status setItem (const int64_t index, const int8_t *values_buf, const int32_t nof_values, const int32_t *sizes_buf, const int32_t nof_sizes, const int32_t *sizes_of_sizes_buf, const int32_t nof_sizes_of_sizes)
 
template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status setItem (const int64_t index, const NestedArrayItem< NDIM > &item)
 
template<size_t NDIM = 0, bool check_sizes = true>
HOST DEVICE Status concatItem (const int64_t index, const int8_t *values_buf, const int32_t nof_values)
 
template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status concatItem (const int64_t index, const NestedArrayItem< NDIM > &item)
 
Status getItem (const int64_t index, std::string &s, bool &is_null)
 
template<typename CT >
Status getItem (const int64_t index, std::vector< CT > &values, std::vector< int32_t > &sizes, bool &is_null)
 
template<typename CT >
Status getItem (const int64_t index, std::vector< CT > &values, std::vector< int32_t > &sizes, std::vector< int32_t > &sizes_of_sizes, bool &is_null)
 
Status setItem (const int64_t index, const std::string &s)
 
template<typename CT , size_t NDIM = 0>
Status setItem (const int64_t index, const std::vector< CT > &arr)
 
template<typename CT , size_t NDIM = 1, bool check_sizes = false>
Status setItem (const int64_t index, const std::vector< std::vector< CT >> &item)
 
template<typename CT , size_t NDIM = 2, bool check_sizes = false>
Status setItem (const int64_t index, const std::vector< std::vector< std::vector< CT >>> &item)
 
template<typename CT , size_t NDIM = 1, bool check_sizes = true>
Status setItem (const int64_t index, const std::vector< CT > &values, const std::vector< int32_t > &sizes)
 
template<typename CT , size_t NDIM = 2, bool check_sizes = true>
Status setItem (const int64_t index, const std::vector< CT > &values, const std::vector< int32_t > &sizes, const std::vector< int32_t > &sizes_of_sizes)
 
Status setItemOld (const int64_t index, const int8_t *src, const int64_t size, int8_t **dest=nullptr)
 
Status setItemNoValidation (const int64_t index, const int8_t *src, const int64_t size, int8_t **dest)
 
Status setEmptyItemNoValidation (int64_t index, int64_t size, int8_t **dest)
 
HOST DEVICE bool isSpecified (int64_t index) const
 
HOST DEVICE Status setNull (int64_t index)
 
HOST DEVICE Status setNullNoValidation (int64_t index)
 
HOST DEVICE Status isNull (int64_t index, bool &is_null) const
 
HOST DEVICE Status getItemOld (int64_t index, int64_t &size, int8_t *&dest, bool &is_null)
 
HOST DEVICE Status getItemOld (int64_t index, size_t &size, int8_t *&dest, bool &is_null)
 

Static Public Member Functions

static size_t get_size (ValueType type)
 
HOST static DEVICE bool isFlatBuffer (const void *buffer)
 
static int64_t getBufferSize (const void *buffer)
 
static int64_t compute_flatbuffer_size (FlatBufferFormat format_id, const int8_t *format_metadata_ptr)
 
static int64_t computeBufferSizeNestedArray (int64_t ndims, int64_t total_items_count, int64_t total_sizes_count, int64_t total_values_count, ValueType value_type, size_t user_data_size)
 

Public Attributes

int8_t * buffer
 

Detailed Description

Definition at line 334 of file FlatBuffer.h.

Member Typedef Documentation

Definition at line 392 of file FlatBuffer.h.

typedef int32_t FlatBufferManager::sizes_t

Definition at line 391 of file FlatBuffer.h.

Member Enumeration Documentation

Enumerator
Success 
IndexError 
SubIndexError 
SizeError 
FlatbufferSizeError 
ItemAlreadySpecifiedError 
ItemUnspecifiedError 
UnexpectedNullItemError 
ValuesBufferTooSmallError 
SizesBufferTooSmallError 
CompressedIndices2BufferTooSmallError 
MemoryError 
NotImplementedError 
NotSupportedFormatError 
InvalidUserDataError 
DimensionalityError 
TypeError 
UserDataError 
InconsistentSizesError 
UnknownFormatError 

Definition at line 495 of file FlatBuffer.h.

495  {
496  Success = 0,
497  IndexError,
499  SizeError,
507  MemoryError,
512  TypeError,
516  };
Enumerator
Bool8 
Int8 
Int16 
Int32 
Int64 
UInt8 
UInt16 
UInt32 
UInt64 
Float32 
Float64 
PointInt32 
PointFloat64 

Definition at line 335 of file FlatBuffer.h.

Member Function Documentation

static int64_t FlatBufferManager::compute_flatbuffer_size ( FlatBufferFormat  format_id,
const int8_t *  format_metadata_ptr 
)
inlinestatic

Definition at line 639 of file FlatBuffer.h.

References _align_to_int64(), FLATBUFFER_UNREACHABLE, and GeoPointFormatId.

Referenced by getFlatBufferSize(), and initialize().

640  {
641  int64_t flatbuffer_size = _align_to_int64(sizeof(FlatBufferManager::BaseWorker));
642  switch (format_id) {
643  case GeoPointFormatId: {
644  const auto format_metadata =
645  reinterpret_cast<const GeoPoint*>(format_metadata_ptr);
646  flatbuffer_size += _align_to_int64(sizeof(GeoPoint));
647  flatbuffer_size += _align_to_int64(sizeof(GeoPointWorker));
648  const auto itemsize =
649  2 * (format_metadata->is_geoint ? sizeof(int32_t) : sizeof(double));
650  flatbuffer_size += _align_to_int64(
651  itemsize * format_metadata->total_items_count); // values buffer size
652  break;
653  }
654  default:
656  }
657  flatbuffer_size += _align_to_int64(sizeof(int64_t)); // footer format id
658  return flatbuffer_size;
659  }
#define FLATBUFFER_UNREACHABLE()
Definition: FlatBuffer.h:316
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:329

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int64_t FlatBufferManager::computeBufferSizeNestedArray ( int64_t  ndims,
int64_t  total_items_count,
int64_t  total_sizes_count,
int64_t  total_values_count,
ValueType  value_type,
size_t  user_data_size 
)
inlinestatic

Definition at line 718 of file FlatBuffer.h.

References _align_to_int64(), and get_size().

Referenced by getFlatBufferSize(), and initializeNestedArray().

723  {
724  size_t value_size = get_size(value_type);
725  offsets_t flatbuffer_size = _align_to_int64(sizeof(FlatBufferManager::BaseWorker));
726  flatbuffer_size += _align_to_int64(sizeof(NestedArray));
727  flatbuffer_size += _align_to_int64(sizeof(NestedArrayWorker));
728  flatbuffer_size +=
729  _align_to_int64(value_size * (total_values_count + 1)); // values buffer
730  flatbuffer_size +=
731  _align_to_int64(sizeof(sizes_t) * total_sizes_count); // sizes buffer
732  flatbuffer_size +=
733  _align_to_int64(sizeof(offsets_t) * (total_items_count + 1)); // values offsets
734  flatbuffer_size += _align_to_int64(sizeof(offsets_t) *
735  (total_items_count * ndims + 1)); // sizes offsets
736  flatbuffer_size += _align_to_int64(
737  sizeof(sizes_t) * total_items_count); // storage indices, must use signed type
738  flatbuffer_size += _align_to_int64(user_data_size); // user data
739  flatbuffer_size += _align_to_int64(sizeof(int64_t)); // format id
740  return flatbuffer_size;
741  }
static size_t get_size(ValueType type)
Definition: FlatBuffer.h:355
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:329

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<size_t NDIM = 0, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::concatItem ( const int64_t  index,
const int8_t *  values_buf,
const int32_t  nof_values 
)
inline

Definition at line 1655 of file FlatBuffer.h.

1657  {
1658  const int32_t* const sizes_buffers[1] = {nullptr};
1659  int32_t sizes_lengths[1] = {0};
1660  return concatItemWorker<1, check_sizes>(index,
1661  values_buf,
1662  nof_values,
1663  sizes_buffers,
1664  sizes_lengths,
1665  0);
1666  }
template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::concatItem ( const int64_t  index,
const NestedArrayItem< NDIM > &  item 
)
inline

Definition at line 1669 of file FlatBuffer.h.

References FlatBufferManager::NestedArrayItem< NDIM >::is_null, FlatBufferManager::NestedArrayItem< NDIM >::nof_sizes, FlatBufferManager::NestedArrayItem< NDIM >::nof_values, FlatBufferManager::NestedArrayItem< NDIM >::sizes_buffers, FlatBufferManager::NestedArrayItem< NDIM >::sizes_lengths, Success, and FlatBufferManager::NestedArrayItem< NDIM >::values.

1670  {
1671  if (item.is_null) {
1672  return Success;
1673  }
1674  return concatItemWorker<NDIM, check_sizes>(index,
1675  item.values,
1676  item.nof_values,
1677  item.sizes_buffers,
1678  item.sizes_lengths,
1679  item.nof_sizes);
1680  }
template<size_t NDIM, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::concatItemWorker ( const int64_t  index,
const int8_t *  values,
const int32_t  nof_values,
const int32_t *const  sizes_buffers[NDIM],
const int32_t  sizes_lengths[NDIM],
const int32_t  nof_sizes 
)
inline

Definition at line 1498 of file FlatBuffer.h.

References DimensionalityError, FLATBUFFER_UNREACHABLE, format(), get_storage_indices(), getNDims(), getValueSize(), InconsistentSizesError, IndexError, itemsCount(), MemoryError, NestedArrayFormatId, NotImplementedError, NotSupportedFormatError, RETURN_ERROR, SizesBufferTooSmallError, Success, and ValuesBufferTooSmallError.

1503  {
1504  if (format() != NestedArrayFormatId) {
1506  }
1507  if (index < 0 || index >= itemsCount()) {
1509  }
1510  const int32_t ndims = getNDims();
1511  if (nof_sizes + 1 != ndims) {
1513  }
1514  auto* storage_indices = get_storage_indices();
1515  auto storage_index = storage_indices[index];
1516  if (storage_index == -1) { // unspecified, so setting the item
1517  return setItemWorker<NDIM, check_sizes>(index,
1518  values,
1519  nof_values,
1520  sizes_buffers,
1521  sizes_lengths,
1522  nof_sizes);
1523  }
1524  auto* worker = getNestedArrayWorker();
1525  if (storage_index != worker->specified_items_count - 1) {
1526  // index does not correspond to the last item, only the last
1527  // item can be concatenated atm.
1528  // TODO: to support intermediate item concatenation, we'll need
1529  // to move the content of sizes and values buffers of the
1530  // following items to make extra room for the to-be concatenated
1531  // item buffers.
1533  }
1534  auto* values_offsets = get_values_offsets();
1535  auto values_offset = values_offsets[storage_index];
1536  if (values_offset < 0) {
1537  // TODO: support concat to null
1539  }
1540  auto* values_buffer = get_values_buffer();
1541  auto* sizes_offsets = get_sizes_offsets();
1542  auto* sizes_buffer = get_sizes_buffer();
1543  const auto sizes_offset = sizes_offsets[storage_index * ndims];
1544  const auto* metadata = getNestedArrayMetadata();
1545  const auto valuesize = getValueSize();
1546  values_offset += sizes_buffer[sizes_offset];
1547  if (values_offset + nof_values > metadata->total_values_count) {
1549  }
1550  switch (ndims) {
1551  case 1:
1552  sizes_buffer[sizes_offset] += nof_values;
1553  break;
1554  case 2: {
1555  const auto sizes2_offset = sizes_offset + 1;
1556  if (sizes2_offset + sizes_buffer[sizes_offset] + sizes_lengths[0] > metadata->total_sizes_count) {
1558  }
1559  if constexpr (check_sizes) {
1560  // check consistency of sizes and nof_values
1561  int32_t sum_of_sizes = 0;
1562  for (int32_t i=0; i < sizes_lengths[0]; i++) {
1563  sum_of_sizes += sizes_buffers[0][i];
1564  }
1565  if (nof_values != sum_of_sizes) {
1567  }
1568  }
1569  if (memcpy(sizes_buffer + sizes2_offset + sizes_buffer[sizes_offset],
1570  sizes_buffers[0],
1571  sizes_lengths[0] * sizeof(sizes_t)) == nullptr) {
1573  }
1574  sizes_buffer[sizes_offset] += sizes_lengths[0];
1575  sizes_offsets[storage_index * ndims + 2] += sizes_lengths[0];
1576  }
1577  break;
1578  case 3: // TODO: concat multipolygons
1580  default:
1582  break;
1583  }
1584  if (nof_values > 0 && values != nullptr &&
1585  memcpy(values_buffer + values_offset * valuesize, values, nof_values * valuesize) == nullptr) {
1587  }
1588  values_offsets[storage_index + 1] += nof_values;
1589  return Success;
1590  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
#define FLATBUFFER_UNREACHABLE()
Definition: FlatBuffer.h:316
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE sizes_t * get_storage_indices()
Definition: FlatBuffer.h:1021
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604

+ Here is the call graph for this function:

HOST DEVICE bool FlatBufferManager::containsNullValue ( const int8_t *  value_ptr) const
inline

Definition at line 994 of file FlatBuffer.h.

References getNullValuePtr(), and getValueSize().

Referenced by getItemWorker().

994  {
995  const int8_t* null_value_ptr = getNullValuePtr();
996  if (null_value_ptr != nullptr) {
997  switch (getValueSize()) {
998  case 1:
999  return *null_value_ptr == *value_ptr;
1000  case 2:
1001  return *reinterpret_cast<const int16_t*>(null_value_ptr) ==
1002  *reinterpret_cast<const int16_t*>(value_ptr);
1003  case 4:
1004  return *reinterpret_cast<const int32_t*>(null_value_ptr) ==
1005  *reinterpret_cast<const int32_t*>(value_ptr);
1006  case 8:
1007  return *reinterpret_cast<const int64_t*>(null_value_ptr) ==
1008  *reinterpret_cast<const int64_t*>(value_ptr);
1009  case 16:
1010  return (*reinterpret_cast<const int64_t*>(null_value_ptr) ==
1011  *reinterpret_cast<const int64_t*>(value_ptr) &&
1012  *(reinterpret_cast<const int64_t*>(null_value_ptr) + 1) ==
1013  *(reinterpret_cast<const int64_t*>(value_ptr) + 1));
1014  default:
1015  break;
1016  }
1017  }
1018  return false;
1019  }
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
HOST DEVICE const int8_t * getNullValuePtr() const
Definition: FlatBuffer.h:987

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE int64_t FlatBufferManager::dtypeSize ( ) const
inline

Definition at line 628 of file FlatBuffer.h.

References format(), and GeoPointFormatId.

Referenced by getItemOld(), isNull(), setItemNoValidation(), setItemOld(), setNullNoValidation(), and writeBackCellGeoPoint().

628  { // TODO: use valueByteSize instead
629  switch (format()) {
630  case GeoPointFormatId:
631  return 2 * (getGeoPointMetadata()->is_geoint ? sizeof(int32_t) : sizeof(double));
632  default:
633  break;
634  }
635  return -1;
636  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FlatBufferManager::FLATBUFFER_GET_BUFFER_METHODS ( user_data_buffer  ,
int8_t   
)
FlatBufferManager::FLATBUFFER_GET_BUFFER_METHODS ( values_buffer  ,
int8_t   
)
FlatBufferManager::FLATBUFFER_GET_BUFFER_METHODS ( sizes_buffer  ,
sizes_t   
)
FlatBufferManager::FLATBUFFER_GET_BUFFER_METHODS ( values_offsets  ,
offsets_t   
)
FlatBufferManager::FLATBUFFER_GET_BUFFER_METHODS ( sizes_offsets  ,
offsets_t   
)
FlatBufferManager::FLATBUFFER_MANAGER_FORMAT_TOOLS ( GeoPoint  )
FlatBufferManager::FLATBUFFER_MANAGER_FORMAT_TOOLS ( NestedArray  )
HOST DEVICE FlatBufferFormat FlatBufferManager::format ( ) const
inline

Definition at line 598 of file FlatBuffer.h.

References buffer, and FlatBufferManager::BaseWorker::format_id.

Referenced by concatItemWorker(), dtypeSize(), get_max_nof_values(), get_storage_count(), get_storage_indices(), get_values(), get_values_buffer_size(), getItemOld(), isNestedArray(), isNull(), itemsCount(), setItemNoValidation(), setItemOld(), setItemWorker(), setNull(), setNullNoValidation(), and valueByteSize().

598  {
599  const auto* base = reinterpret_cast<const BaseWorker*>(buffer);
600  return base->format_id;
601  }

+ Here is the caller graph for this function:

int64_t FlatBufferManager::get_max_nof_values ( ) const
inline

Definition at line 876 of file FlatBuffer.h.

References format(), and GeoPointFormatId.

876  {
877  switch (format()) {
878  case GeoPointFormatId:
879  return getGeoPointMetadata()->total_items_count;
880  default:
881  break;
882  }
883  return -1;
884  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

static size_t FlatBufferManager::get_size ( ValueType  type)
inlinestatic

Definition at line 355 of file FlatBuffer.h.

References Bool8, FLATBUFFER_UNREACHABLE, Float32, Float64, Int16, Int32, Int64, Int8, PointFloat64, PointInt32, UInt16, UInt32, UInt64, and UInt8.

Referenced by computeBufferSizeNestedArray(), and initializeNestedArray().

355  {
356  switch (type) {
357  case Bool8:
358  case Int8:
359  case UInt8:
360  return 1;
361  case Int16:
362  case UInt16:
363  return 2;
364  case Int32:
365  case UInt32:
366  case Float32:
367  return 4;
368  case Int64:
369  case UInt64:
370  case Float64:
371  case PointInt32:
372  return 8;
373  case PointFloat64:
374  return 16;
375  }
377  return 0;
378  }
#define FLATBUFFER_UNREACHABLE()
Definition: FlatBuffer.h:316

+ Here is the caller graph for this function:

HOST DEVICE int64_t& FlatBufferManager::get_storage_count ( )
inline

Definition at line 888 of file FlatBuffer.h.

References format(), and GeoPointFormatId.

888  {
889  switch (format()) {
890  case GeoPointFormatId:
891  return getGeoPointMetadata()->total_items_count;
892  default:
893  break;
894  }
895  static int64_t dummy_storage_count = -1;
896  return dummy_storage_count;
897  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

const int64_t& FlatBufferManager::get_storage_count ( ) const
inline

Definition at line 900 of file FlatBuffer.h.

References format(), and GeoPointFormatId.

900  {
901  switch (format()) {
902  case GeoPointFormatId:
903  return getGeoPointMetadata()->total_items_count;
904  default:
905  break;
906  }
907  static int64_t dummy = -1;
908  return dummy;
909  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

HOST DEVICE sizes_t FlatBufferManager::get_storage_index ( const int64_t  index) const
inline

Definition at line 1045 of file FlatBuffer.h.

References get_storage_indices().

Referenced by getItemWorker(), getLength(), and isNull().

1045  {
1046  return get_storage_indices()[index];
1047  }
HOST DEVICE sizes_t * get_storage_indices()
Definition: FlatBuffer.h:1021

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE sizes_t* FlatBufferManager::get_storage_indices ( )
inline

Definition at line 1021 of file FlatBuffer.h.

References buffer, format(), and NestedArrayFormatId.

Referenced by concatItemWorker(), get_storage_index(), initializeNestedArray(), isSpecified(), setItemWorker(), and setNull().

1021  {
1022  offsets_t offset = 0;
1023  switch (format()) {
1024  case NestedArrayFormatId:
1025  offset = getNestedArrayWorker()->storage_indices_offset;
1026  break;
1027  default:
1028  return nullptr;
1029  }
1030  return reinterpret_cast<sizes_t*>(buffer + offset);
1031  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE const sizes_t* FlatBufferManager::get_storage_indices ( ) const
inline

Definition at line 1033 of file FlatBuffer.h.

References buffer, format(), and NestedArrayFormatId.

1033  {
1034  offsets_t offset = 0;
1035  switch (format()) {
1036  case NestedArrayFormatId:
1037  offset = getNestedArrayWorker()->storage_indices_offset;
1038  break;
1039  default:
1040  return nullptr;
1041  }
1042  return reinterpret_cast<sizes_t*>(buffer + offset);
1043  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

HOST DEVICE int8_t* FlatBufferManager::get_values ( )
inline

Definition at line 930 of file FlatBuffer.h.

References buffer, format(), and GeoPointFormatId.

Referenced by getItemOld(), isNull(), setItemNoValidation(), and setNullNoValidation().

930  {
931  int64_t offset = 0;
932  switch (format()) {
933  case GeoPointFormatId:
934  offset = getGeoPointWorker()->values_offset;
935  break;
936  default:
937  return nullptr;
938  }
939  return buffer + offset;
940  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE const int8_t* FlatBufferManager::get_values ( ) const
inline

Definition at line 943 of file FlatBuffer.h.

References buffer, format(), and GeoPointFormatId.

943  {
944  int64_t offset = 0;
945  switch (format()) {
946  case GeoPointFormatId:
947  offset = getGeoPointWorker()->values_offset;
948  break;
949  default:
950  return nullptr;
951  }
952  return buffer + offset;
953  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

int64_t FlatBufferManager::get_values_buffer_size ( ) const
inline

Definition at line 913 of file FlatBuffer.h.

References _align_to_int64(), format(), and GeoPointFormatId.

913  {
914  switch (format()) {
915  case GeoPointFormatId: {
916  const auto* metadata = getGeoPointMetadata();
917  const auto itemsize =
918  2 * (metadata->is_geoint ? sizeof(int32_t) : sizeof(double));
919  return _align_to_int64(itemsize * metadata->total_items_count);
920  }
921  default:
922  break;
923  }
924  static int64_t dummy = -1;
925  return dummy;
926  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:329

+ Here is the call graph for this function:

HOST DEVICE BaseWorker* FlatBufferManager::getBaseWorker ( )
inline

Definition at line 661 of file FlatBuffer.h.

References buffer.

Referenced by initialize(), and initializeNestedArray().

661  {
662  return reinterpret_cast<FlatBufferManager::BaseWorker*>(buffer);
663  }

+ Here is the caller graph for this function:

HOST DEVICE const BaseWorker* FlatBufferManager::getBaseWorker ( ) const
inline

Definition at line 664 of file FlatBuffer.h.

References buffer.

664  {
665  return reinterpret_cast<const BaseWorker*>(buffer);
666  }
static int64_t FlatBufferManager::getBufferSize ( const void *  buffer)
inlinestatic

Definition at line 553 of file FlatBuffer.h.

References buffer, and isFlatBuffer().

Referenced by TableFunctionExecutionContext::launchCpuCode(), and synthesize_metadata_table_function().

553  {
554  if (isFlatBuffer(buffer)) {
555  return reinterpret_cast<const BaseWorker*>(buffer)->flatbuffer_size;
556  } else {
557  return -1;
558  }
559  }
HOST static DEVICE bool isFlatBuffer(const void *buffer)
Definition: FlatBuffer.h:528

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t FlatBufferManager::getBufferSize ( ) const
inline

Definition at line 563 of file FlatBuffer.h.

References buffer.

Referenced by ColumnFetcher::transferColumnIfNeeded().

563  {
564  return reinterpret_cast<const BaseWorker*>(buffer)->flatbuffer_size;
565  }

+ Here is the caller graph for this function:

template<size_t NDIM>
HOST DEVICE Status FlatBufferManager::getItem ( const int64_t  index,
NestedArrayItem< NDIM > &  result 
)
inline

Definition at line 1349 of file FlatBuffer.h.

References run_benchmark_import::result.

Referenced by getItem(), and writeBackCellArrayScalar().

1349  {
1350  const int64_t index_[NDIM] = {index};
1351  return getItem<NDIM>(index_, 1, result);
1352  }

+ Here is the caller graph for this function:

template<size_t NDIM>
HOST DEVICE Status FlatBufferManager::getItem ( const int64_t  index[NDIM],
const size_t  n,
NestedArrayItem< NDIM > &  result 
)
inline
Status FlatBufferManager::getItem ( const int64_t  index,
std::string &  s,
bool &  is_null 
)
inline

Definition at line 1682 of file FlatBuffer.h.

References getItem(), InconsistentSizesError, Int8, FlatBufferManager::NestedArrayItem< NDIM >::is_null, FlatBufferManager::NestedArrayItem< NDIM >::nof_sizes, FlatBufferManager::NestedArrayItem< NDIM >::nof_values, RETURN_ERROR, Success, TypeError, and FlatBufferManager::NestedArrayItem< NDIM >::values.

1682  {
1683  is_null = true;
1684  const auto* metadata = getNestedArrayMetadata();
1685  if (metadata->value_type != Int8) {
1687  }
1688  NestedArrayItem<1> item;
1689  Status status = getItem(index, item);
1690  if (status != Success) {
1691  return status;
1692  }
1693  if (item.nof_sizes != 0) {
1695  }
1696  if (!item.is_null) {
1697  s.assign(reinterpret_cast<const char*>(item.values), static_cast<size_t>(item.nof_values));
1698  is_null = false;
1699  }
1700  return status;
1701  }
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE Status getItem(const int64_t index, NestedArrayItem< NDIM > &result)
Definition: FlatBuffer.h:1349
CONSTEXPR DEVICE bool is_null(const T &value)

+ Here is the call graph for this function:

template<typename CT >
Status FlatBufferManager::getItem ( const int64_t  index,
std::vector< CT > &  values,
std::vector< int32_t > &  sizes,
bool &  is_null 
)
inline

Definition at line 1704 of file FlatBuffer.h.

References getItem(), getValueSize(), InconsistentSizesError, FlatBufferManager::NestedArrayItem< NDIM >::is_null, FlatBufferManager::NestedArrayItem< NDIM >::nof_sizes, FlatBufferManager::NestedArrayItem< NDIM >::nof_values, NotImplementedError, PointFloat64, PointInt32, RETURN_ERROR, FlatBufferManager::NestedArrayItem< NDIM >::sizes_buffers, FlatBufferManager::NestedArrayItem< NDIM >::sizes_lengths, Success, TypeError, and FlatBufferManager::NestedArrayItem< NDIM >::values.

1707  {
1708  if constexpr (!std::is_same<CT, uint8_t>::value) {
1709  if constexpr (std::is_same<CT, double>::value) {
1710  const auto* metadata = getNestedArrayMetadata();
1711  if (metadata->value_type != PointFloat64) {
1713  }
1714  } else if constexpr (std::is_same<CT, int32_t>::value) {
1715  const auto* metadata = getNestedArrayMetadata();
1716  if (metadata->value_type != PointInt32) {
1718  }
1719  } else {
1721  }
1722  }
1723  NestedArrayItem<2> item;
1724  Status status = getItem(index, item);
1725  if (status != Success) {
1726  return status;
1727  }
1728  if (item.is_null) {
1729  return Success;
1730  }
1731  if (item.nof_sizes != 1) {
1733  }
1734  const auto valuesize = getValueSize();
1735  const auto values_count = item.nof_values * valuesize / sizeof(CT);
1736  values.reserve(values_count);
1737  values.insert(values.end(),
1738  reinterpret_cast<CT*>(item.values),
1739  reinterpret_cast<CT*>(item.values) + values_count);
1740 
1741  sizes.reserve(item.sizes_lengths[0]);
1742  sizes.insert(sizes.end(),
1743  reinterpret_cast<sizes_t*>(item.sizes_buffers[0]),
1744  reinterpret_cast<sizes_t*>(item.sizes_buffers[0] + item.sizes_lengths[0] * sizeof(int32_t)));
1745  return Success;
1746  }
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE Status getItem(const int64_t index, NestedArrayItem< NDIM > &result)
Definition: FlatBuffer.h:1349

+ Here is the call graph for this function:

template<typename CT >
Status FlatBufferManager::getItem ( const int64_t  index,
std::vector< CT > &  values,
std::vector< int32_t > &  sizes,
std::vector< int32_t > &  sizes_of_sizes,
bool &  is_null 
)
inline

Definition at line 1749 of file FlatBuffer.h.

References getItem(), getValueSize(), InconsistentSizesError, FlatBufferManager::NestedArrayItem< NDIM >::is_null, FlatBufferManager::NestedArrayItem< NDIM >::nof_sizes, FlatBufferManager::NestedArrayItem< NDIM >::nof_values, NotImplementedError, PointFloat64, PointInt32, RETURN_ERROR, FlatBufferManager::NestedArrayItem< NDIM >::sizes_buffers, FlatBufferManager::NestedArrayItem< NDIM >::sizes_lengths, Success, TypeError, and FlatBufferManager::NestedArrayItem< NDIM >::values.

1753  {
1754  if constexpr (!std::is_same<CT, uint8_t>::value) {
1755  if constexpr (std::is_same<CT, double>::value) {
1756  const auto* metadata = getNestedArrayMetadata();
1757  if (metadata->value_type != PointFloat64) {
1759  }
1760  } else if constexpr (std::is_same<CT, int32_t>::value) {
1761  const auto* metadata = getNestedArrayMetadata();
1762  if (metadata->value_type != PointInt32) {
1764  }
1765  } else {
1767  }
1768  }
1769  NestedArrayItem<3> item;
1770  Status status = getItem(index, item);
1771  if (status != Success) {
1772  return status;
1773  }
1774  if (item.is_null) {
1775  return Success;
1776  }
1777  if (item.nof_sizes != 2) {
1779  }
1780  const auto valuesize = getValueSize();
1781  const auto values_count = item.nof_values * valuesize / sizeof(CT);
1782  values.reserve(values_count);
1783  values.insert(values.end(),
1784  reinterpret_cast<CT*>(item.values),
1785  reinterpret_cast<CT*>(item.values) + values_count);
1786 
1787  sizes.reserve(item.sizes_lengths[1]);
1788  sizes.insert(sizes.end(),
1789  reinterpret_cast<sizes_t*>(item.sizes_buffers[1]),
1790  reinterpret_cast<sizes_t*>(item.sizes_buffers[1] + item.sizes_lengths[1] * sizeof(int32_t)));
1791 
1792  sizes_of_sizes.reserve(item.sizes_lengths[0]);
1793  sizes_of_sizes.insert(sizes_of_sizes.end(),
1794  reinterpret_cast<sizes_t*>(item.sizes_buffers[0]),
1795  reinterpret_cast<sizes_t*>(item.sizes_buffers[0] + item.sizes_lengths[0] * sizeof(int32_t)));
1796  return Success;
1797 
1798  }
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE Status getItem(const int64_t index, NestedArrayItem< NDIM > &result)
Definition: FlatBuffer.h:1349

+ Here is the call graph for this function:

HOST DEVICE Status FlatBufferManager::getItemOld ( int64_t  index,
int64_t &  size,
int8_t *&  dest,
bool &  is_null 
)
inline

Definition at line 2140 of file FlatBuffer.h.

References dtypeSize(), format(), GeoPointFormatId, get_values(), IndexError, itemsCount(), RETURN_ERROR, Success, and UnknownFormatError.

Referenced by getItemOld().

2140  {
2141  if (index < 0 || index >= itemsCount()) {
2143  }
2144  switch (format()) {
2145  case GeoPointFormatId: {
2146  int8_t* values = get_values();
2147  int64_t itemsize = dtypeSize();
2148  size = itemsize;
2149  dest = values + index * itemsize;
2150  is_null = false;
2151  return Success;
2152  }
2153  default:
2154  break;
2155  }
2157  }
HOST DEVICE int64_t dtypeSize() const
Definition: FlatBuffer.h:628
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
CONSTEXPR DEVICE bool is_null(const T &value)
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604
HOST DEVICE int8_t * get_values()
Definition: FlatBuffer.h:930

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE Status FlatBufferManager::getItemOld ( int64_t  index,
size_t &  size,
int8_t *&  dest,
bool &  is_null 
)
inline

Definition at line 2160 of file FlatBuffer.h.

References getItemOld().

2160  {
2161  int64_t sz{0};
2162  Status status = getItemOld(index, sz, dest, is_null);
2163  size = sz;
2164  return status;
2165  }
HOST DEVICE Status getItemOld(int64_t index, int64_t &size, int8_t *&dest, bool &is_null)
Definition: FlatBuffer.h:2140
CONSTEXPR DEVICE bool is_null(const T &value)

+ Here is the call graph for this function:

template<size_t NDIM>
HOST DEVICE Status FlatBufferManager::getItemWorker ( const int64_t  index[NDIM],
const size_t  n,
int8_t *&  values,
int32_t &  nof_values,
int32_t *  sizes_buffers[NDIM],
int32_t  sizes_lengths[NDIM],
int32_t &  nof_sizes,
bool &  is_null 
)
inline

Definition at line 1141 of file FlatBuffer.h.

References containsNullValue(), DimensionalityError, FLATBUFFER_UNREACHABLE, get_storage_index(), getNDims(), getValueSize(), IndexError, isNestedArray(), itemsCount(), ItemUnspecifiedError, anonymous_namespace{Utm.h}::n, NotImplementedError, NotSupportedFormatError, RETURN_ERROR, SubIndexError, and Success.

1148  {
1149  values = nullptr;
1150  nof_values = 0;
1151  nof_sizes = 0;
1152  std::memset(sizes_buffers, 0, NDIM * sizeof(int32_t*));
1153  std::memset(sizes_lengths, 0, NDIM * sizeof(int32_t));
1154  is_null = true;
1155 
1156  if (!isNestedArray()) {
1158  }
1159 
1160  const size_t ndims = getNDims();
1161  if (n <= 0 || n > ndims + 1) {
1163  }
1164  // clang-format off
1165  /*
1166  multipolygon (ndims == 3):
1167 
1168  n == 0 means return a column of multipolygons: flatbuffer, getLenght returns
1169  itemsCount()
1170 
1171  n == 1 means return a multipolygon: values, sizes(=sizes_buffers[1]),
1172  sizes_of_sizes(=sizes_buffers[0]), getLength returns
1173  len(sizes_of_sizes)(=sizes_lengths[0])
1174 
1175  n == 2 means return a polygon: values, sizes, getLength
1176  returns len(sizes)
1177 
1178  n == 3 means return a linestring: values, getLength returns
1179  len(values)
1180 
1181  n == 4 means return a point: value, getLength returns 0 [NOTIMPL]
1182 
1183  polygon/multilinestring (ndims == 2):
1184 
1185  n == 0 means return a column of polygons/multilinestring:
1186  flatbuffer, getLenght returns itemsCount()
1187 
1188  n == 1 means return a polygon/multilinestring: values, sizes,
1189  getLength returns len(sizes)
1190 
1191  n == 2 means return a linestring: values, getLength
1192  returns len(values)
1193 
1194  n == 3 means return a point: value, getLength returns 0 [NOTIMPL]
1195 
1196  linestring/multipoint/array of scalars/textencodingnone (ndims == 1):
1197 
1198  n == 0 means return a column of linestring/multipoint:
1199  flatbuffer, getLenght returns itemsCount()
1200 
1201  n == 1 means return a linestring: values, getLength returns
1202  len(values)
1203 
1204  n == 2 means return a point: value, getLength returns 0 [NOTIMPL]
1205  */
1206  // clang-format off
1207  if (index[0] < 0 || index[0] >= itemsCount()) {
1208  // Callers may interpret the IndexError as a NULL value return
1209  return IndexError;
1210  }
1211  const auto storage_index = get_storage_index(index[0]);
1212  if (storage_index < 0) {
1213  return ItemUnspecifiedError;
1214  }
1215  const auto* values_offsets = get_values_offsets();
1216  const auto values_offset = values_offsets[storage_index];
1217  if (values_offset < 0) {
1218  return Success;
1219  }
1220  is_null = false;
1221  const auto* sizes_offsets = get_sizes_offsets();
1222  auto* sizes_buffer = get_sizes_buffer();
1223  auto* values_buffer = get_values_buffer();
1224  const auto valuesize = getValueSize();
1225  const auto next_values_offset = values_offsets[storage_index + 1];
1226 
1227  const auto sizes_offset = sizes_offsets[storage_index * ndims];
1228  nof_sizes = ndims - n;
1229  switch (n) {
1230  case 1: {
1231  if (next_values_offset < 0) {
1232  nof_values = -(next_values_offset + 1) - values_offset;
1233  } else {
1234  nof_values = next_values_offset - values_offset;
1235  }
1236  values = values_buffer + values_offset * valuesize;
1237  switch (ndims) {
1238  case 3: {
1239  const auto sizes2_offset = sizes_offsets[storage_index * ndims + 1];
1240  const auto sizes3_offset = sizes_offsets[storage_index * ndims + 2];
1241  sizes_buffers[0] = sizes_buffer + sizes2_offset;
1242  sizes_buffers[1] = sizes_buffer + sizes3_offset;
1243  sizes_lengths[0] = sizes_buffer[sizes_offset];
1244  sizes_lengths[1] = sizes_offsets[storage_index * ndims + 3] - sizes3_offset;
1245  break;
1246  }
1247  case 2: {
1248  const auto sizes2_offset = sizes_offsets[storage_index * ndims + 1];
1249  sizes_buffers[0] = sizes_buffer + sizes2_offset;
1250  sizes_lengths[0] = sizes_buffer[sizes_offset];
1251  break;
1252  }
1253  case 1:
1254  break;
1255  default:
1257  break;
1258  }
1259  break;
1260  }
1261  case 2: {
1262  const auto sizes2_offset = sizes_offsets[storage_index * ndims + 1];
1263  if (index[1] < 0 || index[1] >= sizes_buffer[sizes_offset]) {
1265  }
1266  offsets_t soffset = 0;
1267  for (int64_t i = 0; i < index[1]; i++) {
1268  soffset += sizes_buffer[sizes2_offset + i];
1269  }
1270  values = values_buffer + (values_offset + soffset) * valuesize;
1271  switch (ndims) {
1272  case 3: {
1273  const auto sizes3_offset = sizes_offsets[storage_index * ndims + 2];
1274  const sizes_t nsizes = sizes_buffer[sizes2_offset + index[1]];
1275  auto sizes_buf = sizes_buffer + sizes3_offset + soffset;
1276  sizes_buffers[0] = sizes_buf;
1277  sizes_lengths[0] = nsizes;
1278  nof_values = 0;
1279  for (int64_t i = 0; i < nsizes; i++) {
1280  nof_values += sizes_buf[i];
1281  }
1282  break;
1283  }
1284  case 2: {
1285  nof_values = sizes_buffer[sizes2_offset + index[1]];
1286  break;
1287  }
1288  case 1: {
1289  nof_values = 1;
1290  is_null = containsNullValue(values);
1291  break;
1292  }
1293  default:
1295  break;
1296  }
1297  break;
1298  }
1299  case 3: {
1300  if (ndims != 3) {
1302  }
1303  const auto sizes2_offset = sizes_offsets[storage_index * ndims + 1];
1304  const auto sizes3_offset = sizes_offsets[storage_index * ndims + 2];
1305  if (index[1] < 0 || index[1] >= sizes_buffer[sizes_offset]) {
1307  }
1308  if (index[2] < 0 || index[2] >= sizes_buffer[sizes2_offset + index[1]]) {
1310  }
1311 
1312  int64_t i3 = 0;
1313  int64_t soffset = 0;
1314  int64_t voffset = 0;
1315  for (int64_t i = 0; i < index[1]; i++) {
1316  auto size2 = sizes_buffer[sizes2_offset + i];
1317  soffset += size2;
1318  for (int64_t j = 0; j < size2; j++) {
1319  voffset += sizes_buffer[sizes3_offset + i3];
1320  i3++;
1321  }
1322  }
1323  for (int64_t j = 0; j < index[2]; j++) {
1324  voffset += sizes_buffer[sizes3_offset + i3];
1325  i3++;
1326  }
1327  values = values_buffer + (values_offset + voffset) * valuesize;
1328  nof_values = sizes_buffer[sizes3_offset + soffset + index[2]];
1329  break;
1330  }
1331  default:
1333  break;
1334  }
1335  return Success;
1336  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567
#define FLATBUFFER_UNREACHABLE()
Definition: FlatBuffer.h:316
HOST DEVICE bool containsNullValue(const int8_t *value_ptr) const
Definition: FlatBuffer.h:994
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE sizes_t get_storage_index(const int64_t index) const
Definition: FlatBuffer.h:1045
CONSTEXPR DEVICE bool is_null(const T &value)
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604
constexpr double n
Definition: Utm.h:38

+ Here is the call graph for this function:

template<size_t NDIM = 1>
HOST DEVICE Status FlatBufferManager::getLength ( const int64_t  index,
size_t &  length 
)
inline

Definition at line 1066 of file FlatBuffer.h.

1066  {
1067  const int64_t index_[NDIM] = {index};
1068  return getLength<NDIM>(index_, 1, length);
1069  }
template<size_t NDIM>
HOST DEVICE Status FlatBufferManager::getLength ( const int64_t  index[NDIM],
const size_t  n,
size_t &  length 
) const
inline

Definition at line 1074 of file FlatBuffer.h.

References DimensionalityError, get_storage_index(), getNDims(), IndexError, isNestedArray(), itemsCount(), ItemUnspecifiedError, NotImplementedError, NotSupportedFormatError, RETURN_ERROR, SubIndexError, and Success.

1076  {
1077  if (!isNestedArray()) {
1079  }
1080  const size_t ndims = getNDims();
1081  if (n == 0) {
1082  length = itemsCount();
1083  return Success;
1084  }
1085  if (n > ndims + 1) {
1087  }
1088  if (index[0] < 0 || index[0] >= itemsCount()) {
1089  // Callers may interpret the IndexError as a NULL value return
1090  return IndexError;
1091  }
1092  const auto storage_index = get_storage_index(index[0]);
1093  if (storage_index < 0) {
1094  return ItemUnspecifiedError;
1095  }
1096  const auto* values_offsets = get_values_offsets();
1097  const auto values_offset = values_offsets[storage_index];
1098  if (values_offset < 0) { // NULL item
1099  length = 0;
1100  return Success;
1101  }
1102  const auto* sizes_offsets = get_sizes_offsets();
1103  const auto* sizes_buffer = get_sizes_buffer();
1104  const auto sizes_offset = sizes_offsets[storage_index * ndims];
1105  switch (n) {
1106  case 1: {
1107  length = sizes_buffer[sizes_offset];
1108  } break;
1109  case 2: {
1110  const auto sizes2_offset = sizes_offsets[storage_index * ndims + 1];
1111  if (index[1] < 0 || index[1] >= sizes_buffer[sizes_offset]) {
1113  }
1114  length = sizes_buffer[sizes2_offset + index[1]];
1115  } break;
1116  case 3: {
1117  const auto sizes2_offset = sizes_offsets[storage_index * ndims + 1];
1118  const auto sizes3_offset = sizes_offsets[storage_index * ndims + 2];
1119  if (index[1] < 0 || index[1] >= sizes_buffer[sizes_offset]) {
1121  }
1122  if (index[2] < 0 || index[2] >= sizes_buffer[sizes2_offset + index[1]]) {
1124  }
1125  offsets_t soffset = 0;
1126  for (int64_t i = 0; i < index[1]; i++) {
1127  soffset += sizes_buffer[sizes2_offset + i];
1128  }
1129  length = sizes_buffer[sizes3_offset + soffset + index[2]];
1130  } break;
1131  default:
1133  break;
1134  }
1135  return Success;
1136  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE sizes_t get_storage_index(const int64_t index) const
Definition: FlatBuffer.h:1045
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604
constexpr double n
Definition: Utm.h:38

+ Here is the call graph for this function:

HOST DEVICE size_t FlatBufferManager::getNDims ( ) const
inline

Definition at line 866 of file FlatBuffer.h.

References FLATBUFFER_UNREACHABLE, and isNestedArray().

Referenced by concatItemWorker(), getItemWorker(), getLength(), setItem(), setItemWorker(), and setNull().

866  {
867  if (isNestedArray()) {
868  return getNestedArrayMetadata()->ndims;
869  }
871  return 0;
872  }
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567
#define FLATBUFFER_UNREACHABLE()
Definition: FlatBuffer.h:316

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE const int8_t* FlatBufferManager::getNullValuePtr ( ) const
inline

Definition at line 987 of file FlatBuffer.h.

References getValuesBufferSize(), and isNestedArray().

Referenced by containsNullValue().

987  {
988  if (isNestedArray()) {
989  return get_values_buffer() + getValuesBufferSize();
990  }
991  return nullptr;
992  }
HOST DEVICE size_t getValuesBufferSize() const
Definition: FlatBuffer.h:575
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE const int8_t* FlatBufferManager::getValuesBuffer ( ) const
inline

Definition at line 581 of file FlatBuffer.h.

References buffer.

581  {
582  const auto offset = getNestedArrayWorker()->values_buffer_offset;
583  return reinterpret_cast<const int8_t*>(buffer + offset);
584  }
HOST DEVICE size_t FlatBufferManager::getValuesBufferSize ( ) const
inline

Definition at line 575 of file FlatBuffer.h.

Referenced by getNullValuePtr().

575  {
576  const auto* metadata = getNestedArrayMetadata();
577  const auto* worker = getNestedArrayWorker();
578  return worker->value_size * metadata->total_values_count;
579  }

+ Here is the caller graph for this function:

size_t FlatBufferManager::getValuesCount ( ) const
inline

Definition at line 586 of file FlatBuffer.h.

586  {
587  const auto* worker = getNestedArrayWorker();
588  const auto* values_offsets = get_values_offsets();
589  const auto storage_index = worker->specified_items_count;
590  const auto values_offset = values_offsets[storage_index];
591  if (values_offset < 0) {
592  return -(values_offset + 1);
593  }
594  return values_offset;
595  }
HOST DEVICE size_t FlatBufferManager::getValueSize ( ) const
inline

Definition at line 571 of file FlatBuffer.h.

Referenced by concatItemWorker(), containsNullValue(), getItem(), getItemWorker(), setItem(), and setItemWorker().

571  {
572  return getNestedArrayWorker()->value_size;
573  }

+ Here is the caller graph for this function:

void FlatBufferManager::initialize ( FlatBufferFormat  format_id,
const int8_t *  format_metadata_ptr 
)
inline

Definition at line 833 of file FlatBuffer.h.

References _align_to_int64(), buffer, compute_flatbuffer_size(), FLATBUFFER_UNREACHABLE, GeoPointFormatId, getBaseWorker(), and NestedArrayFormatId.

Referenced by initializeFlatBuffer().

833  {
834  auto* base = getBaseWorker();
835  base->format_id = format_id;
836  base->flatbuffer_size = compute_flatbuffer_size(format_id, format_metadata_ptr);
837  base->format_metadata_offset = _align_to_int64(sizeof(FlatBufferManager::BaseWorker));
838  switch (format_id) {
839  case NestedArrayFormatId:
841  break;
842  case GeoPointFormatId: {
843  base->format_worker_offset =
844  base->format_metadata_offset + _align_to_int64(sizeof(GeoPoint));
845 
846  const auto* format_metadata =
847  reinterpret_cast<const GeoPoint*>(format_metadata_ptr);
848  auto* this_metadata = getGeoPointMetadata();
849  this_metadata->total_items_count = format_metadata->total_items_count;
850  this_metadata->input_srid = format_metadata->input_srid;
851  this_metadata->output_srid = format_metadata->output_srid;
852  this_metadata->is_geoint = format_metadata->is_geoint;
853 
854  auto* this_worker = getGeoPointWorker();
855  this_worker->values_offset =
856  base->format_worker_offset + _align_to_int64(sizeof(GeoPointWorker));
857  break;
858  }
859  }
860  ((int64_t*)buffer)[base->flatbuffer_size / sizeof(int64_t) - 1] =
861  static_cast<int64_t>(format_id);
862  }
#define FLATBUFFER_UNREACHABLE()
Definition: FlatBuffer.h:316
static int64_t compute_flatbuffer_size(FlatBufferFormat format_id, const int8_t *format_metadata_ptr)
Definition: FlatBuffer.h:639
HOST DEVICE BaseWorker * getBaseWorker()
Definition: FlatBuffer.h:661
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:329

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Status FlatBufferManager::initializeNestedArray ( int64_t  ndims,
int64_t  total_items_count,
int64_t  total_sizes_count,
int64_t  total_values_count,
ValueType  value_type,
const int8_t *  null_value_ptr,
const int8_t *  user_data_ptr,
size_t  user_data_size 
)
inline

Definition at line 743 of file FlatBuffer.h.

References _align_to_int64(), buffer, computeBufferSizeNestedArray(), FLATBUFFER_MANAGER_SET_OFFSET, FlatbufferSizeError, get_size(), get_storage_indices(), getBaseWorker(), isFlatBuffer(), MemoryError, NestedArrayFormatId, RETURN_ERROR, Success, and UnknownFormatError.

Referenced by initializeFlatBuffer().

750  {
751  auto* base = getBaseWorker();
752  base->format_id = NestedArrayFormatId;
753  size_t value_size = get_size(value_type);
754  base->flatbuffer_size = computeBufferSizeNestedArray(ndims,
755  total_items_count,
756  total_sizes_count,
757  total_values_count,
758  value_type,
759  user_data_size);
760  offsets_t offset = 0;
761  size_t previous_size = sizeof(FlatBufferManager::BaseWorker);
762  FLATBUFFER_MANAGER_SET_OFFSET(base, format_metadata, sizeof(NestedArray));
763  FLATBUFFER_MANAGER_SET_OFFSET(base, format_worker, sizeof(NestedArrayWorker));
764 
765  auto* metadata = getNestedArrayMetadata();
766  metadata->ndims = ndims;
767  metadata->total_items_count = total_items_count;
768  metadata->total_sizes_count = total_sizes_count;
769  metadata->total_values_count = total_values_count;
770  metadata->value_type = value_type;
771  metadata->user_data_size = user_data_size;
772 
773  auto* worker = getNestedArrayWorker();
774  worker->specified_items_count = 0;
775  worker->value_size = value_size;
776 
778  worker, values_buffer, value_size * (total_values_count + 1));
780  worker, sizes_buffer, sizeof(sizes_t) * total_sizes_count);
782  worker, values_offsets, sizeof(offsets_t) * (total_items_count + 1));
784  worker, sizes_offsets, sizeof(offsets_t) * (total_items_count * ndims + 1));
786  worker, storage_indices, sizeof(sizes_t) * total_items_count);
787  FLATBUFFER_MANAGER_SET_OFFSET(worker, user_data_buffer, user_data_size);
788 
789  if (base->flatbuffer_size !=
790  offset + _align_to_int64(previous_size) + _align_to_int64(sizeof(int64_t))) {
792  }
793 
794  offsets_t* values_offsets = get_values_offsets();
795  offsets_t* sizes_offsets = get_sizes_offsets();
796  values_offsets[0] = 0;
797  sizes_offsets[0] = 0;
798  sizes_t* storage_indices = get_storage_indices();
799  for (int i = 0; i < total_items_count; i++) {
800  storage_indices[i] = -1;
801  }
802 
803  // the last value in values_buffer stores a null value:
804  int8_t* null_value_buffer = get_values_buffer() + value_size * total_values_count;
805  if (null_value_ptr != nullptr) {
806  if (memcpy(null_value_buffer, null_value_ptr, value_size) == nullptr) {
808  }
809  } else {
810  if (memset(null_value_buffer, 0, value_size) == nullptr) {
812  }
813  }
814 
815  if (user_data_size > 0 && user_data_ptr != nullptr) {
816  int8_t* user_data_buffer = get_user_data_buffer();
817  if (memcpy(user_data_buffer, user_data_ptr, user_data_size) == nullptr) {
819  }
820  }
821 
822  ((int64_t*)buffer)[base->flatbuffer_size / sizeof(int64_t) - 1] =
823  static_cast<int64_t>(base->format_id);
824 
825  if (isFlatBuffer(buffer)) {
826  // make sure that initialization leads to a valid FlatBuffer
827  return Success;
828  }
830  }
static size_t get_size(ValueType type)
Definition: FlatBuffer.h:355
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE sizes_t * get_storage_indices()
Definition: FlatBuffer.h:1021
static int64_t computeBufferSizeNestedArray(int64_t ndims, int64_t total_items_count, int64_t total_sizes_count, int64_t total_values_count, ValueType value_type, size_t user_data_size)
Definition: FlatBuffer.h:718
HOST DEVICE BaseWorker * getBaseWorker()
Definition: FlatBuffer.h:661
#define FLATBUFFER_MANAGER_SET_OFFSET(OBJ, NAME, SIZE)
Definition: FlatBuffer.h:714
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:329
HOST static DEVICE bool isFlatBuffer(const void *buffer)
Definition: FlatBuffer.h:528

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST static DEVICE bool FlatBufferManager::isFlatBuffer ( const void *  buffer)
inlinestatic

Definition at line 528 of file FlatBuffer.h.

References buffer, FlatBufferManager::BaseWorker::format_id, GeoPointFormatId, and NestedArrayFormatId.

Referenced by TableFunctionManager::allocate_output_buffers(), ChunkIter_get_nth(), ChunkIter_get_nth_varlen(), getBufferSize(), ResultSet::getTargetValueFromBufferColwise(), getTargetValueFromFlatBuffer(), initializeNestedArray(), ResultSet::makeGeoTargetValue(), ResultSet::makeVarlenTargetValue(), synthesize_metadata_table_function(), ColumnFetcher::transferColumnIfNeeded(), and ColumnarResults::writeBackCell().

528  {
529  if (buffer) {
530  // warning: assume that buffer size is at least 8 bytes
531  const auto* base = reinterpret_cast<const BaseWorker*>(buffer);
532  FlatBufferFormat header_format = base->format_id;
533  switch (header_format) {
534  case NestedArrayFormatId:
535  case GeoPointFormatId: {
536  int64_t flatbuffer_size = base->flatbuffer_size;
537  if (flatbuffer_size > 0) {
538  FlatBufferFormat footer_format = static_cast<FlatBufferFormat>(
539  ((int64_t*)buffer)[flatbuffer_size / sizeof(int64_t) - 1]);
540  return footer_format == header_format;
541  }
542  break;
543  }
544  default:
545  break;
546  }
547  }
548  return false;
549  }
FlatBufferFormat
Definition: FlatBuffer.h:324

+ Here is the caller graph for this function:

HOST DEVICE bool FlatBufferManager::isNestedArray ( ) const
inline

Definition at line 567 of file FlatBuffer.h.

References format(), and NestedArrayFormatId.

Referenced by getItemWorker(), getLength(), getNDims(), getNullValuePtr(), isNull(), isSpecified(), and setNull().

567  {
568  return format() == NestedArrayFormatId;
569  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<size_t NDIM>
HOST DEVICE Status FlatBufferManager::isNull ( const int64_t  index[NDIM],
const size_t  n,
bool &  is_null 
)
inline

Definition at line 1052 of file FlatBuffer.h.

References FlatBufferManager::NestedArrayItem< NDIM >::is_null, isNestedArray(), anonymous_namespace{Utm.h}::n, NotSupportedFormatError, RETURN_ERROR, and Success.

1052  {
1053  if (isNestedArray()) {
1054  NestedArrayItem<NDIM> item;
1055  auto status = getItem<NDIM>(index, n, item);
1056  if (status != Success) {
1057  RETURN_ERROR(status);
1058  }
1059  is_null = item.is_null;
1060  return Success;
1061  }
1063  }
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
CONSTEXPR DEVICE bool is_null(const T &value)
constexpr double n
Definition: Utm.h:38

+ Here is the call graph for this function:

HOST DEVICE Status FlatBufferManager::isNull ( int64_t  index,
bool &  is_null 
) const
inline

Definition at line 2099 of file FlatBuffer.h.

References dtypeSize(), format(), GeoPointFormatId, get_storage_index(), get_values(), IndexError, isNestedArray(), itemsCount(), RETURN_ERROR, Success, and UnknownFormatError.

2099  {
2100  if (index < 0 || index >= itemsCount()) {
2102  }
2103  if (isNestedArray()) {
2104  const auto storage_index = get_storage_index(index);
2105  const auto* values_offsets = get_values_offsets();
2106  const auto values_offset = values_offsets[storage_index];
2107  is_null = values_offset < 0;
2108  return Success;
2109  }
2110  if (index < 0 || index >= itemsCount()) {
2112  }
2113  // To be deprecated in favor of NestedArray format:
2114  switch (format()) {
2115  case GeoPointFormatId: {
2116  const int8_t* values = get_values();
2117  const auto* metadata = getGeoPointMetadata();
2118  int64_t itemsize = dtypeSize();
2119  if (metadata->is_geoint) {
2120  // per Geospatial/CompressionRuntime.h:is_null_point_longitude_geoint32
2121  is_null = (*reinterpret_cast<const uint32_t*>(values + index * itemsize)) ==
2122  0x80000000U;
2123  } else {
2124  // per Shared/InlineNullValues.h:NULL_ARRAY_DOUBLE
2125  is_null = (*reinterpret_cast<const double*>(values + index * itemsize)) ==
2126  2 * DBL_MIN;
2127  }
2128  return Success;
2129  }
2130  default:
2131  break;
2132  }
2134  }
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567
HOST DEVICE int64_t dtypeSize() const
Definition: FlatBuffer.h:628
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE sizes_t get_storage_index(const int64_t index) const
Definition: FlatBuffer.h:1045
CONSTEXPR DEVICE bool is_null(const T &value)
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604
HOST DEVICE int8_t * get_values()
Definition: FlatBuffer.h:930

+ Here is the call graph for this function:

HOST DEVICE bool FlatBufferManager::isSpecified ( int64_t  index) const
inline

Definition at line 2017 of file FlatBuffer.h.

References get_storage_indices(), isNestedArray(), and itemsCount().

2017  {
2018  if (index < 0 || index >= itemsCount()) {
2019  return false;
2020  }
2021  if (isNestedArray()) {
2022  auto* storage_indices = get_storage_indices();
2023  return storage_indices[index] >= 0;
2024  }
2025  return false;
2026  }
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567
HOST DEVICE sizes_t * get_storage_indices()
Definition: FlatBuffer.h:1021
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604

+ Here is the call graph for this function:

HOST DEVICE int64_t FlatBufferManager::itemsCount ( ) const
inline

Definition at line 604 of file FlatBuffer.h.

References format(), GeoPointFormatId, and NestedArrayFormatId.

Referenced by concatItemWorker(), getItemOld(), getItemWorker(), getLength(), isNull(), isSpecified(), setItemOld(), setItemWorker(), and setNull().

604  {
605  switch (format()) {
606  case GeoPointFormatId:
607  return getGeoPointMetadata()->total_items_count;
608  case NestedArrayFormatId:
609  return getNestedArrayMetadata()->total_items_count;
610  default:
611  break;
612  }
613  return -1; // invalid value
614  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Status FlatBufferManager::setEmptyItemNoValidation ( int64_t  index,
int64_t  size,
int8_t **  dest 
)
inline

Definition at line 2013 of file FlatBuffer.h.

References setItemNoValidation().

2013  {
2014  return setItemNoValidation(index, nullptr, size, dest);
2015  }
Status setItemNoValidation(const int64_t index, const int8_t *src, const int64_t size, int8_t **dest)
Definition: FlatBuffer.h:1986

+ Here is the call graph for this function:

template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::setItem ( const int64_t  index,
const int8_t *  values_buf,
const int32_t  nof_values 
)
inline

Definition at line 1593 of file FlatBuffer.h.

Referenced by writeBackCellArrayScalar(), writeBackCellGeoNestedArray(), and writeBackCellTextEncodingNone().

1595  {
1596  const int32_t* const sizes_buffers[1] = {nullptr};
1597  int32_t sizes_lengths[1] = {0};
1598  return setItemWorker<1, check_sizes>(index,
1599  values_buf,
1600  nof_values,
1601  sizes_buffers,
1602  sizes_lengths,
1603  0);
1604  }

+ Here is the caller graph for this function:

template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::setItem ( const int64_t  index,
const int8_t *  values_buf,
const int32_t  nof_values,
const int32_t *  sizes_buf,
const int32_t  nof_sizes 
)
inline

Definition at line 1607 of file FlatBuffer.h.

1611  {
1612  const int32_t* const sizes_buffers[NDIM] = {sizes_buf};
1613  int32_t sizes_lengths[NDIM] = {nof_sizes};
1614  return setItemWorker<NDIM, check_sizes>(index,
1615  values_buf,
1616  nof_values,
1617  sizes_buffers,
1618  sizes_lengths,
1619  static_cast<int32_t>(NDIM));
1620  }
template<size_t NDIM = 2, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::setItem ( const int64_t  index,
const int8_t *  values_buf,
const int32_t  nof_values,
const int32_t *  sizes_buf,
const int32_t  nof_sizes,
const int32_t *  sizes_of_sizes_buf,
const int32_t  nof_sizes_of_sizes 
)
inline

Definition at line 1623 of file FlatBuffer.h.

1629  {
1630  const int32_t* const sizes_buffers[NDIM] = {sizes_of_sizes_buf, sizes_buf};
1631  int32_t sizes_lengths[NDIM] = {nof_sizes_of_sizes, nof_sizes};
1632  return setItemWorker<NDIM, check_sizes>(index,
1633  values_buf,
1634  nof_values,
1635  sizes_buffers,
1636  sizes_lengths,
1637  static_cast<int32_t>(NDIM));
1638  }
template<size_t NDIM = 1, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::setItem ( const int64_t  index,
const NestedArrayItem< NDIM > &  item 
)
inline

Definition at line 1641 of file FlatBuffer.h.

References FlatBufferManager::NestedArrayItem< NDIM >::is_null, FlatBufferManager::NestedArrayItem< NDIM >::nof_sizes, FlatBufferManager::NestedArrayItem< NDIM >::nof_values, FlatBufferManager::NestedArrayItem< NDIM >::sizes_buffers, FlatBufferManager::NestedArrayItem< NDIM >::sizes_lengths, Success, and FlatBufferManager::NestedArrayItem< NDIM >::values.

1642  {
1643  if (item.is_null) {
1644  return Success;
1645  }
1646  return setItemWorker<NDIM, check_sizes>(index,
1647  item.values,
1648  item.nof_values,
1649  item.sizes_buffers,
1650  item.sizes_lengths,
1651  item.nof_sizes);
1652  }
Status FlatBufferManager::setItem ( const int64_t  index,
const std::string &  s 
)
inline

Definition at line 1800 of file FlatBuffer.h.

References Int8, RETURN_ERROR, and TypeError.

1800  {
1801  const auto* metadata = getNestedArrayMetadata();
1802  if (metadata->value_type != Int8) {
1804  }
1805  return setItem<1, false>(index, reinterpret_cast<const int8_t*>(s.data()), s.size());
1806  }
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
template<typename CT , size_t NDIM = 0>
Status FlatBufferManager::setItem ( const int64_t  index,
const std::vector< CT > &  arr 
)
inline

Definition at line 1809 of file FlatBuffer.h.

References DimensionalityError, getNDims(), getValueSize(), NotImplementedError, PointFloat64, PointInt32, RETURN_ERROR, and TypeError.

1809  {
1810  if (getNDims() != NDIM + 1) {
1812  }
1813  if constexpr (!std::is_same<CT, uint8_t>::value) {
1814  if constexpr (std::is_same<CT, double>::value) {
1815  const auto* metadata = getNestedArrayMetadata();
1816  if (metadata->value_type != PointFloat64) {
1818  }
1819  } else if constexpr (std::is_same<CT, int32_t>::value) {
1820  const auto* metadata = getNestedArrayMetadata();
1821  if (metadata->value_type != PointInt32) {
1823  }
1824  } else {
1826  }
1827  }
1828  const auto valuesize = getValueSize();
1829  auto sz = (arr.size() * sizeof(CT)) / valuesize;
1830  const int32_t* const sizes_buffers[1] = {nullptr};
1831  int32_t sizes_lengths[1] = {0};
1832  return setItemWorker<1, false>(index,
1833  reinterpret_cast<const int8_t*>(arr.data()),
1834  sz,
1835  sizes_buffers,
1836  sizes_lengths,
1837  0);
1838  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299

+ Here is the call graph for this function:

template<typename CT , size_t NDIM = 1, bool check_sizes = false>
Status FlatBufferManager::setItem ( const int64_t  index,
const std::vector< std::vector< CT >> &  item 
)
inline

Definition at line 1841 of file FlatBuffer.h.

References getValueSize().

1841  {
1842  const auto valuesize = getValueSize();
1843  std::vector<int32_t> sizes;
1844  sizes.reserve(item.size());
1845  int32_t nof_values = 0;
1846  size_t nof_elements = 0;
1847  for (const auto& subitem: item) {
1848  const auto sz = (subitem.size() * sizeof(CT)) / valuesize;
1849  sizes.push_back(sz);
1850  nof_values += sz;
1851  nof_elements += subitem.size();
1852  }
1853  std::vector<CT> flatitem;
1854  flatitem.reserve(nof_elements);
1855  for (const auto& subitem: item) {
1856  flatitem.insert(flatitem.end(), subitem.begin(), subitem.end());
1857  }
1858  return setItem<CT, NDIM, check_sizes>(index, flatitem, sizes);
1859  }
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571

+ Here is the call graph for this function:

template<typename CT , size_t NDIM = 2, bool check_sizes = false>
Status FlatBufferManager::setItem ( const int64_t  index,
const std::vector< std::vector< std::vector< CT >>> &  item 
)
inline

Definition at line 1862 of file FlatBuffer.h.

References getValueSize().

1863  {
1864  const auto valuesize = getValueSize();
1865  std::vector<int32_t> sizes_of_sizes;
1866  std::vector<int32_t> sizes;
1867  std::vector<CT> flatitem;
1868  sizes_of_sizes.reserve(item.size());
1869  size_t nof_sizes_of_sizes = 0;
1870  for (const auto& subitem: item) {
1871  sizes_of_sizes.push_back(subitem.size());
1872  nof_sizes_of_sizes += subitem.size();
1873  }
1874  sizes.reserve(nof_sizes_of_sizes);
1875  int32_t nof_values = 0;
1876  size_t nof_elements = 0;
1877  for (const auto& subitem: item) {
1878  for (const auto& subitem1: subitem) {
1879  const auto sz = (subitem1.size() * sizeof(CT)) / valuesize;
1880  sizes.push_back(sz);
1881  nof_values += sz;
1882  nof_elements += subitem1.size();
1883  }
1884  }
1885  flatitem.reserve(nof_elements);
1886  for (const auto& subitem: item) {
1887  for (const auto& subitem1: subitem) {
1888  flatitem.insert(flatitem.end(), subitem1.begin(), subitem1.end());
1889  }
1890  }
1891  return setItem<CT, NDIM, check_sizes>(index, flatitem, sizes, sizes_of_sizes);
1892  }
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571

+ Here is the call graph for this function:

template<typename CT , size_t NDIM = 1, bool check_sizes = true>
Status FlatBufferManager::setItem ( const int64_t  index,
const std::vector< CT > &  values,
const std::vector< int32_t > &  sizes 
)
inline

Definition at line 1895 of file FlatBuffer.h.

References DimensionalityError, getNDims(), getValueSize(), NotImplementedError, PointFloat64, PointInt32, RETURN_ERROR, and TypeError.

1897  {
1898  if (getNDims() != NDIM + 1) {
1900  }
1901  const auto* metadata = getNestedArrayMetadata();
1902  if constexpr (!std::is_same<CT, uint8_t>::value) {
1903  if constexpr (std::is_same<CT, double>::value) {
1904  if (metadata->value_type != PointFloat64) {
1906  }
1907  } else if constexpr (std::is_same<CT, int32_t>::value) {
1908  if (metadata->value_type != PointInt32) {
1910  }
1911  } else {
1913  }
1914  }
1915  const auto valuesize = getValueSize();
1916  const int32_t nof_values = (values.size() * sizeof(CT)) / valuesize;
1917  return setItem<NDIM, check_sizes>(index,
1918  reinterpret_cast<const int8_t*>(values.data()),
1919  nof_values,
1920  sizes.data(),
1921  sizes.size());
1922  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299

+ Here is the call graph for this function:

template<typename CT , size_t NDIM = 2, bool check_sizes = true>
Status FlatBufferManager::setItem ( const int64_t  index,
const std::vector< CT > &  values,
const std::vector< int32_t > &  sizes,
const std::vector< int32_t > &  sizes_of_sizes 
)
inline

Definition at line 1925 of file FlatBuffer.h.

References DimensionalityError, getNDims(), getValueSize(), NotImplementedError, PointFloat64, PointInt32, RETURN_ERROR, and TypeError.

1928  {
1929  if (getNDims() != NDIM + 1) {
1931  }
1932  const auto* metadata = getNestedArrayMetadata();
1933  if constexpr (!std::is_same<CT, uint8_t>::value) {
1934  if constexpr (std::is_same<CT, double>::value) {
1935  if (metadata->value_type != PointFloat64) {
1937  }
1938  } else if constexpr (std::is_same<CT, int32_t>::value) {
1939  if (metadata->value_type != PointInt32) {
1941  }
1942  } else {
1944  }
1945  }
1946  const auto valuesize = getValueSize();
1947  const auto nof_values = (values.size() * sizeof(CT)) / valuesize;
1948  return setItem<NDIM, check_sizes>(index,
1949  reinterpret_cast<const int8_t*>(values.data()),
1950  nof_values,
1951  sizes.data(),
1952  sizes.size(),
1953  sizes_of_sizes.data(),
1954  sizes_of_sizes.size()
1955  );
1956  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299

+ Here is the call graph for this function:

Status FlatBufferManager::setItemNoValidation ( const int64_t  index,
const int8_t *  src,
const int64_t  size,
int8_t **  dest 
)
inline

Definition at line 1986 of file FlatBuffer.h.

References dtypeSize(), format(), GeoPointFormatId, get_values(), MemoryError, RETURN_ERROR, Success, and UnknownFormatError.

Referenced by setEmptyItemNoValidation(), and setItemOld().

1989  {
1990  switch (format()) {
1991  case GeoPointFormatId: {
1992  int8_t* values = get_values();
1993  const int64_t itemsize = dtypeSize();
1994  const int64_t csize = index * itemsize;
1995  if (src != nullptr && memcpy(values + csize, src, size) == nullptr) {
1997  }
1998  if (dest != nullptr) {
1999  *dest = values + csize;
2000  }
2001  break;
2002  }
2003  default:
2005  }
2006 
2007  return Success;
2008  }
HOST DEVICE int64_t dtypeSize() const
Definition: FlatBuffer.h:628
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE int8_t * get_values()
Definition: FlatBuffer.h:930

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Status FlatBufferManager::setItemOld ( const int64_t  index,
const int8_t *  src,
const int64_t  size,
int8_t **  dest = nullptr 
)
inline

Definition at line 1963 of file FlatBuffer.h.

References run_benchmark_import::dest, dtypeSize(), format(), GeoPointFormatId, IndexError, itemsCount(), RETURN_ERROR, setItemNoValidation(), SizeError, and UnknownFormatError.

Referenced by writeBackCellGeoPoint().

1966  {
1967  if (index < 0 || index >= itemsCount()) {
1969  }
1970  switch (format()) {
1971  case GeoPointFormatId: {
1972  const int64_t itemsize = dtypeSize();
1973  if (size != itemsize) {
1975  }
1976  break;
1977  }
1978  default:
1980  }
1981  return setItemNoValidation(index, src, size, dest);
1982  }
HOST DEVICE int64_t dtypeSize() const
Definition: FlatBuffer.h:628
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604
Status setItemNoValidation(const int64_t index, const int8_t *src, const int64_t size, int8_t **dest)
Definition: FlatBuffer.h:1986

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<size_t NDIM, bool check_sizes = true>
HOST DEVICE Status FlatBufferManager::setItemWorker ( const int64_t  index,
const int8_t *  values,
const int32_t  nof_values,
const int32_t *const  sizes_buffers[NDIM],
const int32_t  sizes_lengths[NDIM],
const int32_t  nof_sizes 
)
inline

Definition at line 1368 of file FlatBuffer.h.

References DimensionalityError, FLATBUFFER_UNREACHABLE, format(), get_storage_indices(), getNDims(), getValueSize(), InconsistentSizesError, IndexError, ItemAlreadySpecifiedError, itemsCount(), MemoryError, NestedArrayFormatId, NotSupportedFormatError, RETURN_ERROR, SizesBufferTooSmallError, Success, and ValuesBufferTooSmallError.

1373  {
1374  if (format() != NestedArrayFormatId) {
1376  }
1377  if (index < 0 || index >= itemsCount()) {
1379  }
1380  const int32_t ndims = getNDims();
1381  if (nof_sizes + 1 != ndims) {
1383  }
1384 
1385  auto* storage_indices = get_storage_indices();
1386  if (storage_indices[index] >= 0) {
1388  }
1389  auto* worker = getNestedArrayWorker();
1390  const auto storage_index = worker->specified_items_count;
1391  storage_indices[index] = storage_index;
1392  worker->specified_items_count++;
1393 
1394  auto* values_offsets = get_values_offsets();
1395  auto* sizes_offsets = get_sizes_offsets();
1396  auto* sizes_buffer = get_sizes_buffer();
1397  auto* values_buffer = get_values_buffer();
1398  const auto* metadata = getNestedArrayMetadata();
1399  const auto valuesize = getValueSize();
1400 
1401  auto values_offset = values_offsets[storage_index];
1402  const auto sizes_offset = sizes_offsets[storage_index * ndims];
1403  if (values_offset + nof_values > metadata->total_values_count) {
1405  }
1406 
1407  switch (ndims) {
1408  case 1: {
1409  sizes_buffer[sizes_offset] = nof_values;
1410  sizes_offsets[storage_index * ndims + 1] = sizes_offset + 1;
1411  } break;
1412  case 2: {
1413  const auto sizes2_offset = sizes_offset + 1;
1414  if (sizes2_offset + sizes_lengths[0] > metadata->total_sizes_count) {
1416  }
1417  sizes_buffer[sizes_offset] = sizes_lengths[0];
1418  if constexpr (check_sizes) {
1419  // check consistency of sizes and nof_values
1420  int32_t sum_of_sizes = 0;
1421  for (int32_t i=0; i < sizes_lengths[0]; i++) {
1422  sum_of_sizes += sizes_buffers[0][i];
1423  }
1424  if (nof_values != sum_of_sizes) {
1426  }
1427  }
1428  if (memcpy(sizes_buffer + sizes2_offset,
1429  sizes_buffers[0],
1430  sizes_lengths[0] * sizeof(sizes_t)) == nullptr) {
1432  }
1433  sizes_offsets[storage_index * ndims + 1] = sizes2_offset;
1434  sizes_offsets[storage_index * ndims + 2] = sizes2_offset + sizes_lengths[0];
1435  } break;
1436  case 3: {
1437  const auto sizes2_offset = sizes_offset + 1;
1438  const auto sizes3_offset = sizes2_offset + sizes_lengths[0];
1439  if (sizes2_offset + sizes_lengths[0] + sizes_lengths[1] >
1440  metadata->total_sizes_count) {
1442  }
1443  sizes_buffer[sizes_offset] = sizes_lengths[0];
1444  if constexpr (check_sizes) {
1445  // check consistency of sizes of sizes and nof_sizes
1446  int32_t sum_of_sizes_of_sizes = 0;
1447  for (int32_t i=0; i < sizes_lengths[0]; i++) {
1448  sum_of_sizes_of_sizes += sizes_buffers[0][i];
1449  }
1450  if (sizes_lengths[1] != sum_of_sizes_of_sizes) {
1452  }
1453  }
1454  if (memcpy(sizes_buffer + sizes2_offset,
1455  sizes_buffers[0],
1456  sizes_lengths[0] * sizeof(sizes_t)) == nullptr) {
1458  }
1459  if constexpr (check_sizes) {
1460  // check consistency of sizes and nof_values
1461  int32_t sum_of_sizes = 0;
1462  for (int32_t i=0; i < sizes_lengths[1]; i++) {
1463  sum_of_sizes += sizes_buffers[1][i];
1464  }
1465  if (nof_values != sum_of_sizes) {
1467  }
1468  }
1469  if (memcpy(sizes_buffer + sizes3_offset,
1470  sizes_buffers[1],
1471  sizes_lengths[1] * sizeof(sizes_t)) == nullptr) {
1473  }
1474  sizes_offsets[storage_index * ndims + 1] = sizes2_offset;
1475  sizes_offsets[storage_index * ndims + 2] = sizes3_offset;
1476  sizes_offsets[storage_index * ndims + 3] = sizes3_offset + sizes_lengths[1];
1477  } break;
1478  default:
1480  break;
1481  }
1482  if (values != nullptr) {
1483  if (memcpy(values_buffer + values_offset * valuesize,
1484  values,
1485  nof_values * valuesize) == nullptr) {
1487  }
1488  }
1489  values_offsets[storage_index + 1] = values_offset + nof_values;
1490  return Success;
1491  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
#define FLATBUFFER_UNREACHABLE()
Definition: FlatBuffer.h:316
HOST DEVICE size_t getValueSize() const
Definition: FlatBuffer.h:571
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE sizes_t * get_storage_indices()
Definition: FlatBuffer.h:1021
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604

+ Here is the call graph for this function:

HOST DEVICE Status FlatBufferManager::setNull ( int64_t  index)
inline

Definition at line 2029 of file FlatBuffer.h.

References format(), GeoPointFormatId, get_storage_indices(), getNDims(), IndexError, isNestedArray(), ItemAlreadySpecifiedError, itemsCount(), RETURN_ERROR, setNullNoValidation(), Success, and UnknownFormatError.

Referenced by Column< GeoPoint >::setNull(), writeBackCellArrayScalar(), writeBackCellGeoNestedArray(), and writeBackCellTextEncodingNone().

2029  {
2030  if (index < 0 || index >= itemsCount()) {
2032  }
2033  if (isNestedArray()) {
2034  auto* storage_indices = get_storage_indices();
2035  if (storage_indices[index] >= 0) {
2037  }
2038  auto* worker = getNestedArrayWorker();
2039  const auto storage_index = worker->specified_items_count;
2040  worker->specified_items_count++;
2041  storage_indices[index] = storage_index;
2042  const size_t ndims = getNDims();
2043  auto* sizes_buffer = get_sizes_buffer();
2044  auto* values_offsets = get_values_offsets();
2045  auto* sizes_offsets = get_sizes_offsets();
2046  const auto values_offset = values_offsets[storage_index];
2047  const auto sizes_offset = sizes_offsets[storage_index * ndims];
2048  sizes_buffer[sizes_offset] = 0;
2049  for (size_t i = 0; i < ndims; i++) {
2050  sizes_offsets[storage_index * ndims + i + 1] = sizes_offset + 1;
2051  }
2052  values_offsets[storage_index] = -(values_offset + 1);
2053  values_offsets[storage_index + 1] = values_offset;
2054  return Success;
2055  }
2056  // To be deprecated in favor of NestedArray format:
2057  if (index < 0 || index >= itemsCount()) {
2059  }
2060 
2061  switch (format()) {
2062  case GeoPointFormatId: {
2063  return setNullNoValidation(index);
2064  }
2065  default:
2066  break;
2067  }
2069  }
HOST DEVICE size_t getNDims() const
Definition: FlatBuffer.h:866
HOST DEVICE bool isNestedArray() const
Definition: FlatBuffer.h:567
HOST DEVICE Status setNullNoValidation(int64_t index)
Definition: FlatBuffer.h:2073
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE sizes_t * get_storage_indices()
Definition: FlatBuffer.h:1021
HOST DEVICE int64_t itemsCount() const
Definition: FlatBuffer.h:604

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE Status FlatBufferManager::setNullNoValidation ( int64_t  index)
inline

Definition at line 2073 of file FlatBuffer.h.

References dtypeSize(), format(), GeoPointFormatId, get_values(), RETURN_ERROR, Success, and UnknownFormatError.

Referenced by setNull().

2073  {
2074  switch (format()) {
2075  case GeoPointFormatId: {
2076  int8_t* values = get_values();
2077  int64_t itemsize = dtypeSize();
2078  const auto* metadata = getGeoPointMetadata();
2079  if (metadata->is_geoint) {
2080  // per Geospatial/CompressionRuntime.h:is_null_point_longitude_geoint32
2081  *reinterpret_cast<uint32_t*>(values + index * itemsize) = 0x80000000U;
2082  *reinterpret_cast<uint32_t*>(values + index * itemsize + sizeof(int32_t)) =
2083  0x80000000U;
2084  } else {
2085  // per Shared/InlineNullValues.h:NULL_ARRAY_DOUBLE
2086  *reinterpret_cast<double*>(values + index * itemsize) = 2 * DBL_MIN;
2087  *reinterpret_cast<double*>(values + index * itemsize + sizeof(double)) =
2088  2 * DBL_MIN;
2089  }
2090  break;
2091  }
2092  default:
2094  }
2095  return Success;
2096  }
HOST DEVICE int64_t dtypeSize() const
Definition: FlatBuffer.h:628
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598
#define RETURN_ERROR(exc)
Definition: FlatBuffer.h:299
HOST DEVICE int8_t * get_values()
Definition: FlatBuffer.h:930

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

HOST DEVICE int64_t FlatBufferManager::valueByteSize ( ) const
inline

Definition at line 617 of file FlatBuffer.h.

References format(), and GeoPointFormatId.

617  {
618  switch (format()) {
619  case GeoPointFormatId:
620  return 2 * (getGeoPointMetadata()->is_geoint ? sizeof(int32_t) : sizeof(double));
621  default:
622  break;
623  }
624  return -1;
625  }
HOST DEVICE FlatBufferFormat format() const
Definition: FlatBuffer.h:598

+ Here is the call graph for this function:

Member Data Documentation


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