public abstract class AbstractBlobStore extends Object implements BlobStore, Cache.Backend<AbstractBlobStore.BlockId,AbstractBlobStore.Data>
Each data store id is a list of zero or more entries. Each entry is either
The the format of a 'data' entry is: type (one byte; 0 for data), length (variable size int), data (bytes).
The format of a 'hash of content' entry is: type (one byte; 1 for hash), level (variable size int, 0 meaning not nested), size (variable size long), hash code length (variable size int), hash code.
The format of a 'hash of data store id' entry is: type (one byte; 1 for hash), level (variable size int, nesting level), total size (variable size long), size of data store id (variable size long), hash code length (variable size int), hash code.
| Modifier and Type | Class and Description |
|---|---|
static class |
AbstractBlobStore.BlockId
A block id.
|
static class |
AbstractBlobStore.Data
The data for a block.
|
| Modifier and Type | Field and Description |
|---|---|
protected static int |
BLOCK_SIZE_LIMIT |
protected static String |
HASH_ALGORITHM |
protected Map<String,WeakReference<String>> |
inUse |
protected static int |
TYPE_DATA |
protected static int |
TYPE_HASH |
protected static int |
TYPE_HASH_COMPRESSED |
| Constructor and Description |
|---|
AbstractBlobStore() |
| Modifier and Type | Method and Description |
|---|---|
void |
clearCache() |
void |
clearInUse() |
long |
getBlobLength(String blobId)
Get the length of the blob.
|
int |
getBlockSize() |
long |
getBlockSizeMin() |
protected abstract boolean |
isMarkEnabled() |
AbstractBlobStore.Data |
load(AbstractBlobStore.BlockId id)
Load the object.
|
protected abstract void |
mark(AbstractBlobStore.BlockId id) |
protected void |
mark(String blobId) |
protected void |
markInUse() |
int |
readBlob(String blobId,
long pos,
byte[] buff,
int off,
int length)
Read a number of bytes from a blob.
|
protected abstract byte[] |
readBlockFromBackend(AbstractBlobStore.BlockId id)
Load the block from the storage backend.
|
void |
setBlockSize(int x) |
void |
setBlockSizeMin(int x) |
abstract void |
startMark() |
protected abstract void |
storeBlock(byte[] digest,
int level,
byte[] data)
Store a block of data.
|
abstract int |
sweep() |
protected void |
usesBlobId(String blobId) |
String |
writeBlob(InputStream in)
Write a blob from an input stream.
|
String |
writeBlob(String tempFilePath)
Write a blob from a temporary file.
|
protected static final String HASH_ALGORITHM
protected static final int TYPE_DATA
protected static final int TYPE_HASH
protected static final int TYPE_HASH_COMPRESSED
protected static final int BLOCK_SIZE_LIMIT
protected Map<String,WeakReference<String>> inUse
public void setBlockSizeMin(int x)
public long getBlockSizeMin()
public void setBlockSize(int x)
public int getBlockSize()
public String writeBlob(String tempFilePath) throws Exception
tempFilePath - the temporary fileExceptionpublic String writeBlob(InputStream in) throws Exception
BlobStoreprotected void usesBlobId(String blobId)
public void clearInUse()
public void clearCache()
protected abstract void storeBlock(byte[] digest,
int level,
byte[] data)
throws Exception
digest - the content hashlevel - the indirection level (0 is for user data, 1 is a list of
digests that point to user data, 2 is a list of digests that
point to digests, and so on). This parameter is for
informational use only, and it is not required to store it
unless that's easy to achievedata - the data to be storedExceptionprotected abstract boolean isMarkEnabled()
protected abstract void mark(AbstractBlobStore.BlockId id) throws Exception
Exceptionpublic int readBlob(String blobId, long pos, byte[] buff, int off, int length) throws Exception
BlobStorepublic AbstractBlobStore.Data load(AbstractBlobStore.BlockId id)
Cache.Backendload in interface Cache.Backend<AbstractBlobStore.BlockId,AbstractBlobStore.Data>id - the keyprotected abstract byte[] readBlockFromBackend(AbstractBlobStore.BlockId id) throws Exception
id - the block idExceptionpublic long getBlobLength(String blobId) throws IOException
BlobStoregetBlobLength in interface BlobStoreblobId - the blob idIOExceptionprotected void mark(String blobId) throws IOException
IOExceptionCopyright © 2012-2013 The Apache Software Foundation. All Rights Reserved.