public static BlockType read(DataInputStream in) throws IOException { byte[] buf = new byte[MAGIC_LENGTH]; in.readFully(buf); return parse(buf, 0, buf.length); }
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; }
/** * Convert the contents of the block header into a human readable string. * This is mostly helpful for debugging. This assumes that the block * has minor version > 0. */ @VisibleForTesting static String toStringHeader(ByteBuff buf) throws IOException { byte[] magicBuf = new byte[Math.min(buf.limit() - buf.position(), BlockType.MAGIC_LENGTH)]; buf.get(magicBuf); BlockType bt = BlockType.parse(magicBuf, 0, BlockType.MAGIC_LENGTH); int compressedBlockSizeNoHeader = buf.getInt(); int uncompressedBlockSizeNoHeader = buf.getInt(); long prevBlockOffset = buf.getLong(); byte cksumtype = buf.get(); long bytesPerChecksum = buf.getInt(); long onDiskDataSizeWithHeader = buf.getInt(); return " Header dump: magic: " + Bytes.toString(magicBuf) + " blockType " + bt + " compressedBlockSizeNoHeader " + compressedBlockSizeNoHeader + " uncompressedBlockSizeNoHeader " + uncompressedBlockSizeNoHeader + " prevBlockOffset " + prevBlockOffset + " checksumType " + ChecksumType.codeToType(cksumtype) + " bytesPerChecksum " + bytesPerChecksum + " onDiskDataSizeWithHeader " + onDiskDataSizeWithHeader; }
public static BlockType read(DataInputStream in) throws IOException { byte[] buf = new byte[MAGIC_LENGTH]; in.readFully(buf); return parse(buf, 0, buf.length); }
public static BlockType read(DataInputStream in) throws IOException { byte[] buf = new byte[MAGIC_LENGTH]; in.readFully(buf); return parse(buf, 0, buf.length); }
public static BlockType read(DataInputStream in) throws IOException { byte[] buf = new byte[MAGIC_LENGTH]; in.readFully(buf); return parse(buf, 0, buf.length); }
public static BlockType read(DataInputStream in) throws IOException { byte[] buf = new byte[MAGIC_LENGTH]; in.readFully(buf); return parse(buf, 0, buf.length); }
public static BlockType read(ByteBuffer 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; }
public static BlockType read(ByteBuffer buf) throws IOException { BlockType blockType = parse(buf.array(), buf.arrayOffset() + buf.position(), Math.min(buf.limit() - buf.position(), MAGIC_LENGTH)); // If we got here, we have read exactly MAGIC_LENGTH bytes. buf.position(buf.position() + MAGIC_LENGTH); return blockType; }
/** * Convert the contents of the block header into a human readable string. * This is mostly helpful for debugging. This assumes that the block * has minor version > 0. */ static String toStringHeader(ByteBuffer buf) throws IOException { byte[] magicBuf = new byte[Math.min(buf.limit() - buf.position(), BlockType.MAGIC_LENGTH)]; buf.get(magicBuf); BlockType bt = BlockType.parse(magicBuf, 0, BlockType.MAGIC_LENGTH); int compressedBlockSizeNoHeader = buf.getInt(); int uncompressedBlockSizeNoHeader = buf.getInt(); long prevBlockOffset = buf.getLong(); byte cksumtype = buf.get(); long bytesPerChecksum = buf.getInt(); long onDiskDataSizeWithHeader = buf.getInt(); return " Header dump: magic: " + Bytes.toString(magicBuf) + " blockType " + bt + " compressedBlockSizeNoHeader " + compressedBlockSizeNoHeader + " uncompressedBlockSizeNoHeader " + uncompressedBlockSizeNoHeader + " prevBlockOffset " + prevBlockOffset + " checksumType " + ChecksumType.codeToType(cksumtype) + " bytesPerChecksum " + bytesPerChecksum + " onDiskDataSizeWithHeader " + onDiskDataSizeWithHeader; } }
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; }
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; }
BlockType newBlockType = BlockType.parse(buf.array(), buf.arrayOffset() + HEADER_DELTA, MAGIC_LENGTH);