#ifndef TUPLE_INTERSECTION_HPP_
#define TUPLE_INTERSECTION_HPP_
#include "tuple_sketch.hpp"
#include "theta_intersection_base.hpp"
namespace datasketches {
template<
typename Summary,
typename Policy,
typename Allocator = std::allocator<Summary>
>
class tuple_intersection {
public:
using Entry = std::pair<uint64_t, Summary>;
using ExtractKey = pair_extract_key<uint64_t, Summary>;
using Sketch = tuple_sketch<Summary, Allocator>;
using CompactSketch = compact_tuple_sketch<Summary, Allocator>;
using AllocEntry = typename std::allocator_traits<Allocator>::template rebind_alloc<Entry>;
struct internal_policy {
internal_policy(const Policy& external_policy): external_policy_(external_policy) {}
void operator()(Entry& internal_entry, const Entry& incoming_entry) const {
external_policy_(internal_entry.second, incoming_entry.second);
}
void operator()(Entry& internal_entry, Entry&& incoming_entry) const {
external_policy_(internal_entry.second, std::move(incoming_entry.second));
}
const Policy& get_external_policy() const { return external_policy_; }
Policy external_policy_;
};
using State = theta_intersection_base<Entry, ExtractKey, internal_policy, Sketch, CompactSketch, AllocEntry>;
explicit tuple_intersection(uint64_t seed = DEFAULT_SEED, const Policy& policy = Policy(), const Allocator& allocator = Allocator());
template<typename FwdSketch>
void update(FwdSketch&& sketch);
CompactSketch get_result(bool ordered = true) const;
bool has_result() const;
protected:
State state_;
};
}
#include "tuple_intersection_impl.hpp"
#endif