apache/druid · error · IllegalArgumentException
!= 0
Error message
%d != 0
What it means
Bounds-check guard in SingleIndexedInt.get: this IndexedInts always has exactly one element (size() == 1), so only index 0 is valid; any other index is a caller bug. The message '%d != 0' reports the offending index. It fires when a generic consumer (e.g. query result iteration code) reads SingleIndexedInt with an index other than 0, typically from a bad cursor/offset computation rather than bad data; only position 0 may be read.
Solutions
- Only call get(0) on SingleIndexedInt, honoring its size()==1
- Check `indexed.size()` and iterate only within it instead of assuming a fixed loop count
- If you need many values, use the appropriate IndexedInts implementation rather than a single-value wrapper
Example fix
// before for (int i = 0; i < numValues; i++) v = singleIndexedInt.get(i); // after for (int i = 0; i < singleIndexedInt.size(); i++) v = singleIndexedInt.get(i);
Defensive patterns
Strategy: validation
Validate before calling
assert indexed.size() == 1; int v = indexed.get(0);
Type guard
boolean isSingle(Indexed<?> col) { return col != null && col.size() == 1; } Prevention
- Check size() before indexing
- Treat SingleIndexedInt as a one-element container only
- Avoid offset arithmetic (base + i) on it
When it happens
Trigger: Calling get(i) with a nonzero i, usually by generic code iterating a column assuming multiple values, or applying an offset to the index.
Common situations: Treating a single-valued (SingleIndexedInt-backed) column like a multi-valued one; row-holder code that adds an offset (offset + i) to indexes.
Related errors
- Index[ ] >= size[ ]
- Index[ ] >= size[ ] or < 0
- index[ ] >= size[ ] or < 0
- Actual Row count mismatch. Expected
- Attempt to add row to swapped-out sink for segment
AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07).
Data as JSON: /api/errors/43e9753a18341093.
Report an issue: GitHub.
Appendix: source
Thrown at processing/src/main/java/org/apache/druid/segment/data/SingleIndexedInt.java:51
{
}
public void setValue(int value)
{
this.value = value;
}
@Override
public int size()
{
return 1;
}
@Override
public int get(int i)
{
if (i != 0) {
throw new IAE("%d != 0", i);
}
return value;
}
@Override
public void inspectRuntimeShape(RuntimeShapeInspector inspector)
{
// nothing to inspect
}
}
View on GitHub (pinned to 9b90983fd2)