DataBlock nextRawBlock(DataBlock reuse) throws IOException { if (!hasNextBlock()) { throw new NoSuchElementException(); } if (reuse == null || reuse.data.length < (int) blockSize) { reuse = new DataBlock(blockRemaining, (int) blockSize); } else { reuse.numEntries = blockRemaining; reuse.blockSize = (int)blockSize; } // throws if it can't read the size requested vin.readFixed(reuse.data, 0, reuse.blockSize); vin.readFixed(syncBuffer); availableBlock = false; if (!Arrays.equals(syncBuffer, header.sync)) throw new IOException("Invalid sync!"); return reuse; }
/** True if more entries remain in this file. */ @Override public boolean hasNext() { try { if (blockRemaining == 0) { // check that the previous block was finished if (null != datumIn) { boolean atEnd = datumIn.isEnd(); if (!atEnd) { throw new IOException("Block read partially, the data may be corrupt"); } } if (hasNextBlock()) { block = nextRawBlock(block); block.decompressUsing(codec); blockBuffer = block.getAsByteBuffer(); datumIn = DecoderFactory.get().binaryDecoder( blockBuffer.array(), blockBuffer.arrayOffset() + blockBuffer.position(), blockBuffer.remaining(), datumIn); } } return blockRemaining != 0; } catch (EOFException e) { // at EOF return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
nextBlockRaw.writeBlockTo(vout, sync); nextBlockRaw.decompressUsing(otherCodec); nextBlockRaw.compressUsing(codec); nextBlockRaw.writeBlockTo(vout, sync);
nextBlockRaw.writeBlockTo(vout, sync); nextBlockRaw.decompressUsing(otherCodec); nextBlockRaw.compressUsing(codec); nextBlockRaw.writeBlockTo(vout, sync);
nextBlockRaw.writeBlockTo(vout, sync); nextBlockRaw.decompressUsing(otherCodec); nextBlockRaw.compressUsing(codec); nextBlockRaw.writeBlockTo(vout, sync);
/** True if more entries remain in this file. */ @Override public boolean hasNext() { try { if (blockRemaining == 0) { // check that the previous block was finished if (null != datumIn) { boolean atEnd = datumIn.isEnd(); if (!atEnd) { throw new IOException("Block read partially, the data may be corrupt"); } } if (hasNextBlock()) { block = nextRawBlock(block); block.decompressUsing(codec); blockBuffer = block.getAsByteBuffer(); datumIn = DecoderFactory.get().binaryDecoder( blockBuffer.array(), blockBuffer.arrayOffset() + blockBuffer.position(), blockBuffer.remaining(), datumIn); } } return blockRemaining != 0; } catch (EOFException e) { // at EOF return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
/** True if more entries remain in this file. */ public boolean hasNext() { try { if (blockRemaining == 0) { // check that the previous block was finished if (null != datumIn) { boolean atEnd = datumIn.isEnd(); if (!atEnd) { throw new IOException("Block read partially, the data may be corrupt"); } } if (hasNextBlock()) { block = nextRawBlock(block); block.decompressUsing(codec); blockBuffer = block.getAsByteBuffer(); datumIn = DecoderFactory.defaultFactory().createBinaryDecoder( blockBuffer.array(), blockBuffer.arrayOffset() + blockBuffer.position(), blockBuffer.remaining(), datumIn); } } return blockRemaining != 0; } catch (EOFException e) { // at EOF return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
/** True if more entries remain in this file. */ @Override public boolean hasNext() { try { if (blockRemaining == 0) { // check that the previous block was finished if (null != datumIn) { boolean atEnd = datumIn.isEnd(); if (!atEnd) { throw new IOException("Block read partially, the data may be corrupt"); } } if (hasNextBlock()) { block = nextRawBlock(block); block.decompressUsing(codec); blockBuffer = block.getAsByteBuffer(); datumIn = DecoderFactory.get().binaryDecoder( blockBuffer.array(), blockBuffer.arrayOffset() + blockBuffer.position(), blockBuffer.remaining(), datumIn); } } return blockRemaining != 0; } catch (EOFException e) { // at EOF return false; } catch (IOException e) { throw new AvroRuntimeException(e); } }
DataBlock nextRawBlock(DataBlock reuse) throws IOException { if (!hasNextBlock()) { throw new NoSuchElementException(); } if (reuse == null || reuse.data.length < (int) blockSize) { reuse = new DataBlock(blockRemaining, (int) blockSize); } else { reuse.numEntries = blockRemaining; reuse.blockSize = (int)blockSize; } // throws if it can't read the size requested vin.readFixed(reuse.data, 0, reuse.blockSize); vin.readFixed(syncBuffer); availableBlock = false; if (!Arrays.equals(syncBuffer, header.sync)) throw new IOException("Invalid sync!"); return reuse; }
DataBlock nextRawBlock(DataBlock reuse) throws IOException { if (!hasNextBlock()) { throw new NoSuchElementException(); } if (reuse == null || reuse.data.length < (int) blockSize) { reuse = new DataBlock(blockRemaining, (int) blockSize); } else { reuse.numEntries = blockRemaining; reuse.blockSize = (int)blockSize; } // throws if it can't read the size requested vin.readFixed(reuse.data, 0, reuse.blockSize); vin.readFixed(syncBuffer); if (!Arrays.equals(syncBuffer, sync)) throw new IOException("Invalid sync!"); availableBlock = false; return reuse; }
DataBlock nextRawBlock(DataBlock reuse) throws IOException { if (!hasNextBlock()) { throw new NoSuchElementException(); } if (reuse == null || reuse.data.length < (int) blockSize) { reuse = new DataBlock(blockRemaining, (int) blockSize); } else { reuse.numEntries = blockRemaining; reuse.blockSize = (int)blockSize; } // throws if it can't read the size requested vin.readFixed(reuse.data, 0, reuse.blockSize); vin.readFixed(syncBuffer); if (!Arrays.equals(syncBuffer, header.sync)) throw new IOException("Invalid sync!"); availableBlock = false; return reuse; }
DataBlock nextBlock(DataBlock reuse) throws IOException { if (!hasNextBlock()) { throw new NoSuchElementException(); } if (reuse == null || reuse.data.length < (int) blockSize) { reuse = new DataBlock(blockRemaining, (int) blockSize); } else { reuse.numEntries = blockRemaining; reuse.blockSize = (int)blockSize; } // throws if it can't read the size requested vin.readFixed(reuse.data, 0, reuse.blockSize); skipSync(); availableBlock = false; return reuse; }
void decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
private void writeBlock() throws IOException { if (blockCount > 0) { ByteBuffer uncompressed = buffer.getByteArrayAsByteBuffer(); DataBlock block = new DataBlock(uncompressed, blockCount); block.compressUsing(codec); block.writeBlockTo(vout, sync); buffer.reset(); blockCount = 0; } }
private void writeBlock() throws IOException { if (blockCount > 0) { bufOut.flush(); ByteBuffer uncompressed = buffer.getByteArrayAsByteBuffer(); DataBlock block = new DataBlock(uncompressed, blockCount); block.setFlushOnWrite(flushOnEveryBlock); block.compressUsing(codec); block.writeBlockTo(vout, sync); buffer.reset(); blockCount = 0; } }
void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void compressUsing(Codec c) throws IOException { ByteBuffer result = c.compress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }
void decompressUsing(Codec c) throws IOException { ByteBuffer result = c.decompress(getAsByteBuffer()); data = result.array(); blockSize = result.remaining(); }