OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RowSetMemoryOwner Class Referencefinal

#include <RowSetMemoryOwner.h>

+ Inheritance diagram for RowSetMemoryOwner:
+ Collaboration diagram for RowSetMemoryOwner:

Classes

struct  CountDistinctBitmapBuffer
 

Public Types

enum  StringTranslationType { StringTranslationType::SOURCE_INTERSECTION, StringTranslationType::SOURCE_UNION }
 

Public Member Functions

 RowSetMemoryOwner (const size_t arena_block_size, const size_t executor_id, const size_t num_kernel_threads=0)
 
int8_t * allocate (const size_t num_bytes, const size_t thread_idx=0) override
 
std::pair< int64_t *, bool > allocateCachedGroupByBuffer (const size_t num_bytes, const size_t thread_idx)
 
int8_t * allocateCountDistinctBuffer (const size_t num_bytes, const size_t thread_idx=0)
 
void addCountDistinctBuffer (int8_t *count_distinct_buffer, const size_t bytes, const bool physical_buffer)
 
void addCountDistinctSet (CountDistinctSet *count_distinct_set)
 
void clearNonOwnedGroupByBuffers ()
 
void addVarlenBuffer (void *varlen_buffer)
 
void addVarlenInputBuffer (Data_Namespace::AbstractBuffer *buffer)
 
std::string * addString (const std::string &str)
 
std::vector< int64_t > * addArray (const std::vector< int64_t > &arr)
 
StringDictionaryProxyaddStringDict (std::shared_ptr< StringDictionary > str_dict, const shared::StringDictKey &dict_key, const int64_t generation)
 
