OmniSciDB  c1a53651b2
 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 num_kernel_threads=0)
 
int8_t * allocate (const size_t num_bytes, const size_t thread_idx=0) override
 
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 addGroupByBuffer (int64_t *group_by_buffer)
 
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 * > 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_
 
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 375 of file RowSetMemoryOwner.h.

Member Enumeration Documentation

Enumerator
SOURCE_INTERSECTION 
SOURCE_UNION 

Definition at line 60 of file RowSetMemoryOwner.h.

60 { SOURCE_INTERSECTION, SOURCE_UNION };

Constructor & Destructor Documentation

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

Definition at line 52 of file RowSetMemoryOwner.h.

References allocators_, and CHECK.

53  : arena_block_size_(arena_block_size) {
54  for (size_t i = 0; i < num_kernel_threads + 1; i++) {
55  allocators_.emplace_back(std::make_unique<DramArena>(arena_block_size));
56  }
57  CHECK(!allocators_.empty());
58  }
std::vector< std::unique_ptr< Arena > > allocators_
#define CHECK(condition)
Definition: Logger.h:291
RowSetMemoryOwner::~RowSetMemoryOwner ( )
inline

Definition at line 270 of file RowSetMemoryOwner.h.

References CHECK, col_buffers_, count_distinct_sets_, group_by_buffers_, varlen_buffers_, and varlen_input_buffers_.

270  {
271  for (auto count_distinct_set : count_distinct_sets_) {
272  delete count_distinct_set;
273  }
274  for (auto group_by_buffer : group_by_buffers_) {
275  free(group_by_buffer);
276  }
277  for (auto varlen_buffer : varlen_buffers_) {
278  free(varlen_buffer);
279  }
280  for (auto varlen_input_buffer : varlen_input_buffers_) {
281  CHECK(varlen_input_buffer);
282  varlen_input_buffer->unPin();
283  }
284  for (auto col_buffer : col_buffers_) {
285  free(col_buffer);
286  }
287  }
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
std::vector< int64_t * > group_by_buffers_

Member Function Documentation

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

Definition at line 120 of file RowSetMemoryOwner.h.

References arrays_, and state_mutex_.

120  {
121  std::lock_guard<std::mutex> lock(state_mutex_);
122  arrays_.emplace_back(arr);
123  return &arrays_.back();
124  }
std::list< std::vector< int64_t > > arrays_
void RowSetMemoryOwner::addColBuffer ( const void *  col_buffer)
inline

Definition at line 265 of file RowSetMemoryOwner.h.

References col_buffers_, and state_mutex_.

265  {
266  std::lock_guard<std::mutex> lock(state_mutex_);
267  col_buffers_.push_back(const_cast<void*>(col_buffer));
268  }
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 77 of file RowSetMemoryOwner.h.

References count_distinct_bitmaps_, and state_mutex_.

Referenced by allocateCountDistinctBuffer().

79  {
80  std::lock_guard<std::mutex> lock(state_mutex_);
81  count_distinct_bitmaps_.emplace_back(
82  CountDistinctBitmapBuffer{count_distinct_buffer, bytes, physical_buffer});
83  }
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 85 of file RowSetMemoryOwner.h.

References count_distinct_sets_, and state_mutex_.

85  {
86  std::lock_guard<std::mutex> lock(state_mutex_);
87  count_distinct_sets_.push_back(count_distinct_set);
88  }
std::vector< CountDistinctSet * > count_distinct_sets_
void RowSetMemoryOwner::addGroupByBuffer ( int64_t *  group_by_buffer)
inline

Definition at line 90 of file RowSetMemoryOwner.h.

References group_by_buffers_, and state_mutex_.

90  {
91  std::lock_guard<std::mutex> lock(state_mutex_);
92  group_by_buffers_.push_back(group_by_buffer);
93  }
std::vector< int64_t * > group_by_buffers_
void RowSetMemoryOwner::addLiteralStringDictProxy ( std::shared_ptr< StringDictionaryProxy lit_str_dict_proxy)
inline

Definition at line 241 of file RowSetMemoryOwner.h.

References lit_str_dict_proxy_, and state_mutex_.

242  {
243  std::lock_guard<std::mutex> lock(state_mutex_);
244  lit_str_dict_proxy_ = lit_str_dict_proxy;
245  }
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
std::string* RowSetMemoryOwner::addString ( const std::string &  str)
inline

