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

#include <heavydbTypes.h>

+ Collaboration diagram for TableFunctionManager:

Public Member Functions

void set_output_array_values_total_number (int32_t index, int64_t output_array_values_total_number)
 
void set_output_item_values_total_number (int32_t index, int64_t output_item_values_total_number)
 
void set_output_row_size (int64_t num_rows)
 
void disable_output_allocations ()
 
void enable_output_allocations ()
 
int32_t error_message (const char *message)
 
template<typename T >
void set_metadata (const std::string &key, const T &value)
 
template<typename T >
void get_metadata (const std::string &key, T &value)
 
int32_t getNewDictDbId ()
 
int32_t getNewDictId ()
 
StringDictionaryProxygetStringDictionaryProxy (int32_t db_id, int32_t dict_id)
 
std::string getString (int32_t db_id, int32_t dict_id, int32_t string_id)
 
int32_t getOrAddTransient (int32_t db_id, int32_t dict_id, std::string str)
 
int8_t * makeBuffer (int64_t element_count, int64_t element_size)
 
std::string toString () const
 
 TableFunctionManager (const TableFunctionExecutionUnit &exe_unit, Executor *executor, std::vector< const int8_t * > &col_buf_ptrs, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, bool is_singleton)
 
size_t get_ncols () const
 
size_t get_nrows () const
 
void check_thread_id () const
 
void set_output_column (int32_t index, int8_t *ptr)
 
void set_output_item_values_total_number (int32_t index, int64_t output_item_values_total_number)
 
void set_output_array_values_total_number (int32_t index, int64_t output_array_values_total_number)
 
void allocate_output_buffers (int64_t output_num_rows)
 
const char * get_error_message () const
 
void set_error_message (const char *msg)
 
void set_metadata (const char *key, const uint8_t *raw_bytes, const size_t num_bytes, const TableFunctionMetadataType value_type) const
 
void get_metadata (const char *key, const uint8_t *&raw_bytes, size_t &num_bytes, TableFunctionMetadataType &value_type) const
 
int32_t getNewDictDbId ()
 
int32_t getNewDictId ()
 
int8_t * getStringDictionaryProxy (int32_t db_id, int32_t dict_id)
 
std::string getString (int32_t db_id, int32_t dict_id, int32_t string_id)
 
const int32_t getOrAddTransient (int32_t db_id, int32_t dict_id, const std::string &str)
 
int8_t * makeBuffer (int64_t element_count, int64_t element_size)
 
bool isSingleton () const
 
 ~TableFunctionManager ()
 

Static Public Member Functions

static TableFunctionManagerget_singleton ()
 
static TableFunctionManager *& get_singleton_internal ()
 

Public Attributes

bool output_allocations_disabled false
 
std::unique_ptr
< QueryMemoryInitializer
query_buffers
 

Private Member Functions

void lock ()
 
void unlock ()
 

Static Private Member Functions

static void set_singleton (TableFunctionManager *instance)
 

Private Attributes

const TableFunctionExecutionUnitexe_unit_
 
Executorexecutor_
 
std::vector< const int8_t * > & col_buf_ptrs_
 
std::shared_ptr
< RowSetMemoryOwner
row_set_mem_owner_
 
std::vector< int64_t * > output_col_buf_ptrs
 
size_t output_num_rows_
 
std::vector< int64_t > output_item_values_total_number_
 
std::vector< int8_t * > output_column_ptrs
 
bool is_singleton_
 
std::thread::id thread_id_
 
std::string error_message_
 

Detailed Description

Definition at line 356 of file heavydbTypes.h.

Constructor & Destructor Documentation

TableFunctionManager::TableFunctionManager ( const TableFunctionExecutionUnit exe_unit,
Executor executor,
std::vector< const int8_t * > &  col_buf_ptrs,
std::shared_ptr< RowSetMemoryOwner row_set_mem_owner,
bool  is_singleton 
)
inline

Definition at line 62 of file TableFunctionManager.h.

References get_ncols(), isSingleton(), output_col_buf_ptrs, output_column_ptrs, output_item_values_total_number_, and set_singleton().

