OmniSciDB  8a228a1076
RowSetMemoryOwner Class Reference

#include <RowSetMemoryOwner.h>

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

Classes

struct  CountDistinctBitmapBuffer
 

Public Member Functions

 RowSetMemoryOwner (const size_t arena_block_size)
 
int8_t * allocate (const size_t num_bytes)
 
int8_t * allocateCountDistinctBuffer (const size_t num_bytes)
 
void addCountDistinctBuffer (int8_t *count_distinct_buffer, const size_t bytes, const bool physical_buffer)
 
void addCountDistinctSet (std::set< int64_t > *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 int dict_id, const ssize_t generation)
 
StringDictionaryProxygetStringDictProxy (const int dict_id) const
 
void addLiteralStringDictProxy (std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy)
 
StringDictionaryProxygetLiteralStringDictProxy () const
 
void addColBuffer (const void *col_buffer)
 
 ~RowSetMemoryOwner ()
 
std::shared_ptr< RowSetMemoryOwnercloneStrDictDataOnly ()
 

Private Attributes

std::vector< CountDistinctBitmapBuffercount_distinct_bitmaps_
 
std::vector< std::set< int64_t > * > 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< int, std::shared_ptr< StringDictionaryProxy > > str_dict_proxy_owned_
 
std::shared_ptr< StringDictionaryProxylit_str_dict_proxy_
 
std::vector< void * > col_buffers_
 
std::vector< Data_Namespace::AbstractBuffer * > varlen_input_buffers_
 
size_t arena_block_size_
 
std::unique_ptr< Arenaallocator_
 
std::mutex state_mutex_
 

Friends

class ResultSet
 
class QueryExecutionContext
 

Detailed Description

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

Definition at line 39 of file RowSetMemoryOwner.h.

Constructor & Destructor Documentation

◆ RowSetMemoryOwner()

RowSetMemoryOwner::RowSetMemoryOwner ( const size_t  arena_block_size)
inline

Definition at line 41 of file RowSetMemoryOwner.h.

42  : arena_block_size_(arena_block_size)
43  , allocator_(std::make_unique<Arena>(arena_block_size)) {}
std::unique_ptr< Arena > allocator_

◆ ~RowSetMemoryOwner()

RowSetMemoryOwner::~RowSetMemoryOwner ( )
inline

Definition at line 146 of file RowSetMemoryOwner.h.

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

146  {
147  for (auto count_distinct_set : count_distinct_sets_) {
148  delete count_distinct_set;
149  }
150  for (auto group_by_buffer : group_by_buffers_) {
151  free(group_by_buffer);
152  }
153  for (auto varlen_buffer : varlen_buffers_) {
154  free(varlen_buffer);
155  }
156  for (auto varlen_input_buffer : varlen_input_buffers_) {
157  CHECK(varlen_input_buffer);
158  varlen_input_buffer->unPin();
159  }
160  for (auto col_buffer : col_buffers_) {
161  free(col_buffer);
162  }
163  }
std::vector< std::set< int64_t > * > 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:197
std::vector< int64_t * > group_by_buffers_

Member Function Documentation

◆ addArray()

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

Definition at line 100 of file RowSetMemoryOwner.h.

References arrays_, and state_mutex_.

100  {
101  std::lock_guard<std::mutex> lock(state_mutex_);
102  arrays_.emplace_back(arr);
103  return &arrays_.back();
104  }
std::list< std::vector< int64_t > > arrays_

◆ addColBuffer()

void RowSetMemoryOwner::addColBuffer ( const void *  col_buffer)
inline

Definition at line 141 of file RowSetMemoryOwner.h.

References col_buffers_, and state_mutex_.

141  {
142  std::lock_guard<std::mutex> lock(state_mutex_);
143  col_buffers_.push_back(const_cast<void*>(col_buffer));
144  }
std::vector< void * > col_buffers_

◆ addCountDistinctBuffer()

void RowSetMemoryOwner::addCountDistinctBuffer ( int8_t *  count_distinct_buffer,
const size_t  bytes,
const bool  physical_buffer 
)
inline

Definition at line 60 of file RowSetMemoryOwner.h.

References count_distinct_bitmaps_, and state_mutex_.

62  {
63  std::lock_guard<std::mutex> lock(state_mutex_);
64  count_distinct_bitmaps_.emplace_back(
65  CountDistinctBitmapBuffer{count_distinct_buffer, bytes, physical_buffer});
66  }
std::vector< CountDistinctBitmapBuffer > count_distinct_bitmaps_