Definition at line 114 of file RowSetMemoryOwner.h.

References state_mutex_, and strings_.

114  {
115  std::lock_guard<std::mutex> lock(state_mutex_);
116  strings_.emplace_back(str);
117  return &strings_.back();
118  }
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 126 of file RowSetMemoryOwner.h.

References CHECK_EQ, state_mutex_, and str_dict_proxy_owned_.

128  {
129  std::lock_guard<std::mutex> lock(state_mutex_);
130  auto it = str_dict_proxy_owned_.find(dict_key);
131  if (it != str_dict_proxy_owned_.end()) {
132  CHECK_EQ(it->second->getDictionary(), str_dict.get());
133  it->second->updateGeneration(generation);
134  return it->second.get();
135  }
137  .emplace(
138  dict_key,
139  std::make_shared<StringDictionaryProxy>(str_dict, dict_key, generation))
140  .first;
141  return it->second.get();
142  }
#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 164 of file RowSetMemoryOwner.h.

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

167  {
168  std::lock_guard<std::mutex> lock(state_mutex_);
169  const auto map_key =
171  dest_proxy->getDictionary()->getDictKey(),
172  string_op_infos);
173  auto it = str_proxy_intersection_translation_maps_owned_.find(map_key);
176  .emplace(map_key,
178  dest_proxy, string_op_infos))
179  .first;
180  }
181  return &it->second;
182  }
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 184 of file RowSetMemoryOwner.h.

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

186  {
187  const auto map_key = generate_translation_map_key(
188  source_proxy->getDictionary()->getDictKey(), string_op_infos);
189  auto it = str_proxy_numeric_translation_maps_owned_.lower_bound(map_key);
190  if (it->first != map_key) {
192  it, map_key, source_proxy->buildNumericTranslationMap(string_op_infos));
193  }
194  return &it->second;
195  }
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 197 of file RowSetMemoryOwner.h.

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

200  {
201  std::lock_guard<std::mutex> lock(state_mutex_);
202  const auto map_key =
204  dest_proxy->getDictionary()->getDictKey(),
205  string_op_infos);
206  auto it = str_proxy_union_translation_maps_owned_.find(map_key);
207  if (it == str_proxy_union_translation_maps_owned_.end()) {
209  .emplace(map_key,
211  dest_proxy, string_op_infos))
212  .first;
213  }
214  return &it->second;
215  }
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 95 of file RowSetMemoryOwner.h.

References state_mutex_, and varlen_buffers_.

95  {
96  std::lock_guard<std::mutex> lock(state_mutex_);
97  if (std::find(varlen_buffers_.begin(), varlen_buffers_.end(), varlen_buffer) ==
98  varlen_buffers_.end()) {
99  varlen_buffers_.push_back(varlen_buffer);
100  }
101  }
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 108 of file RowSetMemoryOwner.h.

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

108  {
109  std::lock_guard<std::mutex> lock(state_mutex_);
111  varlen_input_buffers_.push_back(buffer);
112  }
#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 62 of file RowSetMemoryOwner.h.

References allocators_, CHECK_LT, and state_mutex_.

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

62  {
63  CHECK_LT(thread_idx, allocators_.size());
64  auto allocator = allocators_[thread_idx].get();
65  std::lock_guard<std::mutex> lock(state_mutex_);
66  return reinterpret_cast<int8_t*>(allocator->allocate(num_bytes));
67  }
std::vector< std::unique_ptr< Arena > > allocators_
#define CHECK_LT(x, y)
Definition: Logger.h:303

+ 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 69 of file RowSetMemoryOwner.h.

References addCountDistinctBuffer(), and allocate().

70  {
71  int8_t* buffer = allocate(num_bytes, thread_idx);
72  std::memset(buffer, 0, num_bytes);
73  addCountDistinctBuffer(buffer, num_bytes, /*physical_buffer=*/true);
74  return buffer;
75  }
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 335 of file RowSetMemoryOwner.h.

References mode_maps_, and state_mutex_.

335  {
336  std::lock_guard<std::mutex> lock(state_mutex_);
337  return &mode_maps_.emplace_back();
338  }
std::list< AggMode > mode_maps_
std::shared_ptr<RowSetMemoryOwner> RowSetMemoryOwner::cloneStrDictDataOnly ( )
inline

Definition at line 289 of file RowSetMemoryOwner.h.

References arena_block_size_, lit_str_dict_proxy_, and str_dict_proxy_owned_.

