OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StreamingTopN.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 
25 #ifndef QUERYENGINE_STREAMINGTOPN_H
26 #define QUERYENGINE_STREAMINGTOPN_H
27 
28 #include <cstddef>
29 #include <cstdint>
30 #include <vector>
31 
32 namespace streaming_top_n {
33 
34 size_t get_heap_size(const size_t row_size, const size_t n, const size_t thread_count);
35 
36 size_t get_rows_offset_of_heaps(const size_t n, const size_t thread_count);
37 
38 std::vector<int8_t> get_rows_copy_from_heaps(const int64_t* heaps,
39  const size_t heaps_size,
40  const size_t n,
41  const size_t thread_count);
42 
43 } // namespace streaming_top_n
44 
45 struct RelAlgExecutionUnit;
46 bool use_streaming_top_n(const RelAlgExecutionUnit& ra_exe_unit,
47  const bool output_columnar);
48 
49 namespace Analyzer {
50 class Expr;
51 } // namespace Analyzer
52 
53 // Compute the slot index where the target given by target_idx is stored, where
54 // target_exprs is the list all projected expressions.
55 size_t get_heap_key_slot_index(const std::vector<Analyzer::Expr*>& target_exprs,
56  const size_t target_idx);
57 
58 #ifdef HAVE_CUDA
59 namespace Data_Namespace {
60 
61 class DataMgr;
62 
63 } // namespace Data_Namespace
64 
66 std::vector<int8_t> pick_top_n_rows_from_dev_heaps(
67  Data_Namespace::DataMgr* data_mgr,
68  const int64_t* dev_heaps,
69  const RelAlgExecutionUnit& ra_exe_unit,
71  const size_t thread_count,
72  const int device_id);
73 #endif // HAVE_CUDA
74 #endif // QUERYENGINE_STREAMINGTOPN_H
bool use_streaming_top_n(const RelAlgExecutionUnit &ra_exe_unit, const bool output_columnar)
size_t get_rows_offset_of_heaps(const size_t n, const size_t thread_count)
size_t get_heap_key_slot_index(const std::vector< Analyzer::Expr * > &target_exprs, const size_t target_idx)
std::vector< int8_t > get_rows_copy_from_heaps(const int64_t *heaps, const size_t heaps_size, const size_t n, const size_t thread_count)
size_t get_heap_size(const size_t row_size, const size_t n, const size_t thread_count)