OmniSciDB  340b00dbf6
 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 
47 namespace Analyzer {
48 class Expr;
49 } // namespace Analyzer
50 
51 // Compute the slot index where the target given by target_idx is stored, where
52 // target_exprs is the list all projected expressions.
53 size_t get_heap_key_slot_index(const std::vector<Analyzer::Expr*>& target_exprs,
54  const size_t target_idx);
55 
56 #ifdef HAVE_CUDA
57 namespace Data_Namespace {
58 
59 class DataMgr;
60 
61 } // namespace Data_Namespace
62 
64 std::vector<int8_t> pick_top_n_rows_from_dev_heaps(
65  Data_Namespace::DataMgr* data_mgr,
66  const int64_t* dev_heaps,
67  const RelAlgExecutionUnit& ra_exe_unit,
69  const size_t thread_count,
70  const int device_id);
71 #endif // HAVE_CUDA
72 #endif // QUERYENGINE_STREAMINGTOPN_H
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)