Package org.h2.mvstore.db
Class MVSpatialIndex
- java.lang.Object
-
- org.h2.engine.DbObject
-
- org.h2.schema.SchemaObject
-
- org.h2.index.Index
-
- org.h2.mvstore.db.MVIndex<Spatial,Value>
-
- org.h2.mvstore.db.MVSpatialIndex
-
- All Implemented Interfaces:
SpatialIndex
,HasSQL
public class MVSpatialIndex extends MVIndex<Spatial,Value> implements SpatialIndex
This is an index based on a MVRTreeMap.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
MVSpatialIndex.FindBoundsCursor
A cursor for getBounds() method.private static class
MVSpatialIndex.MVStoreCursor
A cursor.private static class
MVSpatialIndex.SpatialKeyIterator
-
Field Summary
Fields Modifier and Type Field Description private TransactionMap<Spatial,Value>
dataMap
(package private) MVTable
mvTable
The multi-value table.private MVRTreeMap<VersionedValue<Value>>
spatialMap
-
Fields inherited from class org.h2.index.Index
columnIds, columns, indexColumns, indexType, table, uniqueColumnColumn
-
Fields inherited from class org.h2.engine.DbObject
AGGREGATE, comment, COMMENT, CONSTANT, CONSTRAINT, database, DOMAIN, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, trace, TRIGGER, USER
-
Fields inherited from interface org.h2.util.HasSQL
ADD_PLAN_INFORMATION, DEFAULT_SQL_FLAGS, NO_CASTS, QUOTE_ONLY_WHEN_REQUIRED, REPLACE_LOBS_FOR_TRACE, TRACE_SQL_FLAGS
-
-
Constructor Summary
Constructors Constructor Description MVSpatialIndex(Database db, MVTable table, int id, java.lang.String indexName, IndexColumn[] columns, int uniqueColumnCount, IndexType indexType)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(SessionLocal session, Row row)
Add a row to the index.void
addBufferedRows(java.util.List<java.lang.String> bufferNames)
Add all the index data from the buffers to the index.void
addRowsToBuffer(java.util.List<Row> rows, java.lang.String bufferName)
Add the rows to a temporary storage (not to the index yet).void
close(SessionLocal session)
Close this index.Cursor
find(SessionLocal session, SearchRow first, SearchRow last)
Find a row or a list of rows and create a cursor to iterate over the result.Cursor
findByGeometry(SessionLocal session, SearchRow first, SearchRow last, SearchRow intersection)
Find a row or a list of rows and create a cursor to iterate over the result.Value
getBounds(SessionLocal session)
Returns the minimum bounding box that encloses all keys.double
getCost(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)
Estimate the cost to search for rows given the search mask.static long
getCostRangeIndex(int[] masks, Column[] columns)
Compute spatial index costlong
getDiskSpaceUsed()
Get the used disk space for this index.Value
getEstimatedBounds(SessionLocal session)
Returns the estimated minimum bounding box that encloses all keys.private SpatialKey
getKey(SearchRow row)
private TransactionMap<Spatial,Value>
getMap(SessionLocal session)
Get the map to store the data.MVMap<Spatial,VersionedValue<Value>>
getMVMap()
long
getRowCount(SessionLocal session)
Get the row count of this table, for the given session.long
getRowCountApproximation(SessionLocal session)
Get the approximated row count for this table.MVTable
getTable()
Get the table on which this index is based.boolean
needRebuild()
Check if the index needs to be rebuilt.void
remove(SessionLocal session)
Remove the index.void
remove(SessionLocal session, Row row)
Remove a row from the index.void
truncate(SessionLocal session)
Remove all rows from the index.-
Methods inherited from class org.h2.index.Index
canFindNext, canGetFirstOrLast, canScan, checkIndexColumnTypes, compareRows, findFirstOrLast, findNext, getColumnIndex, getColumns, getCostRangeIndex, getCreateSQL, getCreateSQLForCopy, getDuplicateKeyException, getDuplicatePrimaryKeyMessage, getIndexColumns, getIndexType, getPlanSQL, getRow, getRowFactory, getType, getUniqueColumnCount, getUniqueRowFactory, isFindUsingFullTableScan, isFirstColumn, isHidden, isRowIdIndex, mayHaveNullDuplicates, removeChildrenAndResources, update
-
Methods inherited from class org.h2.schema.SchemaObject
getSchema, getSQL, getSQL
-
Methods inherited from class org.h2.engine.DbObject
checkRename, getChildren, getComment, getCreateSQLForMeta, getDatabase, getDropSQL, getId, getModificationId, getName, invalidate, isTemporary, isValid, rename, setComment, setModified, setObjectName, setTemporary, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.h2.util.HasSQL
getTraceSQL
-
-
-
-
Field Detail
-
mvTable
final MVTable mvTable
The multi-value table.
-
dataMap
private final TransactionMap<Spatial,Value> dataMap
-
spatialMap
private final MVRTreeMap<VersionedValue<Value>> spatialMap
-
-
Constructor Detail
-
MVSpatialIndex
public MVSpatialIndex(Database db, MVTable table, int id, java.lang.String indexName, IndexColumn[] columns, int uniqueColumnCount, IndexType indexType)
Constructor.- Parameters:
db
- the databasetable
- the table instanceid
- the index idindexName
- the index namecolumns
- the indexed columns (only one geometry column allowed)uniqueColumnCount
- count of unique columns (0 or 1)indexType
- the index type (only spatial index)
-
-
Method Detail
-
addRowsToBuffer
public void addRowsToBuffer(java.util.List<Row> rows, java.lang.String bufferName)
Description copied from class:MVIndex
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.- Specified by:
addRowsToBuffer
in classMVIndex<Spatial,Value>
- Parameters:
rows
- the rowsbufferName
- the name of the temporary storage
-
addBufferedRows
public void addBufferedRows(java.util.List<java.lang.String> bufferNames)
Description copied from class:MVIndex
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.- Specified by:
addBufferedRows
in classMVIndex<Spatial,Value>
- Parameters:
bufferNames
- the names of the temporary storage
-
close
public void close(SessionLocal session)
Description copied from class:Index
Close this index.
-
add
public void add(SessionLocal session, Row row)
Description copied from class:Index
Add a row to the index.
-
remove
public void remove(SessionLocal session, Row row)
Description copied from class:Index
Remove a row from the index.
-
find
public Cursor find(SessionLocal session, SearchRow first, SearchRow last)
Description copied from class:Index
Find a row or a list of rows and create a cursor to iterate over the result.
-
findByGeometry
public Cursor findByGeometry(SessionLocal session, SearchRow first, SearchRow last, SearchRow intersection)
Description copied from interface:SpatialIndex
Find a row or a list of rows and create a cursor to iterate over the result.- Specified by:
findByGeometry
in interfaceSpatialIndex
- Parameters:
session
- the sessionfirst
- the lower boundlast
- the upper boundintersection
- the geometry which values should intersect with, or null for anything- Returns:
- the cursor to iterate over the results
-
getBounds
public Value getBounds(SessionLocal session)
Returns the minimum bounding box that encloses all keys.- Parameters:
session
- the session- Returns:
- the minimum bounding box that encloses all keys, or null
-
getEstimatedBounds
public Value getEstimatedBounds(SessionLocal session)
Returns the estimated minimum bounding box that encloses all keys. The returned value may be incorrect.- Parameters:
session
- the session- Returns:
- the estimated minimum bounding box that encloses all keys, or null
-
getKey
private SpatialKey getKey(SearchRow row)
-
getTable
public MVTable getTable()
Description copied from class:Index
Get the table on which this index is based.
-
getCost
public double getCost(SessionLocal session, int[] masks, TableFilter[] filters, int filter, SortOrder sortOrder, AllColumnsForPlan allColumnsSet)
Description copied from class:Index
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.- Specified by:
getCost
in classIndex
- Parameters:
session
- the sessionmasks
- per-column comparison bit masks, null means 'always false', see constants in IndexConditionfilters
- all joined table filtersfilter
- the current table filter indexsortOrder
- the sort orderallColumnsSet
- the set of all columns- Returns:
- the estimated cost
-
getCostRangeIndex
public static long getCostRangeIndex(int[] masks, Column[] columns)
Compute spatial index cost- Parameters:
masks
- Search maskcolumns
- Table columns- Returns:
- Index cost hint
-
remove
public void remove(SessionLocal session)
Description copied from class:Index
Remove the index.
-
truncate
public void truncate(SessionLocal session)
Description copied from class:Index
Remove all rows from the index.
-
needRebuild
public boolean needRebuild()
Description copied from class:Index
Check if the index needs to be rebuilt. This method is called after opening an index.- Specified by:
needRebuild
in classIndex
- Returns:
- true if a rebuild is required.
-
getRowCount
public long getRowCount(SessionLocal session)
Description copied from class:Index
Get the row count of this table, for the given session.- Specified by:
getRowCount
in classIndex
- Parameters:
session
- the session- Returns:
- the row count
-
getRowCountApproximation
public long getRowCountApproximation(SessionLocal session)
Description copied from class:Index
Get the approximated row count for this table.- Specified by:
getRowCountApproximation
in classIndex
- Parameters:
session
- the session- Returns:
- the approximated row count
-
getDiskSpaceUsed
public long getDiskSpaceUsed()
Description copied from class:Index
Get the used disk space for this index.- Overrides:
getDiskSpaceUsed
in classIndex
- Returns:
- the estimated number of bytes
-
getMap
private TransactionMap<Spatial,Value> getMap(SessionLocal session)
Get the map to store the data.- Parameters:
session
- the session- Returns:
- the map
-
-