Interface BlobStore

All Superinterfaces:
AutoCloseable
All Known Subinterfaces:
BlobStoreWrapper, GarbageCollectableBlobStore, SplitBlobStore
All Known Implementing Classes:
AbstractBlobStore, CachingBlobStore, DataStoreBlobStore, DefaultSplitBlobStore, FileBlobStore, MemoryBlobStore, WrappingSplitBlobStore

public interface BlobStore extends AutoCloseable
An interface to store and read large binary objects.
  • Method Details

    • writeBlob

      String writeBlob(InputStream in) throws IOException
      Write a blob from an input stream. This method closes the input stream.
      Parameters:
      in - the input stream
      Returns:
      the blob id
      Throws:
      IOException
    • writeBlob

      String writeBlob(InputStream in, BlobOptions options) throws IOException
      Write a blob from an input stream with specified options. This method closes the input stream.
      Parameters:
      in - the input stream to write
      options - the options to use
      Returns:
      Throws:
      IOException
    • readBlob

      int readBlob(String blobId, long pos, byte[] buff, int off, int length) throws IOException
      Read a number of bytes from a blob.
      Parameters:
      blobId - the blob id
      pos - the position within the blob
      buff - the target byte array
      off - the offset within the target array
      length - the number of bytes to read
      Returns:
      the number of bytes read
      Throws:
      IOException
    • getBlobLength

      long getBlobLength(String blobId) throws IOException
      Get the length of the blob.
      Parameters:
      blobId - the blob id
      Returns:
      the length
      Throws:
      IOException
    • getInputStream

      InputStream getInputStream(String blobId) throws IOException
      Returns a new stream for given blobId. The streams returned from multiple calls to this method are byte wise equals. That is, subsequent calls to read return the same sequence of bytes as long as neither call throws an exception.
      Parameters:
      blobId - the blob id
      Returns:
      a new stream for given blobId
      Throws:
      IOException
    • getBlobId

      @Nullable @Nullable String getBlobId(@NotNull @NotNull String reference)
      Returns the blobId that referred by the given binary reference. Returns null if the reference is invalid, for example if it points to a blob that does not exist.
      Parameters:
      reference - binary reference
      Returns:
      matching blobId, or null
    • getReference

      @Nullable @Nullable String getReference(@NotNull @NotNull String blobId)
      Returns a secure reference to blob referred by blobid, or null if no such reference is available.
      Parameters:
      blobId - blobId referring the blob for which reference is required
      Returns:
      binary reference, or null