Package org.h2.mvstore.db
Class LobStorageMap
- java.lang.Object
-
- org.h2.mvstore.db.LobStorageMap
-
- All Implemented Interfaces:
LobStorageInterface
public final class LobStorageMap extends java.lang.Object implements LobStorageInterface
This class stores LOB objects in the database, in maps. This is the back-end i.e. the server side of the LOB storage.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LobStorageMap.BlobMeta
static class
LobStorageMap.BlobReference
private class
LobStorageMap.LobInputStream
-
Field Summary
Fields Modifier and Type Field Description private Database
database
private MVMap<java.lang.Long,LobStorageMap.BlobMeta>
lobMap
The lob metadata map.(package private) MVStore
mvStore
private java.util.concurrent.atomic.AtomicLong
nextLobId
private MVMap<LobStorageMap.BlobReference,Value>
refMap
The reference map.private StreamStore
streamStore
private MVMap<java.lang.Long,byte[]>
tempLobMap
The lob metadata map for temporary lobs.private static boolean
TRACE
-
Constructor Summary
Constructors Constructor Description LobStorageMap(Database database)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ValueLob
copyLob(ValueLob old, int tableId)
Copy a lob.private ValueBlob
createBlob(java.io.InputStream in)
ValueBlob
createBlob(java.io.InputStream in, long maxLength)
Create a BLOB object.ValueClob
createClob(java.io.Reader reader, long maxLength)
Create a CLOB object.private long
generateLobId()
java.io.InputStream
getInputStream(long lobId, int tableId, long byteCount)
Get the input stream for the given lobjava.io.InputStream
getInputStream(long lobId, long byteCount)
Get the input stream for the given lob, only called on server side of a TCP connection.boolean
isReadOnly()
Whether the storage is read-onlyprivate static boolean
isTemporaryLob(int tableId)
static MVMap<java.lang.Long,byte[]>
openLobDataMap(TransactionStore txStore)
Open map used to store LOB datastatic MVMap<java.lang.Long,LobStorageMap.BlobMeta>
openLobMap(TransactionStore txStore)
Open map used to store LOB metadatavoid
removeAllForTable(int tableId)
Remove all LOBs for this table.private void
removeLob(int tableId, long lobId)
void
removeLob(ValueLob lob)
Delete a LOB (from the database, if it is stored there).private static void
trace(java.lang.String op)
-
-
-
Field Detail
-
TRACE
private static final boolean TRACE
- See Also:
- Constant Field Values
-
database
private final Database database
-
mvStore
final MVStore mvStore
-
nextLobId
private final java.util.concurrent.atomic.AtomicLong nextLobId
-
lobMap
private final MVMap<java.lang.Long,LobStorageMap.BlobMeta> lobMap
The lob metadata map. It contains the mapping from the lob id (which is a long) to the blob metadata, including stream store id (which is a byte array).
-
tempLobMap
private final MVMap<java.lang.Long,byte[]> tempLobMap
The lob metadata map for temporary lobs. It contains the mapping from the lob id (which is a long) to the stream store id (which is a byte array). Key: lobId (long) Value: streamStoreId (byte[])
-
refMap
private final MVMap<LobStorageMap.BlobReference,Value> refMap
The reference map. It is used to remove data from the stream store: if no more entries for the given streamStoreId exist, the data is removed from the stream store.
-
streamStore
private final StreamStore streamStore
-
-
Constructor Detail
-
LobStorageMap
public LobStorageMap(Database database)
-
-
Method Detail
-
openLobMap
public static MVMap<java.lang.Long,LobStorageMap.BlobMeta> openLobMap(TransactionStore txStore)
Open map used to store LOB metadata- Parameters:
txStore
- containing map- Returns:
- MVMap instance
-
openLobDataMap
public static MVMap<java.lang.Long,byte[]> openLobDataMap(TransactionStore txStore)
Open map used to store LOB data- Parameters:
txStore
- containing map- Returns:
- MVMap instance
-
createBlob
public ValueBlob createBlob(java.io.InputStream in, long maxLength)
Description copied from interface:LobStorageInterface
Create a BLOB object.- Specified by:
createBlob
in interfaceLobStorageInterface
- Parameters:
in
- the input streammaxLength
- the maximum length (-1 if not known)- Returns:
- the LOB
-
createClob
public ValueClob createClob(java.io.Reader reader, long maxLength)
Description copied from interface:LobStorageInterface
Create a CLOB object.- Specified by:
createClob
in interfaceLobStorageInterface
- Parameters:
reader
- the readermaxLength
- the maximum length (-1 if not known)- Returns:
- the LOB
-
createBlob
private ValueBlob createBlob(java.io.InputStream in) throws java.io.IOException
- Throws:
java.io.IOException
-
generateLobId
private long generateLobId()
-
isReadOnly
public boolean isReadOnly()
Description copied from interface:LobStorageInterface
Whether the storage is read-only- Specified by:
isReadOnly
in interfaceLobStorageInterface
- Returns:
- true if yes
-
copyLob
public ValueLob copyLob(ValueLob old, int tableId)
Description copied from interface:LobStorageInterface
Copy a lob.- Specified by:
copyLob
in interfaceLobStorageInterface
- Parameters:
old
- the old lobtableId
- the new table id- Returns:
- the new lob
-
getInputStream
public java.io.InputStream getInputStream(long lobId, long byteCount) throws java.io.IOException
Description copied from interface:LobStorageInterface
Get the input stream for the given lob, only called on server side of a TCP connection.- Specified by:
getInputStream
in interfaceLobStorageInterface
- Parameters:
lobId
- the lob idbyteCount
- the number of bytes to read, or -1 if not known- Returns:
- the stream
- Throws:
java.io.IOException
- on failure
-
getInputStream
public java.io.InputStream getInputStream(long lobId, int tableId, long byteCount) throws java.io.IOException
Description copied from interface:LobStorageInterface
Get the input stream for the given lob- Specified by:
getInputStream
in interfaceLobStorageInterface
- Parameters:
lobId
- the lob idtableId
- the able idbyteCount
- the number of bytes to read, or -1 if not known- Returns:
- the stream
- Throws:
java.io.IOException
- on failure
-
removeAllForTable
public void removeAllForTable(int tableId)
Description copied from interface:LobStorageInterface
Remove all LOBs for this table.- Specified by:
removeAllForTable
in interfaceLobStorageInterface
- Parameters:
tableId
- the table id
-
removeLob
public void removeLob(ValueLob lob)
Description copied from interface:LobStorageInterface
Delete a LOB (from the database, if it is stored there).- Specified by:
removeLob
in interfaceLobStorageInterface
- Parameters:
lob
- the lob
-
removeLob
private void removeLob(int tableId, long lobId)
-
isTemporaryLob
private static boolean isTemporaryLob(int tableId)
-
trace
private static void trace(java.lang.String op)
-
-