OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ColumnFetcher Class Reference

#include <ColumnFetcher.h>

+ Collaboration diagram for ColumnFetcher:

Public Member Functions

 ColumnFetcher (Executor *executor, const ColumnCacheMap &column_cache)
 
const int8_t * getOneTableColumnFragment (const int table_id, const int frag_id, const int col_id, const std::map< int, const TableFragments * > &all_tables_fragments, std::list< std::shared_ptr< Chunk_NS::Chunk >> &chunk_holder, std::list< ChunkIter > &chunk_iter_holder, const Data_Namespace::MemoryLevel memory_level, const int device_id) const
 
const int8_t * getAllTableColumnFragments (const int table_id, const int col_id, const std::map< int, const TableFragments * > &all_tables_fragments, const Data_Namespace::MemoryLevel memory_level, const int device_id) const
 
const int8_t * getResultSetColumn (const InputColDescriptor *col_desc, const Data_Namespace::MemoryLevel memory_level, const int device_id) const
 

Static Public Member Functions

static std::pair< const int8_t
*, size_t > 
getOneColumnFragment (Executor *executor, const Analyzer::ColumnVar &hash_col, const Fragmenter_Namespace::FragmentInfo &fragment, const Data_Namespace::MemoryLevel effective_mem_lvl, const int device_id, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, ColumnCacheMap &column_cache)
 
static std::pair< const int8_t
*, size_t > 
getAllColumnFragments (Executor *executor, const Analyzer::ColumnVar &hash_col, const std::deque< Fragmenter_Namespace::FragmentInfo > &fragments, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, ColumnCacheMap &column_cache)
 

Private Types

using CacheKey = std::vector< int >
 

Private Member Functions

const int8_t * getResultSetColumn (const ResultSetPtr &buffer, const int table_id, const int col_id, const Data_Namespace::MemoryLevel memory_level, const int device_id) const
 

Static Private Member Functions

static const int8_t * transferColumnIfNeeded (const ColumnarResults *columnar_results, const int col_id, Data_Namespace::DataMgr *data_mgr, const Data_Namespace::MemoryLevel memory_level, const int device_id)
 

Private Attributes

Executorexecutor_
 
std::mutex columnar_conversion_mutex_
 
ColumnCacheMap columnarized_table_cache_
 
std::unordered_map
< InputColDescriptor,
std::unordered_map< CacheKey,
std::unique_ptr< const
ColumnarResults > > > 
columnarized_ref_table_cache_
 
std::unordered_map
< InputColDescriptor,
std::unique_ptr< const
ColumnarResults > > 
columnarized_scan_table_cache_
 

Friends

class QueryCompilationDescriptor
 
class TableFunctionExecutionContext
 

Detailed Description

Definition at line 21 of file ColumnFetcher.h.

Member Typedef Documentation

using ColumnFetcher::CacheKey = std::vector<int>
private

Definition at line 77 of file ColumnFetcher.h.

Constructor & Destructor Documentation

ColumnFetcher::ColumnFetcher ( Executor executor,
const ColumnCacheMap column_cache 
)

Definition at line 20 of file ColumnFetcher.cpp.

21  : executor_(executor), columnarized_table_cache_(column_cache) {}
ColumnCacheMap columnarized_table_cache_
Definition: ColumnFetcher.h:79
Executor * executor_
Definition: ColumnFetcher.h:76

Member Function Documentation

std::pair< const int8_t *, size_t > ColumnFetcher::getAllColumnFragments ( Executor executor,
const Analyzer::ColumnVar hash_col,
const std::deque< Fragmenter_Namespace::FragmentInfo > &  fragments,
std::vector< std::shared_ptr< Chunk_NS::Chunk >> &  chunks_owner,
ColumnCacheMap column_cache 
)
static

Definition at line 91 of file ColumnFetcher.cpp.

