Class TransactionJournal


  • final class TransactionJournal
    extends java.lang.Object
    The list of all primitive operations to the database that a transaction performed. It includes the list of all rows added or removed to all tables, and the tables created and dropped and any table that had constraint modifications.

    This journal is updated inside a Transaction. When the transaction is completed, this journal is used both to determine if the transaction can be committed, and also to update the changes to the data that a transaction has made.

    THREADING: The journal update commands are synchronized because they need to be atomic operations and can be accessed by multiple threads.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private byte[] command_journal
      A byte[] array that represents the set of commands a transaction performed on a table.
      private IntegerVector command_parameters
      An IntegerVector that is filled with parameters from the command journal.
      private boolean has_added_table_rows
      Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      private boolean has_constraint_alterations
      Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      private boolean has_created_tables
      Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      private boolean has_dropped_tables
      Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      private boolean has_removed_table_rows
      Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      private int journal_entries
      The number of entries in this journal.
      (package private) static byte TABLE_ADD
      Journal commands.
      (package private) static byte TABLE_CONSTRAINT_ALTER  
      (package private) static byte TABLE_CREATE  
      (package private) static byte TABLE_DROP  
      (package private) static byte TABLE_REMOVE  
      private IntegerVector touched_tables
      The list of table's that have been touched by this transaction.
    • Constructor Summary

      Constructors 
      Constructor Description
      TransactionJournal()
      Constructs a blank journal.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addCommand​(byte command)
      Adds a command to the journal.
      private void addParameter​(int param)
      Adds a parameter to the journal command parameters.
      (package private) void entryAddTableRow​(int table_id, int row_index)
      Makes a journal entry that a table entry has been added to the table with the given id.
      (package private) void entryAddTouchedTable​(int table_id)
      Logs in this journal that the transaction touched the given table id.
      (package private) void entryRemoveTableRow​(int table_id, int row_index)
      Makes a journal entry that a table entry has been removed from the table with the given id.
      (package private) void entryTableConstraintAlter​(int table_id)
      Makes a journal entry that a table with the given 'table_id' has been altered by this transaction.
      (package private) void entryTableCreate​(int table_id)
      Makes a journal entry that a table with the given 'table_id' has been created by this transaction.
      (package private) void entryTableDrop​(int table_id)
      Makes a journal entry that a table with the given 'table_id' has been dropped by this transaction.
      (package private) IntegerVector getTablesConstraintAltered()
      Returns the list of tables id's that were constraint altered by this journal.
      (package private) IntegerVector getTablesCreated()
      Returns the list of tables id's that were created by this journal.
      (package private) IntegerVector getTablesDropped()
      Returns the list of tables id's that were dropped by this journal.
      (package private) MasterTableJournal[] makeMasterTableJournals()
      Generates an array of MasterTableJournal objects that specify the changes that occur to each table affected by this transaction.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • TABLE_ADD

        static byte TABLE_ADD
        Journal commands.
      • TABLE_REMOVE

        static byte TABLE_REMOVE
      • TABLE_CREATE

        static byte TABLE_CREATE
      • TABLE_DROP

        static byte TABLE_DROP
      • TABLE_CONSTRAINT_ALTER

        static byte TABLE_CONSTRAINT_ALTER
      • journal_entries

        private int journal_entries
        The number of entries in this journal.
      • touched_tables

        private IntegerVector touched_tables
        The list of table's that have been touched by this transaction. A table is touched if the 'getTable' method in the transaction is used to get the table. This means even if a table is just read from, the journal will record that the table was touched.

        This object records the 'table_id' of the touched tables in a sorted list.

      • command_journal

        private byte[] command_journal
        A byte[] array that represents the set of commands a transaction performed on a table.
      • command_parameters

        private IntegerVector command_parameters
        An IntegerVector that is filled with parameters from the command journal. For example, a 'TABLE_ADD' journal log will have as parameters the table id the row was added to, and the row_index that was added.
      • has_added_table_rows

        private boolean has_added_table_rows
        Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      • has_removed_table_rows

        private boolean has_removed_table_rows
        Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      • has_created_tables

        private boolean has_created_tables
        Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      • has_dropped_tables

        private boolean has_dropped_tables
        Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
      • has_constraint_alterations

        private boolean has_constraint_alterations
        Optimization, these flags are set to true when various types of journal entries are made to the transaction journal.
    • Constructor Detail

      • TransactionJournal

        TransactionJournal()
        Constructs a blank journal.
    • Method Detail

      • addCommand

        private void addCommand​(byte command)
        Adds a command to the journal.
      • addParameter

        private void addParameter​(int param)
        Adds a parameter to the journal command parameters.
      • entryAddTouchedTable

        void entryAddTouchedTable​(int table_id)
        Logs in this journal that the transaction touched the given table id.
      • entryAddTableRow

        void entryAddTableRow​(int table_id,
                              int row_index)
        Makes a journal entry that a table entry has been added to the table with the given id.
      • entryRemoveTableRow

        void entryRemoveTableRow​(int table_id,
                                 int row_index)
        Makes a journal entry that a table entry has been removed from the table with the given id.
      • entryTableCreate

        void entryTableCreate​(int table_id)
        Makes a journal entry that a table with the given 'table_id' has been created by this transaction.
      • entryTableDrop

        void entryTableDrop​(int table_id)
        Makes a journal entry that a table with the given 'table_id' has been dropped by this transaction.
      • entryTableConstraintAlter

        void entryTableConstraintAlter​(int table_id)
        Makes a journal entry that a table with the given 'table_id' has been altered by this transaction.
      • makeMasterTableJournals

        MasterTableJournal[] makeMasterTableJournals()
        Generates an array of MasterTableJournal objects that specify the changes that occur to each table affected by this transaction. Each array element represents a change to an individual table in the conglomerate that changed as a result of this transaction.

        This is used when a transaction successfully commits and we need to log the transaction changes with the master table.

        If no changes occurred to a table, then no entry is returned here.

      • getTablesDropped

        IntegerVector getTablesDropped()
        Returns the list of tables id's that were dropped by this journal.
      • getTablesCreated

        IntegerVector getTablesCreated()
        Returns the list of tables id's that were created by this journal.
      • getTablesConstraintAltered

        IntegerVector getTablesConstraintAltered()
        Returns the list of tables id's that were constraint altered by this journal.