67  : exe_unit_(exe_unit)
68  , executor_(executor)
69  , col_buf_ptrs_(col_buf_ptrs)
70  , row_set_mem_owner_(row_set_mem_owner)
71  , output_num_rows_(-1)
72  , is_singleton_(is_singleton)
73  , thread_id_(std::this_thread::get_id()) {
74  if (isSingleton()) {
75  set_singleton(this); // start of singleton life
76  }
77  auto num_out_columns = get_ncols();
78  output_col_buf_ptrs.reserve(num_out_columns);
79  output_column_ptrs.reserve(num_out_columns);
80  output_item_values_total_number_.reserve(num_out_columns);
81  for (size_t i = 0; i < num_out_columns; i++) {
82  output_col_buf_ptrs.emplace_back(nullptr);
83  output_column_ptrs.emplace_back(nullptr);
84  output_item_values_total_number_.emplace_back(-1);
85  }
86  }
std::vector< int64_t > output_item_values_total_number_
std::vector< const int8_t * > & col_buf_ptrs_
const TableFunctionExecutionUnit & exe_unit_
std::vector< int8_t * > output_column_ptrs
std::vector< int64_t * > output_col_buf_ptrs
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
static void set_singleton(TableFunctionManager *instance)

+ Here is the call graph for this function:

TableFunctionManager::~TableFunctionManager ( )
inline

Definition at line 334 of file TableFunctionManager.h.

References isSingleton(), and set_singleton().

334  {
335  if (isSingleton()) {
336  set_singleton(nullptr); // end of singleton life
337  }
338  }
static void set_singleton(TableFunctionManager *instance)

+ Here is the call graph for this function:

Member Function Documentation

void TableFunctionManager::allocate_output_buffers ( int64_t  output_num_rows)
inline

Definition at line 132 of file TableFunctionManager.h.

References QueryMemoryDescriptor::addColSlotInfo(), QueryMemoryDescriptor::addColSlotInfoFlatBuffer(), align_to_int64(), CHECK, CHECK_EQ, check_thread_id(), col_buf_ptrs_, CPU, exe_unit_, executor_, get_ncols(), getFlatBufferSize(), table_functions::TableFunction::getName(), initializeFlatBuffer(), FlatBufferManager::isFlatBuffer(), kARRAY, kENCODING_NONE, kLINESTRING, kMULTILINESTRING, kMULTIPOINT, kMULTIPOLYGON, kPOINT, kPOLYGON, kTEXT, output_col_buf_ptrs, output_column_ptrs, output_item_values_total_number_, output_num_rows_, query_buffers, query_mem_desc, row_set_mem_owner_, Column< T >::size(), TableFunctionExecutionUnit::table_func, heavyai::TableFunction, TableFunctionExecutionUnit::target_exprs, to_string(), toString(), and UNREACHABLE.

132  {
133  check_thread_id();
135  size_t(-1)); // re-allocation of output buffers is not supported
136 
137  output_num_rows_ = output_num_rows;
138  auto num_out_columns = get_ncols();
140  output_num_rows, // divide by row multiplier???
142 
143  for (size_t i = 0; i < num_out_columns; i++) {
144  // All outputs have padded width set to logical column width
145  auto ti = exe_unit_.target_exprs[i]->get_type_info();
146  if (ti.usesFlatBuffer()) {
147  int64_t total_number = -1;
148  switch (ti.get_type()) {
149  case kTEXT:
150  if (ti.get_compression() != kENCODING_NONE) {
151  UNREACHABLE() << "allocate_output_buffers not implemented for "
152  << ti.toString();
153  }
154  case kARRAY:
155  case kLINESTRING:
156  case kPOLYGON:
157  case kMULTIPOINT:
158  case kMULTILINESTRING:
159  case kMULTIPOLYGON: {
160  if (output_item_values_total_number_[i] == -1) {
161  throw std::runtime_error("set_output_item_values_total_number(" +
162  std::to_string(i) +
163  ", <total_number>) must be called before "
164  "set_output_row_size(<size>) in " +
166  }
167  total_number = output_item_values_total_number_[i];
168  break;
169  }
170  case kPOINT:
171  break;
172  default:
173  UNREACHABLE() << "allocate_output_buffers not implemented for "
174  << ti.toString();
175  }
176  /*
177  Here we compute the byte size of flatbuffer and store it in
178  query memory descriptor's ColSlotContext instance. The
179  flatbuffer memory will be allocated in
180  QueryMemoryInitializer constructor and the memory will be
181  initialized below.
182  */
183  query_mem_desc.addColSlotInfoFlatBuffer(getFlatBufferSize(
184  output_num_rows_, total_number, ti)); // used by QueryMemoryInitializer
185  } else {
186  const size_t col_width = ti.get_size();
187  query_mem_desc.addColSlotInfo({std::make_tuple(col_width, col_width)});
188  }
189  }
190 
191  // The members layout of Column must match with Column defined in
192  // heavydbTypes.h
193  struct Column {
194  int8_t* ptr;
195  int64_t size;
196  // just for debugging:
197  std::string toString() const {
198  return "Column{" + ::toString(ptr) + ", " + ::toString(size) + "}";
199  }
200  };
201  // We do not init output buffers for CPU currently, so CPU
202  // table functions are expected to handle their own initialization
203  query_buffers = std::make_unique<QueryMemoryInitializer>(
204  exe_unit_,
206  /*device_id=*/0,
208  (output_num_rows_ == 0 ? 1 : output_num_rows_),
209  std::vector<std::vector<const int8_t*>>{col_buf_ptrs_},
210  std::vector<std::vector<uint64_t>>{{0}}, // frag offsets
212  nullptr,
213  executor_);
214  if (output_num_rows_ != 0) {
215  auto group_by_buffers_ptr = query_buffers->getGroupByBuffersPtr();
216  CHECK(group_by_buffers_ptr);
217  auto output_buffers_ptr = reinterpret_cast<int8_t*>(group_by_buffers_ptr[0]);
218  for (size_t i = 0; i < num_out_columns; i++) {
219  Column* col = reinterpret_cast<Column*>(output_column_ptrs[i]);
220  CHECK(col);
221  // set the members of output Column instances:
222  output_col_buf_ptrs[i] = reinterpret_cast<int64_t*>(output_buffers_ptr);
223  col->ptr = output_buffers_ptr;
224  col->size = output_num_rows_;
225 
226  auto ti = exe_unit_.target_exprs[i]->get_type_info();
227  if (ti.usesFlatBuffer()) {
228  FlatBufferManager m{output_buffers_ptr};
229  int64_t total_number = -1;
230  switch (ti.get_type()) {
231  case kTEXT:
232  if (ti.get_compression() != kENCODING_NONE) {
233  UNREACHABLE() << "allocate_output_buffers not implemented for "
234  << ti.toString();
235  }
236  case kARRAY:
237  case kLINESTRING:
238  case kPOLYGON:
239  case kMULTIPOINT:
240  case kMULTILINESTRING:
241  case kMULTIPOLYGON: {
242  total_number = output_item_values_total_number_[i];
243  break;
244  }
245  case kPOINT:
246  break;
247  default:
248  UNREACHABLE() << "allocate_output_buffers not implemented for "
249  << ti.toString();
250  }
251  initializeFlatBuffer(m, output_num_rows_, total_number, ti);
252  CHECK(FlatBufferManager::isFlatBuffer(output_buffers_ptr));
253  // Checks if the implementations of getFlatBufferSize and
254  // initializeFlatBuffer in sqltypes.h are in sync:
255  CHECK_EQ(m.getBufferSize(), query_mem_desc.getFlatBufferSize(i));
256  output_buffers_ptr = align_to_int64(output_buffers_ptr + m.getBufferSize());
257  } else {
258  const size_t col_width = ti.get_size();
259  output_buffers_ptr =
260  align_to_int64(output_buffers_ptr + col_width * output_num_rows_);
261  }
262  }
263  }
264  }
std::vector< int64_t > output_item_values_total_number_
std::unique_ptr< QueryMemoryInitializer > query_buffers
#define CHECK_EQ(x, y)
Definition: Logger.h:301
std::vector< const int8_t * > & col_buf_ptrs_
const TableFunctionExecutionUnit & exe_unit_
const table_functions::TableFunction table_func
DEVICE int64_t size() const
#define UNREACHABLE()
Definition: Logger.h:338
std::vector< int8_t * > output_column_ptrs
void initializeFlatBuffer(FlatBufferManager &m, int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
Definition: sqltypes.h:1993
std::vector< int64_t * > output_col_buf_ptrs
std::string to_string(char const *&&v)
TableFunction
Definition: enums.h:58
int64_t getFlatBufferSize(int64_t items_count, int64_t max_nof_values, const SQLTypeInfo &ti)
Definition: sqltypes.h:1841
std::string getName(const bool drop_suffix=false, const bool lower=false) const
Definition: sqltypes.h:79
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
#define CHECK(condition)
Definition: Logger.h:291
std::vector< Analyzer::Expr * > target_exprs
HOST static DEVICE bool isFlatBuffer(const void *buffer)
Definition: FlatBuffer.h:528
std::string toString() const
Definition: heavydbTypes.h:436
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)

+ Here is the call graph for this function:

void TableFunctionManager::check_thread_id ( ) const
inline

Definition at line 94 of file TableFunctionManager.h.

References thread_id_.

Referenced by allocate_output_buffers(), get_error_message(), set_error_message(), and set_output_column().

94  {
95  if (std::this_thread::get_id() != thread_id_) {
96  throw std::runtime_error(
97  "TableFunctionManager instance accessed from an alien thread!");
98  }
99  }

+ Here is the caller graph for this function:

void TableFunctionManager::disable_output_allocations ( )
inline

Definition at line 379 of file heavydbTypes.h.

