org.h2.store
Interface DataHandler

All Known Implementing Classes:
Database, Recover, RunScriptCommand, ScriptBase, ScriptCommand, SessionRemote

public interface DataHandler

A data handler contains a number of callback methods. The most important implementing class is a database.


Method Summary
 int allocateObjectId(boolean needFresh, boolean dataFile)
          Get the next object id.
 void checkPowerOff()
          Check if the simulated power failure occurred.
 void checkWritingAllowed()
          Check if writing is allowed.
 int compareTypeSave(Value a, Value b)
          Compare two values.
 java.lang.String createTempFile()
          Create a temporary file and return the file name.
 void freeUpDiskSpace()
          Free up disk space if possible.
 int getChecksum(byte[] data, int start, int end)
          Calculate the checksum for the byte array.
 java.lang.String getDatabasePath()
          Get the database path.
 java.lang.String getLobCompressionAlgorithm(int type)
          Get the compression algorithm used for large objects.
 SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()
          Get the lob file list cache if it is used.
 boolean getLobFilesInDirectories()
          Checks if the lob files stored in directories.
 java.lang.Object getLobSyncObject()
          Get the synchronization object for lob operations.
 int getMaxLengthInplaceLob()
          Get the maximum length of a in-place large object
 TempFileDeleter getTempFileDeleter()
          Get the temp file deleter mechanism.
 Trace getTrace()
          Get the trace writer.
 void handleInvalidChecksum()
          Called when the checksum was invalid.
 FileStore openFile(java.lang.String name, java.lang.String mode, boolean mustExist)
          Open a file at the given location.
 

Method Detail

getDatabasePath

java.lang.String getDatabasePath()
Get the database path.

Returns:
the database path

openFile

FileStore openFile(java.lang.String name,
                   java.lang.String mode,
                   boolean mustExist)
                   throws java.sql.SQLException
Open a file at the given location.

Parameters:
name - the file name
mode - the mode
mustExist - whether the file must already exist
Returns:
the file
Throws:
java.sql.SQLException

getChecksum

int getChecksum(byte[] data,
                int start,
                int end)
Calculate the checksum for the byte array.

Parameters:
data - the byte array
start - the starting offset
end - the end offset
Returns:
the checksum

checkPowerOff

void checkPowerOff()
                   throws java.sql.SQLException
Check if the simulated power failure occurred. This call will decrement the countdown.

Throws:
java.sql.SQLException - if the simulated power failure occurred

checkWritingAllowed

void checkWritingAllowed()
                         throws java.sql.SQLException
Check if writing is allowed.

Throws:
java.sql.SQLException - if it is not allowed

freeUpDiskSpace

void freeUpDiskSpace()
                     throws java.sql.SQLException
Free up disk space if possible. This method is called if more space is needed.

Throws:
java.sql.SQLException - if no more space could be freed

handleInvalidChecksum

void handleInvalidChecksum()
                           throws java.sql.SQLException
Called when the checksum was invalid.

Throws:
java.sql.SQLException - if this should not be ignored

compareTypeSave

int compareTypeSave(Value a,
                    Value b)
                    throws java.sql.SQLException
Compare two values.

Parameters:
a - the first value
b - the second value
Returns:
0 for equal, 1 if a is larger than b, and -1 otherwise
Throws:
java.sql.SQLException

getMaxLengthInplaceLob

int getMaxLengthInplaceLob()
Get the maximum length of a in-place large object

Returns:
the maximum size

getLobCompressionAlgorithm

java.lang.String getLobCompressionAlgorithm(int type)
Get the compression algorithm used for large objects.

Parameters:
type - the data type (CLOB or BLOB)
Returns:
the compression algorithm, or null

allocateObjectId

int allocateObjectId(boolean needFresh,
                     boolean dataFile)
Get the next object id. This method is not required if LOB_FILES_IN_DIRECTORIES is enabled.

Parameters:
needFresh - if a fresh id is required
dataFile - true if the id is for the data file
Returns:
the new id

createTempFile

java.lang.String createTempFile()
                                throws java.sql.SQLException
Create a temporary file and return the file name.

Returns:
the file name
Throws:
java.sql.SQLException

getTempFileDeleter

TempFileDeleter getTempFileDeleter()
Get the temp file deleter mechanism.

Returns:
the temp file deleter

getLobSyncObject

java.lang.Object getLobSyncObject()
Get the synchronization object for lob operations.

Returns:
the synchronization object

getLobFilesInDirectories

boolean getLobFilesInDirectories()
Checks if the lob files stored in directories.

Returns:
true if lob files are stored in directories.

getLobFileListCache

SmallLRUCache<java.lang.String,java.lang.String[]> getLobFileListCache()
Get the lob file list cache if it is used.

Returns:
the cache or null

getTrace

Trace getTrace()
Get the trace writer.

Returns:
the trace writer