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

#include <FlatBuffer.h>

Classes

struct  DTypeMetadataSize
 
struct  DTypeMetadataSizeDictId
 

Public Types

enum  Status {
  Success = 0, IndexError, SizeError, ItemAlreadySpecifiedError,
  ItemUnspecifiedError, ValuesBufferTooSmallError, MemoryError, NotImplemnentedError,
  UnknownFormatError
}
 
enum  VarlenArrayHeader {
  FORMAT_ID = 0, FLATBUFFER_SIZE, ITEMS_COUNT, DTYPE_METADATA_KIND,
  DTYPE_METADATA_BUFFER_SIZE, MAX_NOF_VALUES, STORAGE_COUNT, DTYPE_METADATA_BUFFER_OFFSET,
  VALUES_OFFSET, COMPRESSED_INDICES_OFFSET, STORAGE_INDICES_OFFSET, EOFHEADER
}
 
enum  DTypeMetadataKind { SIZE = 1, SIZE_DICTID }
 

Public Member Functions

FlatBufferFormat format () const
 
int64_t flatbufferSize () const
 
DTypeMetadataKind getDTypeMetadataKind () const
 
int8_t * getDTypeMetadataBuffer ()
 
const int8_t * getDTypeMetadataBuffer () const
 
void setDTypeMetadataSize (int64_t size)
 
int64_t getDTypeMetadataSize () const
 
void setDTypeMetadataDictId (int32_t dict_id)
 
int32_t getDTypeMetadataDictId () const
 