Referenced by r2_score_impl().

379 { output_allocations_disabled = true; }

+ Here is the caller graph for this function:

void TableFunctionManager::enable_output_allocations ( )
inline

Definition at line 381 of file heavydbTypes.h.

Referenced by ct_test_allocator(), and r2_score_impl().

381 { output_allocations_disabled = false; }

+ Here is the caller graph for this function:

int32_t TableFunctionManager::error_message ( const char *  message)
inline

Definition at line 383 of file heavydbTypes.h.

References TableFunctionManager_error_message().

383  {
384  return TableFunctionManager_error_message(reinterpret_cast<int8_t*>(this), message);
385  }
EXTENSION_NOINLINE_HOST int32_t TableFunctionManager_error_message(int8_t *mgr_ptr, const char *message)

+ Here is the call graph for this function:

const char* TableFunctionManager::get_error_message ( ) const
inline

Definition at line 266 of file TableFunctionManager.h.

References check_thread_id(), and error_message_.

266  {
267  check_thread_id();
268  return error_message_.c_str();
269  }

+ Here is the call graph for this function:

void TableFunctionManager::get_metadata ( const char *  key,
const uint8_t *&  raw_bytes,
size_t &  num_bytes,
TableFunctionMetadataType value_type 
) const
inline

Definition at line 284 of file TableFunctionManager.h.

References CHECK, and row_set_mem_owner_.

287  {
289  row_set_mem_owner_->getTableFunctionMetadata(key, raw_bytes, num_bytes, value_type);
290  }
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
#define CHECK(condition)
Definition: Logger.h:291
template<typename T >
void TableFunctionManager::get_metadata ( const std::string &  key,
T &  value 
)
inline

Definition at line 397 of file heavydbTypes.h.

References heavydb.dtypes::T, and TableFunctionManager_get_metadata().

Referenced by tf_metadata_getter__cpu_template(), and tf_metadata_getter_bad__cpu_template().

397  {
398  const uint8_t* raw_data{};
399  size_t num_bytes{};
400  TableFunctionMetadataType value_type;
402  reinterpret_cast<int8_t*>(this), key.c_str(), raw_data, num_bytes, value_type);
403  if (sizeof(T) != num_bytes) {
404  throw std::runtime_error("Size mismatch for Table Function Metadata '" + key + "'");
405  }
406  if (get_metadata_type<T>() != value_type) {
407  throw std::runtime_error("Type mismatch for Table Function Metadata '" + key + "'");
408  }
409  std::memcpy(&value, raw_data, num_bytes);
410  }
EXTENSION_NOINLINE_HOST void TableFunctionManager_get_metadata(int8_t *mgr_ptr, const char *key, const uint8_t *&raw_bytes, size_t &num_bytes, TableFunctionMetadataType &value_type)
TableFunctionMetadataType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t TableFunctionManager::get_ncols ( ) const
inline

Definition at line 89 of file TableFunctionManager.h.

References exe_unit_, and TableFunctionExecutionUnit::target_exprs.

Referenced by allocate_output_buffers(), set_output_column(), set_output_item_values_total_number(), and TableFunctionManager().

89 { return exe_unit_.target_exprs.size(); }
const TableFunctionExecutionUnit & exe_unit_
std::vector< Analyzer::Expr * > target_exprs

+ Here is the caller graph for this function:

size_t TableFunctionManager::get_nrows ( ) const
inline

Definition at line 92 of file TableFunctionManager.h.

References output_num_rows_.

92 { return output_num_rows_; }
static TableFunctionManager* TableFunctionManager::get_singleton ( )
inlinestatic

Definition at line 357 of file heavydbTypes.h.

References TableFunctionManager_get_singleton().

Referenced by ct_sleep1__cpu_(), ct_sleep2(), and sum_along_row__cpu_template().

357  {
358  return reinterpret_cast<TableFunctionManager*>(TableFunctionManager_get_singleton());
359  }
EXTENSION_NOINLINE_HOST int8_t * TableFunctionManager_get_singleton()

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static TableFunctionManager*& TableFunctionManager::get_singleton_internal ( )
inlinestatic

Definition at line 340 of file TableFunctionManager.h.

References lockmgr::instance().

Referenced by set_singleton().

340  {
341  static TableFunctionManager* instance = nullptr;
342  return instance;
343  }
T & instance()
Definition: LockMgr.cpp:101

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t TableFunctionManager::getNewDictDbId ( )
inline

Definition at line 292 of file TableFunctionManager.h.

References executor_, row_set_mem_owner_, and TRANSIENT_DICT_ID.

