public class BinaryStore extends PamControlledUnit implements PamSettings, PamSettingsSource, OfflineDataStore
The binary store has a number of advantages over database storage, particularly when it comes to writing objects with varying record lengths such as clicks and whistle contours.
Further information about binary storage and information on formats can be found here.
Modifier and Type | Field and Description |
---|---|
static int |
CURRENT_FORMAT |
static java.lang.String |
fileType |
static java.lang.String |
indexFileType |
static java.lang.String |
settingsFileType |
static java.lang.String |
unitType |
Constructor and Description |
---|
BinaryStore(java.lang.String unitName) |
Modifier and Type | Method and Description |
---|---|
javax.swing.JMenuItem |
createFileMenu(javax.swing.JFrame parentFrame) |
boolean |
createMapPoint(java.io.File aFile,
BinaryHeaderAndFooter bhf,
java.util.ArrayList<PamDataBlock> streams)
Create a data map point and add it to the map.
|
void |
createOfflineDataMap(java.awt.Window parentFrame)
Create a basic map of the data including first and
last times and some kind of data/unit time count
plus ideally some kind of start and stop time list
of where there are gaps in the data.
|
java.io.File |
findIndexFile(java.io.File dataFile,
boolean checkExists)
Find the index file to match a given data file.
|
BinaryStoreSettings |
getBinaryStoreSettings() |
DatagramManager |
getDatagramManager() |
java.lang.String |
getDataSourceName()
Get the data source name
|
BinaryHeaderAndFooter |
getFileHeaderAndFooter(java.io.File file)
Run checks on each file.
|
java.lang.String |
getFolderName(long timeStamp,
boolean addSeparator)
Get the name of the current storage folder and
check the folder exists, if necessary, creating it.
|
int |
getNumSettings()
Get the number of different settings
within the settings source.
|
PamSettingsGroup |
getSettings(int settingsIndex)
Get a specific PamSettingsGroup
|
java.io.Serializable |
getSettingsReference() |
java.lang.String |
getSettingsSourceName()
Get a name for the settings source
|
long |
getSettingsVersion() |
static java.util.ArrayList<PamDataBlock> |
getStreamingDataBlocks(boolean binaryStore)
Get a list of data blocks with binary storage.
|
java.lang.String |
getUnitName()
Returns the name of the unit
|
java.lang.String |
getUnitType() |
java.util.List<java.io.File> |
listAllFiles()
List all the files in the binary storage folder
|
boolean |
loadData(PamDataBlock dataBlock,
BinaryOfflineDataMapPoint mapPoint,
long dataStart,
long dataEnd)
Load the data from a single file.
|
boolean |
loadData(PamDataBlock dataBlock,
long dataStart,
long dataEnd,
RequestCancellationObject cancellationObject,
ViewLoadObserver loadObserver)
Load data for a given datablock between two time limits.
|
void |
notifyModelChanged(int changeType)
General notification when the PAMGAURD model changes.
|
void |
pamClose()
Called when PAMGUARD is finally closing down so that a module
may free any remaining resources (e.g.
|
void |
pamHasStopped()
Called for all controlled units after Pam acquisition has stopped
|
void |
pamToStart()
called just before data acquisition starts.
|
boolean |
removeMapPoint(java.io.File aFile,
java.util.ArrayList<PamDataBlock> streams) |
boolean |
restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) |
boolean |
rewriteIndexFile(PamDataBlock dataBlock,
OfflineDataMapPoint offlineDataMapPoint)
rewrite the index file.
|
boolean |
saveData(PamDataBlock pamDataBlock)
Saves data in a PamDataBlock.
|
boolean |
saveStartSettings(long timeNow)
Save the settings in some way or another.
|
void |
setBinaryStoreSettings(BinaryStoreSettings binaryStoreSettings) |
addOfflineTaskGroup, addOtherRelatedMenuItems, addPamProcess, addRelatedMenuItems, addXMLParameter, addXMLParameter, addXMLParameter, addXMLParameter, canClose, canPlayViewerSound, createDetectionMenu, createDisplayMenu, createHelpMenu, fillXMLElement, flushDataBlockBuffers, getFrameNumber, getGuiFrame, getModuleSummary, getNumOfflineTaskGroups, getNumPamProcesses, getOfflineTaskGroup, getPamController, getPamModuleInfo, getPamProcess, getPamView, getShortUnitType, getSidePanel, getTabClipCopier, getTabPanel, getTabSpecificMenuBar, getToolbarComponent, getVerboseLevel, gotoTab, isViewer, playViewerSound, removePamProcess, removeUnit, rename, saveViewerData, setFrameNumber, setPamController, setPamModuleInfo, setPamView, setSidePanel, setTabPanel, setupControlledUnit, stopViewerSound, terminalPrint, terminalPrintln, toString
public static final java.lang.String fileType
public static final java.lang.String indexFileType
public static final java.lang.String settingsFileType
public static int CURRENT_FORMAT
public static final java.lang.String unitType
public void notifyModelChanged(int changeType)
PamControlledUnit
notifyModelChanged
in class PamControlledUnit
changeType
- type of changepublic void pamToStart()
PamControlledUnit
pamToStart
in class PamControlledUnit
public void pamHasStopped()
PamControlledUnit
pamHasStopped
in class PamControlledUnit
public static java.util.ArrayList<PamDataBlock> getStreamingDataBlocks(boolean binaryStore)
binaryStore
- true if binary storage - blocks with binaryStore flag set false will not
be included.public java.io.Serializable getSettingsReference()
getSettingsReference
in interface PamSettings
public long getSettingsVersion()
getSettingsVersion
in interface PamSettings
public java.lang.String getUnitName()
PamControlledUnit
getUnitName
in interface PamSettings
getUnitName
in class PamControlledUnit
public java.lang.String getUnitType()
getUnitType
in interface PamSettings
getUnitType
in class PamControlledUnit
public java.lang.String getFolderName(long timeStamp, boolean addSeparator)
timeStamp
- current time in milliseconds.addSeparator
- if true, add a path separator character to the
end of the path.public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
restoreSettings
in interface PamSettings
public javax.swing.JMenuItem createFileMenu(javax.swing.JFrame parentFrame)
createFileMenu
in class PamControlledUnit
parentFrame
- parent frame for the menupublic boolean saveStartSettings(long timeNow)
PamSettingsSource
saveStartSettings
in interface PamSettingsSource
timeNow
- current time.public int getNumSettings()
PamSettingsSource
getNumSettings
in interface PamSettingsSource
public PamSettingsGroup getSettings(int settingsIndex)
PamSettingsSource
getSettings
in interface PamSettingsSource
settingsIndex
- index of grouppublic java.lang.String getSettingsSourceName()
PamSettingsSource
getSettingsSourceName
in interface PamSettingsSource
public BinaryStoreSettings getBinaryStoreSettings()
public void setBinaryStoreSettings(BinaryStoreSettings binaryStoreSettings)
binaryStoreSettings
- the binaryStoreSettings to setpublic void createOfflineDataMap(java.awt.Window parentFrame)
OfflineDataStore
createOfflineDataMap
in interface OfflineDataStore
public java.util.List<java.io.File> listAllFiles()
public BinaryHeaderAndFooter getFileHeaderAndFooter(java.io.File file)
file
- file to check.public boolean removeMapPoint(java.io.File aFile, java.util.ArrayList<PamDataBlock> streams)
public boolean createMapPoint(java.io.File aFile, BinaryHeaderAndFooter bhf, java.util.ArrayList<PamDataBlock> streams)
First the correct data stream (PamDataBlock) must be located then the correct map within that stream. All this searching is necessary since the files will not be read in order so we've no idea up until now which stream it's going to be.
bhf
- binary header and footer.streams
- list of data streamspublic java.io.File findIndexFile(java.io.File dataFile, boolean checkExists)
dataFile
- data file.checkExists
- check teh file exists and if it doens't return nullpublic boolean rewriteIndexFile(PamDataBlock dataBlock, OfflineDataMapPoint offlineDataMapPoint)
rewriteIndexFile
in interface OfflineDataStore
dmp
- dataBlock
- public java.lang.String getDataSourceName()
OfflineDataStore
getDataSourceName
in interface OfflineDataStore
public boolean loadData(PamDataBlock dataBlock, long dataStart, long dataEnd, RequestCancellationObject cancellationObject, ViewLoadObserver loadObserver)
OfflineDataStore
loadData
in interface OfflineDataStore
dataBlock
- datablock owner of the datadataStart
- start time in millisecondsdataEnd
- end time in millisecondspublic boolean loadData(PamDataBlock dataBlock, BinaryOfflineDataMapPoint mapPoint, long dataStart, long dataEnd)
Generally, PAMGUARD will use the above function which loads between two times, but for some offline analysis tasks, it's convenient to scroll through file at a time in which case this function can be used.
dataBlock
- PamDataBlock to receive the databinaryOfflineDataMapPoint
- data map pointdataStart
- data startdataEnd
- data endpublic boolean saveData(PamDataBlock pamDataBlock)
First scans all data in the pamDataBlock and works out which files actually need updating based on info in their DataUnitFileInformation then rewrites those files.
Note that data from many files may be in memory and it's also possible that files are only partially read in, in which case, it will be necessary to partially take data from the old file and partially from the stuff in memory !
saveData
in interface OfflineDataStore
pamDataBlock
- data block holding the data.public void pamClose()
PamControlledUnit
pamClose
in class PamControlledUnit
public DatagramManager getDatagramManager()
getDatagramManager
in interface OfflineDataStore