prestodb/presto · error · IllegalArgumentException
splitCount must be >= 0, found:
Error message
splitCount must be >= 0, found:
What it means
SplitWeight.rawValueForStandardSplitCount converts a count of standard-weight splits into a raw weight value using Math.multiplyExact. It throws IllegalArgumentException("splitCount must be >= 0, found: ...") when splitCount is negative.
Source
Thrown at presto-spi/src/main/java/com/facebook/presto/spi/SplitWeight.java:104
public static SplitWeight standard()
{
return STANDARD_WEIGHT;
}
public static SplitWeight fromProportion(double weight)
{
if (weight <= 0 || !Double.isFinite(weight)) {
throw new IllegalArgumentException("Invalid weight: " + weight);
}
// Must round up to avoid small weights rounding to 0
return fromRawValue((long) Math.ceil(weight * UNIT_VALUE));
}
public static long rawValueForStandardSplitCount(int splitCount)
{
if (splitCount < 0) {
throw new IllegalArgumentException("splitCount must be >= 0, found: " + splitCount);
}
return multiplyExact(splitCount, UNIT_VALUE);
}
public static <T> long rawValueSum(Collection<T> collection, Function<T, SplitWeight> getter)
{
long sum = 0;
for (T item : collection) {
long value = getter.apply(item).getRawValue();
sum = addExact(sum, value);
}
return sum;
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Fix the caller so split counts never go negative (use max(0, count))
- Audit increment/decrement logic for double decrements or underflow
- Note multiplyExact will also throw ArithmeticException on overflow, so validate the range of the count too
Example fix
// before long raw = SplitWeight.rawValueForStandardSplitCount(delta); // after long raw = SplitWeight.rawValueForStandardSplitCount(Math.max(0, delta));
Defensive patterns
Strategy: validation
Validate before calling
if (splitCount < 0) splitCount = 0;
Prevention
- Clamp counters/deltas with Math.max(0, n) before use
- Beware int overflow when tracking split counts; use long internally
When it happens
Trigger: Calling SplitWeight.rawValueForStandardSplitCount(-1) or any negative count, typically from bookkeeping code computing split counts that underflowed.
Common situations: Subtracting more splits than were added in a stats tracker; int underflow on large counters; passing a delta instead of an absolute count.
Related errors
- value must be > 0, found:
- Invalid weight:
- partitionHandle must be NOT_PARTITIONED
- Invalid NodeState value:
- SchemaTableName should have exactly 2 parts
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/a86b87a6355d2b6d.
Report an issue: GitHub.