void initializeVarlenArray (int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
 
int64_t itemsCount () const
 
int64_t dtypeSize () const
 
int64_t VarlenArray_max_nof_values () const
 
int64_t VarlenArray_values_buffer_size () const
 
int64_t & VarlenArray_storage_count ()
 
int8_t * VarlenArray_values ()
 
const int8_t * VarlenArray_values () const
 
int64_t * VarlenArray_compressed_indices ()
 
const int64_t * VarlenArray_compressed_indices () const
 
int64_t * VarlenArray_storage_indices ()
 
const int64_t * VarlenArray_storage_indices () const
 
Status setItem (int64_t index, const int8_t *src, int64_t size, int8_t **dest=nullptr)
 
Status setItemNoValidation (int64_t index, const int8_t *src, int64_t size, int8_t **dest)
 
Status setEmptyItemNoValidation (int64_t index, int64_t size, int8_t **dest)
 
Status concatItem (int64_t index, const int8_t *src, int64_t size)
 
Status setNull (int64_t index)
 
Status setNullNoValidation (int64_t index)
 
Status isNull (int64_t index, bool &is_null) const
 
Status getItem (int64_t index, int64_t &size, int8_t *&dest, bool &is_null)
 

Static Public Member Functions

static bool isFlatBuffer (const void *buffer)
 
static int64_t getDTypeMetadataBufferSize (DTypeMetadataKind kind)
 
static int64_t get_VarlenArray_flatbuffer_size (int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
 

Public Attributes

int8_t * buffer
 

Detailed Description

Definition at line 146 of file FlatBuffer.h.

Member Enumeration Documentation

Enumerator
SIZE 
SIZE_DICTID 

Definition at line 214 of file FlatBuffer.h.

Enumerator
FORMAT_ID 
FLATBUFFER_SIZE 
ITEMS_COUNT 
DTYPE_METADATA_KIND 
DTYPE_METADATA_BUFFER_SIZE 
MAX_NOF_VALUES 
STORAGE_COUNT 
DTYPE_METADATA_BUFFER_OFFSET 
VALUES_OFFSET 
COMPRESSED_INDICES_OFFSET 
STORAGE_INDICES_OFFSET 
EOFHEADER 

Definition at line 159 of file FlatBuffer.h.

159  {
160  FORMAT_ID = 0, // storage format id
161  FLATBUFFER_SIZE, // in bytes
162  ITEMS_COUNT, /* the number of items
163  (e.g. the number of
164  rows in a column) */
165  DTYPE_METADATA_KIND, /* the kind of dtype metadata */
166  DTYPE_METADATA_BUFFER_SIZE, /* the size of dtype metadata buffer */
167  MAX_NOF_VALUES, /* the upper bound to the
168  total number of values
169  in all items */
170  STORAGE_COUNT, /* the number of specified
171  items, incremented by
172  one on each
173  setNull/setItem call */
178  EOFHEADER
179  };

Member Function Documentation

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

Definition at line 505 of file FlatBuffer.h.

References dtypeSize(), format(), IndexError, itemsCount(), MemoryError, NotImplemnentedError, setItem(), SizeError, Success, UnknownFormatError, VarlenArray, VarlenArray_compressed_indices(), VarlenArray_storage_count(), VarlenArray_storage_indices(), and VarlenArray_values().

505  {
507  if (index < 0 || index >= itemsCount()) {
508  return IndexError;
509  }
510  int64_t next_storage_count = VarlenArray_storage_count();
511  int64_t storage_count = next_storage_count - 1;
512  int64_t* compressed_indices = VarlenArray_compressed_indices();
513  int64_t* storage_indices = VarlenArray_storage_indices();
514  int8_t* values = VarlenArray_values();
515  int64_t itemsize = dtypeSize();
516  int64_t storage_index = storage_indices[index];
517 
518  if (storage_index == -1) { // unspecified, so setting the item
519  return setItem(index, src, size, nullptr);
520  }
521  if (size % itemsize != 0) {
522  return SizeError;
523  }
524  if (storage_index != storage_count) {
525  return IndexError; // index does not correspond to the last set
526  // item, only the last item can be
527  // concatenated
528  }
529  if (compressed_indices[storage_index] < 0) {
530  return NotImplemnentedError; // todo: support concat to null when last
531  }
532  int64_t values_count =
533  compressed_indices[next_storage_count] - compressed_indices[storage_index];
534  int64_t extra_values_count = size / itemsize;
535  compressed_indices[next_storage_count] += extra_values_count;
536  int8_t* ptr = values + compressed_indices[storage_index] * itemsize;
537  if (size > 0 && src != nullptr &&
538  memcpy(ptr + values_count * itemsize, src, size) == nullptr) {
539  return MemoryError;
540  }
541  return Success;
542  }
543  return UnknownFormatError;
544  }
int64_t dtypeSize() const
Definition: FlatBuffer.h:393
Status setItem(int64_t index, const int8_t *src, int64_t size, int8_t **dest=nullptr)
Definition: FlatBuffer.h:443
int8_t * VarlenArray_values()
Definition: FlatBuffer.h:411
int64_t & VarlenArray_storage_count()
Definition: FlatBuffer.h:406
FlatBufferFormat format() const
Definition: FlatBuffer.h:202
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t itemsCount() const
Definition: FlatBuffer.h:385
int64_t * VarlenArray_compressed_indices()
Definition: FlatBuffer.h:420

+ Here is the call graph for this function:

int64_t FlatBufferManager::dtypeSize ( ) const
inline

Definition at line 393 of file FlatBuffer.h.

References getDTypeMetadataSize().

Referenced by concatItem(), getItem(), setItem(), setItemNoValidation(), and VarlenArray_values_buffer_size().

393 { return getDTypeMetadataSize(); }
int64_t getDTypeMetadataSize() const
Definition: FlatBuffer.h:270

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t FlatBufferManager::flatbufferSize ( ) const
inline

Definition at line 208 of file FlatBuffer.h.

References buffer.

Referenced by TableFunctionExecutionContext::launchCpuCode().

208  {
209  return ((int64_t*)buffer)[VarlenArrayHeader::FLATBUFFER_SIZE];
210  }

+ Here is the caller graph for this function:

FlatBufferFormat FlatBufferManager::format ( ) const
inline

Definition at line 202 of file FlatBuffer.h.

References buffer.

Referenced by concatItem(), getItem(), isNull(), itemsCount(), setItem(), and setNull().

202  {
203  return static_cast<FlatBufferFormat>(
204  ((int64_t*)buffer)[VarlenArrayHeader::FORMAT_ID]);
205  }
FlatBufferFormat
Definition: FlatBuffer.h:137

+ Here is the caller graph for this function:

static int64_t FlatBufferManager::get_VarlenArray_flatbuffer_size ( int64_t  items_count,
int64_t  max_nof_values,
int64_t  dtype_size,
DTypeMetadataKind  dtype_metadata_kind 
)
inlinestatic

Definition at line 316 of file FlatBuffer.h.

References _align_to_int64(), and getDTypeMetadataBufferSize().

Referenced by getVarlenArrayBufferSize(), and initializeVarlenArray().

319  {
320  const int64_t VarlenArray_buffer_header_size =
321  VarlenArrayHeader::EOFHEADER * sizeof(int64_t);
322  const int64_t dtype_metadata_buffer_size =
323  getDTypeMetadataBufferSize(dtype_metadata_kind);
324  const int64_t values_buffer_size = _align_to_int64(dtype_size * max_nof_values);
325  return (VarlenArray_buffer_header_size // see above
326  + dtype_metadata_buffer_size // size of dtype metadata buffer in bytes,
327  // aligned to int64
328  + values_buffer_size // size of values buffer, aligned to int64
329  + (items_count + 1 // size of compressed_indices buffer
330  + items_count // size of storage_indices buffer
331  + 1 // footer format id
332  ) * sizeof(int64_t));
333  }
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:141
static int64_t getDTypeMetadataBufferSize(DTypeMetadataKind kind)
Definition: FlatBuffer.h:228

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int8_t* FlatBufferManager::getDTypeMetadataBuffer ( )
inline

Definition at line 244 of file FlatBuffer.h.

References buffer.

Referenced by getDTypeMetadataDictId(), getDTypeMetadataSize(), setDTypeMetadataDictId(), and setDTypeMetadataSize().

244  {
245  return buffer + ((int64_t*)buffer)[VarlenArrayHeader::DTYPE_METADATA_BUFFER_OFFSET];
246  }

+ Here is the caller graph for this function:

const int8_t* FlatBufferManager::getDTypeMetadataBuffer ( ) const
inline

Definition at line 248 of file FlatBuffer.h.

References buffer.

248  {
249  return buffer +
250  ((const int64_t*)buffer)[VarlenArrayHeader::DTYPE_METADATA_BUFFER_OFFSET];
251  }
static int64_t FlatBufferManager::getDTypeMetadataBufferSize ( DTypeMetadataKind  kind)
inlinestatic

Definition at line 228 of file FlatBuffer.h.

References _align_to_int64().

Referenced by get_VarlenArray_flatbuffer_size(), and initializeVarlenArray().

228  {
229  switch (kind) {
230  case DTypeMetadataKind::SIZE:
231  return _align_to_int64(sizeof(DTypeMetadataSize));
232  case DTypeMetadataKind::SIZE_DICTID:
233  return _align_to_int64(sizeof(DTypeMetadataSizeDictId));
234  default:
235  return 0;
236  }
237  }
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:141

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t FlatBufferManager::getDTypeMetadataDictId ( ) const
inline

Definition at line 301 of file FlatBuffer.h.

References FlatBufferManager::DTypeMetadataSizeDictId::dict_id, getDTypeMetadataBuffer(), and getDTypeMetadataKind().

Referenced by Column< Array< T > >::getDictId().

301  {
302  switch (getDTypeMetadataKind()) {
303  case DTypeMetadataKind::SIZE:
304  break;
305  case DTypeMetadataKind::SIZE_DICTID: {
306  const DTypeMetadataSizeDictId* metadata =
307  reinterpret_cast<const DTypeMetadataSizeDictId*>(getDTypeMetadataBuffer());
308  return metadata->dict_id;
309  }
310  default:;
311  }
312  return 0;
313  }
DTypeMetadataKind getDTypeMetadataKind() const
Definition: FlatBuffer.h:239
int8_t * getDTypeMetadataBuffer()
Definition: FlatBuffer.h:244

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

DTypeMetadataKind FlatBufferManager::getDTypeMetadataKind ( ) const
inline

Definition at line 239 of file FlatBuffer.h.

References buffer.

Referenced by getDTypeMetadataDictId(), getDTypeMetadataSize(), setDTypeMetadataDictId(), and setDTypeMetadataSize().

239  {
240  return static_cast<DTypeMetadataKind>(
241  ((int64_t*)buffer)[VarlenArrayHeader::DTYPE_METADATA_KIND]);
242  }

+ Here is the caller graph for this function:

int64_t FlatBufferManager::getDTypeMetadataSize ( ) const
inline

Definition at line 270 of file FlatBuffer.h.

References getDTypeMetadataBuffer(), getDTypeMetadataKind(), FlatBufferManager::DTypeMetadataSize::size, and FlatBufferManager::DTypeMetadataSizeDictId::size.

Referenced by dtypeSize().

270  {
271  switch (getDTypeMetadataKind()) {
272  case DTypeMetadataKind::SIZE: {
273  const DTypeMetadataSize* metadata =
274  reinterpret_cast<const DTypeMetadataSize*>(getDTypeMetadataBuffer());
275  return metadata->size;
276  }
277  case DTypeMetadataKind::SIZE_DICTID: {
278  const DTypeMetadataSizeDictId* metadata =
279  reinterpret_cast<const DTypeMetadataSizeDictId*>(getDTypeMetadataBuffer());
280  return metadata->size;
281  }
282  default:;
283  }
284  return 0;
285  }
DTypeMetadataKind getDTypeMetadataKind() const
Definition: FlatBuffer.h:239
int8_t * getDTypeMetadataBuffer()
Definition: FlatBuffer.h:244

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 595 of file FlatBuffer.h.

References dtypeSize(), format(), IndexError, itemsCount(), ItemUnspecifiedError, Success, UnknownFormatError, VarlenArray, VarlenArray_compressed_indices(), VarlenArray_storage_indices(), and VarlenArray_values().

Referenced by ResultSet::makeVarlenTargetValue().

595  {
597  if (index < 0 || index >= itemsCount()) {
598  return IndexError;
599  }
600  int8_t* values = VarlenArray_values();
601  const int64_t* compressed_indices = VarlenArray_compressed_indices();
602  const int64_t* storage_indices = VarlenArray_storage_indices();
603  const int64_t storage_index = storage_indices[index];
604  if (storage_index < 0) {
605  return ItemUnspecifiedError;
606  }
607  const int64_t cindex = compressed_indices[storage_index];
608  if (cindex < 0) {
609  // null varlen array
610  size = 0;
611  dest = nullptr;
612  is_null = true;
613  } else {
614  const int64_t dtypesize = dtypeSize();
615  const int64_t next_cindex = compressed_indices[storage_index + 1];
616  const int64_t length =
617  (next_cindex < 0 ? -(next_cindex + 1) - cindex : next_cindex - cindex);
618  size = length * dtypesize;
619  dest = values + cindex * dtypesize;
620  is_null = false;
621  }
622  return Success;
623  } else {
624  return UnknownFormatError;
625  }
626  }
int64_t dtypeSize() const
Definition: FlatBuffer.h:393
int8_t * VarlenArray_values()
Definition: FlatBuffer.h:411
CONSTEXPR DEVICE bool is_null(const T &value)
FlatBufferFormat format() const
Definition: FlatBuffer.h:202
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t itemsCount() const
Definition: FlatBuffer.h:385
int64_t * VarlenArray_compressed_indices()
Definition: FlatBuffer.h:420

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FlatBufferManager::initializeVarlenArray ( int64_t  items_count,
int64_t  max_nof_values,
int64_t  dtype_size,
DTypeMetadataKind  dtype_metadata_kind 
)
inline

