{"record":{"id":"ce1f349ec4bd62ce","repo":"apache/hadoop","slug":"corrupted-data-index-negative-block-count","errorCode":null,"errorMessage":"Corrupted data index: negative block count ","messagePattern":"Corrupted data index: negative block count ","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java","lineNumber":876,"sourceCode":"   */\n  static class DataIndex {\n    final static String BLOCK_NAME = \"BCFile.index\";\n\n    private final Algorithm defaultCompressionAlgorithm;\n\n    // for data blocks, each entry specifies a block's offset, compressed size\n    // and raw size\n    private final ArrayList<BlockRegion> listRegions;\n\n    // for read, deserialized from a file\n    public DataIndex(DataInput in) throws IOException {\n      defaultCompressionAlgorithm =\n          Compression.getCompressionAlgorithmByName(\n              Utils.readString(in, MAX_META_STRING_LENGTH));\n\n      int n = Utils.readVInt(in);\n      if (n < 0) {\n        throw new IOException(\"Corrupted data index: negative block count \"\n            + n);\n      }\n      // Only a capacity hint: bound it so a corrupt count cannot force a huge\n      // pre-allocation. The loop is limited by the bytes actually available.\n      listRegions = new ArrayList<>(Math.min(n, 1024));\n\n      for (int i = 0; i < n; i++) {\n        BlockRegion region = new BlockRegion(in);\n        listRegions.add(region);\n      }\n    }\n\n    // for write\n    public DataIndex(String defaultCompressionAlgorithmName) {\n      this.defaultCompressionAlgorithm =\n          Compression\n              .getCompressionAlgorithmByName(defaultCompressionAlgorithmName);\n      listRegions = new ArrayList<>();","sourceCodeStart":858,"sourceCodeEnd":894,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java#L858-L894","documentation":"Error \"Corrupted data index: negative block count \" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/file/tfile/BCFile.java:876 when the library encounters an invalid state.","commonSituations":"Occurs when the BCFile data index reports a negative block count, indicating corruption. Verify file integrity and treat as unrecoverable corrupt input.","solutions":["The data index is corrupted; regenerate the file and check for disk or transfer errors."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}