◆ addCountDistinctSet()

void RowSetMemoryOwner::addCountDistinctSet ( std::set< int64_t > *  count_distinct_set)
inline

Definition at line 68 of file RowSetMemoryOwner.h.

References count_distinct_sets_, and state_mutex_.

68  {
69  std::lock_guard<std::mutex> lock(state_mutex_);
70  count_distinct_sets_.push_back(count_distinct_set);
71  }
std::vector< std::set< int64_t > * > count_distinct_sets_

◆ addGroupByBuffer()

void RowSetMemoryOwner::addGroupByBuffer ( int64_t *  group_by_buffer)
inline

Definition at line 73 of file RowSetMemoryOwner.h.

References group_by_buffers_, and state_mutex_.

73  {
74  std::lock_guard<std::mutex> lock(state_mutex_);
75  group_by_buffers_.push_back(group_by_buffer);
76  }
std::vector< int64_t * > group_by_buffers_

◆ addLiteralStringDictProxy()

void RowSetMemoryOwner::addLiteralStringDictProxy ( std::shared_ptr< StringDictionaryProxy lit_str_dict_proxy)
inline

Definition at line 130 of file RowSetMemoryOwner.h.

References lit_str_dict_proxy_, and state_mutex_.

131  {
132  std::lock_guard<std::mutex> lock(state_mutex_);
133  lit_str_dict_proxy_ = lit_str_dict_proxy;
134  }
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_

◆ addString()

std::string* RowSetMemoryOwner::addString ( const std::string &  str)
inline

Definition at line 94 of file RowSetMemoryOwner.h.

References state_mutex_, and strings_.

94  {
95  std::lock_guard<std::mutex> lock(state_mutex_);
96  strings_.emplace_back(str);
97  return &strings_.back();
98  }
std::list< std::string > strings_

◆ addStringDict()

StringDictionaryProxy* RowSetMemoryOwner::addStringDict ( std::shared_ptr< StringDictionary str_dict,
const int  dict_id,
const ssize_t  generation 
)
inline

Definition at line 106 of file RowSetMemoryOwner.h.

References CHECK_EQ, state_mutex_, and str_dict_proxy_owned_.

