com.amazon.carbonado.spi
Class LobEngine

java.lang.Object
  extended by com.amazon.carbonado.spi.LobEngine

public class LobEngine
extends Object

Complete Lob support for repositories, although repository is responsible for binding Lob properties to this engine. Lobs are referenced by locators, which are non-zero long integers. A zero locator is equivalent to null.

Author:
Brian S O'Neill
See Also:
getSupportTrigger(Class, int)

Constructor Summary
LobEngine(Repository lobRepo, Repository locatorRepo)
           
LobEngine(Repository lobRepo, SequenceValueProducer locatorSequenceProducer)
           
 
Method Summary
 Blob createNewBlob(int blockSize)
          Returns a new Blob whose length is zero.
 Clob createNewClob(int blockSize)
          Returns a new Clob whose length is zero.
 void deleteLob(Lob lob)
          Deletes Lob data, freeing up all space consumed by it.
 void deleteLob(long locator)
          Deletes Lob data, freeing up all space consumed by it.
 Blob getBlobValue(long locator)
          Loads a Blob value, without checking if it exists or not.
 Clob getClobValue(long locator)
          Loads a Clob value, without checking if it exists or not.
 long getLocator(Lob lob)
          Returns the locator for the given Lob, or zero if null.
<S extends Storable>
Trigger<S>
getSupportTrigger(Class<S> type, int blockSize)
          Returns a Trigger for binding to this LobEngine.
static
<S extends Storable>
boolean
hasLobs(Class<S> type)
           
 void setBlobValue(long locator, Blob data)
          Stores a value into a Blob, replacing anything that was there before.
 void setBlobValue(long locator, InputStream data)
          Stores a value into a Blob, replacing anything that was there before.
 void setClobValue(long locator, Clob data)
          Stores a value into a Clob, replacing anything that was there before.
 void setClobValue(long locator, Reader data)
          Stores a value into a Clob, replacing anything that was there before.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LobEngine

public LobEngine(Repository lobRepo,
                 Repository locatorRepo)
          throws RepositoryException
Parameters:
lobRepo - storage for Lobs - should not be replicated
locatorRepo - storage for producing unique values for Lob locators - should be root repository
Throws:
RepositoryException
Since:
1.2

LobEngine

public LobEngine(Repository lobRepo,
                 SequenceValueProducer locatorSequenceProducer)
          throws RepositoryException
Parameters:
lobRepo - storage for Lobs - should not be replicated
locatorSequenceProducer - source of unique values for Lob locators
Throws:
RepositoryException
Since:
1.2
Method Detail

hasLobs

public static <S extends Storable> boolean hasLobs(Class<S> type)

createNewBlob

public Blob createNewBlob(int blockSize)
                   throws PersistException
Returns a new Blob whose length is zero.

Parameters:
blockSize - block size (in bytes) to use
Returns:
new empty Blob
Throws:
PersistException

createNewClob

public Clob createNewClob(int blockSize)
                   throws PersistException
Returns a new Clob whose length is zero.

Parameters:
blockSize - block size (in bytes) to use
Returns:
new empty Clob
Throws:
PersistException

getLocator

public long getLocator(Lob lob)
Returns the locator for the given Lob, or zero if null.

Throws:
ClassCastException - if Lob is unrecognized

deleteLob

public void deleteLob(long locator)
               throws PersistException
Deletes Lob data, freeing up all space consumed by it.

Throws:
PersistException

deleteLob

public void deleteLob(Lob lob)
               throws PersistException
Deletes Lob data, freeing up all space consumed by it.

Throws:
PersistException

getBlobValue

public Blob getBlobValue(long locator)
Loads a Blob value, without checking if it exists or not.

Parameters:
locator - lob locator as returned by getLocator
Returns:
Blob value or null

getClobValue

public Clob getClobValue(long locator)
Loads a Clob value, without checking if it exists or not.

Parameters:
locator - lob locator as returned by getLocator
Returns:
Clob value or null

setBlobValue

public void setBlobValue(long locator,
                         Blob data)
                  throws PersistException,
                         IOException
Stores a value into a Blob, replacing anything that was there before. Passing null deletes the Blob, which is a convenience for auto-generated code that may call this method.

Parameters:
locator - lob locator as created by createNewBlob
data - source of data for Blob, which may be null to delete
Throws:
IllegalArgumentException - if locator is zero
PersistException
IOException

setBlobValue

public void setBlobValue(long locator,
                         InputStream data)
                  throws PersistException,
                         IOException
Stores a value into a Blob, replacing anything that was there before. Passing null deletes the Blob, which is a convenience for auto-generated code that may call this method.

Parameters:
locator - lob locator as created by createNewBlob
data - source of data for Blob, which may be null to delete
Throws:
IllegalArgumentException - if locator is zero
PersistException
IOException

setClobValue

public void setClobValue(long locator,
                         Clob data)
                  throws PersistException,
                         IOException
Stores a value into a Clob, replacing anything that was there before. Passing null deletes the Clob, which is a convenience for auto-generated code that may call this method.

Parameters:
locator - lob locator as created by createNewClob
data - source of data for Clob, which may be null to delete
Throws:
IllegalArgumentException - if locator is zero
PersistException
IOException

setClobValue

public void setClobValue(long locator,
                         Reader data)
                  throws PersistException,
                         IOException
Stores a value into a Clob, replacing anything that was there before. Passing null deletes the Clob, which is a convenience for auto-generated code that may call this method.

Parameters:
locator - lob locator as created by createNewClob
data - source of data for Clob, which may be null to delete
Throws:
IllegalArgumentException - if locator is zero
PersistException
IOException

getSupportTrigger

public <S extends Storable> Trigger<S> getSupportTrigger(Class<S> type,
                                                         int blockSize)
Returns a Trigger for binding to this LobEngine. Storage implementations which use LobEngine must install this Trigger. Trigger instances are cached, so subsequent calls for the same trigger return the same instance.

Parameters:
type - type of Storable to create trigger for
blockSize - block size to use
Returns:
support trigger or null if storable type has no lob properties


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.