Package edu.caltech.nanodb.indexes
Class IndexUpdater
- java.lang.Object
-
- edu.caltech.nanodb.indexes.IndexUpdater
-
- All Implemented Interfaces:
RowEventListener
public class IndexUpdater extends java.lang.Object implements RowEventListener
This class implements theRowEventListener
interface to make sure that all indexes on an updated table are kept up to date. This handler is installed by theStorageManager.initialize(edu.caltech.nanodb.server.NanoDBServer)
setup method.Note that this class does not enforce table constraints like UNIQUE constraints; it is only responsible for updating table indexes.
-
-
Field Summary
Fields Modifier and Type Field Description private IndexManager
indexManager
A cached reference to the index manager since we use it a lot in this class.private static org.apache.logging.log4j.Logger
logger
A logging object for reporting anything interesting that happens.
-
Constructor Summary
Constructors Constructor Description IndexUpdater(StorageManager storageManager)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addRowToIndexes(TableInfo tblFileInfo, PageTuple ptup)
This helper method handles the case when a tuple is being added to the table, after the row has already been added to the table.void
afterRowDeleted(TableInfo tblFileInfo, Tuple oldValues)
Perform processing after a row has been deleted from a table.void
afterRowInserted(TableInfo tblFileInfo, Tuple newTuple)
Perform processing after a row is inserted into a table.void
afterRowUpdated(TableInfo tblFileInfo, Tuple oldValues, Tuple newTuple)
Perform processing after a row is updated in a table.void
beforeRowDeleted(TableInfo tblFileInfo, Tuple oldTuple)
Perform processing after a row has been deleted from a table.void
beforeRowInserted(TableInfo tblFileInfo, Tuple newValues)
Perform processing before a row is inserted into a table.void
beforeRowUpdated(TableInfo tblFileInfo, Tuple oldTuple, Tuple newValues)
Perform processing before a row is updated in a table.private void
removeRowFromIndexes(TableInfo tableInfo, PageTuple ptup)
This helper method handles the case when a tuple is being removed from the table, before the row has actually been removed from the table.
-
-
-
Field Detail
-
logger
private static org.apache.logging.log4j.Logger logger
A logging object for reporting anything interesting that happens.
-
indexManager
private IndexManager indexManager
A cached reference to the index manager since we use it a lot in this class.
-
-
Constructor Detail
-
IndexUpdater
public IndexUpdater(StorageManager storageManager)
-
-
Method Detail
-
beforeRowInserted
public void beforeRowInserted(TableInfo tblFileInfo, Tuple newValues)
Description copied from interface:RowEventListener
Perform processing before a row is inserted into a table.- Specified by:
beforeRowInserted
in interfaceRowEventListener
- Parameters:
tblFileInfo
- the table that the tuple will be inserted into.newValues
- the new values that will be inserted into the table.
-
afterRowInserted
public void afterRowInserted(TableInfo tblFileInfo, Tuple newTuple)
Description copied from interface:RowEventListener
Perform processing after a row is inserted into a table.- Specified by:
afterRowInserted
in interfaceRowEventListener
- Parameters:
tblFileInfo
- the table that the tuple was inserted into.newTuple
- the new tuple that was inserted into the table.
-
beforeRowUpdated
public void beforeRowUpdated(TableInfo tblFileInfo, Tuple oldTuple, Tuple newValues)
Description copied from interface:RowEventListener
Perform processing before a row is updated in a table.- Specified by:
beforeRowUpdated
in interfaceRowEventListener
- 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
public void afterRowUpdated(TableInfo tblFileInfo, Tuple oldValues, Tuple newTuple)
Description copied from interface:RowEventListener
Perform processing after a row is updated in a table.- Specified by:
afterRowUpdated
in interfaceRowEventListener
- 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
public void beforeRowDeleted(TableInfo tblFileInfo, Tuple oldTuple)
Description copied from interface:RowEventListener
Perform processing after a row has been deleted from a table.- Specified by:
beforeRowDeleted
in interfaceRowEventListener
- 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
public void afterRowDeleted(TableInfo tblFileInfo, Tuple oldValues)
Description copied from interface:RowEventListener
Perform processing after a row has been deleted from a table.- Specified by:
afterRowDeleted
in interfaceRowEventListener
- Parameters:
tblFileInfo
- the table that the tuple was deleted from.oldValues
- the old values that were in the tuple before it was deleted.
-
addRowToIndexes
private void addRowToIndexes(TableInfo tblFileInfo, PageTuple ptup)
This helper method handles the case when a tuple is being added to the table, after the row has already been added to the table. All indexes on the table are updated to include the new row.- Parameters:
tblFileInfo
- details of the table being updatedptup
- the new tuple that was inserted into the table
-
removeRowFromIndexes
private void removeRowFromIndexes(TableInfo tableInfo, PageTuple ptup)
This helper method handles the case when a tuple is being removed from the table, before the row has actually been removed from the table. All indexes on the table are updated to remove the row.- Parameters:
tableInfo
- details of the table being updatedptup
- the tuple about to be removed from the table
-
-