References CHECK(), CHECK_EQ, CHECK_NE, checked_malloc(), Data_Namespace::CPU_LEVEL, SQLTypeInfoCore< TYPE_FACET_PACK >::get_size(), Analyzer::Expr::get_type_info(), and getOneColumnFragment().

Referenced by JoinHashTable::getAllColumnFragments(), and BaselineJoinHashTable::getAllColumnFragments().

96  {
97  CHECK(!fragments.empty());
98  const size_t elem_width = hash_col.get_type_info().get_size();
99  std::vector<const int8_t*> col_frags;
100  std::vector<size_t> elem_counts;
101  for (auto& frag : fragments) {
102  const int8_t* col_frag = nullptr;
103  size_t elem_count = 0;
104  std::tie(col_frag, elem_count) = getOneColumnFragment(executor,
105  hash_col,
106  frag,
108  0,
109  chunks_owner,
110  column_cache);
111  if (col_frag == nullptr) {
112  continue;
113  }
114  CHECK_NE(elem_count, size_t(0));
115  col_frags.push_back(col_frag);
116  elem_counts.push_back(elem_count);
117  }
118  if (col_frags.empty()) {
119  return {nullptr, 0};
120  }
121  CHECK_EQ(col_frags.size(), elem_counts.size());
122  const auto total_elem_count =
123  std::accumulate(elem_counts.begin(), elem_counts.end(), size_t(0));
124  auto col_buff =
125  reinterpret_cast<int8_t*>(checked_malloc(total_elem_count * elem_width));
126  for (size_t i = 0, offset = 0; i < col_frags.size(); ++i) {
127  memcpy(col_buff + offset, col_frags[i], elem_counts[i] * elem_width);
128  offset += elem_counts[i] * elem_width;
129  }
130  return {col_buff, total_elem_count};
131 }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
HOST DEVICE int get_size() const
Definition: sqltypes.h:336
CHECK(cgen_state)
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:40
#define CHECK_NE(x, y)
Definition: Logger.h:199
static std::pair< const int8_t *, size_t > getOneColumnFragment(Executor *executor, const Analyzer::ColumnVar &hash_col, const Fragmenter_Namespace::FragmentInfo &fragment, const Data_Namespace::MemoryLevel effective_mem_lvl, const int device_id, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, ColumnCacheMap &column_cache)
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:78

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int8_t * ColumnFetcher::getAllTableColumnFragments ( const int  table_id,
const int  col_id,
const std::map< int, const TableFragments * > &  all_tables_fragments,
const Data_Namespace::MemoryLevel  memory_level,
const int  device_id 
) const

Definition at line 208 of file ColumnFetcher.cpp.

References CHECK(), columnar_conversion_mutex_, columnarized_scan_table_cache_, Data_Namespace::CPU_LEVEL, executor_, getOneTableColumnFragment(), InputColDescriptor::getScanDesc(), InputDescriptor::getSourceType(), ColumnarResults::mergeResults(), TABLE, and transferColumnIfNeeded().

Referenced by Executor::fetchChunks().

