Skip to content

Quantiles javadoc: name the exception each sketch throws when empty - #791

Merged
leerho merged 1 commit into
mainfrom
quantiles-throws-javadoc
Nov 2, 2026
Merged

leerho merged 1 commit into
mainfrom
quantiles-throws-javadoc

Conversation

@leerho

@leerho leerho commented Nov 1, 2026

Copy link
Copy Markdown
Member

Docs only. The quantiles API javadoc said that every query on an empty sketch throws IllegalArgumentException, but only some implementations do. A caller who followed the docs would miss the exception from a KLL sketch, because SketchesArgumentException extends RuntimeException, not IllegalArgumentException.

What each sketch actually throws on an empty sketch

Methods KLL (doubles, floats, longs, items) QuantilesDoublesSketch, QuantilesItemsSketch, ReqSketch
getQuantile(s), getRank(s), getPMF, getCDF, getMin/MaxItem, getQuantileLower/UpperBound SketchesArgumentException IllegalArgumentException
getSortedView() SketchesArgumentException SketchesArgumentException
getPartitionBoundariesFrom*() (items sketches) IllegalArgumentException IllegalArgumentException

I found this by calling every documented method on an empty instance of each implementation, including the heapify, wrap and compact forms.

Changes

  • QuantilesDoublesAPI, QuantilesFloatsAPI, QuantilesGenericAPI: each "if sketch is empty" @throws now names both cases, for example SketchesArgumentException for KllFloatsSketch and IllegalArgumentException for ReqSketch.
  • QuantilesLongsAPI, which only KLL implements, now names SketchesArgumentException.
  • PartitioningFeature: adds the missing @throws IllegalArgumentException if sketch is empty.
  • GenericPartitionBoundaries.getMinItem() / getMaxItem(): removes a @throws tag. They return a stored field and never throw.

The getSortedView() docs were already correct.

No behavior changes. Making the empty checks throw one exception type everywhere would change behavior for callers who catch IllegalArgumentException, so that is left for 10.0.

Testing

mvn verify, including javadoc and checkstyle: 2320 tests, 0 failures.

🤖 Generated with Claude Code

The quantiles API interfaces said every query on an empty sketch throws
IllegalArgumentException. Only some implementations do:

- KLL (doubles, floats, longs, items) throws SketchesArgumentException,
  which extends RuntimeException, not IllegalArgumentException.
- QuantilesDoublesSketch, QuantilesItemsSketch and ReqSketch throw
  IllegalArgumentException.

Each @throws tag in QuantilesDoublesAPI, QuantilesFloatsAPI and
QuantilesGenericAPI now names both cases. QuantilesLongsAPI, which only
KLL implements, names SketchesArgumentException.

PartitioningFeature now documents the IllegalArgumentException its
implementations throw for an empty sketch. GenericPartitionBoundaries
getMinItem() and getMaxItem() lose a @throws tag: they return a stored
field and never throw.

No behavior changes. Checked by calling every documented method on an
empty instance of each implementation, including the heapify, wrap and
compact forms.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leerho
leerho requested review from proost and tisonkun November 1, 2026 20:45
@leerho
leerho merged commit 10e7e28 into main Nov 2, 2026
6 checks passed
@leerho
leerho deleted the quantiles-throws-javadoc branch November 2, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants