@Override public Decoder getDecoder(ByteBuff buf) { return getDecoder(new ByteBuffInputStream(buf)); }
/** * Skips <code>n</code> bytes of input from this input stream. Fewer bytes might be skipped if the * end of the input stream is reached. The actual number <code>k</code> of bytes to be skipped is * equal to the smaller of <code>n</code> and remaining bytes in the stream. * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. */ @Override public long skip(long n) { long k = Math.min(n, available()); if (k <= 0) { return 0; } this.buf.skip((int) k); return k; }
ByteBuffInputStream bbis = new ByteBuffInputStream(new MultiByteBuff(bb)); assertEquals(15 + s.length(), bbis.available()); assertEquals(1, bbis.read()); byte[] ib = new byte[4]; bbis.read(ib); assertEquals(i, Bytes.toInt(ib)); byte[] sb = new byte[s.length()]; bbis.read(sb); assertEquals(s, Bytes.toString(sb)); byte[] lb = new byte[8]; bbis.read(lb); assertEquals(12345, Bytes.toLong(lb)); assertEquals(2, bbis.available()); ib = new byte[4]; int read = bbis.read(ib, 0, ib.length); assertEquals(0, bbis.available()); assertEquals(-1, bbis.read()); bbis.close(); bbis = new ByteBuffInputStream(new MultiByteBuff(bb)); DataInputStream dis = new DataInputStream(bbis); dis.read();
@Override public void prepareDecoding(int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader, ByteBuff blockBufferWithoutHeader, ByteBuff onDiskBlock) throws IOException { final ByteBuffInputStream byteBuffInputStream = new ByteBuffInputStream(onDiskBlock); InputStream dataInputStream = new DataInputStream(byteBuffInputStream); byteBuffInputStream.close(); dataInputStream.close();
ByteBuffInputStream bbis = new ByteBuffInputStream(new MultiByteBuff(bb)); assertEquals(15 + s.length(), bbis.available()); assertEquals(1, bbis.read()); byte[] ib = new byte[4]; bbis.read(ib); assertEquals(i, Bytes.toInt(ib)); byte[] sb = new byte[s.length()]; bbis.read(sb); assertEquals(s, Bytes.toString(sb)); byte[] lb = new byte[8]; bbis.read(lb); assertEquals(12345, Bytes.toLong(lb)); assertEquals(2, bbis.available()); ib = new byte[4]; int read = bbis.read(ib, 0, ib.length); assertEquals(0, bbis.available()); assertEquals(-1, bbis.read()); bbis.close(); bbis = new ByteBuffInputStream(new MultiByteBuff(bb)); DataInputStream dis = new DataInputStream(bbis); dis.read();
@Override public void prepareDecoding(int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader, ByteBuff blockBufferWithoutHeader, ByteBuff onDiskBlock) throws IOException { final ByteBuffInputStream byteBuffInputStream = new ByteBuffInputStream(onDiskBlock); InputStream dataInputStream = new DataInputStream(byteBuffInputStream); byteBuffInputStream.close(); dataInputStream.close();
ByteBuffInputStream bbis = new ByteBuffInputStream(new MultiByteBuff(bb)); assertEquals(15 + s.length(), bbis.available()); assertEquals(1, bbis.read()); byte[] ib = new byte[4]; bbis.read(ib); assertEquals(i, Bytes.toInt(ib)); byte[] sb = new byte[s.length()]; bbis.read(sb); assertEquals(s, Bytes.toString(sb)); byte[] lb = new byte[8]; bbis.read(lb); assertEquals(12345, Bytes.toLong(lb)); assertEquals(2, bbis.available()); ib = new byte[4]; int read = bbis.read(ib, 0, ib.length); assertEquals(0, bbis.available()); assertEquals(-1, bbis.read()); bbis.close(); bbis = new ByteBuffInputStream(new MultiByteBuff(bb)); DataInputStream dis = new DataInputStream(bbis); dis.read();
@Override public Decoder getDecoder(ByteBuff buf) { return getDecoder(new ByteBuffInputStream(buf)); }
@Override public void prepareDecoding(int onDiskSizeWithoutHeader, int uncompressedSizeWithoutHeader, ByteBuff blockBufferWithoutHeader, ByteBuff onDiskBlock) throws IOException { final ByteBuffInputStream byteBuffInputStream = new ByteBuffInputStream(onDiskBlock); InputStream dataInputStream = new DataInputStream(byteBuffInputStream); byteBuffInputStream.close(); dataInputStream.close();
/** * Reads up to next <code>len</code> bytes of data from buffer into passed array(starting from * given offset). * @param b the array into which the data is read. * @param off the start offset in the destination array <code>b</code> * @param len the maximum number of bytes to read. * @return the total number of bytes actually read into the buffer, or <code>-1</code> if not even * 1 byte can be read because the end of the stream has been reached. */ @Override public int read (byte b[], int off, int len) { int avail = available(); if (avail <= 0) { return -1; } if (len <= 0) { return 0; } if (len > avail) { len = avail; } this.buf.get(b, off, len); return len; }
@Override public Decoder getDecoder(ByteBuff buf) { return getDecoder(new ByteBuffInputStream(buf)); }
/** * Skips <code>n</code> bytes of input from this input stream. Fewer bytes might be skipped if the * end of the input stream is reached. The actual number <code>k</code> of bytes to be skipped is * equal to the smaller of <code>n</code> and remaining bytes in the stream. * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. */ @Override public long skip(long n) { long k = Math.min(n, available()); if (k <= 0) { return 0; } this.buf.skip((int) k); return k; }
@Override public Decoder getDecoder(ByteBuff buf) { return getDecoder(new ByteBuffInputStream(buf)); }
/** * Skips <code>n</code> bytes of input from this input stream. Fewer bytes might be skipped if the * end of the input stream is reached. The actual number <code>k</code> of bytes to be skipped is * equal to the smaller of <code>n</code> and remaining bytes in the stream. * @param n the number of bytes to be skipped. * @return the actual number of bytes skipped. */ @Override public long skip(long n) { long k = Math.min(n, available()); if (k <= 0) { return 0; } this.buf.skip((int) k); return k; }
/** * @return a byte stream reading the data + checksum of this block */ DataInputStream getByteStream() { ByteBuff dup = this.buf.duplicate(); dup.position(this.headerSize()); return new DataInputStream(new ByteBuffInputStream(dup)); }
/** * Reads up to next <code>len</code> bytes of data from buffer into passed array(starting from * given offset). * @param b the array into which the data is read. * @param off the start offset in the destination array <code>b</code> * @param len the maximum number of bytes to read. * @return the total number of bytes actually read into the buffer, or <code>-1</code> if not even * 1 byte can be read because the end of the stream has been reached. */ @Override public int read (byte b[], int off, int len) { int avail = available(); if (avail <= 0) { return -1; } if (len <= 0) { return 0; } if (len > avail) { len = avail; } this.buf.get(b, off, len); return len; }
private ByteBuff decompress(CompressionCodec compressor, ByteBuff compressedCellBlock) throws IOException { ByteBuffer cellBlock = decompress(compressor, new ByteBuffInputStream(compressedCellBlock), compressedCellBlock.remaining() * this.cellBlockDecompressionMultiplier); return new SingleByteBuff(cellBlock); }
/** * Reads up to next <code>len</code> bytes of data from buffer into passed array(starting from * given offset). * @param b the array into which the data is read. * @param off the start offset in the destination array <code>b</code> * @param len the maximum number of bytes to read. * @return the total number of bytes actually read into the buffer, or <code>-1</code> if not even * 1 byte can be read because the end of the stream has been reached. */ @Override public int read (byte b[], int off, int len) { int avail = available(); if (avail <= 0) { return -1; } if (len <= 0) { return 0; } if (len > avail) { len = avail; } this.buf.get(b, off, len); return len; }
private ByteBuff decompress(CompressionCodec compressor, ByteBuff compressedCellBlock) throws IOException { ByteBuffer cellBlock = decompress(compressor, new ByteBuffInputStream(compressedCellBlock), compressedCellBlock.remaining() * this.cellBlockDecompressionMultiplier); return new SingleByteBuff(cellBlock); }
@Override public Decoder getDecoder(ByteBuff buf) { return getDecoder(new ByteBuffInputStream(buf)); }