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

public final Class MVRTreeMap<V>

extends MVMap<Spatial, V>
Class Inheritance
Type Parameters
<V>
the value class
Imports
java.util.ArrayList, .Collection, .Iterator, .Map, org.h2.mvstore.CursorPos, .MVMap, .Page, .RootReference, org.h2.mvstore.type.DataType

An r-tree implementation. It supports both the linear and the quadratic split algorithm.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
MVRTreeMap.Builder<
the value type
V
>

A builder for this class.

private static class
private static class
public abstract static class
MVRTreeMap.RTreeCursor<V>

A cursor to iterate over a subset of the keys.

Field Summary

Modifier and TypeField and Description
private final SpatialDataType
keyType

Hides org.h2.mvstore.MVMap.keyType.

The spatial key type.
private boolean
Inherited from org.h2.mvstore.MVMap:
store

Constructor Summary

AccessConstructor and Description
public
MVRTreeMap(Map<String, Object> config, SpatialDataType keyType, DataType<V> valueType)

private

Method Summary

Modifier and TypeMethod and Description
public void
add(Spatial
the key
key
,
V
the value
value
)

Add a given key-value pair.

public void
addNodeKeys(ArrayList<Spatial>
the list
list
,
Page<Spatial, V>
the root page
p
)

Add all node keys (including internal bounds) to the given list.

public MVRTreeMap<V>
cloneIt()

Overrides org.h2.mvstore.MVMap.cloneIt.

Clone the current map.

private boolean
contains(Page<Spatial, V> p, int index, Spatial key)

public MVRTreeMap.RTreeCursor<V>

Returns:

the iterator
findContainedKeys
(Spatial
the rectangle
x
)

Iterate over all keys that are fully contained within the given rectangle.

public MVRTreeMap.RTreeCursor<V>

Returns:

the iterator
findIntersectingKeys
(Spatial
the rectangle
x
)

Iterate over all keys that have an intersection with the given rectangle.

public V

Returns:

the value, or null if not found
get
(Page<Spatial, V>
the page
p
,
Spatial
the key
key
)

Overrides org.h2.mvstore.MVMap.get.

Get the object for the given key.

private Spatial
protected int
getChildPageCount(Page<Spatial, V>
the page
p
)

Overrides org.h2.mvstore.MVMap.getChildPageCount.

Get the child page count for this page.

public String
getType()

Overrides org.h2.mvstore.MVMap.getType.

Get the map type.

public boolean
private static <V> void
move(Page<Spatial, V> source, Page<Spatial, V> target, int sourceIndex)

private Page<Spatial, V>
newPage(boolean leaf)

public V
operate(Spatial
the key (may not be null)
key
,
V
new value, it may be null when removal is intended
value
,
MVMap.DecisionMaker<? super V>
command object to make choices during transaction.
decisionMaker
)

Overrides org.h2.mvstore.MVMap.operate.

Add, replace or remove a key-value pair.

private V
operate(Page<Spatial, V> p, Spatial key, V value, MVMap.DecisionMaker<? super V> decisionMaker, Collection<Page<Spatial, V>> removedPages)

public V
put(Spatial
the key (may not be null)
key
,
V
the value (may not be null)
value
)

Overrides org.h2.mvstore.MVMap.put.

Implements java.util.Map.put.

Add or replace a key-value pair.

public V

Returns:

the old value if the key existed, or null otherwise
remove
(Object
the key (may not be null)
key
)

Overrides org.h2.mvstore.MVMap.remove.

Implements java.util.Map.remove.

Remove a key-value pair, if the key exists.

public void
setQuadraticSplit(boolean quadraticSplit)

private Page<Spatial, V>
private Page<Spatial, V>
private Page<Spatial, V>
Inherited from org.h2.mvstore.MVMap:
appendasStringbeforeWriteceilingKeyclearcontainsKeycreateEmptyLeafcreateEmptyNodecursorcursorcursorentrySetequalsfirstKeyfloorKeyflushAndGetRootgetgetIdgetKeygetKeyIndexgetKeyTypegetNamegetRootgetRootPagegetStoregetValueTypegetVersionhashCodehigherKeyhigherKeyisClosedisEmptyisPersistentisReadOnlyisVolatilekeyIteratorkeyIteratorReversekeyListkeySetlastKeylowerKeylowerKeyopenVersionputIfAbsentregisterUnsavedMemoryremovereplacereplacesetVolatilesizesizeAsLongtoStringtrimLasttryLockunlockRootupdateRoot

