public abstract class BlobVault extends java.lang.Object implements BlobHandleGenerator, Backupable
BlobVault is base class describing interface to
binary large objects (BLOBs) used internally by implementation of PersistentEntityStore.
Blob values are identified by blob handles generated by BlobHandleGenerator.
PersistentEntityStore encapsulates mapping of Entity blob values to blob handles, whereas
BlobVault allows to read/write blob values identified by blob handles. Blob values are immutable, i.e.
blob value by a blob handle cannot be changed, only deleted.
BlobVault allows to get string content of blob for method Entity.getBlobString(String).
In order to reduce CPU consumption on transformation of binary content to UTF-8 strings, BlobVault
encapsulates a cache of blob strings.
PersistentEntityStore,
BlobHandleGenerator| Modifier and Type | Field and Description |
|---|---|
protected static org.slf4j.Logger |
logger |
IMMUTABLE| Modifier | Constructor and Description |
|---|---|
protected |
BlobVault(@NotNull BlobVault source) |
protected |
BlobVault(@NotNull PersistentEntityStoreConfig config) |
| Modifier and Type | Method and Description |
|---|---|
abstract void |
clear()
Is called on PersistentEntityStore.clear().
|
jetbrains.exodus.util.ByteArraySizedInputStream |
cloneFile(@NotNull java.io.File file) |
jetbrains.exodus.util.ByteArraySizedInputStream |
cloneStream(@NotNull java.io.InputStream source,
boolean closeSource) |
abstract void |
close()
Is called on EntityStore.close().
|
java.io.ByteArrayOutputStream |
copyStream(@NotNull java.io.InputStream source,
boolean closeSource) |
abstract boolean |
delete(long blobHandle) |
abstract void |
flushBlobs(@Nullable jetbrains.exodus.core.dataStructures.hash.LongHashMap<java.io.InputStream> blobStreams,
@Nullable jetbrains.exodus.core.dataStructures.hash.LongHashMap<java.io.File> blobFiles,
@Nullable jetbrains.exodus.core.dataStructures.hash.LongSet deferredBlobsToDelete,
@NotNull Transaction txn)
Method called by PersistentEntityStore to flush blobs identified by blobs.
|
abstract @NotNull BlobVaultItem |
getBlob(long blobHandle) |
java.lang.String |
getBlobKey(long blobHandle) |
@NotNull java.io.File |
getBlobLocation(long blobHandle) |
abstract @Nullable java.io.InputStream |
getContent(long blobHandle,
@NotNull Transaction txn)
Returns binary content of blob identified by specified blob handle as InputStream.
|
int |
getIdentity() |
abstract long |
getSize(long blobHandle,
@NotNull Transaction txn)
Returns size of blob identified by specified blob handle in bytes.
|
BlobVault |
getSourceVault() |
@Nullable java.lang.String |
getStringContent(long blobHandle,
@NotNull Transaction txn)
Returns string content of blob identified by specified blob handle.
|
float |
getStringContentCacheHitRate() |
abstract boolean |
requiresTxn()
Returns
true if BlobVault implementation requires transaction to
flush blobs when StoreTransaction.flush() or StoreTransaction.commit() is called. |
abstract long |
size()
Returns amount of disk space occupied by the
BlobVault. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnextHandlegetBackupStrategyprotected BlobVault(@NotNull
@NotNull BlobVault source)
protected BlobVault(@NotNull
@NotNull PersistentEntityStoreConfig config)
public BlobVault getSourceVault()
public int getIdentity()
@NotNull public @NotNull java.io.File getBlobLocation(long blobHandle)
public java.lang.String getBlobKey(long blobHandle)
@NotNull public abstract @NotNull BlobVaultItem getBlob(long blobHandle)
public abstract boolean delete(long blobHandle)
@Nullable
public abstract @Nullable java.io.InputStream getContent(long blobHandle,
@NotNull
@NotNull Transaction txn)
blobHandle - blob handletxn - Transaction instanceEntity.getBlob(String)public abstract long getSize(long blobHandle,
@NotNull
@NotNull Transaction txn)
blobHandle - blob handletxn - Transaction instanceEntity.getBlobSize(String)public abstract boolean requiresTxn()
true if BlobVault implementation requires transaction to
flush blobs when StoreTransaction.flush() or StoreTransaction.commit() is called.true if BlobVault implementation requires transactionpublic abstract void flushBlobs(@Nullable
@Nullable jetbrains.exodus.core.dataStructures.hash.LongHashMap<java.io.InputStream> blobStreams,
@Nullable
@Nullable jetbrains.exodus.core.dataStructures.hash.LongHashMap<java.io.File> blobFiles,
@Nullable
@Nullable jetbrains.exodus.core.dataStructures.hash.LongSet deferredBlobsToDelete,
@NotNull
@NotNull Transaction txn)
throws java.lang.Exception
java.io.File instances. They naturally follow from
the Entity API, having two methods to set blob: Entity.setBlob(String, InputStream)
and Entity.setBlob(String, File).
The set deferredBlobsToDelete contains blob handles of blobs that should be deleted after the
transaction is finished. In most cases, these blobs cannot be deleted immediately without violating isolation
transaction guarantees.
Although transaction passed to the method is @NotNull it can be already finished (check by
Transaction.isFinished()). E.g., StoreTransaction.commit() at first commits
underlying environment Transaction and then flushes blobs passing instance of committed transaction.
blobStreams - map of blob handles to InputStream instancesblobFiles - map of blob handles to File instancesdeferredBlobsToDelete - set of blob handles of blobs that should be deleted after the transaction is finishedtxn - Transaction instancejava.lang.Exception - something went wrongLongHashMap,
LongSet,
Transactionpublic abstract long size()
BlobVault. This value is rather "rough" since it does not
take into consideration particular file system features of storage device.BlobVaultPersistentEntityStore.getUsableSpace(),
IOUtil.getAdjustedFileLength(File)public abstract void clear()
public abstract void close()
@Nullable
public final @Nullable java.lang.String getStringContent(long blobHandle,
@NotNull
@NotNull Transaction txn)
throws java.io.IOException
blobHandle - blob handletxn - Transaction instancejava.io.IOException - if something went wrongpublic final float getStringContentCacheHitRate()
public final java.io.ByteArrayOutputStream copyStream(@NotNull
@NotNull java.io.InputStream source,
boolean closeSource)
throws java.io.IOException
java.io.IOExceptionpublic final jetbrains.exodus.util.ByteArraySizedInputStream cloneStream(@NotNull
@NotNull java.io.InputStream source,
boolean closeSource)
throws java.io.IOException
java.io.IOExceptionpublic final jetbrains.exodus.util.ByteArraySizedInputStream cloneFile(@NotNull
@NotNull java.io.File file)
throws java.io.IOException
java.io.IOException