ValueLob

Implementation of the BLOB and CLOB data types. Small objects are kept in memory and stored in the record. Large objects are stored in their own files. When large objects are set in a prepared statement, they are first stored as 'temporary' files. Later, when they are used in a record, and when the record is stored, the lob files are linked: the file is renamed using the file format (tableId).(objectId). There is one exception: large variables are stored in the file (-1).(objectId). When lobs are deleted, they are first renamed to a temp file, and if the delete operation is committed the file is deleted. Data compression is supported.

Methods
static ValueLob openLinked(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression)
Create a LOB value with the given parameters.
static ValueLob openLinked(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression)
Create a LOB value with the given parameters.
Parameters:
type - the data type
handler - the file handler
tableId - the table object id
objectId - the object id
precision - the precision (length in elements)
compression - if compression is used
Returns:
the value object
static ValueLob openUnlinked(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression, String fileName)
Create a LOB value with the given parameters.
static ValueLob openUnlinked(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression, String fileName)
Create a LOB value with the given parameters.
Parameters:
type - the data type
handler - the file handler
tableId - the table object id
objectId - the object id
precision - the precision (length in elements)
compression - if compression is used
fileName - the file name
Returns:
the value object
static InputStream rangeInputStream(InputStream inputStream, long oneBasedOffset, long length, long dataSize)
Create an input stream that is s subset of the given stream.
static InputStream rangeInputStream(InputStream inputStream, long oneBasedOffset, long length, long dataSize)
Create an input stream that is s subset of the given stream.
Parameters:
inputStream - the source input stream
oneBasedOffset - the offset (1 means no offset)
length - the length of the result, in bytes
dataSize - the length of the input, in bytes
Returns:
the smaller input stream
static Reader rangeReader(Reader reader, long oneBasedOffset, long length, long dataSize)
Create a reader that is s subset of the given reader.
static Reader rangeReader(Reader reader, long oneBasedOffset, long length, long dataSize)
Create a reader that is s subset of the given reader.
Parameters:
reader - the input reader
oneBasedOffset - the offset (1 means no offset)
length - the length of the result, in bytes
dataSize - the length of the input, in bytes
Returns:
the smaller input stream
int compareSecure(Value v, CompareMode mode)
int compareSecure(Value v, CompareMode mode)
Value convertPrecision(long precision, boolean force)
Value convertPrecision(long precision, boolean force)
Value convertTo(int t, int precision, Mode mode, Object column, String[] enumerators)
Convert a lob to another data type.
Value convertTo(int t, int precision, Mode mode, Object column, String[] enumerators)
Convert a lob to another data type. The data is fully read in memory except when converting to BLOB or CLOB.
Parameters:
t - the new type
precision - the precision of the column to convert this value to. The special constant -1 is used to indicate that the precision plays no role when converting the value
mode - the database mode
column - the column (if any), used for to improve the error message if conversion fails
enumerators - the ENUM datatype enumerators (if any), for dealing with ENUM conversions
Returns:
the converted value
void convertToFileIfRequired(DataHandler h)
Store the lob data to a file if the size of the buffer is larger than the maximum size for an in-place lob.
void convertToFileIfRequired(DataHandler h)
Store the lob data to a file if the size of the buffer is larger than the maximum size for an in-place lob.
Parameters:
h - the data handler
Value copy(DataHandler h, int tabId)
Value copy(DataHandler h, int tabId)
ValueLob copyToTemp()
Create an independent copy of this temporary value.
ValueLob copyToTemp()
Create an independent copy of this temporary value. The file will not be deleted automatically.
Returns:
the value
boolean equals(Object other)
boolean equals(Object other)
byte[] getBytes()
byte[] getBytes()
byte[] getBytesNoCopy()
byte[] getBytesNoCopy()
int getDisplaySize()
int getDisplaySize()
String getFileName()
Get the current file name where the lob is saved.
String getFileName()
Get the current file name where the lob is saved.
Returns:
the file name or null
InputStream getInputStream()
InputStream getInputStream()
InputStream getInputStream(long oneBasedOffset, long length)
InputStream getInputStream(long oneBasedOffset, long length)
int getMemory()
int getMemory()
Object getObject()
Object getObject()
int getObjectId()
Get the current object id of this lob.
int getObjectId()
Get the current object id of this lob.
Returns:
the object id
long getPrecision()
long getPrecision()
Reader getReader()
Reader getReader()
Reader getReader(long oneBasedOffset, long length)
Reader getReader(long oneBasedOffset, long length)
String getSQL()
String getSQL()
byte[] getSmall()
Get the data if this a small lob value.
byte[] getSmall()
Get the data if this a small lob value.
Returns:
the data
String getString()
String getString()
int getTableId()
Get the current table id of this lob.
int getTableId()
Get the current table id of this lob.
Returns:
the table id
String getTraceSQL()
String getTraceSQL()
int getType()
int getType()
int hashCode()
int hashCode()
boolean isCompressed()
Check if this lob value is compressed.
boolean isCompressed()
Check if this lob value is compressed.
Returns:
true if it is
boolean isLinkedToTable()
boolean isLinkedToTable()
void remove()
void remove()
void set(PreparedStatement prep, int parameterIndex)
void set(PreparedStatement prep, int parameterIndex) throws SQLException