Repository navigation
fix: density_sketch did not work with a custom allocator - #562
Open
rustyconover wants to merge 2 commits into
Open
rustyconover wants to merge 2 commits into
rustyconover wants to merge 2 commits into
Conversation
gaussian_kernel only accepted std::vector<T>, but the sketch's points are std::vector<T, Allocator>, so a sketch with any other allocator did not compile (get_estimate and compaction call the kernel on them). The kernel now accepts any two vectors of T. The sketch also had an unused Allocator member that neither constructor initialized, so it was always default-constructed, which fails for allocators that need an instance. It is removed; get_allocator() already returns the levels' allocator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rustyconover
force-pushed
the
fix/density-allocator
branch
from
October 29, 2026 16:07
e87d82f to
dd37b4f
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
density_sketch<T, Kernel, Allocator>takes an allocator, but a sketch with anything other thanstd::allocatordidn't work, for two reasons:The kernel only accepted
std::vector<T>.gaussian_kernel::operator()tookconst std::vector<T>&, but the sketch stores its points asstd::vector<T, Allocator>. Compaction andget_estimate()call the kernel on those points, so the sketch didn't compile:The kernel now takes any two vectors of
T. Existing callers that passstd::vector<T>are unaffected.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 astest_allocator, whose default constructor throws for exactly this reason. Nothing reads the member, andget_allocator()already returns the levels' allocator, so this removes it.Test
Added
density sketch: custom allocatortodensity_sketch_test.cpp, usingtest_allocator. It covers:get_estimateWithout 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. 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