prestodb/presto · error · OrcCorruptionException

End of stream in RLE Integer

Error message

End of stream in RLE Integer

What it means

readVarint decodes protobuf-style variable-length integers from the stream. If the stream runs out mid-varint (no bytes available even after advancing), the encoding is incomplete and OrcCorruptionException 'End of stream in RLE Integer' is thrown.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/stream/OrcInputStream.java:356

                    result |= (word & 0x7f) << 56;
                    if ((word & 0x80) == 0) {
                        count++;
                    }
                    else {
                        result |= 1L << 63;
                        count += 2;
                    }
                }
            }
            position += count;
        }
        else {
            do {
                if (available == 0) {
                    advance();
                    available = available();
                    if (available == 0) {
                        throw new OrcCorruptionException(orcDataSourceId, "End of stream in RLE Integer");
                    }
                }
                available--;
                result |= (long) (buffer[position] & 0x7f) << shift;
                shift += 7;
            }
            while ((buffer[position++] & 0x80) != 0);
        }
        if (signed) {
            return zigzagDecode(result);
        }
        else {
            return result;
        }
    }

    public void skipVarints(long items)
            throws IOException

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Verify file completeness and re-transfer the file.
  2. Check the file with orc-tools to locate the corrupt byte offset.
  3. Ensure the reader's byte-encoding setting (version/DWRF variant) matches the file format.
  4. Reopen with fresh metadata in case offsets were stale.

Example fix

// before: reading truncated stream
long v = inputStream.readVarint();
// after
if (inputStream.available() == 0) {
    throw new IOException("stream ended before varint complete");
}
long v = inputStream.readVarint();
Defensive patterns

Strategy: try-catch

Validate before calling

if (stream.available() == 0) throw new IOException("stream exhausted before varint");

Try / catch

try { long v = stream.readVarint(); } catch (OrcCorruptionException e) {
    throw new DataReadException("RLE stream truncated mid-varint", e);
}

Prevention

When it happens

Trigger: readVarint called on a stream whose bytes end while the varint continuation bit is still set (byte with high bit 1 followed by EOF).

Common situations: Truncated ORC file cut off in the middle of an integer-RLE run; corrupted byte stream producing a bogus trailing varint; byte-encoding version mismatch between reader and writer.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/30604539d3b03b94. Report an issue: GitHub.