|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.h2.store.LobStorageBackend
public class LobStorageBackend
This class stores LOB objects in the database. This is the back-end i.e. the server side of the LOB storage.
Using the system session
Why do we use the system session to store the data? Some LOB operations can take a very long time. If we did them on a normal session, we would be locking the LOB tables for long periods of time, which is extremely detrimental to the rest of the system. Perhaps when we shift to the MVStore engine, we can revisit this design decision.
Locking Discussion
Normally, the locking order in H2 is: first lock the Session object, then lock the Database object. However, in the case of the LOB data, we are using the system session to store the data. If we locked the normal way, we see deadlocks caused by the following pattern:
Thread 1:
locks normal session
locks database
waiting to lock system session
Thread 2:
locks system session
waiting to lock database.
So, in this class alone, we do two things: we have our very own dedicated
session, the LOB session, and we take the locks in this order: first the
Database object, and then the LOB session. Since we own the LOB session,
no-one else can lock on it, and we are safe.
| Nested Class Summary | |
|---|---|
class |
LobStorageBackend.LobInputStream
An input stream that reads from a LOB. |
| Field Summary | |
|---|---|
static java.lang.String |
LOB_DATA_TABLE
The name of the lob data table. |
| Constructor Summary | |
|---|---|
LobStorageBackend(Database database)
|
|
| Method Summary | |
|---|---|
ValueLobDb |
copyLob(int type,
long oldLobId,
int tableId,
long length)
Copy a lob. |
Value |
createBlob(java.io.InputStream in,
long maxLength)
Create a BLOB object. |
Value |
createClob(java.io.Reader reader,
long maxLength)
Create a CLOB object. |
java.io.InputStream |
getInputStream(long lobId,
byte[] hmac,
long byteCount)
Get the input stream for the given lob. |
void |
init()
Initialize the lob storage. |
void |
removeAllForTable(int tableId)
Remove all LOBs for this table. |
void |
removeLob(long lob)
Delete a LOB from the database. |
void |
setTable(long lobId,
int table)
Set the table reference of this lob. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String LOB_DATA_TABLE
| Constructor Detail |
|---|
public LobStorageBackend(Database database)
| Method Detail |
|---|
public void init()
public void removeAllForTable(int tableId)
tableId - the table idpublic void removeLob(long lob)
LobStorageInterface
removeLob in interface LobStorageInterfacelob - the lob id
public java.io.InputStream getInputStream(long lobId,
byte[] hmac,
long byteCount)
throws java.io.IOException
LobStorageInterface
getInputStream in interface LobStorageInterfacelobId - the lob idhmac - the message authentication code (for remote input streams)byteCount - the number of bytes to read, or -1 if not known
java.io.IOException
public ValueLobDb copyLob(int type,
long oldLobId,
int tableId,
long length)
LobStorageInterface
copyLob in interface LobStorageInterfacetype - the typeoldLobId - the old lob idtableId - the new table idlength - the length
public Value createBlob(java.io.InputStream in,
long maxLength)
LobStorageInterface
createBlob in interface LobStorageInterfacein - the input streammaxLength - the maximum length (-1 if not known)
public Value createClob(java.io.Reader reader,
long maxLength)
LobStorageInterface
createClob in interface LobStorageInterfacereader - the readermaxLength - the maximum length (-1 if not known)
public void setTable(long lobId,
int table)
LobStorageInterface
setTable in interface LobStorageInterfacelobId - the lobtable - the table
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||