292  {
293  const auto proxy = executor_->getStringDictionaryProxy(
295  return proxy->getDictKey().db_id;
296  }
#define TRANSIENT_DICT_ID
Definition: DbObjectKeys.h:24
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
int32_t TableFunctionManager::getNewDictDbId ( )
inline

Definition at line 411 of file heavydbTypes.h.

References TableFunctionManager_getNewDictDbId().

Referenced by array_asarray__cpu_template().

411  {
412  return TableFunctionManager_getNewDictDbId(reinterpret_cast<int8_t*>(this));
413  }
EXTENSION_NOINLINE_HOST int32_t TableFunctionManager_getNewDictDbId(int8_t *mgr_ptr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t TableFunctionManager::getNewDictId ( )
inline

Definition at line 298 of file TableFunctionManager.h.

References executor_, row_set_mem_owner_, and TRANSIENT_DICT_ID.

298  {
299  const auto proxy = executor_->getStringDictionaryProxy(
301  return proxy->getDictKey().dict_id;
302  }
#define TRANSIENT_DICT_ID
Definition: DbObjectKeys.h:24
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
int32_t TableFunctionManager::getNewDictId ( )
inline

Definition at line 414 of file heavydbTypes.h.

References TableFunctionManager_getNewDictId().

Referenced by array_asarray__cpu_template().

414  {
415  return TableFunctionManager_getNewDictId(reinterpret_cast<int8_t*>(this));
416  }
EXTENSION_NOINLINE_HOST int32_t TableFunctionManager_getNewDictId(int8_t *mgr_ptr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int32_t TableFunctionManager::getOrAddTransient ( int32_t  db_id,
int32_t  dict_id,
const std::string &  str 
)
inline

Definition at line 315 of file TableFunctionManager.h.

References executor_, and row_set_mem_owner_.

317  {
318  const auto proxy =
319  executor_->getStringDictionaryProxy({db_id, dict_id}, row_set_mem_owner_, true);
320  return proxy->getOrAddTransient(str);
321  }
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
int32_t TableFunctionManager::getOrAddTransient ( int32_t  db_id,
int32_t  dict_id,
std::string  str 
)
inline

Definition at line 426 of file heavydbTypes.h.

References TableFunctionManager_getOrAddTransient().

Referenced by array_asarray__cpu_template().

426  {
428  reinterpret_cast<int8_t*>(this), db_id, dict_id, str);
429  }
EXTENSION_NOINLINE_HOST int32_t TableFunctionManager_getOrAddTransient(int8_t *mgr_ptr, int32_t db_id, int32_t dict_id, std::string str)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string TableFunctionManager::getString ( int32_t  db_id,
int32_t  dict_id,
int32_t  string_id 
)
inline

Definition at line 309 of file TableFunctionManager.h.

References executor_, and row_set_mem_owner_.

309  {
310  const auto proxy =
311  executor_->getStringDictionaryProxy({db_id, dict_id}, row_set_mem_owner_, true);
312  return proxy->getString(string_id);
313  }
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
std::string TableFunctionManager::getString ( int32_t  db_id,
int32_t  dict_id,
int32_t  string_id 
)
inline

Definition at line 422 of file heavydbTypes.h.

References TableFunctionManager_getString().

Referenced by array_asarray__cpu_template().

422  {
424  reinterpret_cast<int8_t*>(this), db_id, dict_id, string_id);
425  }
std::string TableFunctionManager_getString(int8_t *mgr_ptr, int32_t db_id, int32_t dict_id, int32_t string_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int8_t* TableFunctionManager::getStringDictionaryProxy ( int32_t  db_id,
int32_t  dict_id 
)
inline

Definition at line 304 of file TableFunctionManager.h.

References executor_, and row_set_mem_owner_.

304  {
305  return reinterpret_cast<int8_t*>(
306  executor_->getStringDictionaryProxy({db_id, dict_id}, row_set_mem_owner_, true));
307  }
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
StringDictionaryProxy* TableFunctionManager::getStringDictionaryProxy ( int32_t  db_id,
int32_t  dict_id 
)
inline

Definition at line 417 of file heavydbTypes.h.

References TableFunctionManager_getStringDictionaryProxy().

417  {
418  return reinterpret_cast<StringDictionaryProxy*>(
420  reinterpret_cast<int8_t*>(this), db_id, dict_id));
421  }
EXTENSION_NOINLINE_HOST int8_t * TableFunctionManager_getStringDictionaryProxy(int8_t *mgr_ptr, int32_t db_id, int32_t dict_id)

+ Here is the call graph for this function:

bool TableFunctionManager::isSingleton ( ) const
inline

Definition at line 332 of file TableFunctionManager.h.

References is_singleton_.

Referenced by TableFunctionManager(), and ~TableFunctionManager().

332 { return is_singleton_; }

+ Here is the caller graph for this function:

void TableFunctionManager::lock ( )
inlineprivate

Definition at line 346 of file TableFunctionManager.h.

References TableFunctionManager_singleton_mutex.

Referenced by set_singleton().

std::mutex TableFunctionManager_singleton_mutex

+ Here is the caller graph for this function:

int8_t* TableFunctionManager::makeBuffer ( int64_t  element_count,
int64_t  element_size 
)
inline

Definition at line 323 of file TableFunctionManager.h.

References checked_malloc(), and row_set_mem_owner_.

323  {
324  int8_t* buffer =
325  reinterpret_cast<int8_t*>(checked_malloc((element_count + 1) * element_size));
326  row_set_mem_owner_->addVarlenBuffer(buffer);
327  return buffer;
328  }
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:45
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_

+ Here is the call graph for this function:

int8_t* TableFunctionManager::makeBuffer ( int64_t  element_count,
int64_t  element_size 
)
inline

Definition at line 430 of file heavydbTypes.h.

References TableFunctionManager_makeBuffer().

430  {
432  reinterpret_cast<int8_t*>(this), element_count, element_size);
433  }
EXTENSION_NOINLINE_HOST int8_t * TableFunctionManager_makeBuffer(int8_t *mgr_ptr, int64_t count, int64_t size)

+ Here is the call graph for this function:

void TableFunctionManager::set_error_message ( const char *  msg)
inline

Definition at line 271 of file TableFunctionManager.h.

References check_thread_id(), and error_message_.

271  {
272  check_thread_id();
273  error_message_ = std::string(msg);
274  }

+ Here is the call graph for this function:

void TableFunctionManager::set_metadata ( const char *  key,
const uint8_t *  raw_bytes,
const size_t  num_bytes,
const TableFunctionMetadataType  value_type 
) const
inline

Definition at line 276 of file TableFunctionManager.h.

References CHECK, and row_set_mem_owner_.

279  {
281  row_set_mem_owner_->setTableFunctionMetadata(key, raw_bytes, num_bytes, value_type);
282  }
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner_
#define CHECK(condition)
Definition: Logger.h:291
template<typename T >
void TableFunctionManager::set_metadata ( const std::string &  key,
const T &  value 
)
inline

Definition at line 388 of file heavydbTypes.h.

References TableFunctionManager_set_metadata().

Referenced by GeoRaster< T, Z >::setMetadata(), tf_metadata_setter__cpu_template(), tf_metadata_setter_repeated__cpu_template(), and tf_metadata_setter_size_mismatch__cpu_template().

388  {
389  TableFunctionManager_set_metadata(reinterpret_cast<int8_t*>(this),
390  key.c_str(),
391  reinterpret_cast<const uint8_t*>(&value),
392  sizeof(value),
393  get_metadata_type<T>());
394  }
EXTENSION_NOINLINE_HOST void TableFunctionManager_set_metadata(int8_t *mgr_ptr, const char *key, const uint8_t *raw_bytes, const size_t num_bytes, const TableFunctionMetadataType value_type)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TableFunctionManager::set_output_array_values_total_number ( int32_t  index,
int64_t  output_array_values_total_number 
)
inline

Definition at line 127 of file TableFunctionManager.h.

References set_output_item_values_total_number().

128  {
129  set_output_item_values_total_number(index, output_array_values_total_number);
130  }
void set_output_item_values_total_number(int32_t index, int64_t output_item_values_total_number)
Definition: heavydbTypes.h:367

+ Here is the call graph for this function:

void TableFunctionManager::set_output_array_values_total_number ( int32_t  index,
int64_t  output_array_values_total_number 
)
inline

Definition at line 361 of file heavydbTypes.h.

References TableFunctionManager_set_output_array_values_total_number().

Referenced by array_append__cpu_template(), array_asarray__cpu_template(), array_concat__cpu_template(), array_copier__cpu_template(), array_split__cpu_template(), GeoRaster< T, Z >::outputDenseColumns(), CrossSectionTableFunctions::tf_cross_section_1d_impl(), GDALTableFunctions::tf_raster_contour_impl(), and GDALTableFunctions::tf_raster_contour_rasterize_impl().

362  {
364  reinterpret_cast<int8_t*>(this), index, output_array_values_total_number);
365  }
EXTENSION_NOINLINE_HOST void TableFunctionManager_set_output_array_values_total_number(int8_t *mgr_ptr, int32_t index, int64_t output_array_values_total_number)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TableFunctionManager::set_output_column ( int32_t  index,
int8_t *  ptr 
)
inline