std::string generate_translation_map_key (const shared::StringDictKey &source_proxy_dict_key, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
std::string generate_translation_map_key (const shared::StringDictKey &source_proxy_dict_key, const shared::StringDictKey &dest_proxy_dict_key, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
const
StringDictionaryProxy::IdMap
addStringProxyIntersectionTranslationMap (const StringDictionaryProxy *source_proxy, const StringDictionaryProxy *dest_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
const
StringDictionaryProxy::TranslationMap
< Datum > * 
addStringProxyNumericTranslationMap (const StringDictionaryProxy *source_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
const
StringDictionaryProxy::IdMap
addStringProxyUnionTranslationMap (const StringDictionaryProxy *source_proxy, StringDictionaryProxy *dest_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
const
StringOps_Namespace::StringOps * 
getStringOps (const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
StringDictionaryProxygetStringDictProxy (const shared::StringDictKey &dict_key) const
 
StringDictionaryProxygetOrAddStringDictProxy (const shared::StringDictKey &dict_key, const bool with_generation)
 
void addLiteralStringDictProxy (std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy)
 
StringDictionaryProxygetLiteralStringDictProxy () const
 
const
StringDictionaryProxy::IdMap
getOrAddStringProxyTranslationMap (const shared::StringDictKey &source_dict_id_in, const shared::StringDictKey &dest_dict_id_in, const bool with_generation, const StringTranslationType translation_map_type, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
const
StringDictionaryProxy::TranslationMap
< Datum > * 
getOrAddStringProxyNumericTranslationMap (const shared::StringDictKey &source_dict_id_in, const bool with_generation, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
 
void addColBuffer (const void *col_buffer)
 
 ~RowSetMemoryOwner ()
 
std::shared_ptr
< RowSetMemoryOwner
cloneStrDictDataOnly ()
 
void setDictionaryGenerations (StringDictionaryGenerations generations)
 
StringDictionaryGenerationsgetStringDictionaryGenerations ()
 
quantile::TDigestnullTDigest (double const q)
 
void setTableFunctionMetadata (const char *key, const uint8_t *raw_data, const size_t num_bytes, const TableFunctionMetadataType value_type)
 
void getTableFunctionMetadata (const char *key, const uint8_t *&raw_data, size_t &num_bytes, TableFunctionMetadataType &value_type) const
 
AggModeallocateMode ()
 

Private Types

using MetadataValue = std::pair< std::vector< uint8_t >, TableFunctionMetadataType >
 

Private Attributes

std::vector
< CountDistinctBitmapBuffer
count_distinct_bitmaps_
 
std::vector< CountDistinctSet * > count_distinct_sets_
 
std::vector< int64_t * > non_owned_group_by_buffers_
 
std::vector< void * > varlen_buffers_
 
std::list< std::string > strings_
 
std::list< std::vector< int64_t > > arrays_
 
std::unordered_map
< shared::StringDictKey,
std::shared_ptr
< StringDictionaryProxy > > 
str_dict_proxy_owned_
 
std::map< std::string,
StringDictionaryProxy::IdMap
str_proxy_intersection_translation_maps_owned_
 
std::map< std::string,
StringDictionaryProxy::IdMap
str_proxy_union_translation_maps_owned_
 
std::map< std::string,
StringDictionaryProxy::TranslationMap
< Datum > > 
str_proxy_numeric_translation_maps_owned_
 
std::shared_ptr
< StringDictionaryProxy
lit_str_dict_proxy_
 
StringDictionaryGenerations string_dictionary_generations_
 
std::vector< void * > col_buffers_
 
std::vector
< Data_Namespace::AbstractBuffer * > 
varlen_input_buffers_
 
std::vector< std::unique_ptr
< quantile::TDigest > > 
t_digests_
 
std::map< std::string,
std::shared_ptr
< StringOps_Namespace::StringOps > > 
string_ops_owned_
 
std::list< AggModemode_maps_
 
size_t arena_block_size_
 
std::vector< std::unique_ptr
< Arena > > 
allocators_
 
size_t executor_id_
 
std::mutex state_mutex_
 
std::map< std::string,
MetadataValue
table_function_metadata_store_
 
std::mutex table_function_metadata_store_mutex_
 

Friends

class ResultSet
 
class QueryExecutionContext
 

Additional Inherited Members

- Protected Member Functions inherited from SimpleAllocator
 ~SimpleAllocator ()=default
 

Detailed Description

Handles allocations and outputs for all stages in a query, either explicitly or via a managed allocator object

Definition at line 50 of file RowSetMemoryOwner.h.

Member Typedef Documentation

using RowSetMemoryOwner::MetadataValue = std::pair<std::vector<uint8_t>, TableFunctionMetadataType>
private

Definition at line 410 of file RowSetMemoryOwner.h.

Member Enumeration Documentation

Enumerator
SOURCE_INTERSECTION 
SOURCE_UNION 

Definition at line 67 of file RowSetMemoryOwner.h.

67 { SOURCE_INTERSECTION, SOURCE_UNION };

Constructor & Destructor Documentation

RowSetMemoryOwner::RowSetMemoryOwner ( const size_t  arena_block_size,
const size_t  executor_id,
const size_t  num_kernel_threads = 0 
)
inline

Definition at line 52 of file RowSetMemoryOwner.h.

References allocators_, CHECK, executor_id_, and VLOG.

55  : non_owned_group_by_buffers_(num_kernel_threads + 1, nullptr)
56  , arena_block_size_(arena_block_size)
57  , executor_id_(executor_id) {
58  VLOG(2) << "Prepare " << num_kernel_threads + 1
59  << " allocators from RowSetMemoryOwner attached to Executor-" << executor_id_;
60  allocators_.reserve(num_kernel_threads + 1);
61  for (size_t i = 0; i < num_kernel_threads + 1; i++) {
62  allocators_.emplace_back(std::make_unique<DramArena>(arena_block_size));
63  }
64  CHECK(!allocators_.empty());
65  }
std::vector< std::unique_ptr< Arena > > allocators_
std::vector< int64_t * > non_owned_group_by_buffers_
#define CHECK(condition)
Definition: Logger.h:291
#define VLOG(n)
Definition: Logger.h:388
RowSetMemoryOwner::~RowSetMemoryOwner ( )
inline

Definition at line 293 of file RowSetMemoryOwner.h.

References allocators_, CHECK, col_buffers_, count_distinct_sets_, executor_id_, varlen_buffers_, varlen_input_buffers_, and VLOG.

293  {
294  std::ostringstream oss;
295  oss << "Destruct RowSetMemoryOwner attached to Executor-" << executor_id_ << "{\t";
296  int allocator_id = 0;
297  for (auto const& allocator : allocators_) {
298  auto const usedBytes = allocator->bytesUsed();
299  if (usedBytes > 0) {
300  oss << "allocator-" << allocator_id << ", byteUsed: " << usedBytes << "/"
301  << allocator->totalBytes() << "\t";
302  }
303  ++allocator_id;
304  }
305  oss << "}";
306  VLOG(2) << oss.str();
307  for (auto count_distinct_set : count_distinct_sets_) {
308  delete count_distinct_set;
309  }
310  for (auto varlen_buffer : varlen_buffers_) {
311  free(varlen_buffer);
312  }
313  for (auto varlen_input_buffer : varlen_input_buffers_) {
314  CHECK(varlen_input_buffer);
315  varlen_input_buffer->unPin();
316  }
317  for (auto col_buffer : col_buffers_) {
318  free(col_buffer);
319  }
320  }
std::vector< std::unique_ptr< Arena > > allocators_
std::vector< CountDistinctSet * > count_distinct_sets_
std::vector< void * > col_buffers_
std::vector< void * > varlen_buffers_
std::vector< Data_Namespace::AbstractBuffer * > varlen_input_buffers_
#define CHECK(condition)
Definition: Logger.h:291
#define VLOG(n)
Definition: Logger.h:388

Member Function Documentation

std::vector<int64_t>* RowSetMemoryOwner::addArray ( const std::vector< int64_t > &  arr)
inline

Definition at line 143 of file RowSetMemoryOwner.h.

References arrays_, and state_mutex_.

143  {
144  std::lock_guard<std::mutex> lock(state_mutex_);
145  arrays_.emplace_back(arr);
146  return &arrays_.back();
147  }
std::list< std::vector< int64_t > > arrays_
void RowSetMemoryOwner::addColBuffer ( const void *  col_buffer)
inline

Definition at line 288 of file RowSetMemoryOwner.h.

References col_buffers_, and state_mutex_.

288  {
289  std::lock_guard<std::mutex> lock(state_mutex_);
290  col_buffers_.push_back(const_cast<void*>(col_buffer));
291  }
std::vector< void * > col_buffers_
void RowSetMemoryOwner::addCountDistinctBuffer ( int8_t *  count_distinct_buffer,
const size_t  bytes,
const bool  physical_buffer 
)
inline

Definition at line 101 of file RowSetMemoryOwner.h.

References count_distinct_bitmaps_, and state_mutex_.

Referenced by allocateCountDistinctBuffer().

103  {
104  std::lock_guard<std::mutex> lock(state_mutex_);
105  count_distinct_bitmaps_.emplace_back(
106  CountDistinctBitmapBuffer{count_distinct_buffer, bytes, physical_buffer});
107  }
std::vector< CountDistinctBitmapBuffer > count_distinct_bitmaps_

+ Here is the caller graph for this function:

void RowSetMemoryOwner::addCountDistinctSet ( CountDistinctSet count_distinct_set)
inline

Definition at line 109 of file RowSetMemoryOwner.h.

References count_distinct_sets_, and state_mutex_.

109  {
110  std::lock_guard<std::mutex> lock(state_mutex_);
111  count_distinct_sets_.push_back(count_distinct_set);
112  }
std::vector< CountDistinctSet * > count_distinct_sets_
void RowSetMemoryOwner::addLiteralStringDictProxy ( std::shared_ptr< StringDictionaryProxy lit_str_dict_proxy)
inline

Definition at line 264 of file RowSetMemoryOwner.h.

References lit_str_dict_proxy_, and state_mutex_.

265  {
266  std::lock_guard<std::mutex> lock(state_mutex_);
267  lit_str_dict_proxy_ = lit_str_dict_proxy;
268  }
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
std::string* RowSetMemoryOwner::addString ( const std::string &  str)
inline

Definition at line 137 of file RowSetMemoryOwner.h.

References state_mutex_, and strings_.

137  {
138  std::lock_guard<std::mutex> lock(state_mutex_);
139  strings_.emplace_back(str);
140  return &strings_.back();
141  }
std::list< std::string > strings_
StringDictionaryProxy* RowSetMemoryOwner::addStringDict ( std::shared_ptr< StringDictionary str_dict,
const shared::StringDictKey dict_key,
const int64_t  generation 
)
inline

Definition at line 149 of file RowSetMemoryOwner.h.

References CHECK_EQ, state_mutex_, and str_dict_proxy_owned_.

151  {
152  std::lock_guard<std::mutex> lock(state_mutex_);
153  auto it = str_dict_proxy_owned_.find(dict_key);
154  if (it != str_dict_proxy_owned_.end()) {
155  CHECK_EQ(it->second->getDictionary(), str_dict.get());
156  it->second->updateGeneration(generation);
157  return it->second.get();
158  }
160  .emplace(
161  dict_key,
162  std::make_shared<StringDictionaryProxy>(str_dict, dict_key, generation))
163  .first;
164  return it->second.get();
165  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
std::unordered_map< shared::StringDictKey, std::shared_ptr< StringDictionaryProxy > > str_dict_proxy_owned_
const StringDictionaryProxy::IdMap* RowSetMemoryOwner::addStringProxyIntersectionTranslationMap ( const StringDictionaryProxy source_proxy,
const StringDictionaryProxy dest_proxy,
const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos 
)
inline

Definition at line 187 of file RowSetMemoryOwner.h.

References StringDictionaryProxy::buildIntersectionTranslationMapToOtherProxy(), generate_translation_map_key(), StringDictionaryProxy::getDictionary(), StringDictionary::getDictKey(), state_mutex_, and str_proxy_intersection_translation_maps_owned_.

190  {
191  std::lock_guard<std::mutex> lock(state_mutex_);
192  const auto map_key =
194  dest_proxy->getDictionary()->getDictKey(),
195  string_op_infos);
196  auto it = str_proxy_intersection_translation_maps_owned_.find(map_key);
199  .emplace(map_key,
201  dest_proxy, string_op_infos))
202  .first;
203  }
204  return &it->second;
205  }
const shared::StringDictKey & getDictKey() const noexcept
StringDictionary * getDictionary() const noexcept
std::map< std::string, StringDictionaryProxy::IdMap > str_proxy_intersection_translation_maps_owned_
IdMap buildIntersectionTranslationMapToOtherProxy(const StringDictionaryProxy *dest_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos) const
std::string generate_translation_map_key(const shared::StringDictKey &source_proxy_dict_key, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)

+ Here is the call graph for this function:

const StringDictionaryProxy::TranslationMap<Datum>* RowSetMemoryOwner::addStringProxyNumericTranslationMap ( const StringDictionaryProxy source_proxy,
const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos 
)
inline

Definition at line 207 of file RowSetMemoryOwner.h.

References StringDictionaryProxy::buildNumericTranslationMap(), generate_translation_map_key(), StringDictionaryProxy::getDictionary(), StringDictionary::getDictKey(), and str_proxy_numeric_translation_maps_owned_.

209  {
210  const auto map_key = generate_translation_map_key(
211  source_proxy->getDictionary()->getDictKey(), string_op_infos);
212  auto it = str_proxy_numeric_translation_maps_owned_.lower_bound(map_key);
213  if (it->first != map_key) {
215  it, map_key, source_proxy->buildNumericTranslationMap(string_op_infos));
216  }
217  return &it->second;
218  }
const shared::StringDictKey & getDictKey() const noexcept
std::map< std::string, StringDictionaryProxy::TranslationMap< Datum > > str_proxy_numeric_translation_maps_owned_
StringDictionary * getDictionary() const noexcept
TranslationMap< Datum > buildNumericTranslationMap(const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos) const
Builds a vectorized string_id translation map from this proxy to dest_proxy.
std::string generate_translation_map_key(const shared::StringDictKey &source_proxy_dict_key, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)

+ Here is the call graph for this function:

const StringDictionaryProxy::IdMap* RowSetMemoryOwner::addStringProxyUnionTranslationMap ( const StringDictionaryProxy source_proxy,
StringDictionaryProxy dest_proxy,
const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos 
)
inline

Definition at line 220 of file RowSetMemoryOwner.h.

References StringDictionaryProxy::buildUnionTranslationMapToOtherProxy(), generate_translation_map_key(), StringDictionaryProxy::getDictionary(), StringDictionary::getDictKey(), state_mutex_, and str_proxy_union_translation_maps_owned_.

223  {
224  std::lock_guard<std::mutex> lock(state_mutex_);
225  const auto map_key =
227  dest_proxy->getDictionary()->getDictKey(),
228  string_op_infos);
229  auto it = str_proxy_union_translation_maps_owned_.find(map_key);
230  if (it == str_proxy_union_translation_maps_owned_.end()) {
232  .emplace(map_key,
234  dest_proxy, string_op_infos))
235  .first;
236  }
237  return &it->second;
238  }
const shared::StringDictKey & getDictKey() const noexcept
StringDictionary * getDictionary() const noexcept
std::map< std::string, StringDictionaryProxy::IdMap > str_proxy_union_translation_maps_owned_
IdMap buildUnionTranslationMapToOtherProxy(StringDictionaryProxy *dest_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_types) const
std::string generate_translation_map_key(const shared::StringDictKey &source_proxy_dict_key, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)

+ Here is the call graph for this function:

void RowSetMemoryOwner::addVarlenBuffer ( void *  varlen_buffer)
inline

Definition at line 118 of file RowSetMemoryOwner.h.

References state_mutex_, and varlen_buffers_.

118  {
119  std::lock_guard<std::mutex> lock(state_mutex_);
120  if (std::find(varlen_buffers_.begin(), varlen_buffers_.end(), varlen_buffer) ==
121  varlen_buffers_.end()) {
122  varlen_buffers_.push_back(varlen_buffer);
123  }
124  }
std::vector< void * > varlen_buffers_
void RowSetMemoryOwner::addVarlenInputBuffer ( Data_Namespace::AbstractBuffer buffer)
inline

Adds a GPU buffer containing a variable length input column. Variable length inputs on GPU are referenced in output projected targets and should not be freed until the query results have been resolved.

Definition at line 131 of file RowSetMemoryOwner.h.

References CHECK_EQ, Data_Namespace::AbstractBuffer::getType(), Data_Namespace::GPU_LEVEL, state_mutex_, and varlen_input_buffers_.

131  {
132  std::lock_guard<std::mutex> lock(state_mutex_);
134  varlen_input_buffers_.push_back(buffer);
135  }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
virtual MemoryLevel getType() const =0
std::vector< Data_Namespace::AbstractBuffer * > varlen_input_buffers_

+ Here is the call graph for this function:

int8_t* RowSetMemoryOwner::allocate ( const size_t  num_bytes,
const size_t  thread_idx = 0 
)
inlineoverridevirtual

Implements SimpleAllocator.

Definition at line 69 of file RowSetMemoryOwner.h.

References allocators_, CHECK_LT, and state_mutex_.

Referenced by anonymous_namespace{QueryMemoryInitializer.cpp}::alloc_group_by_buffer(), and allocateCountDistinctBuffer().

69  {
70  CHECK_LT(thread_idx, allocators_.size());
71  auto allocator = allocators_[thread_idx].get();
72  std::lock_guard<std::mutex> lock(state_mutex_);
73  return reinterpret_cast<int8_t*>(allocator->allocate(num_bytes));
74  }
std::vector< std::unique_ptr< Arena > > allocators_
#define CHECK_LT(x, y)
Definition: Logger.h:303

+ Here is the caller graph for this function:

std::pair<int64_t*, bool> RowSetMemoryOwner::allocateCachedGroupByBuffer ( const size_t  num_bytes,
const size_t  thread_idx 
)
inline

Definition at line 76 of file RowSetMemoryOwner.h.

References allocators_, CHECK, CHECK_LT, non_owned_group_by_buffers_, and state_mutex_.

Referenced by anonymous_namespace{QueryMemoryInitializer.cpp}::alloc_group_by_buffer().

77  {
78  std::lock_guard<std::mutex> lock(state_mutex_);
79  CHECK_LT(thread_idx, non_owned_group_by_buffers_.size());
80  // First try cache
81  if (non_owned_group_by_buffers_[thread_idx]) { // not nullptr
82  return std::make_pair(non_owned_group_by_buffers_[thread_idx], true);
83  }
84  // Was not in cache so must allocate
85  auto allocator = allocators_[thread_idx].get();
86  int64_t* group_by_buffer = reinterpret_cast<int64_t*>(allocator->allocate(num_bytes));
87  CHECK(group_by_buffer);
88  // Put in cache
89  non_owned_group_by_buffers_[thread_idx] = group_by_buffer;
90  return std::make_pair(group_by_buffer, false);
91  }
std::vector< std::unique_ptr< Arena > > allocators_
#define CHECK_LT(x, y)
Definition: Logger.h:303
std::vector< int64_t * > non_owned_group_by_buffers_
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

int8_t* RowSetMemoryOwner::allocateCountDistinctBuffer ( const size_t  num_bytes,
const size_t  thread_idx = 0 
)
inline

Definition at line 93 of file RowSetMemoryOwner.h.

References addCountDistinctBuffer(), and allocate().

94  {
95  int8_t* buffer = allocate(num_bytes, thread_idx);
96  std::memset(buffer, 0, num_bytes);
97  addCountDistinctBuffer(buffer, num_bytes, /*physical_buffer=*/true);
98  return buffer;
99  }
void addCountDistinctBuffer(int8_t *count_distinct_buffer, const size_t bytes, const bool physical_buffer)
int8_t * allocate(const size_t num_bytes, const size_t thread_idx=0) override

+ Here is the call graph for this function:

AggMode* RowSetMemoryOwner::allocateMode ( )
inline

Definition at line 369 of file RowSetMemoryOwner.h.

References mode_maps_, and state_mutex_.

369  {
370  std::lock_guard<std::mutex> lock(state_mutex_);
371  return &mode_maps_.emplace_back();
372  }
std::list< AggMode > mode_maps_
void RowSetMemoryOwner::clearNonOwnedGroupByBuffers ( )
inline

Definition at line 114 of file RowSetMemoryOwner.h.

References non_owned_group_by_buffers_.

114  {
116  }
std::vector< int64_t * > non_owned_group_by_buffers_
std::shared_ptr<RowSetMemoryOwner> RowSetMemoryOwner::cloneStrDictDataOnly ( )
inline

Definition at line 322 of file RowSetMemoryOwner.h.

References arena_block_size_, executor_id_, lit_str_dict_proxy_, and str_dict_proxy_owned_.

322  {
323  auto rtn = std::make_shared<RowSetMemoryOwner>(
324  arena_block_size_, executor_id_, /*num_kernels=*/1);
325  rtn->str_dict_proxy_owned_ = str_dict_proxy_owned_;
326  rtn->lit_str_dict_proxy_ = lit_str_dict_proxy_;
327  return rtn;
328  }
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
std::unordered_map< shared::StringDictKey, std::shared_ptr< StringDictionaryProxy > > str_dict_proxy_owned_
std::string RowSetMemoryOwner::generate_translation_map_key ( const shared::StringDictKey source_proxy_dict_key,
const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos 
)
inline

Definition at line 167 of file RowSetMemoryOwner.h.

Referenced by addStringProxyIntersectionTranslationMap(), addStringProxyNumericTranslationMap(), addStringProxyUnionTranslationMap(), and getStringOps().

169  {
170  std::ostringstream oss;
171  oss << "{source_dict_key: " << source_proxy_dict_key
172  << " StringOps: " << string_op_infos << "}";
173  return oss.str();
174  }

+ Here is the caller graph for this function:

std::string RowSetMemoryOwner::generate_translation_map_key ( const shared::StringDictKey source_proxy_dict_key,
const shared::StringDictKey dest_proxy_dict_key,
const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos 
)
inline

Definition at line 176 of file RowSetMemoryOwner.h.

179  {
180  std::ostringstream oss;
181  oss << "{source_dict_key: " << source_proxy_dict_key
182  << ", dest_dict_key: " << dest_proxy_dict_key << " StringOps: " << string_op_infos
183  << "}";
184  return oss.str();
185  }
StringDictionaryProxy* RowSetMemoryOwner::getLiteralStringDictProxy ( ) const
inline

Definition at line 270 of file RowSetMemoryOwner.h.

References lit_str_dict_proxy_, and state_mutex_.

270  {
271  std::lock_guard<std::mutex> lock(state_mutex_);
272  return lit_str_dict_proxy_.get();
273  }
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
StringDictionaryProxy * RowSetMemoryOwner::getOrAddStringDictProxy ( const shared::StringDictKey dict_key,
const bool  with_generation 
)

Definition at line 572 of file Execute.cpp.

References CHECK, CHECK_EQ, CHECK_LE, shared::StringDictKey::db_id, shared::StringDictKey::dict_id, g_cache_string_hash, Catalog_Namespace::SysCatalog::getCatalog(), Catalog_Namespace::SysCatalog::instance(), dict_ref_t::literalsDictId, and REGULAR_DICT.

574  {
575  const int dict_id{dict_key_in.dict_id < 0 ? REGULAR_DICT(dict_key_in.dict_id)
576  : dict_key_in.dict_id};
577  const auto catalog =
579  if (catalog) {
580  const auto dd = catalog->getMetadataForDict(dict_id);
581  if (dd) {
582  auto dict_key = dict_key_in;
583  dict_key.dict_id = dict_id;
584  CHECK(dd->stringDict);
585  CHECK_LE(dd->dictNBits, 32);
586  const int64_t generation =
587  with_generation ? string_dictionary_generations_.getGeneration(dict_key) : -1;
588  return addStringDict(dd->stringDict, dict_key, generation);
589  }
590  }
592  if (!lit_str_dict_proxy_) {
593  DictRef literal_dict_ref(dict_key_in.db_id, DictRef::literalsDictId);
594  std::shared_ptr<StringDictionary> tsd = std::make_shared<StringDictionary>(
595  literal_dict_ref, "", false, true, g_cache_string_hash);
596  lit_str_dict_proxy_ = std::make_shared<StringDictionaryProxy>(
597  tsd, shared::StringDictKey{literal_dict_ref.dbId, literal_dict_ref.dictId}, 0);
598  }
599  return lit_str_dict_proxy_.get();
600 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
StringDictionaryProxy * addStringDict(std::shared_ptr< StringDictionary > str_dict, const shared::StringDictKey &dict_key, const int64_t generation)
static SysCatalog & instance()
Definition: SysCatalog.h:343
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
StringDictionaryGenerations string_dictionary_generations_
int64_t getGeneration(const shared::StringDictKey &dict_key) const
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
#define REGULAR_DICT(TRANSIENTID)
Definition: sqltypes.h:323
#define CHECK_LE(x, y)
Definition: Logger.h:304
bool g_cache_string_hash
#define CHECK(condition)
Definition: Logger.h:291
static constexpr int32_t literalsDictId
Definition: DictRef.h:18

+ Here is the call graph for this function:

const StringDictionaryProxy::TranslationMap< Datum > * RowSetMemoryOwner::getOrAddStringProxyNumericTranslationMap ( const shared::StringDictKey source_dict_id_in,
const bool  with_generation,
const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos 
)

Definition at line 665 of file Execute.cpp.

668  {
669  const auto source_proxy = getOrAddStringDictProxy(source_dict_key_in, with_generation);
670  return addStringProxyNumericTranslationMap(source_proxy, string_op_infos);
671 }
const StringDictionaryProxy::TranslationMap< Datum > * addStringProxyNumericTranslationMap(const StringDictionaryProxy *source_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
StringDictionaryProxy * getOrAddStringDictProxy(const shared::StringDictKey &dict_key, const bool with_generation)
Definition: Execute.cpp:572
const StringDictionaryProxy::IdMap * RowSetMemoryOwner::getOrAddStringProxyTranslationMap ( const shared::StringDictKey source_dict_id_in,
const shared::StringDictKey dest_dict_id_in,
const bool  with_generation,
const StringTranslationType  translation_map_type,
const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos 
)

Definition at line 648 of file Execute.cpp.

References SOURCE_INTERSECTION.

653  {
654  const auto source_proxy = getOrAddStringDictProxy(source_dict_key_in, with_generation);
655  const auto dest_proxy = getOrAddStringDictProxy(dest_dict_key_in, with_generation);
658  source_proxy, dest_proxy, string_op_infos);
659  } else {
660  return addStringProxyUnionTranslationMap(source_proxy, dest_proxy, string_op_infos);
661  }
662 }
const StringDictionaryProxy::IdMap * addStringProxyUnionTranslationMap(const StringDictionaryProxy *source_proxy, StringDictionaryProxy *dest_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
const StringDictionaryProxy::IdMap * addStringProxyIntersectionTranslationMap(const StringDictionaryProxy *source_proxy, const StringDictionaryProxy *dest_proxy, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)
StringDictionaryProxy * getOrAddStringDictProxy(const shared::StringDictKey &dict_key, const bool with_generation)
Definition: Execute.cpp:572
StringDictionaryGenerations& RowSetMemoryOwner::getStringDictionaryGenerations ( )
inline

Definition at line 334 of file RowSetMemoryOwner.h.

References string_dictionary_generations_.

334  {
336  }
StringDictionaryGenerations string_dictionary_generations_
StringDictionaryProxy* RowSetMemoryOwner::getStringDictProxy ( const shared::StringDictKey dict_key) const
inline

Definition at line 254 of file RowSetMemoryOwner.h.

References CHECK, state_mutex_, and str_dict_proxy_owned_.

254  {
255  std::lock_guard<std::mutex> lock(state_mutex_);
256  auto it = str_dict_proxy_owned_.find(dict_key);
257  CHECK(it != str_dict_proxy_owned_.end());
258  return it->second.get();
259  }
std::unordered_map< shared::StringDictKey, std::shared_ptr< StringDictionaryProxy > > str_dict_proxy_owned_
#define CHECK(condition)
Definition: Logger.h:291
const StringOps_Namespace::StringOps* RowSetMemoryOwner::getStringOps ( const std::vector< StringOps_Namespace::StringOpInfo > &  string_op_infos)
inline

Definition at line 240 of file RowSetMemoryOwner.h.

References generate_translation_map_key(), state_mutex_, and string_ops_owned_.

241  {
242  std::lock_guard<std::mutex> lock(state_mutex_);
243  const auto map_key = generate_translation_map_key({}, {}, string_op_infos);
244  auto it = string_ops_owned_.find(map_key);
245  if (it == string_ops_owned_.end()) {
246  it = string_ops_owned_
247  .emplace(map_key,
248  std::make_shared<StringOps_Namespace::StringOps>(string_op_infos))
249  .first;
250  }
251  return it->second.get();
252  }
std::map< std::string, std::shared_ptr< StringOps_Namespace::StringOps > > string_ops_owned_
std::string generate_translation_map_key(const shared::StringDictKey &source_proxy_dict_key, const std::vector< StringOps_Namespace::StringOpInfo > &string_op_infos)

+ Here is the call graph for this function:

void RowSetMemoryOwner::getTableFunctionMetadata ( const char *  key,
const uint8_t *&  raw_data,
size_t &  num_bytes,
TableFunctionMetadataType value_type 
) const
inline

Definition at line 354 of file RowSetMemoryOwner.h.

References table_function_metadata_store_, and table_function_metadata_store_mutex_.

357  {
358  std::lock_guard<std::mutex> lock(table_function_metadata_store_mutex_);
359  auto const itr = table_function_metadata_store_.find(key);
360  if (itr == table_function_metadata_store_.end()) {
361  throw std::runtime_error("Failed to find Table Function Metadata with key '" +
362  std::string(key) + "'");
363  }
364  raw_data = itr->second.first.data();
365  num_bytes = itr->second.first.size();
366  value_type = itr->second.second;
367  }
std::mutex table_function_metadata_store_mutex_
std::map< std::string, MetadataValue > table_function_metadata_store_
quantile::TDigest * RowSetMemoryOwner::nullTDigest ( double const  q)

Definition at line 673 of file Execute.cpp.

References g_approx_quantile_buffer, and g_approx_quantile_centroids.

673  {
674  std::lock_guard<std::mutex> lock(state_mutex_);
675  return t_digests_
676  .emplace_back(std::make_unique<quantile::TDigest>(
678  .get();
679 }
size_t g_approx_quantile_buffer
Definition: Execute.cpp:167
std::vector< std::unique_ptr< quantile::TDigest > > t_digests_
size_t g_approx_quantile_centroids
Definition: Execute.cpp:168
void RowSetMemoryOwner::setDictionaryGenerations ( StringDictionaryGenerations  generations)
inline

Definition at line 330 of file RowSetMemoryOwner.h.

References string_dictionary_generations_.

330  {
331  string_dictionary_generations_ = generations;
332  }
StringDictionaryGenerations string_dictionary_generations_
void RowSetMemoryOwner::setTableFunctionMetadata ( const char *  key,
const uint8_t *  raw_data,
const size_t  num_bytes,
const TableFunctionMetadataType  value_type 
)
inline

Definition at line 344 of file RowSetMemoryOwner.h.

References table_function_metadata_store_, and table_function_metadata_store_mutex_.

347  {
348  MetadataValue metadata_value(num_bytes, value_type);
349  std::memcpy(metadata_value.first.data(), raw_data, num_bytes);
350  std::lock_guard<std::mutex> lock(table_function_metadata_store_mutex_);
351  table_function_metadata_store_[key] = std::move(metadata_value);
352  }
std::pair< std::vector< uint8_t >, TableFunctionMetadataType > MetadataValue
std::mutex table_function_metadata_store_mutex_
std::map< std::string, MetadataValue > table_function_metadata_store_

Friends And Related Function Documentation

friend class QueryExecutionContext
friend

Definition at line 415 of file RowSetMemoryOwner.h.

friend class ResultSet
friend

Definition at line 414 of file RowSetMemoryOwner.h.

Member Data Documentation

std::vector<std::unique_ptr<Arena> > RowSetMemoryOwner::allocators_
private
size_t RowSetMemoryOwner::arena_block_size_
private

Definition at line 404 of file RowSetMemoryOwner.h.

Referenced by cloneStrDictDataOnly().

std::list<std::vector<int64_t> > RowSetMemoryOwner::arrays_
private

Definition at line 386 of file RowSetMemoryOwner.h.

Referenced by addArray().

std::vector<void*> RowSetMemoryOwner::col_buffers_
private

Definition at line 397 of file RowSetMemoryOwner.h.

Referenced by addColBuffer(), and ~RowSetMemoryOwner().

std::vector<CountDistinctBitmapBuffer> RowSetMemoryOwner::count_distinct_bitmaps_
private

Definition at line 381 of file RowSetMemoryOwner.h.

Referenced by addCountDistinctBuffer().

std::vector<CountDistinctSet*> RowSetMemoryOwner::count_distinct_sets_
private

Definition at line 382 of file RowSetMemoryOwner.h.

Referenced by addCountDistinctSet(), and ~RowSetMemoryOwner().

size_t RowSetMemoryOwner::executor_id_
private
std::shared_ptr<StringDictionaryProxy> RowSetMemoryOwner::lit_str_dict_proxy_
private
std::list<AggMode> RowSetMemoryOwner::mode_maps_
private

Definition at line 402 of file RowSetMemoryOwner.h.

Referenced by allocateMode().

std::vector<int64_t*> RowSetMemoryOwner::non_owned_group_by_buffers_
private
std::unordered_map<shared::StringDictKey, std::shared_ptr<StringDictionaryProxy> > RowSetMemoryOwner::str_dict_proxy_owned_
private

Definition at line 388 of file RowSetMemoryOwner.h.

Referenced by addStringDict(), cloneStrDictDataOnly(), and getStringDictProxy().

std::map<std::string, StringDictionaryProxy::IdMap> RowSetMemoryOwner::str_proxy_intersection_translation_maps_owned_
private

Definition at line 390 of file RowSetMemoryOwner.h.

Referenced by addStringProxyIntersectionTranslationMap().

std::map<std::string, StringDictionaryProxy::TranslationMap<Datum> > RowSetMemoryOwner::str_proxy_numeric_translation_maps_owned_
private

Definition at line 394 of file RowSetMemoryOwner.h.

Referenced by addStringProxyNumericTranslationMap().

std::map<std::string, StringDictionaryProxy::IdMap> RowSetMemoryOwner::str_proxy_union_translation_maps_owned_
private

Definition at line 392 of file RowSetMemoryOwner.h.

Referenced by addStringProxyUnionTranslationMap().

StringDictionaryGenerations RowSetMemoryOwner::string_dictionary_generations_
private
std::map<std::string, std::shared_ptr<StringOps_Namespace::StringOps> > RowSetMemoryOwner::string_ops_owned_
private

Definition at line 401 of file RowSetMemoryOwner.h.

Referenced by getStringOps().

std::list<std::string> RowSetMemoryOwner::strings_
private

Definition at line 385 of file RowSetMemoryOwner.h.

Referenced by addString().

std::vector<std::unique_ptr<quantile::TDigest> > RowSetMemoryOwner::t_digests_
private

Definition at line 399 of file RowSetMemoryOwner.h.

std::map<std::string, MetadataValue> RowSetMemoryOwner::table_function_metadata_store_
private

Definition at line 411 of file RowSetMemoryOwner.h.

Referenced by getTableFunctionMetadata(), and setTableFunctionMetadata().

std::mutex RowSetMemoryOwner::table_function_metadata_store_mutex_
mutableprivate

Definition at line 412 of file RowSetMemoryOwner.h.

Referenced by getTableFunctionMetadata(), and setTableFunctionMetadata().

std::vector<void*> RowSetMemoryOwner::varlen_buffers_
private

Definition at line 384 of file RowSetMemoryOwner.h.

Referenced by addVarlenBuffer(), and ~RowSetMemoryOwner().

std::vector<Data_Namespace::AbstractBuffer*> RowSetMemoryOwner::varlen_input_buffers_
private

Definition at line 398 of file RowSetMemoryOwner.h.

Referenced by addVarlenInputBuffer(), and ~RowSetMemoryOwner().


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