allow pointers to double as input
diff --git a/tuple/include/array_of_doubles_sketch.hpp b/tuple/include/array_of_doubles_sketch.hpp
index a51b46b..a3c26d1 100644
--- a/tuple/include/array_of_doubles_sketch.hpp
+++ b/tuple/include/array_of_doubles_sketch.hpp
@@ -38,7 +38,8 @@
std::vector<double, A> create() const {
return std::vector<double, A>(num_values_, 0, allocator_);
}
- void update(std::vector<double, A>& summary, const std::vector<double, A>& update) const {
+ template<typename InputVector> // to allow any type with indexed access (such as double*)
+ void update(std::vector<double, A>& summary, const InputVector& update) const {
for (uint8_t i = 0; i < num_values_; ++i) summary[i] += update[i];
}
uint8_t get_num_values() const {
diff --git a/tuple/test/array_of_doubles_sketch_test.cpp b/tuple/test/array_of_doubles_sketch_test.cpp
index 98ecf6a..fa5fc92 100644
--- a/tuple/test/array_of_doubles_sketch_test.cpp
+++ b/tuple/test/array_of_doubles_sketch_test.cpp
@@ -127,7 +127,7 @@
TEST_CASE("aod sketch: serialization compatibility with java - exact mode with two values", "[tuple_sketch]") {
auto update_sketch = update_array_of_doubles_sketch::builder(2).build();
std::vector<double> a = {1, 2};
- for (int i = 0; i < 1000; ++i) update_sketch.update(i, a);
+ for (int i = 0; i < 1000; ++i) update_sketch.update(i, a.data()); // pass vector as pointer
auto compact_sketch = update_sketch.compact();
REQUIRE_FALSE(compact_sketch.is_estimation_mode());