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

public Class MVSpatialIndex

extends MVIndex<Spatial, Value>
implements SpatialIndex
Class Inheritance
All Implemented Interfaces
org.h2.index.SpatialIndex
Static Imports
org.h2.util.geometry.GeometryUtils.MAX_X, .GeometryUtils.MAX_Y, .GeometryUtils.MIN_X, .GeometryUtils.MIN_Y

This is an index based on a MVRTreeMap.
Authors
Thomas Mueller, Noel Grandin, Nicolas Fortin, Atelier SIG, IRSTV FR CNRS 24888

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
MVSpatialIndex.FindBoundsCursor

A cursor for getBounds() method.

private static class
private static class

Field Summary

Modifier and TypeField and Description
private final TransactionMap<Spatial, Value>
pack-priv final MVTable
mvTable

The multi-value table.

private final MVRTreeMap<VersionedValue<Value>>

Constructor Summary

AccessConstructor and Description
public
MVSpatialIndex(Database
the database
db
,
MVTable
the table instance
table
,
int
the index id
id
,
String
the index name
indexName
,
IndexColumn[]
the indexed columns (only one geometry column allowed)
columns
,
int
count of unique columns (0 or 1)
uniqueColumnCount
,
IndexType
the index type (only spatial index)
indexType
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
add(SessionLocal
the session to use
session
,
Row
the row to add
row
)

Implements abstract org.h2.index.Index.add.

Add a row to the index.

public void
addBufferedRows(List<String>
the names of the temporary storage
bufferNames
)

Implements abstract org.h2.mvstore.db.MVIndex.addBufferedRows.

Add all the index data from the buffers to the index.

public void
addRowsToBuffer(List<Row>
the rows
rows
,
String
the name of the temporary storage
bufferName
)

Implements abstract org.h2.mvstore.db.MVIndex.addRowsToBuffer.

Add the rows to a temporary storage (not to the index yet).

public void
close(SessionLocal
the session used to write data
session
)

Implements abstract org.h2.index.Index.close.

Close this index.

public Cursor
find(SessionLocal
the session
session
,
SearchRow
the first row, or null for no limit
first
,
SearchRow
the last row, or null for no limit
last
,
boolean
if true, iterate in reverse (descending) order
reverse
)

Implements abstract org.h2.index.Index.find.

Find a row or a list of rows and create a cursor to iterate over the result.

public Cursor
findByGeometry(SessionLocal
the session
session
,
SearchRow
the lower bound
first
,
SearchRow
the upper bound
last
,
boolean
if true, iterate in reverse (descending) order
reverse
,
SearchRow
the geometry which values should intersect with, or null for anything
intersection
)

Implements org.h2.index.SpatialIndex.findByGeometry.

Find a row or a list of rows and create a cursor to iterate over the result.

public Value

Returns:

the minimum bounding box that encloses all keys, or null
getBounds
(SessionLocal
the session
session
)

Returns the minimum bounding box that encloses all keys.

public double
getCost(SessionLocal
the session
session
,
int[]
per-column comparison bit masks, null means 'always false', see constants in IndexCondition
masks
,
TableFilter[]
all joined table filters
filters
,
int
the current table filter index
filter
,
SortOrder
the sort order
sortOrder
,
AllColumnsForPlan
the set of all columns
allColumnsSet
)

Implements abstract org.h2.index.Index.getCost.

Estimate the cost to search for rows given the search mask.

public Value

Returns:

the estimated minimum bounding box that encloses all keys, or null
getEstimatedBounds
(SessionLocal
the session
session
)

Returns the estimated minimum bounding box that encloses all keys.

private SpatialKey
private TransactionMap<Spatial, Value>

Returns:

the map
getMap
(SessionLocal
the session
session
)

Get the map to store the data.

public MVMap<Spatial, VersionedValue<Value>>
public long
getRowCount(SessionLocal
the session
session
)

Implements abstract org.h2.index.Index.getRowCount.

Get the row count of this table, for the given session.

public long
getRowCountApproximation(SessionLocal
the session
session
)

Implements abstract org.h2.index.Index.getRowCountApproximation.

Get the approximated row count for this table.

public MVTable
getTable()

Overrides org.h2.index.Index.getTable.

Get the table on which this index is based.

public boolean
needRebuild()

Implements abstract org.h2.index.Index.needRebuild.

Check if the index needs to be rebuilt.

public void
remove(SessionLocal
the session
session
,
Row
the row
row
)

Implements abstract org.h2.index.Index.remove.

Remove a row from the index.

public void
remove(SessionLocal
the session
session
)

Implements abstract org.h2.index.Index.remove.

Remove the index.

public void
truncate(SessionLocal
the session
session
)

Implements abstract org.h2.index.Index.truncate.

Remove all rows from the index.

Inherited from org.h2.mvstore.db.MVIndex:
getDiskSpaceUsed

Field Detail

dataMapback to summary
private final TransactionMap<Spatial, Value> dataMap
mvTableback to summary
pack-priv final MVTable mvTable

The multi-value table.

spatialMapback to summary
private final MVRTreeMap<VersionedValue<Value>> spatialMap

Constructor Detail

MVSpatialIndexback to summary
public MVSpatialIndex(Database db, MVTable table, int id, String indexName, IndexColumn[] columns, int uniqueColumnCount, IndexType indexType)

Constructor.

Parameters
db:Database

the database

table:MVTable

the table instance

id:int

the index id

indexName:String

the index name

columns:IndexColumn[]

the indexed columns (only one geometry column allowed)

uniqueColumnCount:int

count of unique columns (0 or 1)

indexType:IndexType

the index type (only spatial index)

Method Detail

addback to summary
public void add(SessionLocal session, Row row)

Implements abstract org.h2.index.Index.add.

Doc from org.h2.index.Index.add.

Add a row to the index.

Parameters
session:SessionLocal

the session to use

row:Row

the row to add

Annotations
@Override
addBufferedRowsback to summary
public void addBufferedRows(List<String> bufferNames)

Implements abstract org.h2.mvstore.db.MVIndex.addBufferedRows.

Doc from org.h2.mvstore.db.MVIndex.addBufferedRows.

Add all the index data from the buffers to the index. The index will typically use merge sort to add the data more quickly in sorted order.

Parameters
bufferNames:List<String>

the names of the temporary storage

Annotations
@Override
addRowsToBufferback to summary
public void addRowsToBuffer(List<Row> rows, String bufferName)

Implements abstract org.h2.mvstore.db.MVIndex.addRowsToBuffer.

Doc from org.h2.mvstore.db.MVIndex.addRowsToBuffer.

Add the rows to a temporary storage (not to the index yet). The rows are sorted by the index columns. This is to more quickly build the index.

Parameters
rows:List<Row>

the rows

bufferName:String

the name of the temporary storage

Annotations
@Override
closeback to summary
public void close(SessionLocal session)

Implements abstract org.h2.index.Index.close.

Doc from org.h2.index.Index.close.

Close this index.

Parameters
session:SessionLocal

the session used to write data

Annotations
@Override
findback to summary
public Cursor find(SessionLocal session, SearchRow first, SearchRow last, boolean reverse)

Implements abstract org.h2.index.Index.find.

Doc from org.h2.index.Index.find.

Find a row or a list of rows and create a cursor to iterate over the result.

Parameters
session:SessionLocal

the session

first:SearchRow

the first row, or null for no limit

last:SearchRow

the last row, or null for no limit

reverse:boolean

if true, iterate in reverse (descending) order

Returns:Cursor

the cursor to iterate over the results

Annotations
@Override
findByGeometryback to summary
public Cursor findByGeometry(SessionLocal session, SearchRow first, SearchRow last, boolean reverse, SearchRow intersection)

Implements org.h2.index.SpatialIndex.findByGeometry.

Doc from org.h2.index.SpatialIndex.findByGeometry.

Find a row or a list of rows and create a cursor to iterate over the result.

Parameters
session:SessionLocal

the session

first:SearchRow

the lower bound

last:SearchRow

the upper bound

reverse:boolean

if true, iterate in reverse (descending) order

intersection:SearchRow

the geometry which values should intersect with, or null for anything

Returns:Cursor

the cursor to iterate over the results

Annotations
@Override
getBoundsback to summary
public Value getBounds(SessionLocal session)

Returns the minimum bounding box that encloses all keys.

Parameters
session:SessionLocal

the session

Returns:Value

the minimum bounding box that encloses all keys, or null

getCostback to summary
public double getCost(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)

Implements abstract org.h2.index.Index.getCost.

Doc from org.h2.index.Index.getCost.

Estimate the cost to search for rows given the search mask. There is one element per column in the search mask. For possible search masks, see IndexCondition.

Parameters
session:SessionLocal

the session

masks:int[]

per-column comparison bit masks, null means 'always false', see constants in IndexCondition

filters:TableFilter[]

all joined table filters

filter:int

the current table filter index

sortOrder:SortOrder

the sort order

allColumnsSet:AllColumnsForPlan

the set of all columns

Returns:double

the estimated cost

Annotations
@Override
getEstimatedBoundsback to summary
public Value getEstimatedBounds(SessionLocal session)

Returns the estimated minimum bounding box that encloses all keys. The returned value may be incorrect.

Parameters
session:SessionLocal

the session

Returns:Value

the estimated minimum bounding box that encloses all keys, or null

getKeyback to summary
private SpatialKey getKey(SearchRow row)
getMapback to summary
private TransactionMap<Spatial, Value> getMap(SessionLocal session)

Get the map to store the data.

Parameters
session:SessionLocal

the session

Returns:TransactionMap<Spatial, Value>

the map

getMVMapback to summary
public MVMap<Spatial, VersionedValue<Value>> getMVMap()

Implements abstract org.h2.mvstore.db.MVIndex.getMVMap.

Annotations
@Override
getRowCountback to summary
public long getRowCount(SessionLocal session)

Implements abstract org.h2.index.Index.getRowCount.

Doc from org.h2.index.Index.getRowCount.

Get the row count of this table, for the given session.

Parameters
session:SessionLocal

the session

Returns:long

the row count

Annotations
@Override
getRowCountApproximationback to summary
public long getRowCountApproximation(SessionLocal session)

Implements abstract org.h2.index.Index.getRowCountApproximation.

Doc from org.h2.index.Index.getRowCountApproximation.

Get the approximated row count for this table.

Parameters
session:SessionLocal

the session

Returns:long

the approximated row count

Annotations
@Override
getTableback to summary
public MVTable getTable()

Overrides org.h2.index.Index.getTable.

Doc from org.h2.index.Index.getTable.

Get the table on which this index is based.

Returns:MVTable

the table

Annotations
@Override
needRebuildback to summary
public boolean needRebuild()

Implements abstract org.h2.index.Index.needRebuild.

Doc from org.h2.index.Index.needRebuild.

Check if the index needs to be rebuilt. This method is called after opening an index.

Returns:boolean

true if a rebuild is required.

Annotations
@Override
removeback to summary
public void remove(SessionLocal session, Row row)

Implements abstract org.h2.index.Index.remove.

Doc from org.h2.index.Index.remove.

Remove a row from the index.

Parameters
session:SessionLocal

the session

row:Row

the row

Annotations
@Override
removeback to summary
public void remove(SessionLocal session)

Implements abstract org.h2.index.Index.remove.

Doc from org.h2.index.Index.remove.

Remove the index.

Parameters
session:SessionLocal

the session

Annotations
@Override
truncateback to summary
public void truncate(SessionLocal session)

Implements abstract org.h2.index.Index.truncate.

Doc from org.h2.index.Index.truncate.

Remove all rows from the index.

Parameters
session:SessionLocal

the session

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

private final Class MVSpatialIndex.FindBoundsCursor

extends MVRTreeMap.RTreeCursor<VersionedValue<Value>>
Class Inheritance

A cursor for getBounds() method.

Field Summary

Modifier and TypeField and Description
private double
private float
private double
private float
private double
private float
private double
private float
private final int
private boolean
private final TransactionMap<Spatial, Value>
private final SessionLocal

Constructor Summary

AccessConstructor and Description
pack-priv

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.

pack-priv Value
Inherited from org.h2.mvstore.rtree.MVRTreeMap.RTreeCursor:
hasNextnextskip

Field Detail

bmaxxdback to summary
private double bmaxxd
bmaxxfback to summary
private float bmaxxf
bmaxydback to summary
private double bmaxyd
bmaxyfback to summary
private float bmaxyf
bminxdback to summary
private double bminxd
bminxfback to summary
private float bminxf
bminydback to summary
private double bminyd
bminyfback to summary
private float bminyf
columnIdback to summary
private final int columnId
hasBoundsback to summary
private boolean hasBounds
mapback to summary
private final TransactionMap<Spatial, Value> map
sessionback to summary
private final SessionLocal session

Constructor Detail

FindBoundsCursorback to summary
pack-priv FindBoundsCursor(Page<Spatial, VersionedValue<Value>> root, Spatial filter, SessionLocal session, TransactionMap<Spatial, Value> map, int columnId)

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
getBoundsback to summary
pack-priv Value getBounds()
org.h2.mvstore.db back to summary

private Class MVSpatialIndex.MVStoreCursor

extends Object
implements Cursor
Class Inheritance
All Implemented Interfaces
org.h2.index.Cursor

A cursor.

Field Summary

Modifier and TypeField and Description
private Spatial
private final Iterator<Spatial>
private final MVTable
private Row
private SearchRow
private final SessionLocal

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public Row
get()

Implements org.h2.index.Cursor.get.

Get the complete current row.

public SearchRow
getSearchRow()

Implements org.h2.index.Cursor.getSearchRow.

Get the current row.

public boolean
next()

Implements org.h2.index.Cursor.next.

Skip to the next row if one is available.

public boolean
previous()

Implements org.h2.index.Cursor.previous.

Skip to the previous row if one is available.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private Spatial current
itback to summary
private final Iterator<Spatial> it
mvTableback to summary
private final MVTable mvTable
rowback to summary
private Row row
searchRowback to summary
private SearchRow searchRow
sessionback to summary
private final SessionLocal session

Constructor Detail

MVStoreCursorback to summary
pack-priv MVStoreCursor(SessionLocal session, Iterator<Spatial> it, MVTable mvTable)

Method Detail

getback to summary
public Row get()

Implements org.h2.index.Cursor.get.

Doc from org.h2.index.Cursor.get.

Get the complete current row. All column are available.

Returns:Row

the complete row

Annotations
@Override
getSearchRowback to summary
public SearchRow getSearchRow()

Implements org.h2.index.Cursor.getSearchRow.

Doc from org.h2.index.Cursor.getSearchRow.

Get the current row. Only the data for indexed columns is available in this row.

Returns:SearchRow

the search row

Annotations
@Override
nextback to summary
public boolean next()

Implements org.h2.index.Cursor.next.

Doc from org.h2.index.Cursor.next.

Skip to the next row if one is available.

Returns:boolean

true if another row is available

Annotations
@Override
previousback to summary
public boolean previous()

Implements org.h2.index.Cursor.previous.

Doc from org.h2.index.Cursor.previous.

Skip to the previous row if one is available. No filtering is made here.

Returns:boolean

true if another row is available

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

private Class MVSpatialIndex.SpatialKeyIterator

extends Object
implements Iterator<Spatial>
Class Inheritance
All Implemented Interfaces
java.util.Iterator

Field Summary

Modifier and TypeField and Description
private Spatial
private final boolean
private final Iterator<Spatial>
private final TransactionMap<Spatial, Value>

Constructor Summary

AccessConstructor and Description
pack-priv
SpatialKeyIterator(TransactionMap<Spatial, Value> map, Iterator<Spatial> iterator, boolean includeUncommitted)

Method Summary

Modifier and TypeMethod and Description
private void
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentback to summary
private Spatial current
includeUncommittedback to summary
private final boolean includeUncommitted
iteratorback to summary
private final Iterator<Spatial> iterator
mapback to summary
private final TransactionMap<Spatial, Value> map

Constructor Detail

SpatialKeyIteratorback to summary
pack-priv SpatialKeyIterator(TransactionMap<Spatial, Value> map, Iterator<Spatial> iterator, boolean includeUncommitted)

Method Detail

fetchNextback to summary
private void fetchNext()
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