289  {
290  auto rtn = std::make_shared<RowSetMemoryOwner>(arena_block_size_, /*num_kernels=*/1);
291  rtn->str_dict_proxy_owned_ = str_dict_proxy_owned_;
292  rtn->lit_str_dict_proxy_ = lit_str_dict_proxy_;
293  return rtn;
294  }
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 144 of file RowSetMemoryOwner.h.

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

146  {
147  std::ostringstream oss;
148  oss << "{source_dict_key: " << source_proxy_dict_key
149  << " StringOps: " << string_op_infos << "}";
150  return oss.str();
151  }

+ 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 153 of file RowSetMemoryOwner.h.

156  {
157  std::ostringstream oss;
158  oss << "{source_dict_key: " << source_proxy_dict_key
159  << ", dest_dict_key: " << dest_proxy_dict_key << " StringOps: " << string_op_infos
160  << "}";
161  return oss.str();
162  }
StringDictionaryProxy* RowSetMemoryOwner::getLiteralStringDictProxy ( ) const
inline

Definition at line 247 of file RowSetMemoryOwner.h.

References lit_str_dict_proxy_, and state_mutex_.

247  {
248  std::lock_guard<std::mutex> lock(state_mutex_);
249  return lit_str_dict_proxy_.get();
250  }
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_
StringDictionaryProxy * RowSetMemoryOwner::getOrAddStringDictProxy ( const shared::StringDictKey dict_key,
const bool  with_generation 
)

Definition at line 537 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.

539  {
540  const int dict_id{dict_key_in.dict_id < 0 ? REGULAR_DICT(dict_key_in.dict_id)
541  : dict_key_in.dict_id};
542  const auto catalog =
544  if (catalog) {
545  const auto dd = catalog->getMetadataForDict(dict_id);
546  if (dd) {
547  auto dict_key = dict_key_in;
548  dict_key.dict_id = dict_id;
549  CHECK(dd->stringDict);
550  CHECK_LE(dd->dictNBits, 32);
551  const int64_t generation =
552  with_generation ? string_dictionary_generations_.getGeneration(dict_key) : -1;
553  return addStringDict(dd->stringDict, dict_key, generation);
554  }
555  }
557  if (!lit_str_dict_proxy_) {
558  DictRef literal_dict_ref(dict_key_in.db_id, DictRef::literalsDictId);
559  std::shared_ptr<StringDictionary> tsd = std::make_shared<StringDictionary>(
560  literal_dict_ref, "", false, true, g_cache_string_hash);
561  lit_str_dict_proxy_ = std::make_shared<StringDictionaryProxy>(
562  tsd, shared::StringDictKey{literal_dict_ref.dbId, literal_dict_ref.dictId}, 0);
563  }
564  return lit_str_dict_proxy_.get();
565 }
#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:313
#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 630 of file Execute.cpp.

633  {
634  const auto source_proxy = getOrAddStringDictProxy(source_dict_key_in, with_generation);
635  return addStringProxyNumericTranslationMap(source_proxy, string_op_infos);
636 }
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:537
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 613 of file Execute.cpp.

References SOURCE_INTERSECTION.

618  {
619  const auto source_proxy = getOrAddStringDictProxy(source_dict_key_in, with_generation);
620  const auto dest_proxy = getOrAddStringDictProxy(dest_dict_key_in, with_generation);
623  source_proxy, dest_proxy, string_op_infos);
624  } else {
625  return addStringProxyUnionTranslationMap(source_proxy, dest_proxy, string_op_infos);
626  }
627 }
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:537
StringDictionaryGenerations& RowSetMemoryOwner::getStringDictionaryGenerations ( )
inline

Definition at line 300 of file RowSetMemoryOwner.h.

References string_dictionary_generations_.

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

Definition at line 231 of file RowSetMemoryOwner.h.

References CHECK, state_mutex_, and str_dict_proxy_owned_.

231  {
232  std::lock_guard<std::mutex> lock(state_mutex_);
233  auto it = str_dict_proxy_owned_.find(dict_key);
234  CHECK(it != str_dict_proxy_owned_.end());
235  return it->second.get();
236  }
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 217 of file RowSetMemoryOwner.h.

References generate_translation_map_key(), state_mutex_, and string_ops_owned_.

