Package org.h2.value
Class ValueLob
- java.lang.Object
-
- org.h2.value.VersionedValue<Value>
-
- org.h2.value.Value
-
- org.h2.value.ValueLob
-
public abstract class ValueLob extends Value
A implementation of the BINARY LARGE OBJECT and CHARACTER LARGE OBJECT data types. Small objects are kept in memory and stored in the record. Large objects are either stored in the database, or in temporary files.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
BLOCK_COMPARISON_SIZE
(package private) long
charLength
Length in characters.private int
hash
Cache the hashCode because it can be expensive to compute.(package private) LobData
lobData
(package private) long
octetLength
Length in bytes.private TypeInfo
type
-
Fields inherited from class org.h2.value.Value
ARRAY, ASSIGN_TO, BIGINT, BINARY, BLOB, BOOLEAN, CAST_TO, CHAR, CLOB, CONVERT_TO, DATE, DECFLOAT, DOUBLE, EMPTY_VALUES, ENUM, GEOMETRY, GROUP_BINARY_STRING, GROUP_BOOLEAN, GROUP_CHARACTER_STRING, GROUP_COLLECTION, GROUP_DATETIME, GROUP_INTERVAL_DT, GROUP_INTERVAL_YM, GROUP_NULL, GROUP_NUMERIC, GROUP_OTHER, GROUPS, INTEGER, INTERVAL_DAY, INTERVAL_DAY_TO_HOUR, INTERVAL_DAY_TO_MINUTE, INTERVAL_DAY_TO_SECOND, INTERVAL_HOUR, INTERVAL_HOUR_TO_MINUTE, INTERVAL_HOUR_TO_SECOND, INTERVAL_MINUTE, INTERVAL_MINUTE_TO_SECOND, INTERVAL_MONTH, INTERVAL_SECOND, INTERVAL_YEAR, INTERVAL_YEAR_TO_MONTH, JAVA_OBJECT, JSON, MAX_LONG_DECIMAL, MIN_LONG_DECIMAL, NULL, NUMERIC, REAL, ROW, SMALLINT, TIME, TIME_TZ, TIMESTAMP, TIMESTAMP_TZ, TINYINT, TYPE_COUNT, UNKNOWN, UUID, VARBINARY, VARCHAR, VARCHAR_IGNORECASE
-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ValueLob
copy(DataHandler database, int tableId)
Copy a large value, to be used in the given table.ValueLob
copyToResult()
Create an independent copy of this value, that will be bound to a result.(package private) static java.lang.String
createTempLobFileName(DataHandler handler)
Create file name for temporary LOB storageboolean
equals(java.lang.Object other)
Check if the two values have the same hash code.(package private) DbException
getBinaryTooLong(long precision)
(package private) static int
getBufferSize(DataHandler handler, long remaining)
byte[]
getBytes()
(package private) abstract byte[]
getBytesInternal()
byte[]
getBytesNoCopy()
LobData
getLobData()
int
getMemory()
Get the memory used by this object.java.io.Reader
getReader()
private byte[]
getSmall()
(package private) DbException
getStringTooLong(long precision)
TypeInfo
getType()
Returns the data type.int
hashCode()
boolean
isLinkedToTable()
Check if this value is linked to a specific table.private static void
rangeCheckUnknown(long zeroBasedOffset, long length)
protected static java.io.InputStream
rangeInputStream(java.io.InputStream inputStream, long oneBasedOffset, long length, long dataSize)
Create an input stream that is s subset of the given stream.(package private) static java.io.Reader
rangeReader(java.io.Reader reader, long oneBasedOffset, long length, long dataSize)
Create a reader that is s subset of the given reader.(package private) byte[]
readBytes(int len)
(package private) java.lang.String
readString(int len)
void
remove()
Remove the underlying resource, if any.-
Methods inherited from class org.h2.value.Value
add, cache, castTo, charLength, clearCache, compareTo, compareTypeSafe, compareWithNull, containsNull, convertForAssignTo, convertTo, convertTo, convertTo, convertTo, convertTo, convertToAnyArray, convertToAnyRow, convertToBigint, convertToBoolean, convertToChar, convertToDate, convertToDouble, convertToEnum, convertToGeometry, convertToInt, convertToInt, convertToJavaObject, convertToReal, convertToSmallint, convertToTinyint, convertToUuid, divide, getBigDecimal, getBoolean, getByte, getDataConversionError, getDataConversionError, getDouble, getFloat, getHigherOrder, getHigherOrderKnown, getInputStream, getInputStream, getInt, getLong, getReader, getShort, getSignum, getString, getTypeName, getUnsupportedExceptionForOperation, getValueTooLongException, getValueType, isFalse, isTrue, modulus, multiply, negate, octetLength, rangeCheck, subtract, toString
-
Methods inherited from class org.h2.value.VersionedValue
getCommittedValue, getCurrentValue, getOperationId, isCommitted
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getSQL, getSQL, getTraceSQL
-
-
-
-
Field Detail
-
BLOCK_COMPARISON_SIZE
static final int BLOCK_COMPARISON_SIZE
- See Also:
- Constant Field Values
-
type
private TypeInfo type
-
lobData
final LobData lobData
-
octetLength
long octetLength
Length in bytes.
-
charLength
long charLength
Length in characters.
-
hash
private int hash
Cache the hashCode because it can be expensive to compute.
-
-
Constructor Detail
-
ValueLob
ValueLob(LobData lobData, long octetLength, long charLength)
-
-
Method Detail
-
rangeCheckUnknown
private static void rangeCheckUnknown(long zeroBasedOffset, long length)
-
rangeInputStream
protected static java.io.InputStream rangeInputStream(java.io.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 streamoneBasedOffset
- the offset (1 means no offset)length
- the length of the result, in bytesdataSize
- the length of the input, in bytes- Returns:
- the smaller input stream
-
rangeReader
static java.io.Reader rangeReader(java.io.Reader reader, long oneBasedOffset, long length, long dataSize)
Create a reader that is s subset of the given reader.- Parameters:
reader
- the input readeroneBasedOffset
- the offset (1 means no offset)length
- the length of the result, in bytesdataSize
- the length of the input, in bytes- Returns:
- the smaller input stream
-
createTempLobFileName
static java.lang.String createTempLobFileName(DataHandler handler) throws java.io.IOException
Create file name for temporary LOB storage- Parameters:
handler
- to get path from- Returns:
- full path and name of the created file
- Throws:
java.io.IOException
- if file creation fails
-
getBufferSize
static int getBufferSize(DataHandler handler, long remaining)
-
isLinkedToTable
public boolean isLinkedToTable()
Check if this value is linked to a specific table. For values that are kept fully in memory, this method returns false.- Returns:
- true if it is
-
remove
public void remove()
Remove the underlying resource, if any. For values that are kept fully in memory this method has no effect.
-
copy
public abstract ValueLob copy(DataHandler database, int tableId)
Copy a large value, to be used in the given table. For values that are kept fully in memory this method has no effect.- Parameters:
database
- the data handlertableId
- the table where this object is used- Returns:
- the new value or itself
-
getStringTooLong
DbException getStringTooLong(long precision)
-
readString
java.lang.String readString(int len)
-
getBytesNoCopy
public byte[] getBytesNoCopy()
- Overrides:
getBytesNoCopy
in classValue
-
getSmall
private byte[] getSmall()
-
getBytesInternal
abstract byte[] getBytesInternal()
-
getBinaryTooLong
DbException getBinaryTooLong(long precision)
-
readBytes
byte[] readBytes(int len)
-
equals
public boolean equals(java.lang.Object other)
Description copied from class:Value
Check if the two values have the same hash code. No data conversion is made; this method returns false if the other object is not of the same class. For some values, compareTo may return 0 even if equals return false. Example: ValueDecimal 0.0 and 0.00.
-
getMemory
public int getMemory()
Description copied from class:Value
Get the memory used by this object.
-
getLobData
public LobData getLobData()
-
copyToResult
public ValueLob copyToResult()
Create an independent copy of this value, that will be bound to a result.- Returns:
- the value (this for small objects)
-
-