datasketches-cpp
theta_union_base.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 THETA_UNION_BASE_HPP_
21 #define THETA_UNION_BASE_HPP_
22 
23 #include "theta_update_sketch_base.hpp"
24 
25 namespace datasketches {
26 
27 template<
28  typename Entry,
29  typename ExtractKey,
30  typename Policy,
31  typename Sketch,
32  typename CompactSketch,
33  typename Allocator
34 >
35 class theta_union_base {
36 public:
37  using hash_table = theta_update_sketch_base<Entry, ExtractKey, Allocator>;
38  using resize_factor = typename hash_table::resize_factor;
39  using comparator = compare_by_key<ExtractKey>;
40 
41  theta_union_base(uint8_t lg_cur_size, uint8_t lg_nom_size, resize_factor rf, float p, uint64_t theta, uint64_t seed, const Policy& policy, const Allocator& allocator);
42 
43  template<typename FwdSketch>
44  void update(FwdSketch&& sketch);
45 
46  CompactSketch get_result(bool ordered = true) const;
47 
48  const Policy& get_policy() const;
49 
50  void reset();
51 
52 private:
53  Policy policy_;
54  hash_table table_;
55  uint64_t union_theta_;
56 };
57 
58 } /* namespace datasketches */
59 
60 #include "theta_union_base_impl.hpp"
61 
62 #endif
DataSketches namespace.
Definition: binomial_bounds.hpp:38