Definition at line 102 of file TableFunctionManager.h.

References CHECK, check_thread_id(), get_ncols(), and output_column_ptrs.

102  {
103  check_thread_id();
104  CHECK(index >= 0 && index < static_cast<int32_t>(get_ncols()));
105  CHECK(ptr);
106  output_column_ptrs[index] = ptr;
107  }
std::vector< int8_t * > output_column_ptrs
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

void TableFunctionManager::set_output_item_values_total_number ( int32_t  index,
int64_t  output_item_values_total_number 
)
inline

Definition at line 113 of file TableFunctionManager.h.

References CHECK_EQ, CHECK_LE, CHECK_LT, get_ncols(), output_item_values_total_number_, and output_num_rows_.

114  {
116  size_t(-1)); // set_output_item_values_total_number must
117  // be called before set_output_row_size
118  // because set_output_row_size allocates
119  // the output buffers
120  int32_t num_out_columns = get_ncols();
121  CHECK_LE(0, index);
122  CHECK_LT(index, num_out_columns);
123  output_item_values_total_number_[index] = output_item_values_total_number;
124  }
std::vector< int64_t > output_item_values_total_number_
#define CHECK_EQ(x, y)
Definition: Logger.h:301
#define CHECK_LT(x, y)
Definition: Logger.h:303
#define CHECK_LE(x, y)
Definition: Logger.h:304

