Class AbstractBlobStore

  • All Implemented Interfaces:
    AutoCloseable, Cache.Backend<AbstractBlobStore.BlockId,​AbstractBlobStore.Data>, BlobStore, GarbageCollectableBlobStore
    Direct Known Subclasses:
    CachingBlobStore, FileBlobStore, MemoryBlobStore

    public abstract class AbstractBlobStore
    extends Object
    implements GarbageCollectableBlobStore, Cache.Backend<AbstractBlobStore.BlockId,​AbstractBlobStore.Data>
    An abstract data store that splits the binaries in relatively small blocks, so that each block fits in memory.

    Each data store id is a list of zero or more entries. Each entry is either

    • data (a number of bytes), or
    • the hash code of the content of a number of bytes, or
    • the hash code of the content of a data store id (indirect hash)
    Thanks to the indirection, blocks can be kept relatively small, so that caching is simpler, and so that the storage backend doesn't need to support arbitrary size blobs (some storage backends buffer blobs in memory) and fast seeks (some storage backends re-read the whole blob when seeking).

    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.