Skip to content
Permalink
Browse files
add allocator_type and get_allocator()
  • Loading branch information
Jon committed May 13, 2022
1 parent 752f92a commit 8c630805459bdd19a612dce3435c1079bb4e6424
Showing 3 changed files with 13 additions and 1 deletion.
@@ -151,6 +151,7 @@ template <typename T,
class quantiles_sketch {
public:
using value_type = T;
using allocator_type = Allocator;
using comparator = Comparator;
using vector_double = std::vector<double, typename std::allocator_traits<Allocator>::template rebind_alloc<double>>;

@@ -230,6 +231,12 @@ class quantiles_sketch {
*/
Comparator get_comparator() const;

/**
* Returns the allocator for this sketch.
* @return allocator
*/
allocator_type get_allocator() const;

/**
* Returns an approximation to the value of the data item
* that would be preceded by the given fraction of a hypothetical sorted
@@ -684,6 +684,11 @@ C quantiles_sketch<T, C, A>::get_comparator() const {
return C();
}

template<typename T, typename C, typename A>
A quantiles_sketch<T, C, A>::get_allocator() const {
return allocator_;
}

// implementation for fixed-size arithmetic types (integral and floating point)
template<typename T, typename C, typename A>
template<typename SerDe, typename TT, typename std::enable_if<std::is_arithmetic<TT>::value, int>::type>
@@ -908,7 +908,7 @@ TEST_CASE("quantiles sketch", "[quantiles_sketch]") {
const int n = 403;
quantiles_sketch<double> sk_double(k);

quantiles_sketch<float> sk_float(k);
quantiles_sketch<float> sk_float(k, sk_double.get_allocator());
REQUIRE(sk_float.is_empty());

for (int i = 0; i < n; ++i) sk_double.update(i + .01);

0 comments on commit 8c63080

Please sign in to comment.