public static BlockType read(ByteBuff buf) throws IOException {
    byte[] magicBuf = new byte[Math.min(buf.limit() - buf.position(), MAGIC_LENGTH)];
    buf.get(magicBuf);
    BlockType blockType = parse(magicBuf, 0, magicBuf.length);
    // If we got here, we have read exactly MAGIC_LENGTH bytes.
    return blockType;
  }
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