OmniSciDB  343343d194
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CountDistinctDescriptor.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 
26 #ifndef QUERYENGINE_COUNTDISTINCTDESCRIPTOR_H
27 #define QUERYENGINE_COUNTDISTINCTDESCRIPTOR_H
28 
29 #include "../BufferCompaction.h"
30 #include "../CompilationOptions.h"
31 #include "Shared/Logger.h"
32 
33 inline size_t bitmap_bits_to_bytes(const size_t bitmap_sz) {
34  size_t bitmap_byte_sz = bitmap_sz / 8;
35  if (bitmap_sz % 8) {
36  ++bitmap_byte_sz;
37  }
38  return bitmap_byte_sz;
39 }
40 
42 
45  int64_t min_val;
46  int64_t bitmap_sz_bits;
50 
51  size_t bitmapSizeBytes() const {
53  const auto approx_reg_bytes =
54  (device_type == ExecutorDeviceType::GPU ? sizeof(int32_t) : 1);
55  return approximate ? (1 << bitmap_sz_bits) * approx_reg_bytes
57  }
58 
59  size_t bitmapPaddedSizeBytes() const {
60  const auto effective_size = bitmapSizeBytes();
61  const auto padded_size =
63  ? align_to_int64(effective_size)
64  : effective_size;
65  return padded_size * sub_bitmap_count;
66  }
67 };
68 
69 inline bool operator==(const CountDistinctDescriptor& lhs,
70  const CountDistinctDescriptor& rhs) {
71  return lhs.impl_type_ == rhs.impl_type_ && lhs.min_val == rhs.min_val &&
72  lhs.bitmap_sz_bits == rhs.bitmap_sz_bits && lhs.approximate == rhs.approximate &&
73  lhs.device_type == rhs.device_type;
74 }
75 
76 inline bool operator!=(const CountDistinctDescriptor& lhs,
77  const CountDistinctDescriptor& rhs) {
78  return !(lhs == rhs);
79 }
80 
81 #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:187
FORCE_INLINE HOST DEVICE T align_to_int64(T addr)