Definition at line 336 of file FlatBuffer.h.

References _align_to_int64(), buffer, get_VarlenArray_flatbuffer_size(), getDTypeMetadataBufferSize(), setDTypeMetadataSize(), VarlenArray, VarlenArray_compressed_indices(), and VarlenArray_storage_indices().

Referenced by initializeVarlenArray().

339  {
340  const int64_t VarlenArray_buffer_header_size =
341  VarlenArrayHeader::EOFHEADER * sizeof(int64_t);
342  const int64_t values_buffer_size = _align_to_int64(dtype_size * max_nof_values);
343  const int64_t compressed_indices_buffer_size = (items_count + 1) * sizeof(int64_t);
344  const int64_t dtype_metadata_buffer_size =
345  getDTypeMetadataBufferSize(dtype_metadata_kind);
346  const int64_t flatbuffer_size = get_VarlenArray_flatbuffer_size(
347  items_count, max_nof_values, dtype_size, dtype_metadata_kind);
348  ((int64_t*)buffer)[VarlenArrayHeader::FORMAT_ID] =
349  static_cast<int64_t>(FlatBufferFormat::VarlenArray);
350  ((int64_t*)buffer)[VarlenArrayHeader::FLATBUFFER_SIZE] = flatbuffer_size;
351  ((int64_t*)buffer)[VarlenArrayHeader::ITEMS_COUNT] = items_count;
352  ((int64_t*)buffer)[VarlenArrayHeader::MAX_NOF_VALUES] = max_nof_values;
353  ((int64_t*)buffer)[VarlenArrayHeader::DTYPE_METADATA_KIND] =
354  static_cast<int64_t>(dtype_metadata_kind);
355  ((int64_t*)buffer)[VarlenArrayHeader::DTYPE_METADATA_BUFFER_SIZE] =
356  dtype_metadata_buffer_size;
357  ((int64_t*)buffer)[VarlenArrayHeader::STORAGE_COUNT] = 0;
358  ((int64_t*)buffer)[VarlenArrayHeader::DTYPE_METADATA_BUFFER_OFFSET] =
359  VarlenArray_buffer_header_size;
360  ((int64_t*)buffer)[VarlenArrayHeader::VALUES_OFFSET] =
361  ((const int64_t*)buffer)[VarlenArrayHeader::DTYPE_METADATA_BUFFER_OFFSET] +
362  dtype_metadata_buffer_size;
363  ((int64_t*)buffer)[VarlenArrayHeader::COMPRESSED_INDICES_OFFSET] =
364  ((const int64_t*)buffer)[VarlenArrayHeader::VALUES_OFFSET] + values_buffer_size;
365  ((int64_t*)buffer)[VarlenArrayHeader::STORAGE_INDICES_OFFSET] =
366  ((const int64_t*)buffer)[VarlenArrayHeader::COMPRESSED_INDICES_OFFSET] +
367  compressed_indices_buffer_size;
368 
369  setDTypeMetadataSize(dtype_size);
370 
371  // initialize indices buffers
372  int64_t* compressed_indices = VarlenArray_compressed_indices();
373  int64_t* storage_indices = VarlenArray_storage_indices();
374  for (int i = 0; i < items_count; i++) {
375  compressed_indices[i] = 0;
376  storage_indices[i] = -1;
377  }
378  compressed_indices[items_count] = 0;
379  // store footer format id in the last 8-bytes of the flatbuffer:
380  ((int64_t*)buffer)[flatbuffer_size / sizeof(int64_t) - 1] =
381  static_cast<int64_t>(FlatBufferFormat::VarlenArray);
382  }
static int64_t get_VarlenArray_flatbuffer_size(int64_t items_count, int64_t max_nof_values, int64_t dtype_size, DTypeMetadataKind dtype_metadata_kind)
Definition: FlatBuffer.h:316
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:141
int64_t * VarlenArray_compressed_indices()
Definition: FlatBuffer.h:420
static int64_t getDTypeMetadataBufferSize(DTypeMetadataKind kind)
Definition: FlatBuffer.h:228
void setDTypeMetadataSize(int64_t size)
Definition: FlatBuffer.h:254

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 184 of file FlatBuffer.h.

