org.h2.test.store
Class MVRTreeMap<K,V>

java.lang.Object
  extended by java.util.AbstractMap<K,V>
      extended by org.h2.dev.store.btree.MVMap<K,V>
          extended by org.h2.test.store.MVRTreeMap<K,V>
Type Parameters:
K - the key class
V - the value class
All Implemented Interfaces:
java.util.Map<K,V>

public class MVRTreeMap<K,V>
extends MVMap<K,V>

An r-tree implementation. It uses the quadratic split algorithm.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
java.util.AbstractMap.SimpleEntry<K,V>, java.util.AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Field Summary
 
Fields inherited from class org.h2.dev.store.btree.MVMap
root, store
 
Method Summary
 void add(K key, V value)
          Add a given key-value pair.
 void addNodeKeys(java.util.ArrayList<K> list, Page p)
          Add all node keys (including internal bounds) to the given list.
 V get(java.lang.Object key)
          Get a value.
protected  java.lang.Object get(Page p, java.lang.Object key)
          Get the object for the given key.
protected  Page getPage(K key)
          Get the page for the given value.
 boolean isQuadraticSplit()
           
protected  CursorPos min(Page p, Cursor<K,V> cursor, java.lang.Object key)
          Go to the first element for the given key.
protected  java.lang.Object nextKey(CursorPos p, Cursor<K,V> cursor)
          Get the next key.
 V put(K key, V value)
          Add or replace a key-value pair.
protected  java.lang.Object remove(Page p, long writeVersion, java.lang.Object key)
          Remove a key-value pair.
 void setQuadraticSplit(boolean quadraticSplit)
           
 
Methods inherited from class org.h2.dev.store.btree.MVMap
binarySearch, binarySearchPage, changeIterator, checkOpen, checkWrite, clear, close, containsKey, entrySet, equals, getRoot, getSize, hashCode, hasUnsavedChanges, isClosed, isReadOnly, keyIterator, keySet, openVersion, put, remove, removeMap, removePage, setReadOnly, setRoot, size, toString
 
Methods inherited from class java.util.AbstractMap
clone, containsValue, isEmpty, putAll, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

get

public V get(java.lang.Object key)
Description copied from class: MVMap
Get a value.

Specified by:
get in interface java.util.Map<K,V>
Overrides:
get in class MVMap<K,V>
Parameters:
key - the key
Returns:
the value, or null if not found

get

protected java.lang.Object get(Page p,
                               java.lang.Object key)
Get the object for the given key. An exact match is required.

Parameters:
p - the page
key - the key
Returns:
the value, or null if not found

getPage

protected Page getPage(K key)
Description copied from class: MVMap
Get the page for the given value.

Overrides:
getPage in class MVMap<K,V>
Parameters:
key - the key
Returns:
the value, or null if not found

remove

protected java.lang.Object remove(Page p,
                                  long writeVersion,
                                  java.lang.Object key)
Description copied from class: MVMap
Remove a key-value pair.

Overrides:
remove in class MVMap<K,V>
Parameters:
p - the page (may not be null)
writeVersion - the write version
key - the key
Returns:
the old value, or null if the key did not exist

put

public V put(K key,
             V value)
Description copied from class: MVMap
Add or replace a key-value pair.

Specified by:
put in interface java.util.Map<K,V>
Overrides:
put in class MVMap<K,V>
Parameters:
key - the key (may not be null)
value - the value (may not be null)
Returns:
the old value if the key existed, or null otherwise

add

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

Parameters:
key - the key
value - the value

addNodeKeys

public void addNodeKeys(java.util.ArrayList<K> list,
                        Page p)
Add all node keys (including internal bounds) to the given list. This is mainly used to visualize the internal splits.

Parameters:
list - the list
p - the root page

min

protected CursorPos min(Page p,
                        Cursor<K,V> cursor,
                        java.lang.Object key)
Go to the first element for the given key.

Overrides:
min in class MVMap<K,V>
Parameters:
p - the current page
cursor - the cursor
key - the key
Returns:
the cursor position

nextKey

protected java.lang.Object nextKey(CursorPos p,
                                   Cursor<K,V> cursor)
Get the next key.

Overrides:
nextKey in class MVMap<K,V>
Parameters:
p - the cursor position
cursor - the cursor
Returns:
the next key

isQuadraticSplit

public boolean isQuadraticSplit()

setQuadraticSplit

public void setQuadraticSplit(boolean quadraticSplit)