Top Description Fields Constructors Methods
org.hsqldb.persist

public Class Log

extends Object
Class Inheritance
Imports
java.io.File, .IOException, org.hsqldb.Database, .HsqlException, .NumberSequence, .Row, .Session, .Table, org.hsqldb.error.Error, .ErrorCode, org.hsqldb.lib.FileAccess, .FileUtil, org.hsqldb.scriptio.ScriptReaderBase, .ScriptReaderDecode, .ScriptReaderText, .ScriptWriterBase, .ScriptWriterEncode, .ScriptWriterText

This class is responsible for managing some of the database files. An HSQLDB database consists of a .properties file, a .script file (contains an SQL script), a .data file (contains data of cached tables) a .backup file a .log file and a .lobs file.

When using TEXT tables, a data source for each table is also present.

Notes

on OpenOffice.org integration. A Storage API is used when HSQLDB is integrated into OpenOffice.org. All file operations on the 4 main files are performed by OOo, which integrates the contents of these files into its database file. The script format is always TEXT in this case.

Authors
Fred Toussi (fredt@users dot sourceforge.net), Bob Preston (sqlbob@users dot sourceforge.net) - text table support
Since
1.8.0
Version
2.7.0

Field Summary

Modifier and TypeField and Description
private String
private String
private DataFileCache
private Database
private String
pack-priv ScriptWriterBase
private FileAccess
private boolean
private boolean
private String
private long
private HsqlDatabaseProperties
private String
private int

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private boolean
pack-priv void
checkpoint(Session session, boolean defrag)

Performs checkpoint including pre and post operations.

pack-priv boolean
checkpointClose()

Performs checkpoint including pre and post operations.

pack-priv boolean
pack-priv void
close(boolean script)

Close all the database files.

pack-priv void
closeImmediately()

Fast counterpart to close().

pack-priv void
public boolean
defrag(Session session)

Writes out all the rows to a new .data file without fragmentation.

pack-priv void
pack-priv void
pack-priv static void
deleteFile(FileAccess fileAccess, String fileName)

pack-priv void
pack-priv void
deleteNewAndOldFiles()

Deletes the leftovers from any previous unfinished operations.

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv boolean
forceDefrag()

Returns true if lost space is above the threshold percentage.

pack-priv DataFileCache
getCache()

Responsible for creating the data file cache instance.

pack-priv String
pack-priv int
getWriteDelay()

Write delay specifies the frequency of FileDescriptor.sync() calls.

pack-priv boolean
pack-priv void
pack-priv boolean
isAnyCacheModified()

Checks all the caches and returns true if the modified flag is set for any

pack-priv void
open()

When opening a database, the hsqldb.compatible_version property is used to determine if this version of the engine is equal to or greater than the earliest version of the engine capable of opening that database.

pack-priv void
openLog()

Wrappers for opening-starting / stopping-closing the log file and writer.

private void
processLog()

Performs all the commands in the .log file.

private void
processScript()

Performs all the commands in the .script file.

pack-priv boolean
pack-priv boolean
renameNewFile(FileAccess fileAccess, String baseFileName)

pack-priv boolean
pack-priv void
pack-priv void
setLogSize(int megas)

private void
pack-priv void
setWriteDelay(int delay)

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
writeOtherStatement(Session session, String s)

Various writeXXX() methods are used for logging statements.

pack-priv void
writeScript(boolean full)

Write the .script file as .script.new.

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

backupFileNameback to summary
private String backupFileName
baseFileNameback to summary
private String baseFileName
cacheback to summary
private DataFileCache cache
databaseback to summary
private Database database
dataFileNameback to summary
private String dataFileName
dbLogWriterback to summary
pack-priv ScriptWriterBase dbLogWriter
faback to summary
private FileAccess fa
filesReadOnlyback to summary
private boolean filesReadOnly
isModifiedback to summary
private boolean isModified
logFileNameback to summary
private String logFileName
maxLogSizeback to summary
private long maxLogSize
propertiesback to summary
private HsqlDatabaseProperties properties
scriptFileNameback to summary
private String scriptFileName
writeDelayback to summary
private int writeDelay

Constructor Detail

Logback to summary
pack-priv Log(Database db)

