Repository navigation
Conversation
…apacity() A new ReqSketch, an empty heapified one, and one after reset() no longer allocate the storage of the first compactor. It is allocated on the first update, or the first merge of a non-empty sketch, before anything else changes, with the same size as before: twice the compactor's nominal capacity. ensureCapacity() allocates it up front. Results and the serialized form are unchanged. merge() now grows its levels before it changes totalN, min and max. ReqSketchIterator.next() now skips any level without items, instead of assuming every level above level 0 has some. This follows the lazy allocation convention agreed on dev@. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
| final byte lgWeight, | ||
| final boolean hra, | ||
| final int sectionSize, | ||
| final ReqDebug reqDebug, |
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.
This applies the lazy allocation convention agreed on dev@ (vote, proposal) to
ReqSketch. It is the Java counterpart of apache/datasketches-cpp#575. The KLL part is #800 and the t-digest part is #801.Behavior
reset()releases it.null, is not a first use.ReqSketch.ensureCapacity(): a new public method that allocates the storage up front. It does nothing once the storage exists.OutOfMemoryErrorfrom the first allocation now comes from the first update or merge, not from building the sketch.ReqSketchBuilder.build()points toensureCapacity().Related changes from the C++ review
merge()now adds any levels it needs before it changestotalN, min and max. The merging of compactors themselves is unchanged.ReqSketchIterator.next()now skips any level without items. Before, it assumed every level above level 0 had items. When it moved onto an empty level, it reported a non-existent item, or one too many at the end. C++ found the same problem in expansion and some more cleanup #575.==inupdate(). Java already uses>=in bothupdate()andmerge(), so there's nothing to change.Tests
The new
ReqLazyAllocationTestcovers both accuracy modes. Its sketches use a silentReqDebug, which fixes the random seed, so whole images can be compared byte for byte. It checks:null;toStringandviewCompactorDetail;ensureCapacity()allocates twice the nominal capacity, and a second call changes nothing.ensureCapacity()and one without produce byte-identical images. Calling it after updates changes nothing.ensureCapacity().reset()releases the storage, and the sketch works again afterwards.The full suite passes (2,410 tests), and so do the REQ cross-language checks.
javac -Xlint:all -Xdoclint:all,-missingreports nothing new; the one existing REQ warning, a misplaced@Overrideabove a javadoc, is unchanged.🤖 Generated with Claude Code