Package PamguardMVC.uid.repair
Class LinkedDatabaseUpdate
java.lang.Object
PamguardMVC.uid.repair.LinkedDatabaseUpdate
Functions for updating data in a linked database table, i.e. UID's are
being primarily set by counting up binary data, but some entries are also in
a database table, so also need updating.
Effectively this only ever happens with the offline clicks table.
A system whereby a query was run to update record by record based on a search of the database to match the table record was way too slow, so need to have a quicker way whereby all the records from the database associated with a binary file are read (based on time or other information such as file name), then matching can take place in memory and the records can be more quickly updated in the database based on their Id (which is indexed so faster querying).
Effectively this only ever happens with the offline clicks table.
A system whereby a query was run to update record by record based on a search of the database to match the table record was way too slow, so need to have a quicker way whereby all the records from the database associated with a binary file are read (based on time or other information such as file name), then matching can take place in memory and the records can be more quickly updated in the database based on their Id (which is indexed so faster querying).
- Author:
- dg50
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiongetFileQueryString
(PamConnection con, BinaryOfflineDataMapPoint mapPoint) Return a WHERE clause to select records in the database associated with a map point.getLessThanQueryString
(PamConnection con, BinaryOfflineDataMapPoint mapPoint, boolean onlyNulls, String colNameToTest) Return a WHERE clause to select records in the database with a time less than the mapPoint end time.boolean
loadFileDatabaseData
(PamConnection con, BinaryOfflineDataMapPoint mapPoint) boolean
Load up the pamCursor with a dataset of UID values == nullboolean
matchCursorRecord
(PamDataUnit dataUnit) Function to match data units with a database record.replaceUIDsWithNegatives
(Long startingValue) Replace all the UID's in the PamCursors dataset with negative values.boolean
updateCursorRecord
(PamDataUnit dataUnit) Match the data unit to a cursor record and update that cursor record with the UID.boolean
push everything down into the database.
-
Constructor Details
-
LinkedDatabaseUpdate
-
-
Method Details
-
getFileQueryString
Return a WHERE clause to select records in the database associated with a map point.- Parameters:
mapPoint
-- Returns:
- SQL string beginning with the word "WHERE ..."
-
getLessThanQueryString
public String getLessThanQueryString(PamConnection con, BinaryOfflineDataMapPoint mapPoint, boolean onlyNulls, String colNameToTest) Return a WHERE clause to select records in the database with a time less than the mapPoint end time. This method can also limit the results to only rows with a null in a specified column.- Parameters:
con
- the PamConnection to usemapPoint
- the mapPoint containing the end timeonlyNulls
- whether to only include rows with nulls in a specific column (true) or all rows (false)colNameToTest
- which column to check for nulls - ignored if onlyNulls is false- Returns:
-
loadFileDatabaseData
-
loadUIDNulls
Load up the pamCursor with a dataset of UID values == null- Parameters:
con
-- Returns:
-
replaceUIDsWithNegatives
Replace all the UID's in the PamCursors dataset with negative values.- Parameters:
startingValue
- the negative value to start at- Returns:
- the next negative value to use
-
updateCursorRecord
Match the data unit to a cursor record and update that cursor record with the UID.- Parameters:
dataUnit
-- Returns:
-
matchCursorRecord
Function to match data units with a database record. If the data unit is a ClickDetection object, try to match the click number. Otherwise, try to match the time.- Parameters:
dataUnit
-- Returns:
- true if the data unit matches the selected database row.
-
updateDatabase
public boolean updateDatabase()push everything down into the database.- Returns:
- true if successful.
-