rustyconover opened a new pull request, #562:
URL: https://github.com/apache/datasketches-cpp/pull/562
`density_sketch<T, Kernel, Allocator>` takes an allocator, but a sketch with
anything other than `std::allocator` didn't work, for two reasons:
1. **The kernel only accepted `std::vector<T>`.**
`gaussian_kernel::operator()` took `const std::vector<T>&`, but the sketch
stores its points as `std::vector<T, Allocator>`. Compaction and
`get_estimate()` call the kernel on those points, so the sketch didn't compile:
```
density_sketch_impl.hpp:120:41: error: no match for call to '(const
datasketches::gaussian_kernel<double>) (const std::vector<double,
...test_allocator<double>>&, ...)'
```
The kernel now takes any two vectors of `T`. Existing callers that pass
`std::vector<T>` are unaffected.
2. **An unused member was always default-constructed.** The class had an
`Allocator allocator_` member that neither constructor initialized. That fails
for allocators that require an instance, such as `test_allocator`, whose
default constructor throws for exactly this reason. Nothing reads the member,
and `get_allocator()` already returns the levels' allocator, so this removes it.
### Test
Added `density sketch: custom allocator` to `density_sketch_test.cpp`, using
`test_allocator`. It covers:
- 1,000 updates, which puts the sketch into estimation mode
- `get_estimate`
- merging a second sketch
- a serialize/deserialize round trip with equal estimates
- checking that every byte is released at the end
Without these changes it doesn't compile; with them, all 17 test suites pass
under CTest (GCC 14, aarch64).
We found this in the [DuckDB DataSketches
extension](https://github.com/Query-farm/datasketches). There, aggregate states
keep their sketches in DuckDB's per-query arena through a custom allocator, so
they count toward the memory limit and can spill.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]