OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CountDistinctDescriptor.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 
24 #ifndef QUERYENGINE_COUNTDISTINCTDESCRIPTOR_H
25 #define QUERYENGINE_COUNTDISTINCTDESCRIPTOR_H
26 
27 #include "../BufferCompaction.h"
28 #include "../CompilationOptions.h"
29 #include "Logger/Logger.h"
30 
31 inline size_t bitmap_bits_to_bytes(const size_t bitmap_sz) {
32  size_t bitmap_byte_sz = bitmap_sz / 8;
33  if (bitmap_sz % 8) {
34  ++bitmap_byte_sz;
35  }
36  return bitmap_byte_sz;
37 }
38 
40 
43  int64_t min_val;
44  int64_t bitmap_sz_bits;
48 
49  size_t bitmapSizeBytes() const {
51  const auto approx_reg_bytes =
52  (device_type == ExecutorDeviceType::GPU ? sizeof(int32_t) : 1);
53  return approximate ? (1 << bitmap_sz_bits) * approx_reg_bytes
55  }
56 
57  size_t bitmapPaddedSizeBytes() const {
58  const auto effective_size = bitmapSizeBytes();
59  const auto padded_size =
61  ? align_to_int64(effective_size)
62  : effective_size;
63  return padded_size * sub_bitmap_count;
64  }
65 };
66 
67 inline bool operator==(const CountDistinctDescriptor& lhs,
68  const CountDistinctDescriptor& rhs) {
69  return lhs.impl_type_ == rhs.impl_type_ && lhs.min_val == rhs.min_val &&
70  lhs.bitmap_sz_bits == rhs.bitmap_sz_bits && lhs.approximate == rhs.approximate &&
71  lhs.device_type == rhs.device_type;
72 }
73 
74 inline bool operator!=(const CountDistinctDescriptor& lhs,
75  const CountDistinctDescriptor& rhs) {
76  return !(lhs == rhs);
77 }
78 
79 #endif // QUERYENGINE_COUNTDISTINCTDESCRIPTOR_H
ExecutorDeviceType
size_t bitmap_bits_to_bytes(const size_t bitmap_sz)
CountDistinctImplType impl_type_
bool operator!=(const CountDistinctDescriptor &lhs, const CountDistinctDescriptor &rhs)
bool operator==(const SlotSize &lhs, const SlotSize &rhs)
CountDistinctImplType
#define CHECK(condition)
Definition: Logger.h:291
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)