Class LogReader

java.lang.Object
org.iq80.leveldb.impl.LogReader

public class LogReader extends Object
  • Field Details

    • fileChannel

      private final FileChannel fileChannel
    • monitor

      private final LogMonitor monitor
    • verifyChecksums

      private final boolean verifyChecksums
    • initialOffset

      private final long initialOffset
      Offset at which to start looking for the first record to return
    • eof

      private boolean eof
      Have we read to the end of the file?
    • lastRecordOffset

      private long lastRecordOffset
      Offset of the last record returned by readRecord.
    • endOfBufferOffset

      private long endOfBufferOffset
      Offset of the first location past the end of buffer.
    • recordScratch

      private final DynamicSliceOutput recordScratch
      Scratch buffer in which the next record is assembled.
    • blockScratch

      private final SliceOutput blockScratch
      Scratch buffer for current block. The currentBlock is sliced off the underlying buffer.
    • currentBlock

      private SliceInput currentBlock
      The current block records are being read from.
    • currentChunk

      private Slice currentChunk
      Current chunk which is sliced from the current block.
  • Constructor Details

    • LogReader

      public LogReader(FileChannel fileChannel, LogMonitor monitor, boolean verifyChecksums, long initialOffset)
  • Method Details

    • getLastRecordOffset

      public long getLastRecordOffset()
    • skipToInitialBlock

      private boolean skipToInitialBlock()
      Skips all blocks that are completely before "initial_offset_".

      Handles reporting corruption

      Returns:
      true on success.
    • readRecord

      public Slice readRecord()
    • readNextChunk

      private LogChunkType readNextChunk()
      Return type, or one of the preceding special values
    • readNextBlock

      public boolean readNextBlock()
    • reportCorruption

      private void reportCorruption(long bytes, String reason)
      Reports corruption to the monitor. The buffer must be updated to remove the dropped bytes prior to invocation.
    • reportDrop

      private void reportDrop(long bytes, Throwable reason)
      Reports dropped bytes to the monitor. The buffer must be updated to remove the dropped bytes prior to invocation.