OmniSciDB
a5dc49c757
|
#include <ColumnFetcher.h>
Public Member Functions | |
ColumnFetcher (Executor *executor, ColumnCacheMap &column_cache) | |
const int8_t * | getOneTableColumnFragment (const shared::TableKey &table_key, const int frag_id, const int col_id, const std::map< shared::TableKey, 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, DeviceAllocator *device_allocator) const |
const int8_t * | getAllTableColumnFragments (const shared::TableKey &table_key, const int col_id, const std::map< shared::TableKey, const TableFragments * > &all_tables_fragments, const Data_Namespace::MemoryLevel memory_level, const int device_id, DeviceAllocator *device_allocator, const size_t thread_idx) const |
const int8_t * | getResultSetColumn (const InputColDescriptor *col_desc, const Data_Namespace::MemoryLevel memory_level, const int device_id, DeviceAllocator *device_allocator, const size_t thread_idx) const |
const int8_t * | linearizeColumnFragments (const shared::TableKey &table_key, const int col_id, const std::map< shared::TableKey, 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, DeviceAllocator *device_allocator, const size_t thread_idx) const |
void | freeTemporaryCpuLinearizedIdxBuf () |
void | freeLinearizedBuf () |
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, DeviceAllocator *device_allocator, const size_t thread_idx, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, ColumnCacheMap &column_cache) |
Gets one chunk's pointer and element count on either CPU or GPU. More... | |
static JoinColumn | makeJoinColumn (Executor *executor, const Analyzer::ColumnVar &hash_col, const std::vector< Fragmenter_Namespace::FragmentInfo > &fragments, const Data_Namespace::MemoryLevel effective_mem_lvl, const int device_id, DeviceAllocator *device_allocator, const size_t thread_idx, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, std::vector< std::shared_ptr< void >> &malloc_owner, ColumnCacheMap &column_cache) |
Creates a JoinColumn struct containing an array of JoinChunk structs. More... | |
Private Types | |
using | DeviceMergedChunkIterMap = std::unordered_map< int, int8_t * > |
using | DeviceMergedChunkMap = std::unordered_map< int, AbstractBuffer * > |
Private Member Functions | |
MergedChunk | linearizeVarLenArrayColFrags (int32_t db_id, std::list< std::shared_ptr< Chunk_NS::Chunk >> &chunk_holder, std::list< ChunkIter > &chunk_iter_holder, std::list< std::shared_ptr< Chunk_NS::Chunk >> &local_chunk_holder, std::list< ChunkIter > &local_chunk_iter_holder, std::list< size_t > &local_chunk_num_tuples, MemoryLevel memory_level, const ColumnDescriptor *cd, const int device_id, const size_t total_data_buf_size, const size_t total_idx_buf_size, const size_t total_num_tuples, DeviceAllocator *device_allocator, const size_t thread_idx) const |
MergedChunk | linearizeFixedLenArrayColFrags (int32_t db_id, std::list< std::shared_ptr< Chunk_NS::Chunk >> &chunk_holder, std::list< ChunkIter > &chunk_iter_holder, std::list< std::shared_ptr< Chunk_NS::Chunk >> &local_chunk_holder, std::list< ChunkIter > &local_chunk_iter_holder, std::list< size_t > &local_chunk_num_tuples, MemoryLevel memory_level, const ColumnDescriptor *cd, const int device_id, const size_t total_data_buf_size, const size_t total_idx_buf_size, const size_t total_num_tuples, DeviceAllocator *device_allocator, const size_t thread_idx) const |
void | addMergedChunkIter (const InputColDescriptor col_desc, const int device_id, int8_t *chunk_iter_ptr) const |
const int8_t * | getChunkiter (const InputColDescriptor col_desc, const int device_id=0) const |
ChunkIter | prepareChunkIter (AbstractBuffer *merged_data_buf, AbstractBuffer *merged_index_buf, ChunkIter &chunk_iter, bool is_true_varlen_type, const size_t total_num_tuples) const |
const int8_t * | getResultSetColumn (const ResultSetPtr &buffer, const shared::TableKey &table_key, const int col_id, const Data_Namespace::MemoryLevel memory_level, const int device_id, DeviceAllocator *device_allocator, const size_t thread_idx) 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, DeviceAllocator *device_allocator) |
Private Attributes | |
Executor * | executor_ |
std::mutex | columnar_fetch_mutex_ |
std::mutex | varlen_chunk_fetch_mutex_ |
std::mutex | linearization_mutex_ |
std::mutex | chunk_list_mutex_ |
std::mutex | linearized_col_cache_mutex_ |
ColumnCacheMap & | columnarized_table_cache_ |
std::unordered_map < InputColDescriptor, std::unique_ptr< const ColumnarResults > > | columnarized_scan_table_cache_ |
std::unordered_map < InputColDescriptor, DeviceMergedChunkIterMap > | linearized_multi_frag_chunk_iter_cache_ |
std::unordered_map< int, AbstractBuffer * > | linearlized_temporary_cpu_index_buf_cache_ |
std::unordered_map < InputColDescriptor, DeviceMergedChunkMap > | linearized_data_buf_cache_ |
std::unordered_map < InputColDescriptor, DeviceMergedChunkMap > | linearized_idx_buf_cache_ |
Friends | |
class | QueryCompilationDescriptor |
class | TableFunctionExecutionContext |
Definition at line 49 of file ColumnFetcher.h.
|
private |
Definition at line 189 of file ColumnFetcher.h.
|
private |
Definition at line 190 of file ColumnFetcher.h.
ColumnFetcher::ColumnFetcher | ( | Executor * | executor, |
ColumnCacheMap & | column_cache | ||
) |
Definition at line 65 of file ColumnFetcher.cpp.
|
private |
Definition at line 1016 of file ColumnFetcher.cpp.
References InputColDescriptor::getColId(), InputColDescriptor::getScanDesc(), InputDescriptor::getTableKey(), linearized_col_cache_mutex_, linearized_multi_frag_chunk_iter_cache_, and VLOG.
Referenced by linearizeColumnFragments().
void ColumnFetcher::freeLinearizedBuf | ( | ) |
Definition at line 1079 of file ColumnFetcher.cpp.
References CHECK, executor_, linearized_col_cache_mutex_, linearized_data_buf_cache_, and linearized_idx_buf_cache_.
Referenced by Executor::executeWorkUnitImpl().
void ColumnFetcher::freeTemporaryCpuLinearizedIdxBuf | ( | ) |
Definition at line 1101 of file ColumnFetcher.cpp.
References CHECK, executor_, linearized_col_cache_mutex_, and linearlized_temporary_cpu_index_buf_cache_.
Referenced by Executor::executeWorkUnitImpl().
const int8_t * ColumnFetcher::getAllTableColumnFragments | ( | const shared::TableKey & | table_key, |
const int | col_id, | ||
const std::map< shared::TableKey, const TableFragments * > & | all_tables_fragments, | ||
const Data_Namespace::MemoryLevel | memory_level, | ||
const int | device_id, | ||
DeviceAllocator * | device_allocator, | ||
const size_t | thread_idx | ||
) | const |
Definition at line 288 of file ColumnFetcher.cpp.
References CHECK, columnar_fetch_mutex_, columnarized_scan_table_cache_, Data_Namespace::CPU_LEVEL, shared::TableKey::db_id, executor_, g_enable_non_kernel_time_query_interrupt, getOneTableColumnFragment(), InputColDescriptor::getScanDesc(), InputDescriptor::getSourceType(), ColumnarResults::mergeResults(), TABLE, shared::TableKey::table_id, and transferColumnIfNeeded().
Referenced by Executor::fetchChunks(), and Executor::fetchUnionChunks().
|
private |
Definition at line 1039 of file ColumnFetcher.cpp.
References InputColDescriptor::getColId(), InputColDescriptor::getScanDesc(), InputDescriptor::getTableKey(), linearized_multi_frag_chunk_iter_cache_, and VLOG.
Referenced by linearizeColumnFragments().
|
static |
Gets one chunk's pointer and element count on either CPU or GPU.
Gets a column fragment chunk on CPU or on GPU depending on the effective memory level parameter. For temporary tables, the chunk will be copied to the GPU if needed. Returns a buffer pointer and an element count.
Definition at line 71 of file ColumnFetcher.cpp.
References CHECK, shared::ColumnKey::column_id, anonymous_namespace{ColumnFetcher.cpp}::columnarize_result(), Data_Namespace::CPU_LEVEL, shared::TableKey::db_id, DEBUG_TIMER, Fragmenter_Namespace::FragmentInfo::fragmentId, get_column_descriptor_maybe(), get_temporary_table(), Chunk_NS::Chunk::getChunk(), Fragmenter_Namespace::FragmentInfo::getChunkMetadataMap(), Analyzer::ColumnVar::getColumnKey(), Fragmenter_Namespace::FragmentInfo::getNumTuples(), Fragmenter_Namespace::FragmentInfo::isEmptyPhysicalFragment(), Fragmenter_Namespace::FragmentInfo::physicalTableId, and transferColumnIfNeeded().
Referenced by RelAlgExecutor::createWindowFunctionContext(), TableFunctionExecutionContext::execute(), and makeJoinColumn().
const int8_t * ColumnFetcher::getOneTableColumnFragment | ( | const shared::TableKey & | table_key, |
const int | frag_id, | ||
const int | col_id, | ||
const std::map< shared::TableKey, 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, | ||
DeviceAllocator * | device_allocator | ||
) | const |
Definition at line 214 of file ColumnFetcher.cpp.
References Allocator::alloc(), CHECK, CHECK_EQ, CHECK_GT, chunk_list_mutex_, DeviceAllocator::copyToDevice(), Data_Namespace::CPU_LEVEL, shared::TableKey::db_id, executor_, get_column_descriptor(), get_column_type(), Chunk_NS::Chunk::getChunk(), Data_Namespace::GPU_LEVEL, kENCODING_NONE, shared::TableKey::table_id, and varlen_chunk_fetch_mutex_.
Referenced by Executor::fetchChunks(), Executor::fetchUnionChunks(), and getAllTableColumnFragments().
const int8_t * ColumnFetcher::getResultSetColumn | ( | const InputColDescriptor * | col_desc, |
const Data_Namespace::MemoryLevel | memory_level, | ||
const int | device_id, | ||
DeviceAllocator * | device_allocator, | ||
const size_t | thread_idx | ||
) | const |
Definition at line 354 of file ColumnFetcher.cpp.
References CHECK, executor_, get_temporary_table(), InputColDescriptor::getColId(), InputColDescriptor::getScanDesc(), and InputDescriptor::getTableKey().
Referenced by Executor::fetchChunks(), and Executor::fetchUnionChunks().
|
private |
Definition at line 1112 of file ColumnFetcher.cpp.
References CHECK_GE, CHECK_NE, columnar_fetch_mutex_, anonymous_namespace{ColumnFetcher.cpp}::columnarize_result(), columnarized_table_cache_, executor_, run_benchmark_import::result, and transferColumnIfNeeded().
const int8_t * ColumnFetcher::linearizeColumnFragments | ( | const shared::TableKey & | table_key, |
const int | col_id, | ||
const std::map< shared::TableKey, 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, | ||
DeviceAllocator * | device_allocator, | ||
const size_t | thread_idx | ||
) | const |
Definition at line 372 of file ColumnFetcher.cpp.
References addMergedChunkIter(), Allocator::alloc(), CHECK, CHECK_EQ, CHECK_GT, chunk_list_mutex_, DeviceAllocator::copyToDevice(), Data_Namespace::CPU_LEVEL, shared::TableKey::db_id, DEBUG_TIMER, executor_, get_column_descriptor(), Chunk_NS::Chunk::getChunk(), getChunkiter(), anonymous_namespace{ColumnFetcher.cpp}::getMemoryLevelString(), InputColDescriptor::getScanDesc(), InputDescriptor::getSourceType(), Data_Namespace::GPU_LEVEL, linearization_mutex_, linearized_col_cache_mutex_, linearized_multi_frag_chunk_iter_cache_, linearizeFixedLenArrayColFrags(), linearizeVarLenArrayColFrags(), prepareChunkIter(), run_benchmark_import::res, TABLE, shared::TableKey::table_id, varlen_chunk_fetch_mutex_, and VLOG.
Referenced by Executor::fetchChunks().
|
private |
Definition at line 907 of file ColumnFetcher.cpp.
References Data_Namespace::AbstractBuffer::append(), CHECK_EQ, check_interrupt(), ColumnDescriptor::columnId, Data_Namespace::CPU_LEVEL, executor_, g_enable_non_kernel_time_query_interrupt, anonymous_namespace{ColumnFetcher.cpp}::getMemoryLevelString(), linearized_col_cache_mutex_, linearized_data_buf_cache_, ColumnDescriptor::tableId, timer_start(), timer_stop(), and VLOG.
Referenced by linearizeColumnFragments().
|
private |
Definition at line 582 of file ColumnFetcher.cpp.
References Data_Namespace::AbstractBuffer::append(), threading_serial::async(), CHECK, ColumnDescriptor::columnId, gpu_enabled::copy(), DeviceAllocator::copyToDevice(), Data_Namespace::CPU_LEVEL, cpu_threads(), ArrayNoneEncoder::DEFAULT_NULL_PADDING_SIZE, run_benchmark_import::dest, executor_, g_enable_non_kernel_time_query_interrupt, g_enable_parallel_linearization, anonymous_namespace{ColumnFetcher.cpp}::getMemoryLevelString(), Data_Namespace::AbstractBuffer::getMemoryPtr(), Data_Namespace::GPU_LEVEL, LIKELY, linearized_col_cache_mutex_, linearized_data_buf_cache_, linearized_idx_buf_cache_, linearlized_temporary_cpu_index_buf_cache_, makeIntervals(), gpu_enabled::sort(), ColumnDescriptor::tableId, timer_start(), timer_stop(), and VLOG.
Referenced by linearizeColumnFragments().
|
static |
Creates a JoinColumn struct containing an array of JoinChunk structs.
makeJoinColumn() creates a JoinColumn struct containing a array of JoinChunk structs, col_chunks_buff, malloced in CPU memory. Although the col_chunks_buff array is in CPU memory here, each JoinChunk struct contains an int8_t* pointer from getOneColumnFragment(), col_buff, that can point to either CPU memory or GPU memory depending on the effective_mem_lvl parameter. See also the fetchJoinColumn() function where col_chunks_buff is copied into GPU memory if needed. The malloc_owner parameter will have the malloced array appended. The chunks_owner parameter will be appended with the chunks.
Definition at line 159 of file ColumnFetcher.cpp.
References CHECK, CHECK_GT, checked_malloc(), JoinChunk::col_buff, Data_Namespace::CPU_LEVEL, g_enable_non_kernel_time_query_interrupt, SQLTypeInfo::get_size(), Analyzer::Expr::get_type_info(), getOneColumnFragment(), and JoinChunk::num_elems.
Referenced by HashJoin::fetchJoinColumn().
|
private |
Definition at line 1054 of file ColumnFetcher.cpp.
References ChunkIter::current_pos, ChunkIter::end_pos, Data_Namespace::AbstractBuffer::getMemoryPtr(), ChunkIter::num_elems, ChunkIter::second_buf, Data_Namespace::AbstractBuffer::size(), ChunkIter::skip, ChunkIter::skip_size, ChunkIter::start_pos, and ChunkIter::type_info.
Referenced by linearizeColumnFragments().
|
staticprivate |
Definition at line 987 of file ColumnFetcher.cpp.
References Allocator::alloc(), CHECK, CHECK_LT, DeviceAllocator::copyToDevice(), FlatBufferManager::getBufferSize(), ColumnarResults::getColumnBuffers(), ColumnarResults::getColumnType(), Data_Namespace::GPU_LEVEL, FlatBufferManager::isFlatBuffer(), and ColumnarResults::size().
Referenced by getAllTableColumnFragments(), getOneColumnFragment(), and getResultSetColumn().
|
friend |
Definition at line 200 of file ColumnFetcher.h.
|
friend |
Definition at line 201 of file ColumnFetcher.h.
|
mutableprivate |
Definition at line 184 of file ColumnFetcher.h.
Referenced by getOneTableColumnFragment(), and linearizeColumnFragments().
|
mutableprivate |
Definition at line 181 of file ColumnFetcher.h.
Referenced by getAllTableColumnFragments(), and getResultSetColumn().
|
mutableprivate |
Definition at line 188 of file ColumnFetcher.h.
Referenced by getAllTableColumnFragments().
|
private |
Definition at line 186 of file ColumnFetcher.h.
Referenced by QueryCompilationDescriptor::compile(), TableFunctionExecutionContext::execute(), and getResultSetColumn().
|
private |
Definition at line 180 of file ColumnFetcher.h.
Referenced by freeLinearizedBuf(), freeTemporaryCpuLinearizedIdxBuf(), getAllTableColumnFragments(), getOneTableColumnFragment(), getResultSetColumn(), linearizeColumnFragments(), linearizeFixedLenArrayColFrags(), and linearizeVarLenArrayColFrags().
|
mutableprivate |
Definition at line 183 of file ColumnFetcher.h.
Referenced by linearizeColumnFragments().
|
mutableprivate |
Definition at line 185 of file ColumnFetcher.h.
Referenced by addMergedChunkIter(), freeLinearizedBuf(), freeTemporaryCpuLinearizedIdxBuf(), linearizeColumnFragments(), linearizeFixedLenArrayColFrags(), and linearizeVarLenArrayColFrags().
|
mutableprivate |
Definition at line 196 of file ColumnFetcher.h.
Referenced by freeLinearizedBuf(), linearizeFixedLenArrayColFrags(), and linearizeVarLenArrayColFrags().
|
mutableprivate |
Definition at line 198 of file ColumnFetcher.h.
Referenced by freeLinearizedBuf(), and linearizeVarLenArrayColFrags().
|
mutableprivate |
Definition at line 192 of file ColumnFetcher.h.
Referenced by addMergedChunkIter(), getChunkiter(), and linearizeColumnFragments().
|
mutableprivate |
Definition at line 194 of file ColumnFetcher.h.
Referenced by freeTemporaryCpuLinearizedIdxBuf(), and linearizeVarLenArrayColFrags().
|
mutableprivate |
Definition at line 182 of file ColumnFetcher.h.
Referenced by getOneTableColumnFragment(), and linearizeColumnFragments().