+ Here is the call graph for this function:

void TableFunctionManager::set_output_item_values_total_number ( int32_t  index,
int64_t  output_item_values_total_number 
)
inline

Definition at line 367 of file heavydbTypes.h.

References TableFunctionManager_set_output_item_values_total_number().

Referenced by ct_copy__generic_cpu_template(), ct_linestringn__cpu_(), ct_make_linestring2__cpu_(), ct_make_multipolygon__cpu_(), ct_make_polygon3__cpu_(), ct_polygonn__cpu_(), ct_to_multilinestring__cpu_(), ct_to_polygon__cpu_(), set_output_array_values_total_number(), and CrossSectionTableFunctions::tf_cross_section_2d_impl().

368  {
370  reinterpret_cast<int8_t*>(this), index, output_item_values_total_number);
371  }
EXTENSION_NOINLINE_HOST void TableFunctionManager_set_output_item_values_total_number(int8_t *mgr_ptr, int32_t index, int64_t output_item_values_total_number)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TableFunctionManager::set_output_row_size ( int64_t  num_rows)
inline

Definition at line 373 of file heavydbTypes.h.

References TableFunctionManager_set_output_row_size().

Referenced by array_append__cpu_template(), array_asarray__cpu_template(), array_concat__cpu_template(), array_copier__cpu_template(), array_split__cpu_template(), ct_add_size_and_mul_alpha(), ct_coords__cpu_(), ct_copy__generic_cpu_template(), ct_copy_and_add_size(), ct_cursor_named_args__cpu_(), ct_linestringn__cpu_(), ct_make_linestring2__cpu_(), ct_make_multipolygon__cpu_(), ct_make_polygon3__cpu_(), ct_pointn__cpu_template(), ct_polygonn__cpu_(), ct_pushdown_projection__cpu_template(), ct_pushdown_stats__cpu_template(), ct_scalar_named_args__cpu_(), ct_shift__cpu_(), ct_sleep2(), ct_sparse_add(), ct_string_concat__cpu_(), ct_substr__cpu_(), ct_synthesize_new_dict__cpu_(), ct_test_allocator(), ct_test_calcite_casting_bigint__cpu_(), ct_test_calcite_casting_char__cpu_(), ct_test_calcite_casting_columnlist__template_cpu_(), ct_test_calcite_casting_double__cpu_(), ct_test_calcite_casting_timestamp__cpu_(), ct_test_preflight_multicursor_qe227__cpu_(), ct_test_preflight_singlecursor_qe227__cpu_(), ct_test_runtime_libs_add__cpu_template_(), ct_test_runtime_libs_sub__cpu_template_(), ct_test_string_default_arg__cpu_(), ct_throw_if_gt_100__cpu_template(), ct_timestamp_add_interval__template(), ct_timestamp_add_offset(), ct_timestamp_column_list_input(), ct_timestamp_extract(), ct_timestamp_truncate(), ct_to_multilinestring__cpu_(), ct_to_polygon__cpu_(), ct_union_pushdown_projection__cpu_template(), ct_union_pushdown_stats__cpu_template(), dbscan__cpu_template(), decision_tree_reg_impl(), gbt_reg_fit_impl(), generate_random_strings__cpu_(), generate_series__cpu_template(), get_decision_trees__cpu_1(), kmeans__cpu_template(), linear_reg_coefs__cpu_1(), linear_reg_fit_impl(), Mandelbrot::mandelbrot_cpu_template(), ml_reg_predict_impl(), GeoRaster< T, Z >::outputDenseColumns(), GeoRaster< T, Z >::outputDenseColumnsAndFill(), pca_fit_impl(), r2_score_impl(), random_forest_reg_fit_impl(), random_forest_reg_var_importance__cpu_1(), row_copier_columnlist__cpu__(), row_repeater__cpu_template(), supported_ml_frameworks__cpu_(), CrossSectionTableFunctions::tf_cross_section_1d_impl(), CrossSectionTableFunctions::tf_cross_section_2d_impl(), tf_metadata_getter__cpu_template(), tf_metadata_getter_bad__cpu_template(), tf_metadata_setter__cpu_template(), tf_metadata_setter_repeated__cpu_template(), tf_metadata_setter_size_mismatch__cpu_template(), GDALTableFunctions::tf_raster_contour_impl(), GDALTableFunctions::tf_raster_contour_rasterize_impl(), tf_test_torch_generate_random_column(), tf_test_torch_load_model(), tf_test_torch_regression(), and tf_torch_raster_obj_detect__cpu_template().