Field Detail

keyTypeback to summary
private final SpatialDataType keyType

Hides org.h2.mvstore.MVMap.keyType.

The spatial key type.

quadraticSplitback to summary
private boolean quadraticSplit

Constructor Detail

MVRTreeMapback to summary
public MVRTreeMap(Map<String, Object> config, SpatialDataType keyType, DataType<V> valueType)
MVRTreeMapback to summary
private MVRTreeMap(MVRTreeMap<V> source)

Method Detail

addback to summary
public void add(Spatial key, V value)

Add a given key-value pair. The key should not exist (if it exists, the result is undefined).

Parameters
key:Spatial

the key

value:V

the value

addNodeKeysback to summary
public void addNodeKeys(ArrayList<Spatial> list, Page<Spatial, V> p)

Add all node keys (including internal bounds) to the given list. This is mainly used to visualize the internal splits.

Parameters
list:ArrayList<Spatial>

the list

p:Page<Spatial, V>

the root page

cloneItback to summary
public MVRTreeMap<V> cloneIt()

Overrides org.h2.mvstore.MVMap.cloneIt.

Doc from org.h2.mvstore.MVMap.cloneIt.

Clone the current map.

Returns:MVRTreeMap<V>

clone of this.

Annotations
@Override
containsback to summary
private boolean contains(Page<Spatial, V> p, int index, Spatial key)
findContainedKeysback to summary
public MVRTreeMap.RTreeCursor<V> findContainedKeys(Spatial x)

Iterate over all keys that are fully contained within the given rectangle.

Parameters
x:Spatial

the rectangle

Returns:MVRTreeMap.RTreeCursor<V>

the iterator

findIntersectingKeysback to summary
public MVRTreeMap.RTreeCursor<V> findIntersectingKeys(Spatial x)

Iterate over all keys that have an intersection with the given rectangle.

Parameters
x:Spatial

the rectangle

Returns:MVRTreeMap.RTreeCursor<V>

the iterator

getback to summary
public V get(Page<Spatial, V> p, Spatial key)

Overrides org.h2.mvstore.MVMap.get.

Get the object for the given key. An exact match is required.

Parameters
p:Page<Spatial, V>

the page

key:Spatial

the key

Returns:V

the value, or null if not found

Annotations
@Override
getBoundsback to summary
private Spatial getBounds(Page<Spatial, V> x)
getChildPageCountback to summary
protected int getChildPageCount(Page<Spatial, V> p)

Overrides org.h2.mvstore.MVMap.getChildPageCount.

Doc from org.h2.mvstore.MVMap.getChildPageCount.

Get the child page count for this page. This is to allow another map implementation to override the default, in case the last child is not to be used.

Parameters
p:Page<Spatial, V>

the page

Returns:int

the number of direct children

Annotations
@Override
getTypeback to summary
public String getType()

Overrides org.h2.mvstore.MVMap.getType.

Doc from org.h2.mvstore.MVMap.getType.

Get the map type. When opening an existing map, the map type must match.

Returns:String

the map type

Annotations
@Override
isQuadraticSplitback to summary
public boolean isQuadraticSplit()
Annotations
@SuppressWarnings:unused
moveback to summary
private static <V> void move(Page<Spatial, V> source, Page<Spatial, V> target, int sourceIndex)
newPageback to summary
private Page<Spatial, V> newPage(boolean leaf)
operateback to summary
public V operate(Spatial key, V value, MVMap.DecisionMaker<? super V> decisionMaker)

Overrides org.h2.mvstore.MVMap.operate.

Doc from org.h2.mvstore.MVMap.operate.

Add, replace or remove a key-value pair.

Parameters
key:Spatial

the key (may not be null)

value:V

new value, it may be null when removal is intended

decisionMaker:MVMap.DecisionMaker<? super V>

command object to make choices during transaction.

Returns:V

previous value, if mapping for that key existed, or null otherwise

