datasketches-cpp
Loading...
Searching...
No Matches
cpc_common.hpp
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef CPC_COMMON_HPP_
21#define CPC_COMMON_HPP_
22
23#include <memory>
24
25#include "MurmurHash3.h"
26
27namespace datasketches {
28
30namespace cpc_constants {
32 const uint8_t MIN_LG_K = 4;
34 const uint8_t MAX_LG_K = 26;
36 const uint8_t DEFAULT_LG_K = 11;
37}
38
39// forward declaration
40template<typename A> class u32_table;
41
42template<typename A>
43struct compressed_state {
44 using vector_u32 = std::vector<uint32_t, typename std::allocator_traits<A>::template rebind_alloc<uint32_t>>;
45
46 explicit compressed_state(const A& allocator): table_data(allocator), table_data_words(0), table_num_entries(0),
47 window_data(allocator), window_data_words(0) {}
48 vector_u32 table_data;
49 uint32_t table_data_words;
50 uint32_t table_num_entries; // can be different from the number of entries in the sketch in hybrid mode
51 vector_u32 window_data;
52 uint32_t window_data_words;
53};
54
55template<typename A>
56struct uncompressed_state {
57 using vector_bytes = std::vector<uint8_t, typename std::allocator_traits<A>::template rebind_alloc<uint8_t>>;
58
59 explicit uncompressed_state(const A& allocator): table(allocator), window(allocator) {}
60 u32_table<A> table;
61 vector_bytes window;
62};
63
64} /* namespace datasketches */
65
66#endif
const uint8_t DEFAULT_LG_K
default log2 of K
Definition cpc_common.hpp:36
const uint8_t MIN_LG_K
min log2 of K
Definition cpc_common.hpp:32
const uint8_t MAX_LG_K
max log2 of K
Definition cpc_common.hpp:34
DataSketches namespace.
Definition binomial_bounds.hpp:38