213  {
214  const auto fragments_it = all_tables_fragments.find(table_id);
215  CHECK(fragments_it != all_tables_fragments.end());
216  const auto fragments = fragments_it->second;
217  const auto frag_count = fragments->size();
218  std::vector<std::unique_ptr<ColumnarResults>> column_frags;
219  const ColumnarResults* table_column = nullptr;
220  const InputColDescriptor col_desc(col_id, table_id, int(0));
221  CHECK(col_desc.getScanDesc().getSourceType() == InputSourceType::TABLE);
222  {
223  std::lock_guard<std::mutex> columnar_conversion_guard(columnar_conversion_mutex_);
224  auto column_it = columnarized_scan_table_cache_.find(col_desc);
225  if (column_it == columnarized_scan_table_cache_.end()) {
226  for (size_t frag_id = 0; frag_id < frag_count; ++frag_id) {
227  std::list<std::shared_ptr<Chunk_NS::Chunk>> chunk_holder;
228  std::list<ChunkIter> chunk_iter_holder;
229  const auto& fragment = (*fragments)[frag_id];
230  if (fragment.isEmptyPhysicalFragment()) {
231  continue;
232  }
233  auto chunk_meta_it = fragment.getChunkMetadataMap().find(col_id);
234  CHECK(chunk_meta_it != fragment.getChunkMetadataMap().end());
235  auto col_buffer = getOneTableColumnFragment(table_id,
236  static_cast<int>(frag_id),
237  col_id,
238  all_tables_fragments,
239  chunk_holder,
240  chunk_iter_holder,
242  int(0));
243  column_frags.push_back(
244  boost::make_unique<ColumnarResults>(executor_->row_set_mem_owner_,
245  col_buffer,
246  fragment.getNumTuples(),
247  chunk_meta_it->second.sqlType));
248  }
249  auto merged_results =
250  ColumnarResults::mergeResults(executor_->row_set_mem_owner_, column_frags);
251  table_column = merged_results.get();
252  columnarized_scan_table_cache_.emplace(col_desc, std::move(merged_results));
253  } else {
254  table_column = column_it->second.get();
255  }
256  }
258  table_column, 0, &executor_->getCatalog()->getDataMgr(), memory_level, device_id);
259 }
static std::unique_ptr< ColumnarResults > mergeResults(const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const std::vector< std::unique_ptr< ColumnarResults >> &sub_results)
Executor * executor_
Definition: ColumnFetcher.h:76
std::unordered_map< InputColDescriptor, std::unique_ptr< const ColumnarResults > > columnarized_scan_table_cache_
Definition: ColumnFetcher.h:85
std::mutex columnar_conversion_mutex_
Definition: ColumnFetcher.h:78
const int8_t * getOneTableColumnFragment(const int table_id, const int frag_id, const int col_id, const std::map< int, const TableFragments * > &all_tables_fragments, std::list< std::shared_ptr< Chunk_NS::Chunk >> &chunk_holder, std::list< ChunkIter > &chunk_iter_holder, const Data_Namespace::MemoryLevel memory_level, const int device_id) const
CHECK(cgen_state)
static const int8_t * transferColumnIfNeeded(const ColumnarResults *columnar_results, const int col_id, Data_Namespace::DataMgr *data_mgr, const Data_Namespace::MemoryLevel memory_level, const int device_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::pair< const int8_t *, size_t > ColumnFetcher::getOneColumnFragment ( Executor executor,
const Analyzer::ColumnVar hash_col,
const Fragmenter_Namespace::FragmentInfo fragment,
const Data_Namespace::MemoryLevel  effective_mem_lvl,
const int  device_id,
std::vector< std::shared_ptr< Chunk_NS::Chunk >> &  chunks_owner,
ColumnCacheMap column_cache 
)
static

Definition at line 23 of file ColumnFetcher.cpp.

References CHECK(), columnarize_result(), Data_Namespace::CPU_LEVEL, Fragmenter_Namespace::FragmentInfo::fragmentId, get_column_descriptor_maybe(), Analyzer::ColumnVar::get_column_id(), Analyzer::ColumnVar::get_table_id(), get_temporary_table(), Chunk_NS::Chunk::getChunk(), Fragmenter_Namespace::FragmentInfo::getChunkMetadataMap(), Fragmenter_Namespace::FragmentInfo::getNumTuples(), Fragmenter_Namespace::FragmentInfo::isEmptyPhysicalFragment(), Fragmenter_Namespace::FragmentInfo::physicalTableId, and transferColumnIfNeeded().

Referenced by RelAlgExecutor::createWindowFunctionContext(), TableFunctionExecutionContext::execute(), BaselineJoinHashTable::fetchColumn(), getAllColumnFragments(), and JoinHashTable::getOneColumnFragment().

30  {
31  static std::mutex columnar_conversion_mutex;
32  if (fragment.isEmptyPhysicalFragment()) {
33  return {nullptr, 0};
34  }
35  auto chunk_meta_it = fragment.getChunkMetadataMap().find(hash_col.get_column_id());
36  CHECK(chunk_meta_it != fragment.getChunkMetadataMap().end());
37  const auto& catalog = *executor->getCatalog();
38  const auto cd = get_column_descriptor_maybe(
39  hash_col.get_column_id(), hash_col.get_table_id(), catalog);
40  CHECK(!cd || !(cd->isVirtualCol));
41  const int8_t* col_buff = nullptr;
42  if (cd) {
43  ChunkKey chunk_key{catalog.getCurrentDB().dbId,
44  fragment.physicalTableId,
45  hash_col.get_column_id(),
46  fragment.fragmentId};
47  const auto chunk = Chunk_NS::Chunk::getChunk(
48  cd,
49  &catalog.getDataMgr(),
50  chunk_key,
51  effective_mem_lvl,
52  effective_mem_lvl == Data_Namespace::CPU_LEVEL ? 0 : device_id,
53  chunk_meta_it->second.numBytes,
54  chunk_meta_it->second.numElements);
55  chunks_owner.push_back(chunk);
56  CHECK(chunk);
57  auto ab = chunk->get_buffer();
58  CHECK(ab->getMemoryPtr());
59  col_buff = reinterpret_cast<int8_t*>(ab->getMemoryPtr());
60  } else {
61  const ColumnarResults* col_frag{nullptr};
62  {
63  std::lock_guard<std::mutex> columnar_conversion_guard(columnar_conversion_mutex);
64  const auto table_id = hash_col.get_table_id();
65  const auto frag_id = fragment.fragmentId;
66  if (column_cache.empty() || !column_cache.count(table_id)) {
67  column_cache.insert(std::make_pair(
68  table_id, std::unordered_map<int, std::shared_ptr<const ColumnarResults>>()));
69  }
70  auto& frag_id_to_result = column_cache[table_id];
71  if (frag_id_to_result.empty() || !frag_id_to_result.count(frag_id)) {
72  frag_id_to_result.insert(std::make_pair(
73  frag_id,
74  std::shared_ptr<const ColumnarResults>(columnarize_result(
75  executor->row_set_mem_owner_,
76  get_temporary_table(executor->temporary_tables_, hash_col.get_table_id()),
77  frag_id))));
78  }
79  col_frag = column_cache[table_id][frag_id].get();
80  }
81  col_buff = transferColumnIfNeeded(
82  col_frag,
83  hash_col.get_column_id(),
84  &catalog.getDataMgr(),
85  effective_mem_lvl,
86  effective_mem_lvl == Data_Namespace::CPU_LEVEL ? 0 : device_id);
87  }
88  return {col_buff, fragment.getNumTuples()};
89 }
int get_table_id() const
Definition: Analyzer.h:194
std::vector< int > ChunkKey
Definition: types.h:35
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:179
CHECK(cgen_state)
const ColumnDescriptor * get_column_descriptor_maybe(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:171
static std::shared_ptr< Chunk > getChunk(const ColumnDescriptor *cd, DataMgr *data_mgr, const ChunkKey &key, const MemoryLevel mem_level, const int deviceId, const size_t num_bytes, const size_t num_elems)
Definition: Chunk.cpp:28
const std::map< int, ChunkMetadata > & getChunkMetadataMap() const
const ColumnarResults * columnarize_result(std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const ResultSetPtr &result, const int frag_id)
Definition: Execute.h:223
static const int8_t * transferColumnIfNeeded(const ColumnarResults *columnar_results, const int col_id, Data_Namespace::DataMgr *data_mgr, const Data_Namespace::MemoryLevel memory_level, const int device_id)
int get_column_id() const
Definition: Analyzer.h:195

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int8_t * ColumnFetcher::getOneTableColumnFragment ( const int  table_id,
const int  frag_id,
const int  col_id,
const std::map< int, const TableFragments * > &  all_tables_fragments,
std::list< std::shared_ptr< Chunk_NS::Chunk >> &  chunk_holder,
std::list< ChunkIter > &  chunk_iter_holder,
const Data_Namespace::MemoryLevel  memory_level,
const int  device_id 
) const

Definition at line 133 of file ColumnFetcher.cpp.

References CudaAllocator::alloc(), CHECK(), CHECK_EQ, CHECK_GT, copy_to_gpu(), Data_Namespace::CPU_LEVEL, executor_, get_column_descriptor(), get_column_type(), Chunk_NS::Chunk::getChunk(), Data_Namespace::GPU_LEVEL, and kENCODING_NONE.

Referenced by Executor::fetchChunks(), and getAllTableColumnFragments().

141  {
142  static std::mutex varlen_chunk_mutex; // TODO(alex): remove
143  static std::mutex chunk_list_mutex;
144  const auto fragments_it = all_tables_fragments.find(table_id);
145  CHECK(fragments_it != all_tables_fragments.end());
146  const auto fragments = fragments_it->second;
147  const auto& fragment = (*fragments)[frag_id];
148  if (fragment.isEmptyPhysicalFragment()) {
149  return nullptr;
150  }
151  std::shared_ptr<Chunk_NS::Chunk> chunk;
152  auto chunk_meta_it = fragment.getChunkMetadataMap().find(col_id);
153  CHECK(chunk_meta_it != fragment.getChunkMetadataMap().end());
154  CHECK(table_id > 0);
155  const auto& cat = *executor_->getCatalog();
156  auto cd = get_column_descriptor(col_id, table_id, cat);
157  CHECK(cd);
158  const auto col_type =
159  get_column_type(col_id, table_id, cd, executor_->temporary_tables_);
160  const bool is_real_string =
161  col_type.is_string() && col_type.get_compression() == kENCODING_NONE;
162  const bool is_varlen =
163  is_real_string ||
164  col_type.is_array(); // TODO: should it be col_type.is_varlen_array() ?
165  {
166  ChunkKey chunk_key{
167  cat.getCurrentDB().dbId, fragment.physicalTableId, col_id, fragment.fragmentId};
168  std::unique_ptr<std::lock_guard<std::mutex>> varlen_chunk_lock;
169  if (is_varlen) {
170  varlen_chunk_lock.reset(new std::lock_guard<std::mutex>(varlen_chunk_mutex));
171  }
173  cd,
174  &cat.getDataMgr(),
175  chunk_key,
176  memory_level,
177  memory_level == Data_Namespace::CPU_LEVEL ? 0 : device_id,
178  chunk_meta_it->second.numBytes,
179  chunk_meta_it->second.numElements);
180  std::lock_guard<std::mutex> chunk_list_lock(chunk_list_mutex);
181  chunk_holder.push_back(chunk);
182  }
183  if (is_varlen) {
184  CHECK_GT(table_id, 0);
185  CHECK(chunk_meta_it != fragment.getChunkMetadataMap().end());
186  chunk_iter_holder.push_back(chunk->begin_iterator(chunk_meta_it->second));
187  auto& chunk_iter = chunk_iter_holder.back();
188  if (memory_level == Data_Namespace::CPU_LEVEL) {
189  return reinterpret_cast<int8_t*>(&chunk_iter);
190  } else {
191  CHECK_EQ(Data_Namespace::GPU_LEVEL, memory_level);
192  auto& data_mgr = cat.getDataMgr();
193  auto chunk_iter_gpu = CudaAllocator::alloc(&data_mgr, sizeof(ChunkIter), device_id);
194  copy_to_gpu(&data_mgr,
195  reinterpret_cast<CUdeviceptr>(chunk_iter_gpu),
196  &chunk_iter,
197  sizeof(ChunkIter),
198  device_id);
199  return chunk_iter_gpu;
200  }
201  } else {
202  auto ab = chunk->get_buffer();
203  CHECK(ab->getMemoryPtr());
204  return ab->getMemoryPtr(); // @TODO(alex) change to use ChunkIter
205  }
206 }
#define CHECK_EQ(x, y)
Definition: Logger.h:198
std::vector< int > ChunkKey
Definition: types.h:35
const SQLTypeInfo get_column_type(const int col_id, const int table_id, const ColumnDescriptor *cd, const TemporaryTables *temporary_tables)
Definition: Execute.h:187
Executor * executor_
Definition: ColumnFetcher.h:76
#define CHECK_GT(x, y)
Definition: Logger.h:202
static int8_t * alloc(Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
CHECK(cgen_state)
void copy_to_gpu(Data_Namespace::DataMgr *data_mgr, CUdeviceptr dst, const void *src, const size_t num_bytes, const int device_id)
Definition: GpuMemUtils.cpp:31
static std::shared_ptr< Chunk > getChunk(const ColumnDescriptor *cd, DataMgr *data_mgr, const ChunkKey &key, const MemoryLevel mem_level, const int deviceId, const size_t num_bytes, const size_t num_elems)
Definition: Chunk.cpp:28
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:142

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int8_t * ColumnFetcher::getResultSetColumn ( const InputColDescriptor col_desc,
const Data_Namespace::MemoryLevel  memory_level,
const int  device_id 
) const

Definition at line 261 of file ColumnFetcher.cpp.

References CHECK(), executor_, get_temporary_table(), InputColDescriptor::getColId(), InputColDescriptor::getScanDesc(), and InputDescriptor::getTableId().

Referenced by Executor::fetchChunks().

264  {
265  CHECK(col_desc);
266  const auto table_id = col_desc->getScanDesc().getTableId();
267  return getResultSetColumn(get_temporary_table(executor_->temporary_tables_, table_id),
268  table_id,
269  col_desc->getColId(),
270  memory_level,
271  device_id);
272 }
Executor * executor_
Definition: ColumnFetcher.h:76
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:179
CHECK(cgen_state)
int getColId() const
int getTableId() const
const int8_t * getResultSetColumn(const InputColDescriptor *col_desc, const Data_Namespace::MemoryLevel memory_level, const int device_id) const
const InputDescriptor & getScanDesc() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const int8_t * ColumnFetcher::getResultSetColumn ( const ResultSetPtr buffer,
const int  table_id,
const int  col_id,
const Data_Namespace::MemoryLevel  memory_level,
const int  device_id 
) const
private

Definition at line 299 of file ColumnFetcher.cpp.

References CHECK_GE, CHECK_NE, columnar_conversion_mutex_, columnarize_result(), columnarized_table_cache_, executor_, run_benchmark_import::result, and transferColumnIfNeeded().

304  {
305  const ColumnarResults* result{nullptr};
306  {
307  std::lock_guard<std::mutex> columnar_conversion_guard(columnar_conversion_mutex_);
308  if (columnarized_table_cache_.empty() || !columnarized_table_cache_.count(table_id)) {
309  columnarized_table_cache_.insert(std::make_pair(
310  table_id, std::unordered_map<int, std::shared_ptr<const ColumnarResults>>()));
311  }
312  auto& frag_id_to_result = columnarized_table_cache_[table_id];
313  int frag_id = 0;
314  if (frag_id_to_result.empty() || !frag_id_to_result.count(frag_id)) {
315  frag_id_to_result.insert(
316  std::make_pair(frag_id,
317  std::shared_ptr<const ColumnarResults>(columnarize_result(
318  executor_->row_set_mem_owner_, buffer, frag_id))));
319  }
320  CHECK_NE(size_t(0), columnarized_table_cache_.count(table_id));
321  result = columnarized_table_cache_[table_id][frag_id].get();
322  }
323  CHECK_GE(col_id, 0);
324  return transferColumnIfNeeded(
325  result, col_id, &executor_->getCatalog()->getDataMgr(), memory_level, device_id);
326 }
#define CHECK_GE(x, y)
Definition: Logger.h:203
ColumnCacheMap columnarized_table_cache_
Definition: ColumnFetcher.h:79
Executor * executor_
Definition: ColumnFetcher.h:76
std::mutex columnar_conversion_mutex_
Definition: ColumnFetcher.h:78
#define CHECK_NE(x, y)
Definition: Logger.h:199
const ColumnarResults * columnarize_result(std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const ResultSetPtr &result, const int frag_id)
Definition: Execute.h:223
static const int8_t * transferColumnIfNeeded(const ColumnarResults *columnar_results, const int col_id, Data_Namespace::DataMgr *data_mgr, const Data_Namespace::MemoryLevel memory_level, const int device_id)

+ Here is the call graph for this function:

const int8_t * ColumnFetcher::transferColumnIfNeeded ( const ColumnarResults columnar_results,
const int  col_id,
Data_Namespace::DataMgr data_mgr,
const Data_Namespace::MemoryLevel  memory_level,
const int  device_id 
)
staticprivate

Definition at line 274 of file ColumnFetcher.cpp.

References CudaAllocator::alloc(), CHECK_LT, copy_to_gpu(), ColumnarResults::getColumnBuffers(), ColumnarResults::getColumnType(), Data_Namespace::GPU_LEVEL, and ColumnarResults::size().

Referenced by getAllTableColumnFragments(), getOneColumnFragment(), and getResultSetColumn().

279  {
280  if (!columnar_results) {
281  return nullptr;
282  }
283  const auto& col_buffers = columnar_results->getColumnBuffers();
284  CHECK_LT(static_cast<size_t>(col_id), col_buffers.size());
285  if (memory_level == Data_Namespace::GPU_LEVEL) {
286  const auto& col_ti = columnar_results->getColumnType(col_id);
287  const auto num_bytes = columnar_results->size() * col_ti.get_size();
288  auto gpu_col_buffer = CudaAllocator::alloc(data_mgr, num_bytes, device_id);
289  copy_to_gpu(data_mgr,
290  reinterpret_cast<CUdeviceptr>(gpu_col_buffer),
291  col_buffers[col_id],
292  num_bytes,
293  device_id);
294  return gpu_col_buffer;
295  }
296  return col_buffers[col_id];
297 }
static int8_t * alloc(Data_Namespace::DataMgr *data_mgr, const size_t num_bytes, const int device_id)
void copy_to_gpu(Data_Namespace::DataMgr *data_mgr, CUdeviceptr dst, const void *src, const size_t num_bytes, const int device_id)
Definition: GpuMemUtils.cpp:31
const size_t size() const
#define CHECK_LT(x, y)
Definition: Logger.h:200
const std::vector< int8_t * > & getColumnBuffers() const
const SQLTypeInfo & getColumnType(const int col_id) const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class QueryCompilationDescriptor
friend

Definition at line 87 of file ColumnFetcher.h.

friend class TableFunctionExecutionContext
friend

Definition at line 88 of file ColumnFetcher.h.

Member Data Documentation

std::mutex ColumnFetcher::columnar_conversion_mutex_
mutableprivate

Definition at line 78 of file ColumnFetcher.h.

Referenced by getAllTableColumnFragments(), and getResultSetColumn().

std::unordered_map< InputColDescriptor, std::unordered_map<CacheKey, std::unique_ptr<const ColumnarResults> > > ColumnFetcher::columnarized_ref_table_cache_
mutableprivate

Definition at line 83 of file ColumnFetcher.h.

std::unordered_map<InputColDescriptor, std::unique_ptr<const ColumnarResults> > ColumnFetcher::columnarized_scan_table_cache_
mutableprivate

Definition at line 85 of file ColumnFetcher.h.

Referenced by getAllTableColumnFragments().

ColumnCacheMap ColumnFetcher::columnarized_table_cache_
mutableprivate
Executor* ColumnFetcher::executor_
private

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