References VarlenArray.

Referenced by ColumnarResults::ColumnarResults(), ResultSet::makeVarlenTargetValue(), and ColumnarResults::writeBackCell().

184  {
185  if (buffer) {
186  // warning: assume that buffer size is at least 8 bytes
187  FlatBufferFormat header_format =
188  static_cast<FlatBufferFormat>(((int64_t*)buffer)[VarlenArrayHeader::FORMAT_ID]);
189  if (header_format == FlatBufferFormat::VarlenArray) {
190  int64_t flatbuffer_size = ((int64_t*)buffer)[VarlenArrayHeader::FLATBUFFER_SIZE];
191  if (flatbuffer_size > 0) {
192  FlatBufferFormat footer_format = static_cast<FlatBufferFormat>(
193  ((int64_t*)buffer)[flatbuffer_size / sizeof(int64_t) - 1]);
194  return footer_format == header_format;
195  }
196  }
197  }
198  return false;
199  }
FlatBufferFormat
Definition: FlatBuffer.h:137

+ Here is the caller graph for this function:

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

Definition at line 575 of file FlatBuffer.h.

References format(), IndexError, itemsCount(), ItemUnspecifiedError, Success, UnknownFormatError, VarlenArray, VarlenArray_compressed_indices(), and VarlenArray_storage_indices().

