OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
NullRowsRemoval.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 
17 #pragma once
18 
19 #ifndef __CUDACC__
20 
22 
23 namespace TableFunctions_Namespace {
24 
25 constexpr int32_t NULL_ROW_IDX{-1};
26 
27 template <typename T>
28 struct MaskedData {
29  std::vector<T*> data;
31  int32_t masked_num_rows;
32  std::vector<int32_t> index_map;
33  std::vector<int32_t> reverse_index_map;
34 
35  std::vector<std::vector<T>> data_allocations;
36 };
37 
38 template <typename T>
39 struct InputData {
40  std::vector<T*> col_ptrs;
41  int32_t num_rows;
43 };
44 
45 template <typename T>
46 InputData<T> strip_column_metadata(const ColumnList<T>& input_features);
47 
48 template <typename T>
49 InputData<T> strip_column_metadata(const Column<T>& input_labels,
50  const ColumnList<T>& input_features);
51 
52 template <typename T>
53 InputData<T> get_input_ptrs(const ColumnList<T>& input_features);
54 
55 template <typename T>
56 InputData<T> get_input_ptrs(const MaskedData<T>& masked_input_features);
57 
58 template <typename T>
60 
61 template <typename T>
62 void unmask_data(const T* masked_input,
63  const std::vector<int32_t>& reverse_index_map,
64  T* unmasked_output,
65  const int64_t num_unmasked_rows,
66  const T null_val);
67 
68 template <typename T>
70  auto input_data = strip_column_metadata(features);
71  return remove_null_rows(input_data);
72 }
73 
74 template <typename T>
75 MaskedData<T> denull_data(const Column<T>& labels, const ColumnList<T>& features) {
76  auto input_data = strip_column_metadata(labels, features);
77  return remove_null_rows(input_data);
78 }
79 
80 } // namespace TableFunctions_Namespace
81 
82 #endif // __CUDACC__
std::vector< std::vector< T > > data_allocations
MaskedData< T > denull_data(const ColumnList< T > &features)
std::vector< int32_t > reverse_index_map
InputData< T > get_input_ptrs(const ColumnList< T > &input_features)
void unmask_data(const T *masked_input, const std::vector< int32_t > &reverse_index_map, T *unmasked_output, const int64_t num_unmasked_rows, const T null_val)
constexpr int32_t NULL_ROW_IDX
MaskedData< T > remove_null_rows(const InputData< T > &input_data)
InputData< T > strip_column_metadata(const ColumnList< T > &input_features)