datasketches-cpp
Loading...
Searching...
No Matches
theta_intersection.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_INTERSECTION_HPP_
21#define THETA_INTERSECTION_HPP_
22
23#include "theta_sketch.hpp"
24#include "theta_intersection_base.hpp"
25
26namespace datasketches {
27
28// forward declaration
29template<typename A> class theta_intersection_alloc;
30
31// alias with default allocator for convenience
32using theta_intersection = theta_intersection_alloc<std::allocator<uint64_t>>;
33
38template<typename Allocator = std::allocator<uint64_t>>
40public:
41 using Entry = uint64_t;
42 using ExtractKey = trivial_extract_key;
45
46 // there is no payload in Theta sketch entry
47 struct nop_policy {
48 void operator()(uint64_t internal_entry, uint64_t incoming_entry) const {
49 unused(incoming_entry);
50 unused(internal_entry);
51 }
52 };
53 using State = theta_intersection_base<Entry, ExtractKey, nop_policy, Sketch, CompactSketch, Allocator>;
54
60 explicit theta_intersection_alloc(uint64_t seed = DEFAULT_SEED, const Allocator& allocator = Allocator());
61
68 template<typename FwdSketch>
69 void update(FwdSketch&& sketch);
70
78 CompactSketch get_result(bool ordered = true) const;
79
84 bool has_result() const;
85
86private:
87 State state_;
88};
89
90} /* namespace datasketches */
91
92#include "theta_intersection_impl.hpp"
93
94#endif
Compact Theta sketch.
Definition theta_sketch.hpp:359
Theta intersection.
Definition theta_intersection.hpp:39
CompactSketch get_result(bool ordered=true) const
Produces a copy of the current state of the intersection.
Definition theta_intersection_impl.hpp:37
bool has_result() const
Returns true if the state of the intersection is defined (not infinite "universe").
Definition theta_intersection_impl.hpp:42
void update(FwdSketch &&sketch)
Updates the intersection with a given sketch.
Definition theta_intersection_impl.hpp:32
Base class for the Theta Sketch, a generalization of the Kth Minimum Value (KMV) sketch.
Definition theta_sketch.hpp:127
DataSketches namespace.
Definition binomial_bounds.hpp:38