575  {
577  if (index < 0 || index >= itemsCount()) {
578  return IndexError;
579  }
580  const int64_t* compressed_indices = VarlenArray_compressed_indices();
581  const int64_t* storage_indices = VarlenArray_storage_indices();
582  const int64_t storage_index = storage_indices[index];
583  if (storage_index < 0) {
584  return ItemUnspecifiedError;
585  }
586  is_null = (compressed_indices[storage_index] < 0);
587  return Success;
588  }
589  return UnknownFormatError;
590  }
CONSTEXPR DEVICE bool is_null(const T &value)
FlatBufferFormat format() const
Definition: FlatBuffer.h:202
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t itemsCount() const
Definition: FlatBuffer.h:385
int64_t * VarlenArray_compressed_indices()
Definition: FlatBuffer.h:420

+ Here is the call graph for this function:

int64_t FlatBufferManager::itemsCount ( ) const
inline

Definition at line 385 of file FlatBuffer.h.

References buffer, format(), and VarlenArray.

Referenced by concatItem(), getItem(), isNull(), setItem(), and setNull().

385  {
387  return ((int64_t*)buffer)[VarlenArrayHeader::ITEMS_COUNT];
388  }
389  return -1; // invalid value
390  }
FlatBufferFormat format() const
Definition: FlatBuffer.h:202

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FlatBufferManager::setDTypeMetadataDictId ( int32_t  dict_id)
inline