373  {
374  if (!output_allocations_disabled) {
375  TableFunctionManager_set_output_row_size(reinterpret_cast<int8_t*>(this), num_rows);
376  }
377  }
EXTENSION_NOINLINE_HOST void TableFunctionManager_set_output_row_size(int8_t *mgr_ptr, int64_t num_rows)

+ Here is the call graph for this function:

static void TableFunctionManager::set_singleton ( TableFunctionManager instance)
inlinestaticprivate

Definition at line 349 of file TableFunctionManager.h.

References CHECK, get_singleton_internal(), lockmgr::instance(), lock(), and unlock().

Referenced by TableFunctionManager(), and ~TableFunctionManager().

349  {
351  // ensure being singleton and lock/unlock
352  if (instance) {
353  instance->lock();
354  CHECK(instance_ == nullptr);
355  } else {
356  CHECK(instance_ != nullptr);
357  instance_->unlock();
358  }
359  instance_ = instance;
360  }
static TableFunctionManager *& get_singleton_internal()
T & instance()
Definition: LockMgr.cpp:101
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string TableFunctionManager::toString ( ) const
inline

Definition at line 436 of file heavydbTypes.h.

References run_benchmark_import::result, and typeName().

Referenced by allocate_output_buffers().

436  {
437  std::string result = ::typeName(this) + "(";
438  if (!(void*)this) { // cast to void* to avoid warnings
439  result += "UNINITIALIZED";
440  }
441  result += ")";
442  return result;
443  }
std::string typeName(const T *v)
Definition: toString.h:106

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TableFunctionManager::unlock ( )
inlineprivate

Definition at line 347 of file TableFunctionManager.h.

References TableFunctionManager_singleton_mutex.

Referenced by set_singleton().

std::mutex TableFunctionManager_singleton_mutex

+ Here is the caller graph for this function:

Member Data Documentation

std::vector<const int8_t*>& TableFunctionManager::col_buf_ptrs_
private

Definition at line 365 of file TableFunctionManager.h.

Referenced by allocate_output_buffers().

std::string TableFunctionManager::error_message_
private

Definition at line 382 of file TableFunctionManager.h.

Referenced by get_error_message(), and set_error_message().

const TableFunctionExecutionUnit& TableFunctionManager::exe_unit_
private

Definition at line 362 of file TableFunctionManager.h.

Referenced by allocate_output_buffers(), and get_ncols().

Executor* TableFunctionManager::executor_
private
bool output_allocations_disabled TableFunctionManager::false

Definition at line 445 of file heavydbTypes.h.

bool TableFunctionManager::is_singleton_
private

Definition at line 378 of file TableFunctionManager.h.

Referenced by isSingleton().

std::vector<int64_t*> TableFunctionManager::output_col_buf_ptrs
private

Definition at line 369 of file TableFunctionManager.h.

Referenced by allocate_output_buffers(), and TableFunctionManager().

std::vector<int8_t*> TableFunctionManager::output_column_ptrs
private
std::vector<int64_t> TableFunctionManager::output_item_values_total_number_
private
size_t TableFunctionManager::output_num_rows_
private
std::unique_ptr<QueryMemoryInitializer> TableFunctionManager::query_buffers

Definition at line 60 of file TableFunctionManager.h.

Referenced by allocate_output_buffers().

std::shared_ptr<RowSetMemoryOwner> TableFunctionManager::row_set_mem_owner_
private
std::thread::id TableFunctionManager::thread_id_
private

Definition at line 380 of file TableFunctionManager.h.

Referenced by check_thread_id().


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