|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectPamController.PamControlledUnit
binaryFileStorage.BinaryStore
public class BinaryStore
The binary store will work very much like the database in that it monitors the output of data streams and when data is added to them it writes it to the binary store.
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.
| Nested Class Summary | |
|---|---|
(package private) class |
BinaryStore.BinaryDataMapMaker
|
(package private) class |
BinaryStore.BinaryStorageOptions
|
(package private) class |
BinaryStore.NewFileTask
|
(package private) class |
BinaryStore.StoredUnitServer
Class to serve up the next data unit that needs to be stored from a particular file. |
| Field Summary | |
|---|---|
private BinaryMapMakingDialog |
binaryMapDialog
|
private BinarySettingsStorage |
binarySettingsStorage
|
private BinaryStoreProcess |
binaryStoreProcess
|
protected BinaryStoreSettings |
binaryStoreSettings
|
static int |
CURRENT_FORMAT
|
static java.lang.String |
fileType
|
static java.lang.String |
indexFileType
|
private PamController |
pamController
|
static java.lang.String |
settingsFileType
|
private java.util.Vector<BinaryOutputStream> |
storageStreams
|
static java.lang.String |
unitType
|
| Fields inherited from class PamController.PamControlledUnit |
|---|
isViewer |
| Constructor Summary | |
|---|---|
BinaryStore(java.lang.String unitName)
|
|
| Method Summary | |
|---|---|
private boolean |
checkMemory(PamDataBlock dataBlock)
Check available memory. |
private boolean |
checkMemory(PamDataBlock dataBlock,
long minAmount)
|
private void |
closeStores()
|
private void |
createBinaryDataMaps(java.util.ArrayList<PamDataBlock> streams)
|
private java.util.ArrayList<java.io.File> |
createChangedFileList(PamDataBlock pamDataBlock)
Create a list of files which have data in that datablock that has been flagged as changed. |
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. |
private void |
createNewStores()
|
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. |
private void |
doInitialStoreChecks()
|
private PamDataBlock |
findDataStream(BinaryHeader binaryHeader,
java.util.ArrayList<PamDataBlock> streams)
Find the datastream to go with a particular file header. |
java.io.File |
findIndexFile(java.io.File dataFile,
boolean checkExists)
Find the index file to match a given data file. |
private BinaryOfflineDataMapPoint |
findMapPoint(PamDataBlock pamDataBlock,
java.io.File file)
Find a data map point for a specific file. |
BinaryStoreSettings |
getBinaryStoreSettings()
|
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()
|
private java.util.ArrayList<PamDataBlock> |
getStreamingDataBlocks()
|
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 |
private void |
listDataFiles(java.util.ArrayList<java.io.File> fileList,
java.io.File folder,
PamFileFilter filter)
List all data files - get's called recursively |
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)
Load data for a given datablock between two time limits. |
private void |
makeInitialDataMap()
|
void |
notifyModelChanged(int changeType)
General notification when the PAMGAURD model changes. |
private void |
openStores()
|
void |
pamHasStopped()
Called for all controlled units after Pam acquisition has stopped |
void |
pamToStart()
called just before data acquisition starts. |
private void |
prepareStores()
|
private BinaryHeaderAndFooter |
readHeadAndFoot(java.io.File file)
Read the header and footer from a binary file. |
protected void |
reOpenStores(int endReason)
Called from the process to close and reopen each datastream in a new file. |
private boolean |
reportError(java.lang.String string)
|
boolean |
restoreSettings(PamControlledUnitSettings pamControlledUnitSettings)
|
private boolean |
saveData(java.io.File file,
PamDataBlock pamDataBlock)
Rewrite a specific file using data from pamDataBlock. |
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)
|
private void |
sortBinaryDataMaps(java.util.ArrayList<PamDataBlock> streams)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
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
private PamController pamController
protected BinaryStoreSettings binaryStoreSettings
private java.util.Vector<BinaryOutputStream> storageStreams
private BinaryStoreProcess binaryStoreProcess
private BinarySettingsStorage binarySettingsStorage
public static final java.lang.String unitType
private BinaryMapMakingDialog binaryMapDialog
| Constructor Detail |
|---|
public BinaryStore(java.lang.String unitName)
| Method Detail |
|---|
public void notifyModelChanged(int changeType)
PamControlledUnit
notifyModelChanged in class PamControlledUnitchangeType - type of changepublic void pamToStart()
PamControlledUnit
pamToStart in class PamControlledUnitpublic void pamHasStopped()
PamControlledUnit
pamHasStopped in class PamControlledUnitprivate void prepareStores()
protected void reOpenStores(int endReason)
private void openStores()
private void closeStores()
private void createNewStores()
private java.util.ArrayList<PamDataBlock> getStreamingDataBlocks()
public java.io.Serializable getSettingsReference()
getSettingsReference in interface PamSettingspublic long getSettingsVersion()
getSettingsVersion in interface PamSettingspublic java.lang.String getUnitName()
PamControlledUnit
getUnitName in interface PamSettingsgetUnitName in class PamControlledUnitpublic java.lang.String getUnitType()
getUnitType in interface PamSettingsgetUnitType 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 PamSettingspublic javax.swing.JMenuItem createFileMenu(javax.swing.JFrame parentFrame)
createFileMenu in class PamControlledUnitparentFrame - parent frame for the menu
public boolean saveStartSettings(long timeNow)
PamSettingsSource
saveStartSettings in interface PamSettingsSourcetimeNow - current time.
public int getNumSettings()
PamSettingsSource
getNumSettings in interface PamSettingsSourcepublic PamSettingsGroup getSettings(int settingsIndex)
PamSettingsSource
getSettings in interface PamSettingsSourcesettingsIndex - index of group
public java.lang.String getSettingsSourceName()
PamSettingsSource
getSettingsSourceName in interface PamSettingsSourcepublic BinaryStoreSettings getBinaryStoreSettings()
public void setBinaryStoreSettings(BinaryStoreSettings binaryStoreSettings)
binaryStoreSettings - the binaryStoreSettings to setprivate void doInitialStoreChecks()
private void makeInitialDataMap()
public void createOfflineDataMap(java.awt.Window parentFrame)
OfflineDataStore
createOfflineDataMap in interface OfflineDataStoreprivate void createBinaryDataMaps(java.util.ArrayList<PamDataBlock> streams)
private void sortBinaryDataMaps(java.util.ArrayList<PamDataBlock> streams)
public java.util.List<java.io.File> listAllFiles()
public BinaryHeaderAndFooter getFileHeaderAndFooter(java.io.File file)
file - file to check.
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 streams
private PamDataBlock findDataStream(BinaryHeader binaryHeader,
java.util.ArrayList<PamDataBlock> streams)
binaryHeader - binary header read in from a filestreams - Array list of available data streams
private BinaryHeaderAndFooter readHeadAndFoot(java.io.File file)
file -
public java.io.File findIndexFile(java.io.File dataFile,
boolean checkExists)
dataFile - data file.checkExists - check teh file exists and if it doens't return null
private void listDataFiles(java.util.ArrayList<java.io.File> fileList,
java.io.File folder,
PamFileFilter filter)
fileList - current fiel list - get's added tofolder - folder to searchfilter - file filterpublic java.lang.String getDataSourceName()
OfflineDataStore
getDataSourceName in interface OfflineDataStore
public boolean loadData(PamDataBlock dataBlock,
long dataStart,
long dataEnd)
OfflineDataStore
loadData in interface OfflineDataStoredataBlock - datablock owner of the datadataStart - start time in millisecondsdataEnd - end time in milliseconds
public 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 OfflineDataStorepamDataBlock - data block holding the data.
private boolean saveData(java.io.File file,
PamDataBlock pamDataBlock)
N.B. Not all data from the original file will have been read in, so it will be necessary to take data both from the original file and from the PamDataBlock
file - file to recreatepamDataBlock -
private BinaryOfflineDataMapPoint findMapPoint(PamDataBlock pamDataBlock,
java.io.File file)
private boolean reportError(java.lang.String string)
private java.util.ArrayList<java.io.File> createChangedFileList(PamDataBlock pamDataBlock)
pamDataBlock -
private boolean checkMemory(PamDataBlock dataBlock)
private boolean checkMemory(PamDataBlock dataBlock,
long minAmount)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||