Class FileTxnLog.FileTxnIterator

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, TxnLog.TxnIterator
    Enclosing class:
    FileTxnLog

    public static class FileTxnLog.FileTxnIterator
    extends java.lang.Object
    implements TxnLog.TxnIterator
    this class implements the txnlog iterator interface which is used for reading the transaction logs
    • Constructor Summary

      Constructors 
      Constructor Description
      FileTxnIterator​(java.io.File logDir, long zxid)
      create an iterator over a transaction database directory
      FileTxnIterator​(java.io.File logDir, long zxid, boolean fastForward)
      create an iterator over a transaction database directory
    • Constructor Detail

      • FileTxnIterator

        public FileTxnIterator​(java.io.File logDir,
                               long zxid,
                               boolean fastForward)
                        throws java.io.IOException
        create an iterator over a transaction database directory
        Parameters:
        logDir - the transaction database directory
        zxid - the zxid to start reading from
        fastForward - true if the iterator should be fast forwarded to point to the txn of a given zxid, else the iterator will point to the starting txn of a txnlog that may contain txn of a given zxid
        Throws:
        java.io.IOException
      • FileTxnIterator

        public FileTxnIterator​(java.io.File logDir,
                               long zxid)
                        throws java.io.IOException
        create an iterator over a transaction database directory
        Parameters:
        logDir - the transaction database directory
        zxid - the zxid to start reading from
        Throws:
        java.io.IOException
    • Method Detail

      • getStorageSize

        public long getStorageSize()
        Return total storage size of txnlog that will return by this iterator.
        Specified by:
        getStorageSize in interface TxnLog.TxnIterator
      • inStreamCreated

        protected void inStreamCreated​(InputArchive ia,
                                       java.io.InputStream is)
                                throws java.io.IOException
        read the header from the inputarchive
        Parameters:
        ia - the inputarchive to be read from
        is - the inputstream
        Throws:
        java.io.IOException
      • createInputArchive

        protected InputArchive createInputArchive​(java.io.File logFile)
                                           throws java.io.IOException
        Invoked to indicate that the input stream has been created.
        Parameters:
        logFile - the file to read.
        Throws:
        java.io.IOException
      • makeChecksumAlgorithm

        protected java.util.zip.Checksum makeChecksumAlgorithm()
        create a checksum algorithm
        Returns:
        the checksum algorithm
      • next

        public boolean next()
                     throws java.io.IOException
        the iterator that moves to the next transaction
        Specified by:
        next in interface TxnLog.TxnIterator
        Returns:
        true if there is more transactions to be read false if not.
        Throws:
        java.io.IOException
      • getTxn

        public Record getTxn()
        return the current transaction
        Specified by:
        getTxn in interface TxnLog.TxnIterator
        Returns:
        the current transaction that is read
      • close

        public void close()
                   throws java.io.IOException
        close the iterator and release the resources.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface TxnLog.TxnIterator
        Throws:
        java.io.IOException