OmniSciDB  ca0c39ec8f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StreamingTopN.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, 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 
23 #ifndef QUERYENGINE_STREAMINGTOPN_H
24 #define QUERYENGINE_STREAMINGTOPN_H
25 
26 #include <cstddef>
27 #include <cstdint>
28 #include <vector>
29 
30 namespace streaming_top_n {
31 
32 size_t get_heap_size(const size_t row_size, const size_t n, const size_t thread_count);
33 
34 size_t get_rows_offset_of_heaps(const size_t n, const size_t thread_count);
35 
36 std::vector<int8_t> get_rows_copy_from_heaps(const int64_t* heaps,
37  const size_t heaps_size,
38  const size_t n,
39  const size_t thread_count);
40 
41 } // namespace streaming_top_n
42 
43 struct RelAlgExecutionUnit;
44 
45 namespace Analyzer {
46 class Expr;
47 } // namespace Analyzer
48 
49 // Compute the slot index where the target given by target_idx is stored, where
50 // target_exprs is the list all projected expressions.
51 size_t get_heap_key_slot_index(const std::vector<Analyzer::Expr*>& target_exprs,
52  const size_t target_idx);
53 
54 #ifdef HAVE_CUDA
55 namespace Data_Namespace {
56 
57 class DataMgr;
58 
59 } // namespace Data_Namespace
60 
62 std::vector<int8_t> pick_top_n_rows_from_dev_heaps(
63  Data_Namespace::DataMgr* data_mgr,
64  const int64_t* dev_heaps,
65  const RelAlgExecutionUnit& ra_exe_unit,
67  const size_t thread_count,
68  const int device_id);
69 #endif // HAVE_CUDA
70 #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)
constexpr double n
Definition: Utm.h:38