Top Description Fields Constructors Methods
org.h2.mvstore.rtree

public Class SpatialDataType

extends BasicDataType<Spatial>
Class Inheritance
Imports
java.nio.ByteBuffer, java.util.ArrayList, org.h2.mvstore.DataUtils, .WriteBuffer, org.h2.mvstore.type.BasicDataType

A spatial data type. This class supports up to 31 dimensions. Each dimension can have a minimum and a maximum value of type float. For each dimension, the maximum value is only stored when it is not the same as the minimum.

Field Summary

Modifier and TypeField and Description
private final int

Constructor Summary

AccessConstructor and Description
public
SpatialDataType(int dimensions)

Method Summary

Modifier and TypeMethod and Description
public int
compare(Spatial
the first key
a
,
Spatial
the second key
b
)

Overrides org.h2.mvstore.type.BasicDataType.compare.

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

Compare two keys.

public boolean

Returns:

the area
contains
(Spatial
the bounding box
bounds
,
Spatial
the object
object
)

Check whether bounds contains object.

protected Spatial

Returns:

the spatial object
create
(long
the ID
id
,
float...
min x, max x, min y, max y, and so on
minMax
)

Creates spatial object with specified parameters.

pack-priv Spatial

Returns:

the bounding box
createBoundingBox
(Spatial
the object
object
)

Create a bounding box starting with the given object.

public Spatial[]
createStorage(int
number of values to hold
size
)

Implements org.h2.mvstore.type.DataType.createStorage.

Create storage object of array type to hold values

public boolean

Returns:

true if they are equal
equals
(Spatial
the first value
a
,
Spatial
the second value
b
)

Check whether two spatial values are equal.

private float
public float

Returns:

the area
getAreaIncrease
(Spatial
the bounding box
bounds
,
Spatial
the object
add
)

Get the area increase by extending a to contain b.

pack-priv float

Returns:

the area
getCombinedArea
(Spatial
the first object
a
,
Spatial
the second object
b
)

Get the combined area of both objects.

public int[]

Returns:

the indexes of the extremes
getExtremes
(ArrayList<Spatial>
the objects
list
)

Get the most extreme pair (elements that are as far apart as possible).

public int
getMemory(Spatial
the object
obj
)

Implements abstract org.h2.mvstore.type.BasicDataType.getMemory.

Implements org.h2.mvstore.type.DataType.getMemory.

Calculates the amount of used memory in bytes.

private static ArrayList<Spatial>
public void
increaseBounds(Spatial
the bounds (may be modified)
bounds
,
Spatial
the value
add
)

Increase the bounds in the given spatial object.

private void
public boolean

Returns:

true if a is completely inside b
isInside
(Spatial
the object to check
object
,
Spatial
the bounds
bounds
)

Check whether object is completely inside bounds and does not touch them.

public boolean

Returns:

true if they overlap
isOverlap
(Spatial
the first object
a
,
Spatial
the second object
b
)

Check whether the two objects overlap.

public Spatial
read(ByteBuffer
the source buffer
buff
)

Implements abstract org.h2.mvstore.type.BasicDataType.read.

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

Read an object.

public void
write(WriteBuffer
the target buffer
buff
,
Spatial
the value
k
)

Implements abstract org.h2.mvstore.type.BasicDataType.write.

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

Write an object.

Inherited from org.h2.mvstore.type.BasicDataType:
binarySearchcastequalshashCodeisMemoryEstimationAllowedreadwrite

Field Detail

dimensionsback to summary
private final int dimensions

Constructor Detail

SpatialDataTypeback to summary
public SpatialDataType(int dimensions)

Method Detail

compareback to summary
public int compare(Spatial a, Spatial b)

Overrides org.h2.mvstore.type.BasicDataType.compare.

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

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

Compare two keys.

Parameters
a:Spatial

the first key

b:Spatial

the second key

Returns:int

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

Annotations
@Override
containsback to summary
public boolean contains(Spatial bounds, Spatial object)

Check whether bounds contains object.

Parameters
bounds:Spatial

the bounding box

object:Spatial

the object

Returns:boolean

the area

createback to summary
protected Spatial create(long id, float... minMax)

Creates spatial object with specified parameters.

Parameters
id:long

the ID

minMax:float[]

min x, max x, min y, max y, and so on

Returns:Spatial

the spatial object

createBoundingBoxback to summary
pack-priv Spatial createBoundingBox(Spatial object)

Create a bounding box starting with the given object.

Parameters
object:Spatial

the object

Returns:Spatial

the bounding box

createStorageback to summary
public Spatial[] createStorage(int size)

Implements org.h2.mvstore.type.DataType.createStorage.

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

Create storage object of array type to hold values

Parameters
size:int

number of values to hold

Returns:Spatial[]

storage object

Annotations
@Override
equalsback to summary
public boolean equals(Spatial a, Spatial b)

Check whether two spatial values are equal.

Parameters
a:Spatial

the first value

b:Spatial

the second value

Returns:boolean

true if they are equal

getAreaback to summary
private float getArea(Spatial a)
getAreaIncreaseback to summary
public float getAreaIncrease(Spatial bounds, Spatial add)

Get the area increase by extending a to contain b.

Parameters
bounds:Spatial

the bounding box

add:Spatial

the object

Returns:float

the area

getCombinedAreaback to summary
pack-priv float getCombinedArea(Spatial a, Spatial b)

Get the combined area of both objects.

Parameters
a:Spatial

the first object

b:Spatial

the second object

Returns:float

the area

getExtremesback to summary
public int[] getExtremes(ArrayList<Spatial> list)

Get the most extreme pair (elements that are as far apart as possible). This method is used to split a page (linear split). If no extreme objects could be found, this method returns null.

Parameters
list:ArrayList<Spatial>

the objects

Returns:int[]

the indexes of the extremes

getMemoryback to summary
public int getMemory(Spatial obj)

Implements abstract org.h2.mvstore.type.BasicDataType.getMemory.

Implements org.h2.mvstore.type.DataType.getMemory.

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

Calculates the amount of used memory in bytes.

Parameters
obj:Spatial

the object

Returns:int

the used memory

Annotations
@Override
getNotNullback to summary
private static ArrayList<Spatial> getNotNull(ArrayList<Spatial> list)
increaseBoundsback to summary
public void increaseBounds(Spatial bounds, Spatial add)

Increase the bounds in the given spatial object.

Parameters
bounds:Spatial

the bounds (may be modified)

add:Spatial

the value

increaseMaxInnerBoundsback to summary
private void increaseMaxInnerBounds(Spatial bounds, Spatial add)
isInsideback to summary
public boolean isInside(Spatial object, Spatial bounds)

Check whether object is completely inside bounds and does not touch them.

Parameters
object:Spatial

the object to check

bounds:Spatial

the bounds

Returns:boolean

true if a is completely inside b

isOverlapback to summary
public boolean isOverlap(Spatial a, Spatial b)

Check whether the two objects overlap.

Parameters
a:Spatial

the first object

b:Spatial

the second object

Returns:boolean

true if they overlap

readback to summary
public Spatial read(ByteBuffer buff)

Implements abstract org.h2.mvstore.type.BasicDataType.read.

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

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

Read an object.

Parameters
buff:ByteBuffer

the source buffer

Returns:Spatial

the object

Annotations
@Override
writeback to summary
public void write(WriteBuffer buff, Spatial k)

Implements abstract org.h2.mvstore.type.BasicDataType.write.

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

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

Write an object.

Parameters
buff:WriteBuffer

the target buffer

k:Spatial

the value

Annotations
@Override