OmniSciDB  ab4938a6a3
ColumnFetcher.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "Execute.h"
20 
22  public:
23  ColumnFetcher(Executor* executor, const ColumnCacheMap& column_cache);
24 
26  static std::pair<const int8_t*, size_t> getOneColumnFragment(
27  Executor* executor,
28  const Analyzer::ColumnVar& hash_col,
29  const Fragmenter_Namespace::FragmentInfo& fragment,
30  const Data_Namespace::MemoryLevel effective_mem_lvl,
31  const int device_id,
32  std::vector<std::shared_ptr<Chunk_NS::Chunk>>& chunks_owner,
33  ColumnCacheMap& column_cache);
34 
37  Executor* executor,
38  const Analyzer::ColumnVar& hash_col,
39  const std::vector<Fragmenter_Namespace::FragmentInfo>& fragments,
40  const Data_Namespace::MemoryLevel effective_mem_lvl,
41  const int device_id,
42  std::vector<std::shared_ptr<Chunk_NS::Chunk>>& chunks_owner,
43  std::vector<std::shared_ptr<void>>& malloc_owner,
44  ColumnCacheMap& column_cache);
45 
46  const int8_t* getOneTableColumnFragment(
47  const int table_id,
48  const int frag_id,
49  const int col_id,
50  const std::map<int, const TableFragments*>& all_tables_fragments,
51  std::list<std::shared_ptr<Chunk_NS::Chunk>>& chunk_holder,
52  std::list<ChunkIter>& chunk_iter_holder,
53  const Data_Namespace::MemoryLevel memory_level,
54  const int device_id) const;
55 
56  const int8_t* getAllTableColumnFragments(
57  const int table_id,
58  const int col_id,
59  const std::map<int, const TableFragments*>& all_tables_fragments,
60  const Data_Namespace::MemoryLevel memory_level,
61  const int device_id) const;
62 
63  const int8_t* getResultSetColumn(const InputColDescriptor* col_desc,
64  const Data_Namespace::MemoryLevel memory_level,
65  const int device_id) const;
66 
67  private:
68  static const int8_t* transferColumnIfNeeded(
69  const ColumnarResults* columnar_results,
70  const int col_id,
71  Data_Namespace::DataMgr* data_mgr,
72  const Data_Namespace::MemoryLevel memory_level,
73  const int device_id);
74 
75  const int8_t* getResultSetColumn(const ResultSetPtr& buffer,
76  const int table_id,
77  const int col_id,
78  const Data_Namespace::MemoryLevel memory_level,
79  const int device_id) const;
80 
81  Executor* executor_;
82  using CacheKey = std::vector<int>;
83  mutable std::mutex columnar_conversion_mutex_;
85  mutable std::unordered_map<
87  std::unordered_map<CacheKey, std::unique_ptr<const ColumnarResults>>>
89  mutable std::unordered_map<InputColDescriptor, std::unique_ptr<const ColumnarResults>>
91 
93  friend class TableFunctionExecutionContext; // TODO(adb)
94 };
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, 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.
std::unordered_map< InputColDescriptor, std::unordered_map< CacheKey, std::unique_ptr< const ColumnarResults > > > columnarized_ref_table_cache_
Definition: ColumnFetcher.h:88
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > >> ColumnCacheMap
const int8_t * getResultSetColumn(const InputColDescriptor *col_desc, const Data_Namespace::MemoryLevel memory_level, const int device_id) const
ColumnCacheMap columnarized_table_cache_
Definition: ColumnFetcher.h:84
std::shared_ptr< ResultSet > ResultSetPtr
Executor * executor_
Definition: ColumnFetcher.h:81
std::unordered_map< InputColDescriptor, std::unique_ptr< const ColumnarResults > > columnarized_scan_table_cache_
Definition: ColumnFetcher.h:90
std::mutex columnar_conversion_mutex_
Definition: ColumnFetcher.h:83
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:78
ColumnFetcher(Executor *executor, const ColumnCacheMap &column_cache)
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)
Gets one chunk&#39;s pointer and element count on either CPU or GPU.
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
std::vector< int > CacheKey
Definition: ColumnFetcher.h:82
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
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)