{"record":{"id":"6378fefc8e27e748","repo":"apache/druid","slug":"index-d-size-d-or-0-6378fe","errorCode":null,"errorMessage":"Index[%d] >= size[%d] or < 0","messagePattern":"Index\\[(.+?)\\] >= size\\[(.+?)\\] or < 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"processing/src/main/java/org/apache/druid/segment/data/SliceIndexedInts.java","lineNumber":58,"sourceCode":"  }\n\n  public void setValues(int offset, int size)\n  {\n    this.offset = offset;\n    this.size = size;\n  }\n\n  @Override\n  public int size()\n  {\n    return size;\n  }\n\n  @Override\n  public int get(int index)\n  {\n    if (index < 0 || index >= size) {\n      throw new IAE(\"Index[%d] >= size[%d] or < 0\", index, size);\n    }\n    return base.get(offset + index);\n  }\n\n  @Override\n  public void inspectRuntimeShape(RuntimeShapeInspector inspector)\n  {\n    inspector.visit(\"base\", base);\n  }\n}\n","sourceCodeStart":40,"sourceCodeEnd":69,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/processing/src/main/java/org/apache/druid/segment/data/SliceIndexedInts.java#L40-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"Multi-valued column processing where value counts were misread; mixing indexes from one row's IndexedInts with another's slice.","solutions":["Iterate using ints.size() of the row rather than a cached count","Validate indexes against the slice's size() before get","Check that row value counts read from the segment are consistent (corrupt segment check)"],"exampleFix":"// before\nfor (int i = 0; i < assumedCount; i++) slice.get(i);\n// after\nfor (int i = 0; i < slice.size(); i++) slice.get(i);","handlingStrategy":"validation","validationCode":"for (int i = 0; i < slice.size(); i++) { int v = slice.get(i); }","typeGuard":null,"tryCatchPattern":"try { v = slice.get(i); } catch (IllegalArgumentException e) { log.warn(\"row index %d outside slice size %d\", i, slice.size()); }","preventionTips":["Bound loops by slice.size()","Keep row value counts and slice sizes in sync","Detect corrupted segments whose value counts exceed slice capacity"],"tags":["druid","segment","indexing"],"backgroundTag":"index-out-of-bounds","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}