|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.h2.value.Value
org.h2.value.ValueLob
public class ValueLob
Implementation of the BLOB and CLOB data types. Small objects are kept in memory and stored in the data page of 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.
Field Summary | |
---|---|
static int |
TABLE_ID_SESSION_VARIABLE
The 'table id' to use for session variables. |
Fields inherited from class org.h2.value.Value |
---|
ARRAY, BLOB, BOOLEAN, BYTE, BYTES, CLOB, DATE, DECIMAL, DOUBLE, FLOAT, INT, JAVA_OBJECT, LONG, NULL, RESULT_SET, SHORT, STRING, STRING_FIXED, STRING_IGNORECASE, TIME, TIMESTAMP, TYPE_COUNT, UNKNOWN, UUID |
Method Summary | |
---|---|
void |
close()
Close the underlying resource, if any. |
protected int |
compareSecure(Value v,
CompareMode mode)
Compare the value with another value of the same type. |
Value |
convertTo(int t)
Convert a lob to another data type. |
void |
convertToFileIfRequired(DataHandler handler)
Store the lob data to a file if the size of the buffer it larger than the maximum size for an in-place lob. |
ValueLob |
copyToTemp()
Create an independent copy of this temporary value. |
static ValueLob |
createBlob(java.io.InputStream in,
long length,
DataHandler handler)
Create a BLOB value from a stream. |
static ValueLob |
createClob(java.io.Reader in,
long length,
DataHandler handler)
Create a CLOB value from a stream. |
static ValueLob |
createSmallLob(int type,
byte[] small)
Create a small lob using the given byte array. |
boolean |
equals(java.lang.Object other)
Check if the two values are equal. |
static boolean |
existsLobFile(java.lang.String prefix)
Check if a lob file exists for this database. |
byte[] |
getBytes()
|
byte[] |
getBytesNoCopy()
|
int |
getDisplaySize()
Get the display size in characters. |
java.lang.String |
getFileName()
Get the current file name where the lob is saved. |
java.io.InputStream |
getInputStream()
|
int |
getMemory()
Get the memory used by this object. |
java.lang.Object |
getObject()
Get the value as an object. |
int |
getObjectId()
Get the current object id of this lob. |
long |
getPrecision()
Get the precision. |
java.io.Reader |
getReader()
|
byte[] |
getSmall()
Get the data if this a small lob value. |
java.lang.String |
getSQL()
Get the SQL expression for this value. |
java.lang.String |
getString()
Get the value as a string. |
int |
getTableId()
Get the current table id of this lob. |
java.lang.String |
getTraceSQL()
Get a medium size SQL expression for debugging or tracing. |
int |
getType()
Get the value type. |
int |
hashCode()
|
boolean |
isFileBased()
Check if this value is stored in it's own file. |
boolean |
isLinked()
Check if this value is linked to a specific table. |
Value |
link(DataHandler handler,
int tabId)
Link a large value to a given table. |
static ValueLob |
open(int type,
DataHandler handler,
int tableId,
int objectId,
long precision,
boolean compression)
Create a LOB value with the given parameters. |
static void |
removeAllForTable(DataHandler handler,
int tableId)
Remove all lobs for a given table id. |
void |
set(java.sql.PreparedStatement prep,
int parameterIndex)
Set the value as a parameter in a prepared statement. |
void |
setFileName(java.lang.String fileName,
boolean linked)
Set the file name of this lob value. |
void |
unlink()
Mark any underlying resource as 'not linked to any table'. |
boolean |
useCompression()
Check if this lob value is compressed. |
Methods inherited from class org.h2.value.Value |
---|
add, checkPrecision, compareEqual, compareTo, compareTypeSave, convertPrecision, convertScale, divide, getBigDecimal, getBoolean, getByte, getDate, getDateNoCopy, getDouble, getFloat, getHigherOrder, getInt, getLong, getScale, getShort, getSignum, getTime, getTimeNoCopy, getTimestamp, getTimestampNoCopy, multiply, negate, subtract, throwUnsupportedExceptionForType, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TABLE_ID_SESSION_VARIABLE
Method Detail |
---|
public static ValueLob createSmallLob(int type, byte[] small)
type
- the type (Value.BLOB or CLOB)small
- the byte array
public static ValueLob open(int type, DataHandler handler, int tableId, int objectId, long precision, boolean compression)
type
- the data typehandler
- the file handlertableId
- the table object idobjectId
- the object idprecision
- the precision (length in elements)compression
- if compression is used
public static ValueLob createClob(java.io.Reader in, long length, DataHandler handler) throws java.sql.SQLException
in
- the readerlength
- the number of characters to read, or -1 for no limithandler
- the data handler
java.sql.SQLException
public static ValueLob createBlob(java.io.InputStream in, long length, DataHandler handler) throws java.sql.SQLException
in
- the input streamlength
- the number of characters to read, or -1 for no limithandler
- the data handler
java.sql.SQLException
public Value convertTo(int t) throws java.sql.SQLException
convertTo
in class Value
t
- the new type
java.sql.SQLException
public boolean isLinked()
Value
isLinked
in class Value
public java.lang.String getFileName()
public void close() throws java.sql.SQLException
Value
close
in class Value
java.sql.SQLException
public void unlink() throws java.sql.SQLException
Value
unlink
in class Value
java.sql.SQLException
public Value link(DataHandler handler, int tabId) throws java.sql.SQLException
Value
link
in class Value
handler
- the data handlertabId
- the table to link to
java.sql.SQLException
public int getTableId()
public int getObjectId()
public int getType()
Value
getType
in class Value
public long getPrecision()
Value
getPrecision
in class Value
public java.lang.String getString()
Value
getString
in class Value
public byte[] getBytes() throws java.sql.SQLException
getBytes
in class Value
java.sql.SQLException
public byte[] getBytesNoCopy() throws java.sql.SQLException
getBytesNoCopy
in class Value
java.sql.SQLException
public int hashCode()
hashCode
in class Value
protected int compareSecure(Value v, CompareMode mode) throws java.sql.SQLException
Value
compareSecure
in class Value
v
- the other valuemode
- the compare mode
java.sql.SQLException
public java.lang.Object getObject()
Value
getObject
in class Value
public java.io.Reader getReader()
getReader
in class Value
public java.io.InputStream getInputStream() throws java.sql.SQLException
getInputStream
in class Value
java.sql.SQLException
public void set(java.sql.PreparedStatement prep, int parameterIndex) throws java.sql.SQLException
Value
set
in class Value
prep
- the prepared statementparameterIndex
- the parameter index
java.sql.SQLException
public java.lang.String getSQL()
Value
getSQL
in class Value
public java.lang.String getTraceSQL()
Value
getTraceSQL
in class Value
public byte[] getSmall()
public int getDisplaySize()
Value
getDisplaySize
in class Value
public boolean equals(java.lang.Object other)
Value
equals
in class Value
other
- the other value
public void convertToFileIfRequired(DataHandler handler) throws java.sql.SQLException
handler
- the data handler
java.sql.SQLException
public static void removeAllForTable(DataHandler handler, int tableId) throws java.sql.SQLException
handler
- the data handlertableId
- the table id
java.sql.SQLException
public static boolean existsLobFile(java.lang.String prefix) throws java.sql.SQLException
prefix
- the file name prefix
java.sql.SQLException
public boolean useCompression()
public boolean isFileBased()
Value
isFileBased
in class Value
public void setFileName(java.lang.String fileName, boolean linked)
fileName
- the file namelinked
- if the lob is linkedpublic int getMemory()
Value
getMemory
in class Value
public ValueLob copyToTemp() throws java.sql.SQLException
java.sql.SQLException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |