datasketches-cpp
Loading...
Searching...
No Matches
array_tuple_union.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 ARRAY_TUPLE_UNION_HPP_
21#define ARRAY_TUPLE_UNION_HPP_
22
23#include <vector>
24#include <memory>
25#include "array_tuple_sketch.hpp"
26
27#include "tuple_union.hpp"
28
29namespace datasketches {
30
32template<typename Array>
34 default_array_tuple_union_policy(uint8_t num_values = 1): num_values_(num_values) {}
35
36 void operator()(Array& array, const Array& other) const {
37 for (uint8_t i = 0; i < num_values_; ++i) {
38 array[i] += other[i];
39 }
40 }
41 uint8_t get_num_values() const {
42 return num_values_;
43 }
44private:
45 uint8_t num_values_;
46};
47
49template<
50 typename Array,
52 typename Allocator = typename Array::allocator_type
53>
54class array_tuple_union: public tuple_union<Array, Policy, Allocator> {
55public:
56 using value_type = typename Array::value_type;
59 using resize_factor = theta_constants::resize_factor;
60
61 class builder;
62
63 CompactSketch get_result(bool ordered = true) const;
64
65private:
66 // for builder
67 array_tuple_union(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);
68};
69
70template<typename Array, typename Policy, typename Allocator>
71class array_tuple_union<Array, Policy, Allocator>::builder: public tuple_base_builder<builder, Policy, Allocator> {
72public:
73 builder(const Policy& policy = Policy(), const Allocator& allocator = Allocator());
74 array_tuple_union build() const;
75};
76
77} /* namespace datasketches */
78
79#include "array_tuple_union_impl.hpp"
80
81#endif
array tuple union
Definition array_tuple_union.hpp:54
Compact array tuple sketch.
Definition array_tuple_sketch.hpp:163
Tuple base builder.
Definition tuple_sketch.hpp:614
Tuple Union.
Definition tuple_union.hpp:45
datasketches::resize_factor resize_factor
hash table resize factor
Definition theta_constants.hpp:31
DataSketches namespace.
Definition binomial_bounds.hpp:38
default array tuple union policy
Definition array_tuple_union.hpp:33