Annotations
@Override
operateback to summary
private V operate(Page<Spatial, V> p, Spatial key, V value, MVMap.DecisionMaker<? super V> decisionMaker, Collection<Page<Spatial, V>> removedPages)
putback to summary
public V put(Spatial key, V value)

Overrides org.h2.mvstore.MVMap.put.

Implements java.util.Map.put.

Doc from org.h2.mvstore.MVMap.put.

Add or replace a key-value pair.

Parameters
key:Spatial

the key (may not be null)

value:V

the value (may not be null)

Returns:V

the old value if the key existed, or null otherwise

Annotations
@Override
removeback to summary
public V remove(Object key)

Overrides org.h2.mvstore.MVMap.remove.

Implements java.util.Map.remove.

Remove a key-value pair, if the key exists.

Parameters
key:Object

the key (may not be null)

Returns:V

the old value if the key existed, or null otherwise

Annotations
@Override
setQuadraticSplitback to summary
public void setQuadraticSplit(boolean quadraticSplit)
splitback to summary
private Page<Spatial, V> split(Page<Spatial, V> p)
splitLinearback to summary
private Page<Spatial, V> splitLinear(Page<Spatial, V> p)
splitQuadraticback to summary
private Page<Spatial, V> splitQuadratic(Page<Spatial, V> p)
org.h2.mvstore.rtree back to summary

public Class MVRTreeMap.Builder<V>

extends MVMap.BasicBuilder<MVRTreeMap<V>, Spatial, V>
Class Inheritance
Type Parameters
<V>
the value type

A builder for this class.

Field Summary

Modifier and TypeField and Description
private int

Constructor Summary

AccessConstructor and Description
public
Builder()

Create a new builder for maps with 2 dimensions.

Method Summary

Modifier and TypeMethod and Description
public MVRTreeMap<V>
create(Map<String, Object>
config map
config
)

Implements abstract org.h2.mvstore.MVMap.BasicBuilder.create.

Create map from config.

public MVRTreeMap.Builder<V>

Returns:

this
dimensions
(int
the dimensions to use
dimensions
)

Set the dimensions.

public MVRTreeMap.Builder<V>

Returns:

this
valueType
(DataType<? super V>
the key type
valueType
)

Overrides org.h2.mvstore.MVMap.BasicBuilder.valueType.

Set the key data type.

Inherited from org.h2.mvstore.MVMap.BasicBuilder:
creategetKeyTypegetValueTypekeyTypesetKeyTypesetValueType

Field Detail

dimensionsback to summary
private int dimensions

Constructor Detail

Builderback to summary
public Builder()

Create a new builder for maps with 2 dimensions.

Method Detail

createback to summary
public MVRTreeMap<V> create(Map<String, Object> config)

Implements abstract org.h2.mvstore.MVMap.BasicBuilder.create.

Doc from org.h2.mvstore.MVMap.BasicBuilder.create.

Create map from config.

Parameters
config:Map<String, Object>

config map

Returns:MVRTreeMap<V>

new map

Annotations
@Override
dimensionsback to summary
public MVRTreeMap.Builder<V> dimensions(int dimensions)

Set the dimensions.

Parameters
dimensions:int

the dimensions to use

Returns:MVRTreeMap.Builder<V>

this

valueTypeback to summary
public MVRTreeMap.Builder<V> valueType(DataType<? super V> valueType)

Overrides org.h2.mvstore.MVMap.BasicBuilder.valueType.

Set the key data type.

Parameters
valueType:DataType<? super V>

the key type

Returns:MVRTreeMap.Builder<V>

this

Annotations
@Override
org.h2.mvstore.rtree back to summary

private final Class MVRTreeMap.ContainsRTreeCursor<V>

extends MVRTreeMap.RTreeCursor<V>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SpatialDataType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
check(boolean
if the key is from a leaf page
leaf
,
Spatial
the stored key
key
,
Spatial
the user-supplied test key
test
)

Implements abstract org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor.check.

Check a given key.

Inherited from org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor:
fetchNexthasNextnextskip

Field Detail

keyTypeback to summary
private final SpatialDataType keyType

Constructor Detail

ContainsRTreeCursorback to summary
public ContainsRTreeCursor(Page<Spatial, V> root, Spatial filter, SpatialDataType keyType)

Method Detail

