Class SqlJetMemJournal
java.lang.Object
org.tmatesoft.sqljet.core.internal.fs.SqlJetMemJournal
- All Implemented Interfaces:
ISqlJetFile
This subclass is a subclass of sqlite3_file. Each open memory-journal is an
instance of this class.
- Author:
- TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
-
Field Summary
Fields inherited from interface org.tmatesoft.sqljet.core.internal.ISqlJetFile
PENDING_BYTE, RESERVED_BYTE, SHARED_FIRST, SHARED_SIZE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
This routine checks if there is a RESERVED lock held on the specified file by this or any other process.void
close()
Close a file.Return the device characteristics for the file.long
fileSize()
Determine the current size of a file in bytesReturns file type.Returns lock type of file.Returns assiciated permissions.boolean
Return true if the file-handle passed as an argument is an in-memory journalboolean
lock
(SqlJetLockType lockType) Lock the file with the lock specified by parameter locktype - one of the following: (1) SHARED (2) RESERVED (3) PENDING (4) EXCLUSIVE Sometimes when requesting one lock state, additional lock states are inserted in between.int
read
(ISqlJetMemoryPointer buffer, int amount, long offset) Read data from a file into a buffer.int
Return the sector size in bytes of the underlying block device for the specified file.void
sync
(Set<SqlJetSyncFlags> syncFlags) Make sure all writes to a particular file are committed to disk.void
truncate
(long size) Truncate an open file to a specified sizeboolean
unlock
(SqlJetLockType lockType) Lower the locking level on file descriptor pFile to locktype.void
write
(ISqlJetMemoryPointer buffer, int amount, long offset) Write data from a buffer into a file.
-
Constructor Details
-
SqlJetMemJournal
public SqlJetMemJournal()
-
-
Method Details
-
isMemJournal
public boolean isMemJournal()Description copied from interface:ISqlJetFile
Return true if the file-handle passed as an argument is an in-memory journal- Specified by:
isMemJournal
in interfaceISqlJetFile
-
read
Description copied from interface:ISqlJetFile
Read data from a file into a buffer.- Specified by:
read
in interfaceISqlJetFile
- Returns:
-
write
Description copied from interface:ISqlJetFile
Write data from a buffer into a file.- Specified by:
write
in interfaceISqlJetFile
-
truncate
public void truncate(long size) Description copied from interface:ISqlJetFile
Truncate an open file to a specified size- Specified by:
truncate
in interfaceISqlJetFile
-
close
public void close()Description copied from interface:ISqlJetFile
Close a file.- Specified by:
close
in interfaceISqlJetFile
-
sync
Description copied from interface:ISqlJetFile
Make sure all writes to a particular file are committed to disk. If dataOnly==false then both the file itself and its metadata (file size, access time, etc) are synced. If dataOnly==true then only the file data is synced. Also make sure that the directory entry for the file has been created by fsync-ing the directory that contains the file. If we do not do this and we encounter a power failure, the directory entry for the journal might not exist after we reboot. The next SqlJet to access the file will not know that the journal exists (because the directory entry for the journal was never created) and the transaction will not roll back - possibly leading to database corruption.- Specified by:
sync
in interfaceISqlJetFile
-
fileSize
public long fileSize()Description copied from interface:ISqlJetFile
Determine the current size of a file in bytes- Specified by:
fileSize
in interfaceISqlJetFile
- Returns:
-
checkReservedLock
public boolean checkReservedLock()Description copied from interface:ISqlJetFile
This routine checks if there is a RESERVED lock held on the specified file by this or any other process. The return value is set unless an I/O error occurs during lock checking.- Specified by:
checkReservedLock
in interfaceISqlJetFile
- Returns:
-
deviceCharacteristics
Description copied from interface:ISqlJetFile
Return the device characteristics for the file.- Specified by:
deviceCharacteristics
in interfaceISqlJetFile
- Returns:
-
getFileType
Description copied from interface:ISqlJetFile
Returns file type.- Specified by:
getFileType
in interfaceISqlJetFile
- Returns:
SqlJetFileType
-
getLockType
Description copied from interface:ISqlJetFile
Returns lock type of file.- Specified by:
getLockType
in interfaceISqlJetFile
- Returns:
-
getPermissions
Description copied from interface:ISqlJetFile
Returns assiciated permissions.- Specified by:
getPermissions
in interfaceISqlJetFile
- Returns:
SqlJetFileOpenPermission
-
lock
Description copied from interface:ISqlJetFile
Lock the file with the lock specified by parameter locktype - one of the following: (1) SHARED (2) RESERVED (3) PENDING (4) EXCLUSIVE Sometimes when requesting one lock state, additional lock states are inserted in between. The locking might fail on one of the later transitions leaving the lock state different from what it started but still short of its goal. The following chart shows the allowed transitions and the inserted intermediate states: UNLOCKED -> SHARED SHARED -> RESERVED SHARED -> (PENDING) -> EXCLUSIVE RESERVED -> (PENDING) -> EXCLUSIVE PENDING -> EXCLUSIVE This routine will only increase a lock.- Specified by:
lock
in interfaceISqlJetFile
- Returns:
-
sectorSize
public int sectorSize()Description copied from interface:ISqlJetFile
Return the sector size in bytes of the underlying block device for the specified file. This is almost always 512 bytes, but may be larger for some devices. SqlJet code assumes this function cannot fail. It also assumes that if two files are created in the same file-system directory (i.e. a database and its journal file) that the sector size will be the same for both.- Specified by:
sectorSize
in interfaceISqlJetFile
- Returns:
-
unlock
Description copied from interface:ISqlJetFile
Lower the locking level on file descriptor pFile to locktype. locktype must be either NONE or SHARED. If the locking level of the file descriptor is already at or below the requested locking level, this routine is a no-op.- Specified by:
unlock
in interfaceISqlJetFile
- Returns:
-