Method Detail

checkpointback to summary
private boolean checkpoint()
checkpointback to summary
pack-priv void checkpoint(Session session, boolean defrag)

Performs checkpoint including pre and post operations. Returns to the same state as before the checkpoint.

checkpointCloseback to summary
pack-priv boolean checkpointClose()

Performs checkpoint including pre and post operations. Returns to the same state as before the checkpoint.

checkpointReopenback to summary
pack-priv boolean checkpointReopen()
closeback to summary
pack-priv void close(boolean script)

Close all the database files. If script argument is true, no .data or .backup file will remain and the .script file will contain all the data of the cached tables as well as memory tables. This is not used for filesReadOnly databases which use shutdown.

closeImmediatelyback to summary
pack-priv void closeImmediately()

Fast counterpart to close(). Does not perform a checkpoint or delete backup of the .data file.

closeLogback to summary
pack-priv void closeLog()
defragback to summary
public boolean defrag(Session session)

Writes out all the rows to a new .data file without fragmentation.

deleteBackupFileback to summary
pack-priv void deleteBackupFile()
deleteDataFileback to summary
pack-priv void deleteDataFile()
deleteFileback to summary
pack-priv static void deleteFile(FileAccess fileAccess, String fileName)
deleteLogFileback to summary
pack-priv void deleteLogFile()
deleteNewAndOldFilesback to summary
pack-priv void deleteNewAndOldFiles()

Deletes the leftovers from any previous unfinished operations.

deleteNewScriptFileback to summary
pack-priv void deleteNewScriptFile()
deleteOldFilesback to summary
pack-priv void deleteOldFiles()
deleteOldTempFilesback to summary
pack-priv void deleteOldTempFiles()
deleteTempFileDirectoryback to summary
pack-priv void deleteTempFileDirectory()
forceDefragback to summary
pack-priv boolean forceDefrag()

Returns true if lost space is above the threshold percentage.

getCacheback to summary
pack-priv DataFileCache getCache()

Responsible for creating the data file cache instance.

getLogFileNameback to summary
pack-priv String getLogFileName()
getWriteDelayback to summary
pack-priv int getWriteDelay()

Write delay specifies the frequency of FileDescriptor.sync() calls.

hasCacheback to summary
pack-priv boolean hasCache()
initParamsback to summary
pack-priv void initParams()
isAnyCacheModifiedback to summary
pack-priv boolean isAnyCacheModified()

Checks all the caches and returns true if the modified flag is set for any

openback to summary
pack-priv void open()

When opening a database, the hsqldb.compatible_version property is used to determine if this version of the engine is equal to or greater than the earliest version of the engine capable of opening that database.

openLogback to summary
pack-priv void openLog()

Wrappers for opening-starting / stopping-closing the log file and writer.

processLogback to summary
private void processLog()

Performs all the commands in the .log file.

processScriptback to summary
private void processScript()

Performs all the commands in the .script file.

renameNewDataFileback to summary
pack-priv boolean renameNewDataFile()
renameNewFileback to summary
pack-priv boolean renameNewFile(FileAccess fileAccess, String baseFileName)
renameNewScriptFileback to summary
pack-priv boolean renameNewScriptFile()
setDataChangeLogback to summary
pack-priv void setDataChangeLog()
setLogSizeback to summary
pack-priv void setLogSize(int megas)
setModifiedback to summary
private void setModified()
setWriteDelayback to summary
pack-priv void setWriteDelay(int delay)
synchLogback to summary
pack-priv void synchLog()
writeCommitStatementback to summary
pack-priv void writeCommitStatement(Session session)
writeDeleteStatementback to summary
pack-priv void writeDeleteStatement(Session session, Table t, Object[] row)
writeInsertStatementback to summary
pack-priv void writeInsertStatement(Session session, Row row, Table t)
writeOtherStatementback to summary
pack-priv void writeOtherStatement(Session session, String s)

Various writeXXX() methods are used for logging statements. INSERT, DELETE and SEQUENCE statements do not check log size

writeScriptback to summary
pack-priv void writeScript(boolean full)

Write the .script file as .script.new.

writeSequenceStatementback to summary
pack-priv void writeSequenceStatement(Session session, NumberSequence s)