datasketches-cpp
theta_union_impl.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_IMPL_HPP_
21 #define THETA_UNION_IMPL_HPP_
22 
23 namespace datasketches {
24 
25 template<typename A>
26 theta_union_alloc<A>::theta_union_alloc(uint8_t lg_cur_size, uint8_t lg_nom_size, resize_factor rf, float p, uint64_t theta, uint64_t seed, const A& allocator):
27 state_(lg_cur_size, lg_nom_size, rf, p, theta, seed, nop_policy(), allocator)
28 {}
29 
30 template<typename A>
31 template<typename FwdSketch>
32 void theta_union_alloc<A>::update(FwdSketch&& sketch) {
33  state_.update(std::forward<FwdSketch>(sketch));
34 }
35 
36 template<typename A>
37 auto theta_union_alloc<A>::get_result(bool ordered) const -> CompactSketch {
38  return state_.get_result(ordered);
39 }
40 
41 template<typename A>
43  state_.reset();
44 }
45 
46 template<typename A>
47 theta_union_alloc<A>::builder::builder(const A& allocator): theta_base_builder<builder, A>(allocator) {}
48 
49 template<typename A>
51  return theta_union_alloc(this->starting_lg_size(), this->lg_k_, this->rf_, this->p_, this->starting_theta(), this->seed_, this->allocator_);
52 }
53 
54 } /* namespace datasketches */
55 
56 # endif
Compact Theta sketch.
Definition: theta_sketch.hpp:359
Theta base builder.
Definition: theta_update_sketch_base.hpp:97
theta_union_alloc< A > build() const
Create an instance of the union with predefined parameters.
Definition: theta_union_impl.hpp:50
Theta Union.
Definition: theta_union.hpp:40
void update(FwdSketch &&sketch)
Update the union with a given sketch.
Definition: theta_union_impl.hpp:32
void reset()
Reset the union to the initial empty state.
Definition: theta_union_impl.hpp:42
DataSketches namespace.
Definition: binomial_bounds.hpp:38