218  {
219  std::lock_guard<std::mutex> lock(state_mutex_);
220  const auto map_key = generate_translation_map_key({}, {}, string_op_infos);
221  auto it = string_ops_owned_.find(map_key);
222  if (it == string_ops_owned_.end()) {
223  it = string_ops_owned_
224  .emplace(map_key,
225  std::make_shared<StringOps_Namespace::StringOps>(string_op_infos))
226  .first;
227  }
228  return it->second.get();
229  }
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 320 of file RowSetMemoryOwner.h.

References table_function_metadata_store_, and table_function_metadata_store_mutex_.

323  {
324  std::lock_guard<std::mutex> lock(table_function_metadata_store_mutex_);
325  auto const itr = table_function_metadata_store_.find(key);
326  if (itr == table_function_metadata_store_.end()) {
327  throw std::runtime_error("Failed to find Table Function Metadata with key '" +
328  std::string(key) + "'");
329  }
330  raw_data = itr->second.first.data();
331  num_bytes = itr->second.first.size();
332  value_type = itr->second.second;
333  }
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 638 of file Execute.cpp.

References g_approx_quantile_buffer, and g_approx_quantile_centroids.

638  {
639  std::lock_guard<std::mutex> lock(state_mutex_);
640  return t_digests_
641  .emplace_back(std::make_unique<quantile::TDigest>(
643  .get();
644 }
size_t g_approx_quantile_buffer
Definition: Execute.cpp:159
std::vector< std::unique_ptr< quantile::TDigest > > t_digests_
size_t g_approx_quantile_centroids
Definition: Execute.cpp:160
void RowSetMemoryOwner::setDictionaryGenerations ( StringDictionaryGenerations  generations)
inline

Definition at line 296 of file RowSetMemoryOwner.h.

References string_dictionary_generations_.

296  {
297  string_dictionary_generations_ = generations;
298  }
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 310 of file RowSetMemoryOwner.h.

References table_function_metadata_store_, and table_function_metadata_store_mutex_.

313  {
314  MetadataValue metadata_value(num_bytes, value_type);
315  std::memcpy(metadata_value.first.data(), raw_data, num_bytes);
316  std::lock_guard<std::mutex> lock(table_function_metadata_store_mutex_);
317  table_function_metadata_store_[key] = std::move(metadata_value);
318  }
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 380 of file RowSetMemoryOwner.h.

friend class ResultSet
friend

Definition at line 379 of file RowSetMemoryOwner.h.

Member Data Documentation

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

Definition at line 371 of file RowSetMemoryOwner.h.

Referenced by allocate(), and RowSetMemoryOwner().

size_t RowSetMemoryOwner::arena_block_size_
private

Definition at line 370 of file RowSetMemoryOwner.h.

Referenced by cloneStrDictDataOnly().

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

Definition at line 352 of file RowSetMemoryOwner.h.

Referenced by addArray().

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

Definition at line 363 of file RowSetMemoryOwner.h.

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

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

Definition at line 347 of file RowSetMemoryOwner.h.

Referenced by addCountDistinctBuffer().

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

Definition at line 348 of file RowSetMemoryOwner.h.

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

std::vector<int64_t*> RowSetMemoryOwner::group_by_buffers_
private

Definition at line 349 of file RowSetMemoryOwner.h.

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

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

Definition at line 368 of file RowSetMemoryOwner.h.

Referenced by allocateMode().

std::unordered_map<shared::StringDictKey, std::shared_ptr<StringDictionaryProxy> > RowSetMemoryOwner::str_dict_proxy_owned_
private

Definition at line 354 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 356 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 360 of file RowSetMemoryOwner.h.

Referenced by addStringProxyNumericTranslationMap().

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

Definition at line 358 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 367 of file RowSetMemoryOwner.h.

Referenced by getStringOps().

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

Definition at line 351 of file RowSetMemoryOwner.h.

Referenced by addString().

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

Definition at line 365 of file RowSetMemoryOwner.h.

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

Definition at line 376 of file RowSetMemoryOwner.h.

Referenced by getTableFunctionMetadata(), and setTableFunctionMetadata().

std::mutex RowSetMemoryOwner::table_function_metadata_store_mutex_
mutableprivate

Definition at line 377 of file RowSetMemoryOwner.h.

Referenced by getTableFunctionMetadata(), and setTableFunctionMetadata().

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

Definition at line 350 of file RowSetMemoryOwner.h.

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

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

Definition at line 364 of file RowSetMemoryOwner.h.

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


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