Top Description Constructors Methods
org.h2.mvstore.type

public abstract Class BasicDataType<T>

extends Object
implements DataType<T>
Class Inheritance
All Implemented Interfaces
org.h2.mvstore.type.DataType, java.util.Comparator
Known Direct Subclasses
org.h2.mvstore.type.ByteArrayDataType, org.h2.mvstore.type.LongDataType, org.h2.mvstore.type.MetaType, org.h2.mvstore.type.ObjectDataType, org.h2.mvstore.type.ObjectDataType.AutoDetectDataType, org.h2.mvstore.type.StringDataType, org.h2.mvstore.MVStoreTool.GenericDataType, org.h2.mvstore.db.LobStorageMap.BlobReference.Type, org.h2.mvstore.db.LobStorageMap.BlobMeta.Type, org.h2.mvstore.db.RowDataType, org.h2.mvstore.db.ValueDataType, org.h2.mvstore.rtree.SpatialDataType, org.h2.mvstore.tx.Record.Type, org.h2.mvstore.tx.VersionedValueType
Imports
java.nio.ByteBuffer, org.h2.mvstore.DataUtils, .WriteBuffer

The base class for data type implementations.
Author
Andrei Tokar

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
binarySearch(T
to search for
key
,
Object
to search within (an array of type T)
storageObj
,
int
number of data items in the storage
size
,
int
for key position
initialGuess
)

Implements org.h2.mvstore.type.DataType.binarySearch.

Perform binary search for the key within the storage

protected final T[]

Returns:

the array
cast
(Object
the storage object
storage
)

Cast the storage object to an array of type T.

public int
compare(T
the first key
a
,
T
the second key
b
)

Implements org.h2.mvstore.type.DataType.compare.

Compare two keys.

public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Implements java.util.Comparator.equals.

Indicates whether some other object is "equal to" this comparator.

public abstract int
getMemory(T
the object
obj
)

Redeclares org.h2.mvstore.type.DataType.getMemory.

Calculates the amount of used memory in bytes.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

public boolean
isMemoryEstimationAllowed()

Implements org.h2.mvstore.type.DataType.isMemoryEstimationAllowed.

Whether memory estimation based on previously seen values is allowed/desirable

public abstract T
read(ByteBuffer
the source buffer
buff
)

Redeclares org.h2.mvstore.type.DataType.read.

Read an object.

public void
read(ByteBuffer
the target buffer
buff
,
Object
the objects
storage
,
int
the number of objects to read
len
)

Implements org.h2.mvstore.type.DataType.read.

Read a list of objects.

public abstract void
write(WriteBuffer
the target buffer
buff
,
T
the value
obj
)

Redeclares org.h2.mvstore.type.DataType.write.

Write an object.

public void
write(WriteBuffer
the target buffer
buff
,
Object
the objects
storage
,
int
the number of objects to write
len
)

Implements org.h2.mvstore.type.DataType.write.

Write a list of objects.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Constructor Detail

BasicDataTypeback to summary
public BasicDataType()

Method Detail

binarySearchback to summary
public int binarySearch(T key, Object storageObj, int size, int initialGuess)

Implements org.h2.mvstore.type.DataType.binarySearch.

Doc from org.h2.mvstore.type.DataType.binarySearch.

Perform binary search for the key within the storage

Parameters
key:T

to search for

storageObj:Object

to search within (an array of type T)

size:int

number of data items in the storage

initialGuess:int

for key position

Returns:int

index of the key , if found, - index of the insertion point, if not

Annotations
@Override
castback to summary
protected final T[] cast(Object storage)

Cast the storage object to an array of type T.

Parameters
storage:Object

the storage object

Returns:T[]

the array

Annotations
@SuppressWarnings:unchecked
compareback to summary
public int compare(T a, T b)

Implements org.h2.mvstore.type.DataType.compare.

Doc from org.h2.mvstore.type.DataType.compare.

Compare two keys.

Parameters
a:T

the first key

b:T

the second key

Returns:int

-1 if the first key is smaller, 1 if larger, and 0 if equal

Annotations
@Override
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Implements java.util.Comparator.equals.

Doc from java.util.Comparator.equals.

Indicates whether some other object is "equal to" this comparator. This method must obey the general contract of Object#equals(Object). Additionally, this method can return true only if the specified object is also a comparator and it imposes the same ordering as this comparator. Thus, comp1.equals(comp2) implies that signum(comp1.compare(o1, o2))==signum(comp2.compare(o1, o2)) for every object reference o1 and o2.

Note that it is always safe not to override Object.equals(Object). However, overriding this method may, in some cases, improve performance by allowing programs to determine that two distinct comparators impose the same order.

Parameters
obj:Object

the reference object with which to compare.

Returns:boolean

true only if the specified object is also a comparator and it imposes the same ordering as this comparator.

Annotations
@Override
getMemoryback to summary
public abstract int getMemory(T obj)

Redeclares org.h2.mvstore.type.DataType.getMemory.

Doc from org.h2.mvstore.type.DataType.getMemory.

Calculates the amount of used memory in bytes.

Parameters
obj:T

the object

Returns:int

the used memory

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object

Annotations
@Override
isMemoryEstimationAllowedback to summary
public boolean isMemoryEstimationAllowed()

Implements org.h2.mvstore.type.DataType.isMemoryEstimationAllowed.

Doc from org.h2.mvstore.type.DataType.isMemoryEstimationAllowed.

Whether memory estimation based on previously seen values is allowed/desirable

Returns:boolean

true if memory estimation is allowed

Annotations
@Override
readback to summary
public abstract T read(ByteBuffer buff)

Redeclares org.h2.mvstore.type.DataType.read.

Doc from org.h2.mvstore.type.DataType.read.

Read an object.

Parameters
buff:ByteBuffer

the source buffer

Returns:T

the object

Annotations
@Override
readback to summary
public void read(ByteBuffer buff, Object storage, int len)

Implements org.h2.mvstore.type.DataType.read.

Doc from org.h2.mvstore.type.DataType.read.

Read a list of objects.

Parameters
buff:ByteBuffer

the target buffer

storage:Object

the objects

len:int

the number of objects to read

Annotations
@Override
writeback to summary
public abstract void write(WriteBuffer buff, T obj)

Redeclares org.h2.mvstore.type.DataType.write.

Doc from org.h2.mvstore.type.DataType.write.

Write an object.

Parameters
buff:WriteBuffer

the target buffer

obj:T

the value

Annotations
@Override
writeback to summary
public void write(WriteBuffer buff, Object storage, int len)

Implements org.h2.mvstore.type.DataType.write.

Doc from org.h2.mvstore.type.DataType.write.

Write a list of objects.

Parameters
buff:WriteBuffer

the target buffer

storage:Object

the objects

len:int

the number of objects to write

Annotations
@Override