public static BlockType parse(byte[] buf, int offset, int length) throws IOException {
    if (length != MAGIC_LENGTH) {
      throw new IOException(
        "Magic record of invalid length: " + Bytes.toStringBinary(buf, offset, length));
    }

    for (BlockType blockType : values())
      if (Bytes.compareTo(blockType.magic, 0, MAGIC_LENGTH, buf, offset, MAGIC_LENGTH) == 0)
        return blockType;

    throw new IOException(
      "Invalid HFile block magic: " + Bytes.toStringBinary(buf, offset, MAGIC_LENGTH));
  }
Use this instead of {@link #ordinal()}. They work exactly the same, except DATA and
ENCODED_DATA get the same id using this method (overridden for {@link #ENCODED_DATA}).
@return block type id from 0 to the number of block types - 1
hbase-common/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockType.java