{"record":{"id":"cffef6fe75bebaa5","repo":"apache/hadoop","slug":"unsupported-call-for-block-compressed-sequencefile","errorCode":null,"errorMessage":"Unsupported call for block-compressed SequenceFiles - use SequenceFile.Reader.next(DataOutputStream, ValueBytes)","messagePattern":"Unsupported call for block-compressed SequenceFiles - use SequenceFile\\.Reader\\.next\\(DataOutputStream, ValueBytes\\)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/SequenceFile.java","lineNumber":2569,"sourceCode":"        }\n        length = in.readInt();                  // re-read length\n      } else {\n        syncSeen = false;\n      }\n      \n      return length;\n    }\n    \n    /** Read the next key/value pair in the file into <code>buffer</code>.\n     * Returns the length of the key read, or -1 if at end of file.  The length\n     * of the value may be computed by calling buffer.getLength() before and\n     * after calls to this method. */\n    /** @deprecated Call {@link #nextRaw(DataOutputBuffer,SequenceFile.ValueBytes)}. */\n    @Deprecated\n    synchronized int next(DataOutputBuffer buffer) throws IOException {\n      // Unsupported for block-compressed sequence files\n      if (blockCompressed) {\n        throw new IOException(\"Unsupported call for block-compressed\" +\n                              \" SequenceFiles - use SequenceFile.Reader.next(DataOutputStream, ValueBytes)\");\n      }\n      try {\n        int length = readRecordLength();\n        if (length == -1) {\n          return -1;\n        }\n        int keyLength = in.readInt();\n        buffer.write(in, length);\n        return keyLength;\n      } catch (ChecksumException e) {             // checksum failure\n        handleChecksumException(e);\n        return next(buffer);\n      }\n    }\n\n    public ValueBytes createValueBytes() {\n      ValueBytes val = null;","sourceCodeStart":2551,"sourceCodeEnd":2587,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/SequenceFile.java#L2551-L2587","documentation":"The deprecated SequenceFile.Reader.next(DataOutputBuffer) API predates block compression: BLOCK-compressed SequenceFiles pack many keys and values into per-block streams (keyLenIn/keyIn/valLenIn/valIn), so a method that appends one raw record into a single buffer cannot serve them. It checks the blockCompressed flag up front and throws IOException telling you to use next(DataOutputStream, ValueBytes), i.e. the raw API nextRaw(DataOutputBuffer, ValueBytes) or the typed next(key, value).","triggerScenarios":"Calling the package-visible deprecated next(DataOutputBuffer) (directly, or via next(Object key) internals on non-block files) on a file written with CompressionType.BLOCK. Typical producer settings: io.seqfile.compression.type=BLOCK or mapreduce.map.output.compression.type=BLOCK, then consuming it with legacy raw-buffer RecordReader code.","commonSituations":"Legacy custom InputFormats or third-party libraries compiled against old Hadoop APIs; jobs whose intermediate/map-output compression was switched to BLOCK between versions; old MapFile utilities that reused the raw buffer API.","solutions":["Replace next(DataOutputBuffer) with nextRaw(DataOutputBuffer, ValueBytes) — obtain the ValueBytes from reader.createValueBytes() — or use the typed next(WritableComparable, Writable), both of which handle all compression types.","If the raw-buffer code path cannot be changed, rewrite the input file with CompressionType.RECORD or NONE instead of BLOCK.","Audit for other deprecated calls in the same reader code path; block compression also breaks other record-oriented assumptions."],"exampleFix":"// before\nDataOutputBuffer buf = new DataOutputBuffer();\nint keyLen = reader.next(buf);          // throws on BLOCK-compressed files\n\n// after\nDataOutputBuffer keyBuf = new DataOutputBuffer();\nSequenceFile.ValueBytes val = reader.createValueBytes();\nint recLen = reader.nextRaw(keyBuf, val);  // works for NONE/RECORD/BLOCK","handlingStrategy":"validation","validationCode":"if (reader.isBlockCompressed()) {\n  // BLOCK-compressed: use the raw or typed API that supports blocks\n  SequenceFile.ValueBytes val = reader.createValueBytes();\n  int recLen = reader.nextRaw(keyBuf, val);\n} else {\n  int keyLen = reader.next(buffer);  // deprecated, record-based files only\n}","typeGuard":"static boolean supportsRawBufferRead(SequenceFile.Reader r) {\n  return !r.isBlockCompressed();\n}","tryCatchPattern":null,"preventionTips":["Prefer typed next(key, value) or nextRaw(key, ValueBytes) over deprecated raw-buffer APIs","Branch on reader.isBlockCompressed() before format-sensitive reader code","Keep compression type consistent between the producing job and legacy consumers"],"tags":["sequencefile","block-compression","deprecated-api","hadoop"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}