prestodb/presto · error · RcFileCorruptionException
First column value length is negative
Error message
First column value length is negative
What it means
In RCFile run-length encoding of value lengths, a negative length encodes a run or terminator and requires a previously seen lastValueLength to resolve. If the very first decoded length for a column is negative there is no prior value to reference, so the reader throws RcFileCorruptionException.
Source
Thrown at presto-rcfile/src/main/java/com/facebook/presto/rcfile/RcFileReader.java:638
int valueLength = readNextValueLength();
currentOffset += valueLength;
}
}
private int readNextValueLength()
throws IOException
{
if (runLength > 0) {
runLength--;
return lastValueLength;
}
int valueLength = toIntExact(readVInt(lengthsInput));
// negative length is used to encode a run or the last value
if (valueLength < 0) {
if (lastValueLength == -1) {
throw new RcFileCorruptionException("First column value length is negative");
}
runLength = (~valueLength) - 1;
return lastValueLength;
}
runLength = 0;
lastValueLength = valueLength;
return valueLength;
}
private Slice getDataBuffer()
throws IOException
{
if (compressed) {
if (decompressedBuffer.length < uncompressedDataSize) {
decompressedBuffer = new byte[uncompressedDataSize];
}
Slice buffer = Slices.wrappedBuffer(decompressedBuffer, 0, uncompressedDataSize);View on GitHub (pinned to 55bb57d202)
Solutions
- Treat the file as corrupt and re-generate or re-copy it from the source
- Confirm the reader and writer versions/Hive compatibility match
- Verify you are not seeking to a non-sync-bound offset inside the file
- Catch RcFileCorruptionException and skip/report the offending file
Defensive patterns
Strategy: try-catch
Try / catch
try { reader.read(); }
catch (RcFileCorruptionException e) {
if (e.getMessage().contains("value length is negative")) {
// mark file/stripe corrupt; skip or re-generate
} else { throw e; }
} Prevention
- Read RCFiles only from sync-marker-aligned offsets, never mid-stream
- Keep writer/reader Hive versions compatible
- Checksum column streams after writing
- Treat seek-then-read patterns as high risk for corruption errors
When it happens
Trigger: Reading a column whose first encoded value length is negative — i.e. the length stream starts with run-length metadata instead of an actual length, which only happens when the stream is misaligned or corrupt.
Common situations: Files written by buggy or incompatible RCFile writers; seeking into the middle of a compressed stream so the length stream starts mid-run; byte-level corruption in the column length stream.
Related errors
- Validation failed
- Deserialized SingleMapBlock violates invariants: key %d, val
- Deserialized SingleMapBlock violates invariants: expected ha
- INVALID_VIEW
- HIVE_WRITER_CLOSE_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/41407edcde09e1e7.
Report an issue: GitHub.