Interface RowEventListener

  • All Known Implementing Classes:
    DatabaseConstraintEnforcer, IndexUpdater

    public interface RowEventListener

    This interface can be implemented by components that need to do processing before and/or after a row is inserted, updated, or deleted. Row-event listeners need to be registered on the EventDispatcher before they will be invoked.

    Note that a specific naming convention is followed in the arguments for this interface. All "old" and "new" values are specified as Tuple objects, but whether a tuple is actually in the referenced table depends on the operation being performed. For example, in the beforeRowInserted(edu.caltech.nanodb.relations.TableInfo, edu.caltech.nanodb.relations.Tuple) method, the "new tuple" isn't actually in the table yet, because the insertion hasn't yet taken place. Similarly, in the afterRowDeleted(edu.caltech.nanodb.relations.TableInfo, edu.caltech.nanodb.relations.Tuple) method, the "old tuple" is already removed from the table by the time the method is invoked.

    Therefore, the naming convention in this file is that arguments named oldValues or newValues are not in the referenced table, but oldTuple or newTuple are in the referenced table.

    Design Note:
    (donnie) We have separate insert/update/delete methods on the listener interface, because when these events are fired we know exactly what method to invoke, and there isn't any point in introducing the need to dispatch based on the operation being performed.
    • Method Detail

      • beforeRowInserted

        void beforeRowInserted​(TableInfo tblFileInfo,
                               Tuple newValues)
        Perform processing before a row is inserted into a table.
        Parameters:
        tblFileInfo - the table that the tuple will be inserted into.
        newValues - the new values that will be inserted into the table.
      • afterRowInserted

        void afterRowInserted​(TableInfo tblFileInfo,
                              Tuple newTuple)
        Perform processing after a row is inserted into a table.
        Parameters:
        tblFileInfo - the table that the tuple was inserted into.
        newTuple - the new tuple that was inserted into the table.
      • beforeRowUpdated

        void beforeRowUpdated​(TableInfo tblFileInfo,
                              Tuple oldTuple,
                              Tuple newValues)
        Perform processing before a row is updated in a table.
        Parameters:
        tblFileInfo - the table that the tuple will be updated in.
        oldTuple - the old tuple in the table that is about to be updated.
        newValues - the new values that the tuple will be updated to.
      • afterRowUpdated

        void afterRowUpdated​(TableInfo tblFileInfo,
                             Tuple oldValues,
                             Tuple newTuple)
        Perform processing after a row is updated in a table.
        Parameters:
        tblFileInfo - the table that the tuple was updated in.
        oldValues - the old values that were in the tuple before it was updated.
        newTuple - the new tuple in the table that was updated.
      • beforeRowDeleted

        void beforeRowDeleted​(TableInfo tblFileInfo,
                              Tuple oldTuple)
        Perform processing after a row has been deleted from a table.
        Parameters:
        tblFileInfo - the table that the tuple will be deleted from.
        oldTuple - the old tuple in the table that is about to be deleted.
      • afterRowDeleted

        void afterRowDeleted​(TableInfo tblFileInfo,
                             Tuple oldValues)
        Perform processing after a row has been deleted from a table.
        Parameters:
        tblFileInfo - the table that the tuple was deleted from.
        oldValues - the old values that were in the tuple before it was deleted.