Definition at line 288 of file FlatBuffer.h.

References FlatBufferManager::DTypeMetadataSizeDictId::dict_id, getDTypeMetadataBuffer(), and getDTypeMetadataKind().

Referenced by initializeVarlenArray().

288  {
289  switch (getDTypeMetadataKind()) {
290  case DTypeMetadataKind::SIZE:
291  break;
292  case DTypeMetadataKind::SIZE_DICTID: {
293  DTypeMetadataSizeDictId* metadata =
294  reinterpret_cast<DTypeMetadataSizeDictId*>(getDTypeMetadataBuffer());
295  metadata->dict_id = dict_id;
296  } break;
297  default:;
298  }
299  }
DTypeMetadataKind getDTypeMetadataKind() const
Definition: FlatBuffer.h:239
int8_t * getDTypeMetadataBuffer()
Definition: FlatBuffer.h:244

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void FlatBufferManager::setDTypeMetadataSize ( int64_t  size)
inline

Definition at line 254 of file FlatBuffer.h.

References getDTypeMetadataBuffer(), getDTypeMetadataKind(), FlatBufferManager::DTypeMetadataSize::size, and FlatBufferManager::DTypeMetadataSizeDictId::size.

Referenced by initializeVarlenArray().

254  {
255  switch (getDTypeMetadataKind()) {
256  case DTypeMetadataKind::SIZE: {
257  DTypeMetadataSize* metadata =
258  reinterpret_cast<DTypeMetadataSize*>(getDTypeMetadataBuffer());
259  metadata->size = size;
260  } break;
261  case DTypeMetadataKind::SIZE_DICTID: {
262  DTypeMetadataSizeDictId* metadata =
263  reinterpret_cast<DTypeMetadataSizeDictId*>(getDTypeMetadataBuffer());
264  metadata->size = size;
265  } break;
266  default:;
267  }
268  }
DTypeMetadataKind getDTypeMetadataKind() const
Definition: FlatBuffer.h:239
int8_t * getDTypeMetadataBuffer()
Definition: FlatBuffer.h:244

+ 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 501 of file FlatBuffer.h.

References setItemNoValidation().

501  {
502  return setItemNoValidation(index, nullptr, size, dest);
503  }
Status setItemNoValidation(int64_t index, const int8_t *src, int64_t size, int8_t **dest)
Definition: FlatBuffer.h:474

+ Here is the call graph for this function:

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

Definition at line 443 of file FlatBuffer.h.

References run_benchmark_import::dest, dtypeSize(), format(), IndexError, ItemAlreadySpecifiedError, itemsCount(), setItemNoValidation(), SizeError, UnknownFormatError, ValuesBufferTooSmallError, VarlenArray, VarlenArray_compressed_indices(), VarlenArray_storage_count(), VarlenArray_storage_indices(), and VarlenArray_values_buffer_size().

Referenced by concatItem().

