apache/druid · error · IllegalArgumentException

Index[ ] >= size[ ] or < 0

Error message

Index[%d] >= size[%d] or < 0

What it means

SliceIndexedInts is a view of a base IndexedInts covering `size` elements starting at `offset`; get(index) delegates to base.get(offset + index). It rejects indexes outside [0, size) so the underlying slice is never read out of bounds.

Solutions

  1. Iterate using ints.size() of the row rather than a cached count
  2. Validate indexes against the slice's size() before get
  3. Check that row value counts read from the segment are consistent (corrupt segment check)

Example fix

// before
for (int i = 0; i < assumedCount; i++) slice.get(i);
// after
for (int i = 0; i < slice.size(); i++) slice.get(i);
Defensive patterns

Strategy: validation

Validate before calling

for (int i = 0; i < slice.size(); i++) { int v = slice.get(i); }

Try / catch

try { v = slice.get(i); } catch (IllegalArgumentException e) { log.warn("row index %d outside slice size %d", i, slice.size()); }

Prevention

When it happens

Trigger: Calling get(i) with i < 0 or i >= the slice's size, e.g. iterating past numValues for a row, or applying row-value indexes against the wrong slice.

Common situations: Multi-valued column processing where value counts were misread; mixing indexes from one row's IndexedInts with another's slice.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/6378fefc8e27e748. Report an issue: GitHub.

Appendix: source

Thrown at processing/src/main/java/org/apache/druid/segment/data/SliceIndexedInts.java:58

  }

  public void setValues(int offset, int size)
  {
    this.offset = offset;
    this.size = size;
  }

  @Override
  public int size()
  {
    return size;
  }

  @Override
  public int get(int index)
  {
    if (index < 0 || index >= size) {
      throw new IAE("Index[%d] >= size[%d] or < 0", index, size);
    }
    return base.get(offset + index);
  }

  @Override
  public void inspectRuntimeShape(RuntimeShapeInspector inspector)
  {
    inspector.visit("base", base);
  }
}

View on GitHub (pinned to 9b90983fd2)