checkback to summary
protected boolean check(boolean leaf, Spatial key, Spatial test)

Implements abstract org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor.check.

Doc from org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor.check.

Check a given key.

Parameters
leaf:boolean

if the key is from a leaf page

key:Spatial

the stored key

test:Spatial

the user-supplied test key

Returns:boolean

true if there is a match

Annotations
@Override
org.h2.mvstore.rtree back to summary

private final Class MVRTreeMap.IntersectsRTreeCursor<V>

extends MVRTreeMap.RTreeCursor<V>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final SpatialDataType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected boolean
check(boolean
if the key is from a leaf page
leaf
,
Spatial
the stored key
key
,
Spatial
the user-supplied test key
test
)

Implements abstract org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor.check.

Check a given key.

Inherited from org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor:
fetchNexthasNextnextskip

Field Detail

keyTypeback to summary
private final SpatialDataType keyType

Constructor Detail

IntersectsRTreeCursorback to summary
public IntersectsRTreeCursor(Page<Spatial, V> root, Spatial filter, SpatialDataType keyType)

Method Detail

checkback to summary
protected boolean check(boolean leaf, Spatial key, Spatial test)

Implements abstract org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor.check.

Doc from org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor.check.

Check a given key.

Parameters
leaf:boolean

if the key is from a leaf page

key:Spatial

the stored key

test:Spatial

the user-supplied test key

Returns:boolean

true if there is a match

Annotations
@Override
org.h2.mvstore.rtree back to summary

public abstract Class MVRTreeMap.RTreeCursor<V>

extends Object
implements Iterator<Spatial>
Class Inheritance
All Implemented Interfaces
java.util.Iterator
Known Direct Subclasses
org.h2.mvstore.rtree.MVRTreeMap.IntersectsRTreeCursor, org.h2.mvstore.rtree.MVRTreeMap.ContainsRTreeCursor, org.h2.mvstore.db.MVSpatialIndex.FindBoundsCursor

A cursor to iterate over a subset of the keys.

Field Summary

Modifier and TypeField and Description
private Spatial
private final Spatial
private boolean
private CursorPos<Spatial, V>
private final Page<Spatial, V>

Constructor Summary

AccessConstructor and Description
protected
RTreeCursor(Page<Spatial, V> root, Spatial filter)

Method Summary

Modifier and TypeMethod and Description
protected abstract boolean

Returns:

true if there is a match
check
(boolean
if the key is from a leaf page
leaf
,
Spatial
the stored key
key
,
Spatial
the user-supplied test key
test
)

Check a given key.

pack-priv void
fetchNext()

Fetch the next entry if there is one.

public boolean
hasNext()

Implements java.util.Iterator.hasNext.

Returns true if the iteration has more elements.

public Spatial
next()

Implements java.util.Iterator.next.

Returns the next element in the iteration.

public void
skip(long
the number of entries to skip
n
)

Skip over that many entries.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private Spatial current
filterback to summary
private final Spatial filter
initializedback to summary
private boolean initialized
posback to summary
private CursorPos<Spatial, V> pos
rootback to summary
private final Page<Spatial, V> root

Constructor Detail

RTreeCursorback to summary
protected RTreeCursor(Page<Spatial, V> root, Spatial filter)

Method Detail

checkback to summary
protected abstract boolean check(boolean leaf, Spatial key, Spatial test)

Check a given key.

Parameters
leaf:boolean

if the key is from a leaf page

key:Spatial

the stored key

test:Spatial

the user-supplied test key

Returns:boolean

true if there is a match

fetchNextback to summary
pack-priv void fetchNext()

Fetch the next entry if there is one.

hasNextback to summary
public boolean hasNext()

Implements java.util.Iterator.hasNext.

Doc from java.util.Iterator.hasNext.

Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)

Returns:boolean

true if the iteration has more elements

Annotations
@Override
nextback to summary
public Spatial next()

Implements java.util.Iterator.next.

Doc from java.util.Iterator.next.

Returns the next element in the iteration.

Returns:Spatial

the next element in the iteration

Annotations
@Override
skipback to summary
public void skip(long n)

Skip over that many entries. This method is relatively fast (for this map implementation) even if many entries need to be skipped.

Parameters
n:long

the number of entries to skip