446  {
448  if (index < 0 || index >= itemsCount()) {
449  return IndexError;
450  }
451  int64_t& storage_count = VarlenArray_storage_count();
452  int64_t* compressed_indices = VarlenArray_compressed_indices();
453  int64_t* storage_indices = VarlenArray_storage_indices();
454  const int64_t itemsize = dtypeSize();
455  if (size % itemsize != 0) {
456  return SizeError; // size must be multiple of itemsize. Perhaps size is not in
457  // bytes?
458  }
459  if (storage_indices[index] >= 0) {
461  }
462  const int64_t cindex = compressed_indices[storage_count];
463  const int64_t values_buffer_size = VarlenArray_values_buffer_size();
464  const int64_t csize = cindex * itemsize;
465  if (csize + size > values_buffer_size) {
467  }
468  return setItemNoValidation(index, src, size, dest);
469  }
470  return UnknownFormatError;
471  }
int64_t dtypeSize() const
Definition: FlatBuffer.h:393
int64_t & VarlenArray_storage_count()
Definition: FlatBuffer.h:406
int64_t VarlenArray_values_buffer_size() const
Definition: FlatBuffer.h:401
FlatBufferFormat format() const
Definition: FlatBuffer.h:202
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t itemsCount() const
Definition: FlatBuffer.h:385
int64_t * VarlenArray_compressed_indices()
Definition: FlatBuffer.h:420
Status setItemNoValidation(int64_t index, const int8_t *src, int64_t size, int8_t **dest)
Definition: FlatBuffer.h:474

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 474 of file FlatBuffer.h.

References dtypeSize(), MemoryError, Success, VarlenArray_compressed_indices(), VarlenArray_storage_count(), VarlenArray_storage_indices(), and VarlenArray_values().

Referenced by setEmptyItemNoValidation(), and setItem().

477  {
478  int64_t& storage_count = VarlenArray_storage_count();
479  int64_t* storage_indices = VarlenArray_storage_indices();
480  int64_t* compressed_indices = VarlenArray_compressed_indices();
481  int8_t* values = VarlenArray_values();
482  const int64_t itemsize = dtypeSize();
483  const int64_t values_count = size / itemsize;
484  const int64_t cindex = compressed_indices[storage_count];
485  const int64_t csize = cindex * itemsize;
486  storage_indices[index] = storage_count;
487  compressed_indices[storage_count + 1] = cindex + values_count;
488  if (size > 0 && src != nullptr && memcpy(values + csize, src, size) == nullptr) {
489  return MemoryError;
490  }
491  if (dest != nullptr) {
492  *dest = values + csize;
493  }
494  storage_count++;
495  return Success;
496  }
int64_t dtypeSize() const
Definition: FlatBuffer.h:393
int8_t * VarlenArray_values()
Definition: FlatBuffer.h:411
int64_t & VarlenArray_storage_count()
Definition: FlatBuffer.h:406
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t * VarlenArray_compressed_indices()
Definition: FlatBuffer.h:420

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Status FlatBufferManager::setNull ( int64_t  index)
inline

Definition at line 547 of file FlatBuffer.h.

References format(), IndexError, ItemAlreadySpecifiedError, itemsCount(), setNullNoValidation(), UnknownFormatError, VarlenArray, and VarlenArray_storage_indices().

Referenced by Column< Array< T > >::concatItem(), Column< Array< T > >::setItem(), and Column< Array< T > >::setNull().

547  {
549  if (index < 0 || index >= itemsCount()) {
550  return IndexError;
551  }
552  int64_t* storage_indices = VarlenArray_storage_indices();
553  if (storage_indices[index] >= 0) {
555  }
556  return setNullNoValidation(index);
557  }
558  return UnknownFormatError;
559  }
FlatBufferFormat format() const
Definition: FlatBuffer.h:202
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t itemsCount() const
Definition: FlatBuffer.h:385
Status setNullNoValidation(int64_t index)
Definition: FlatBuffer.h:562

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Status FlatBufferManager::setNullNoValidation ( int64_t  index)
inline

Definition at line 562 of file FlatBuffer.h.

References Success, VarlenArray_compressed_indices(), VarlenArray_storage_count(), and VarlenArray_storage_indices().

Referenced by setNull().