108  {
109  std::lock_guard<std::mutex> lock(state_mutex_);
110  auto it = str_dict_proxy_owned_.find(dict_id);
111  if (it != str_dict_proxy_owned_.end()) {
112  CHECK_EQ(it->second->getDictionary(), str_dict.get());
113  it->second->updateGeneration(generation);
114  return it->second.get();
115  }
117  .emplace(dict_id,
118  std::make_shared<StringDictionaryProxy>(str_dict, generation))
119  .first;
120  return it->second.get();
121  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::unordered_map< int, std::shared_ptr< StringDictionaryProxy > > str_dict_proxy_owned_

◆ addVarlenBuffer()

void RowSetMemoryOwner::addVarlenBuffer ( void *  varlen_buffer)
inline

Definition at line 78 of file RowSetMemoryOwner.h.

References state_mutex_, and varlen_buffers_.

78  {
79  std::lock_guard<std::mutex> lock(state_mutex_);
80  varlen_buffers_.push_back(varlen_buffer);
81  }
std::vector< void * > varlen_buffers_

◆ addVarlenInputBuffer()

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

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

88  {
89  std::lock_guard<std::mutex> lock(state_mutex_);
91  varlen_input_buffers_.push_back(buffer);
92  }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
virtual MemoryLevel getType() const =0
std::vector< Data_Namespace::AbstractBuffer * > varlen_input_buffers_
+ Here is the call graph for this function:

◆ allocate()

int8_t* RowSetMemoryOwner::allocate ( const size_t  num_bytes)
inline

Definition at line 45 of file RowSetMemoryOwner.h.

References allocator_, CHECK, and state_mutex_.

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

45  {
47  std::lock_guard<std::mutex> lock(state_mutex_);
48  return reinterpret_cast<int8_t*>(allocator_->allocate(num_bytes));
49  }
std::unique_ptr< Arena > allocator_
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the caller graph for this function:

◆ allocateCountDistinctBuffer()

int8_t* RowSetMemoryOwner::allocateCountDistinctBuffer ( const size_t  num_bytes)
inline

Definition at line 51 of file RowSetMemoryOwner.h.

References allocator_, CHECK, count_distinct_bitmaps_, and state_mutex_.

51  {
53  std::lock_guard<std::mutex> lock(state_mutex_);
54  auto ret = reinterpret_cast<int8_t*>(allocator_->allocateAndZero(num_bytes));
55  count_distinct_bitmaps_.emplace_back(
56  CountDistinctBitmapBuffer{ret, num_bytes, /*physical_buffer=*/true});
57  return ret;
58  }
std::vector< CountDistinctBitmapBuffer > count_distinct_bitmaps_
std::unique_ptr< Arena > allocator_
#define CHECK(condition)
Definition: Logger.h:197

◆ cloneStrDictDataOnly()

std::shared_ptr<RowSetMemoryOwner> RowSetMemoryOwner::cloneStrDictDataOnly ( )
inline

Definition at line 165 of file RowSetMemoryOwner.h.

References arena_block_size_, lit_str_dict_proxy_, and str_dict_proxy_owned_.

165  {
166  auto rtn = std::make_shared<RowSetMemoryOwner>(arena_block_size_);
167  rtn->str_dict_proxy_owned_ = str_dict_proxy_owned_;
168  rtn->lit_str_dict_proxy_ = lit_str_dict_proxy_;
169  return rtn;
170  }
std::unordered_map< int, std::shared_ptr< StringDictionaryProxy > > str_dict_proxy_owned_
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_

◆ getLiteralStringDictProxy()

StringDictionaryProxy* RowSetMemoryOwner::getLiteralStringDictProxy ( ) const
inline

Definition at line 136 of file RowSetMemoryOwner.h.

References lit_str_dict_proxy_, and state_mutex_.

136  {
137  std::lock_guard<std::mutex> lock(state_mutex_);
138  return lit_str_dict_proxy_.get();
139  }
std::shared_ptr< StringDictionaryProxy > lit_str_dict_proxy_

◆ getStringDictProxy()

StringDictionaryProxy* RowSetMemoryOwner::getStringDictProxy ( const int  dict_id) const
inline

Definition at line 123 of file RowSetMemoryOwner.h.

References CHECK, state_mutex_, and str_dict_proxy_owned_.

123  {
124  std::lock_guard<std::mutex> lock(state_mutex_);
125  auto it = str_dict_proxy_owned_.find(dict_id);
126  CHECK(it != str_dict_proxy_owned_.end());
127  return it->second.get();
128  }
std::unordered_map< int, std::shared_ptr< StringDictionaryProxy > > str_dict_proxy_owned_
#define CHECK(condition)
Definition: Logger.h:197

Friends And Related Function Documentation

◆ QueryExecutionContext

friend class QueryExecutionContext
friend

Definition at line 196 of file RowSetMemoryOwner.h.

◆ ResultSet

friend class ResultSet
friend

Definition at line 195 of file RowSetMemoryOwner.h.

Member Data Documentation

◆ allocator_

std::unique_ptr<Arena> RowSetMemoryOwner::allocator_
private

Definition at line 191 of file RowSetMemoryOwner.h.

Referenced by allocate(), and allocateCountDistinctBuffer().

◆ arena_block_size_

size_t RowSetMemoryOwner::arena_block_size_
private

Definition at line 190 of file RowSetMemoryOwner.h.

Referenced by cloneStrDictDataOnly().

◆ arrays_

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

Definition at line 184 of file RowSetMemoryOwner.h.

Referenced by addArray().

◆ col_buffers_

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

Definition at line 187 of file RowSetMemoryOwner.h.

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

◆ count_distinct_bitmaps_

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

Definition at line 179 of file RowSetMemoryOwner.h.

Referenced by addCountDistinctBuffer(), and allocateCountDistinctBuffer().

◆ count_distinct_sets_

std::vector<std::set<int64_t>*> RowSetMemoryOwner::count_distinct_sets_
private

Definition at line 180 of file RowSetMemoryOwner.h.

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

◆ group_by_buffers_

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

Definition at line 181 of file RowSetMemoryOwner.h.

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

◆ lit_str_dict_proxy_

std::shared_ptr<StringDictionaryProxy> RowSetMemoryOwner::lit_str_dict_proxy_
private

◆ state_mutex_

◆ str_dict_proxy_owned_

std::unordered_map<int, std::shared_ptr<StringDictionaryProxy> > RowSetMemoryOwner::str_dict_proxy_owned_
private

Definition at line 185 of file RowSetMemoryOwner.h.

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

◆ strings_

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

Definition at line 183 of file RowSetMemoryOwner.h.

Referenced by addString().

◆ varlen_buffers_

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

Definition at line 182 of file RowSetMemoryOwner.h.

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

◆ varlen_input_buffers_

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

Definition at line 188 of file RowSetMemoryOwner.h.

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


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