@Override public long getPos() throws IOException { return fdos.getPos(); }
@Override public long getPos() throws IOException { return out.getPos(); }
/** Returns the current length of the output file. * * <p>This always returns a synchronized position. In other words, * immediately after calling {@link SequenceFile.Reader#seek(long)} with a position * returned by this method, {@link SequenceFile.Reader#next(Writable)} may be called. However * the key may be earlier in the file than key last written when this * method was called (e.g., with block-compression, it may be the first key * in the block that was being written when this method was called). */ public synchronized long getLength() throws IOException { return out.getPos(); }
@Override public long getPos() { return fsOut.getPos(); } }
@Override public long getPos() throws IOException { if (outStream == null) { throw new IllegalStateException("Writer is not open"); } return outStream.getPos(); }
@Override protected long writeMagicAndWALHeader(byte[] magic, WALHeader header) throws IOException { output.write(magic); header.writeDelimitedTo(output); return output.getPos(); }
private void checkAndWriteSync() throws IOException { if (sync != null && out.getPos() >= lastSyncPos + SYNC_INTERVAL) { sync(); } }
/** * Get the current position in file. * * @return The current byte offset in underlying file. * @throws IOException */ long getCurrentPos() throws IOException { return fsOut.getPos() + fsBufferedOutput.size(); }
synchronized void checkAndWriteSync() throws IOException { if (sync != null && out.getPos() >= lastSyncPos+this.syncInterval) { // time to emit sync sync(); } }
private void checkAndWriteSync() throws IOException { if (sync != null && out.getPos() >= lastSyncPos + SYNC_INTERVAL) { sync(); } }
@Override public long flush() throws IOException { if (outStream == null) { throw new IllegalStateException("Writer is not open"); } if (syncOnFlush) { outStream.hsync(); } else { outStream.hflush(); } return outStream.getPos(); }
@Override protected long writeWALTrailerAndMagic(WALTrailer trailer, byte[] magic) throws IOException { trailer.writeTo(output); output.writeInt(trailer.getSerializedSize()); output.write(magic); return output.getPos(); } }
@Override protected void doWrite(Tuple tuple) throws IOException { GenericRecord avroRecord = (GenericRecord) tuple.getValue(0); avroWriter.append(avroRecord); offset = this.out.getPos(); this.needsRotation = this.rotationPolicy.mark(tuple, offset); }
public static long writeTrailer(FSDataOutputStream stream, ProcedureStoreTracker tracker) throws IOException { long offset = stream.getPos(); // Write EOF Entry ProcedureWALEntry.newBuilder() .setType(ProcedureWALEntry.Type.PROCEDURE_WAL_EOF) .build().writeDelimitedTo(stream); // Write Tracker tracker.toProto().writeDelimitedTo(stream); stream.write(TRAILER_VERSION); StreamUtils.writeLong(stream, TRAILER_MAGIC); StreamUtils.writeLong(stream, offset); return stream.getPos() - offset; }
@Override public void append(Entry entry) throws IOException { entry.getKey().getBuilder(compressor). setFollowingKvCount(entry.getEdit().size()).build().writeDelimitedTo(output); for (Cell cell : entry.getEdit().getCells()) { // cellEncoder must assume little about the stream, since we write PB and cells in turn. cellEncoder.write(cell); } length.set(output.getPos()); }
private int writeBlock(FSDataOutputStream os, HFileContext fileContext, int size) throws IOException { HFileBlock.Writer hbw = new HFileBlock.Writer(null, fileContext); DataOutputStream dos = hbw.startWriting(BlockType.DATA); for (int j = 0; j < size; j++) { dos.writeInt(j); } hbw.writeHeaderAndData(os); LOG.info("Wrote a block at " + os.getPos() + " with" + " onDiskSizeWithHeader=" + hbw.getOnDiskSizeWithHeader() + " uncompressedSizeWithoutHeader=" + hbw.getOnDiskSizeWithoutHeader() + " uncompressedSizeWithoutHeader=" + hbw.getUncompressedSizeWithoutHeader()); return hbw.getOnDiskSizeWithHeader(); }
private void writeInlineBlocks(HFileBlock.Writer hbw, FSDataOutputStream outputStream, HFileBlockIndex.BlockIndexWriter biw, boolean isClosing) throws IOException { while (biw.shouldWriteBlock(isClosing)) { long offset = outputStream.getPos(); biw.writeInlineBlock(hbw.startWriting(biw.getInlineBlockType())); hbw.writeHeaderAndData(outputStream); biw.blockWritten(offset, hbw.getOnDiskSizeWithHeader(), hbw.getUncompressedSizeWithoutHeader()); LOG.info("Wrote an inline index block at " + offset + ", size " + hbw.getOnDiskSizeWithHeader()); } }