562  {
563  int64_t& storage_count = VarlenArray_storage_count();
564  int64_t* storage_indices = VarlenArray_storage_indices();
565  int64_t* compressed_indices = VarlenArray_compressed_indices();
566  const int64_t cindex = compressed_indices[storage_count];
567  storage_indices[index] = storage_count;
568  compressed_indices[storage_count] = -(cindex + 1);
569  compressed_indices[storage_count + 1] = cindex;
570  storage_count++;
571  return Success;
572  }
int64_t & VarlenArray_storage_count()
Definition: FlatBuffer.h:406
int64_t * VarlenArray_storage_indices()
Definition: FlatBuffer.h:430
int64_t * VarlenArray_compressed_indices()
Definition: FlatBuffer.h:420

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t* FlatBufferManager::VarlenArray_compressed_indices ( )
inline

Definition at line 420 of file FlatBuffer.h.

References buffer.

Referenced by concatItem(), getItem(), initializeVarlenArray(), isNull(), setItem(), setItemNoValidation(), and setNullNoValidation().

420  {
421  return reinterpret_cast<int64_t*>(
422  buffer + ((const int64_t*)buffer)[VarlenArrayHeader::COMPRESSED_INDICES_OFFSET]);
423  }

+ Here is the caller graph for this function:

const int64_t* FlatBufferManager::VarlenArray_compressed_indices ( ) const
inline

Definition at line 424 of file FlatBuffer.h.

References buffer.

424  {
425  return reinterpret_cast<const int64_t*>(
426  buffer + ((const int64_t*)buffer)[VarlenArrayHeader::COMPRESSED_INDICES_OFFSET]);
427  }
int64_t FlatBufferManager::VarlenArray_max_nof_values ( ) const
inline

Definition at line 396 of file FlatBuffer.h.

References buffer.

Referenced by VarlenArray_values_buffer_size().

396  {
397  return ((int64_t*)buffer)[VarlenArrayHeader::MAX_NOF_VALUES];
398  }

+ Here is the caller graph for this function:

int64_t& FlatBufferManager::VarlenArray_storage_count ( )
inline

Definition at line 406 of file FlatBuffer.h.

References buffer.

Referenced by concatItem(), setItem(), setItemNoValidation(), and setNullNoValidation().

406  {
407  return ((int64_t*)buffer)[VarlenArrayHeader::STORAGE_COUNT];
408  }

+ Here is the caller graph for this function:

int64_t* FlatBufferManager::VarlenArray_storage_indices ( )
inline

Definition at line 430 of file FlatBuffer.h.

References buffer.

Referenced by concatItem(), getItem(), initializeVarlenArray(), isNull(), setItem(), setItemNoValidation(), setNull(), and setNullNoValidation().

430  {
431  return reinterpret_cast<int64_t*>(
432  buffer + ((const int64_t*)buffer)[VarlenArrayHeader::STORAGE_INDICES_OFFSET]);
433  }

+ Here is the caller graph for this function:

const int64_t* FlatBufferManager::VarlenArray_storage_indices ( ) const
inline

Definition at line 434 of file FlatBuffer.h.

References buffer.

434  {
435  return reinterpret_cast<const int64_t*>(
436  buffer + ((const int64_t*)buffer)[VarlenArrayHeader::STORAGE_INDICES_OFFSET]);
437  }
int8_t* FlatBufferManager::VarlenArray_values ( )
inline

Definition at line 411 of file FlatBuffer.h.

References buffer.

Referenced by concatItem(), getItem(), and setItemNoValidation().

411  {
412  return buffer + ((const int64_t*)buffer)[VarlenArrayHeader::VALUES_OFFSET];
413  }

+ Here is the caller graph for this function:

const int8_t* FlatBufferManager::VarlenArray_values ( ) const
inline

Definition at line 415 of file FlatBuffer.h.

References buffer.

415  {
416  return buffer + ((const int64_t*)buffer)[VarlenArrayHeader::VALUES_OFFSET];
417  }
int64_t FlatBufferManager::VarlenArray_values_buffer_size ( ) const
inline

Definition at line 401 of file FlatBuffer.h.

References _align_to_int64(), dtypeSize(), and VarlenArray_max_nof_values().

Referenced by setItem().

401  {
403  }
int64_t dtypeSize() const
Definition: FlatBuffer.h:393
int64_t VarlenArray_max_nof_values() const
Definition: FlatBuffer.h:396
int64_t _align_to_int64(int64_t addr)
Definition: FlatBuffer.h:141

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation


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