OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 
25  static std::pair<const int8_t*, size_t> getOneColumnFragment(
26  Executor* executor,
27  const Analyzer::ColumnVar& hash_col,
28  const Fragmenter_Namespace::FragmentInfo& fragment,
29  const Data_Namespace::MemoryLevel effective_mem_lvl,
30  const int device_id,
31  std::vector<std::shared_ptr<Chunk_NS::Chunk>>& chunks_owner,
32  ColumnCacheMap& column_cache);
33 
34  static std::pair<const int8_t*, size_t> getAllColumnFragments(
35  Executor* executor,
36  const Analyzer::ColumnVar& hash_col,
37  const std::deque<Fragmenter_Namespace::FragmentInfo>& fragments,
38  std::vector<std::shared_ptr<Chunk_NS::Chunk>>& chunks_owner,
39  ColumnCacheMap& column_cache);
40 
41  const int8_t* getOneTableColumnFragment(
42  const int table_id,
43  const int frag_id,
44  const int col_id,
45  const std::map<int, const TableFragments*>& all_tables_fragments,
46  std::list<std::shared_ptr<Chunk_NS::Chunk>>& chunk_holder,
47  std::list<ChunkIter>& chunk_iter_holder,
48  const Data_Namespace::MemoryLevel memory_level,
49  const int device_id) const;
50 
51  const int8_t* getAllTableColumnFragments(
52  const int table_id,
53  const int col_id,
54  const std::map<int, const TableFragments*>& all_tables_fragments,
55  const Data_Namespace::MemoryLevel memory_level,
56  const int device_id) const;
57 
58  const int8_t* getResultSetColumn(const InputColDescriptor* col_desc,
59  const Data_Namespace::MemoryLevel memory_level,
60  const int device_id) const;
61 
62  private:
63  static const int8_t* transferColumnIfNeeded(
64  const ColumnarResults* columnar_results,
65  const int col_id,
66  Data_Namespace::DataMgr* data_mgr,
67  const Data_Namespace::MemoryLevel memory_level,
68  const int device_id);
69 
70  const int8_t* getResultSetColumn(const ResultSetPtr& buffer,
71  const int table_id,
72  const int col_id,
73  const Data_Namespace::MemoryLevel memory_level,
74  const int device_id) const;
75 
76  Executor* executor_;
77  using CacheKey = std::vector<int>;
78  mutable std::mutex columnar_conversion_mutex_;
80  mutable std::unordered_map<
82  std::unordered_map<CacheKey, std::unique_ptr<const ColumnarResults>>>
84  mutable std::unordered_map<InputColDescriptor, std::unique_ptr<const ColumnarResults>>
86 
88  friend class TableFunctionExecutionContext; // TODO(adb)
89 };
std::unordered_map< InputColDescriptor, std::unordered_map< CacheKey, std::unique_ptr< const ColumnarResults > > > columnarized_ref_table_cache_
Definition: ColumnFetcher.h:83
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
ColumnCacheMap columnarized_table_cache_
Definition: ColumnFetcher.h:79
std::shared_ptr< ResultSet > ResultSetPtr
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
Used by Fragmenter classes to store info about each fragment - the fragment id and number of tuples(r...
Definition: Fragmenter.h:79
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)
std::vector< int > CacheKey
Definition: ColumnFetcher.h:77
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > > > ColumnCacheMap
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)
const int8_t * getResultSetColumn(const InputColDescriptor *col_desc, 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)