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

public final Class MVSecondaryIndex

extends MVIndex<SearchRow, Value>
Class Inheritance
Imports
java.util.Iterator, .List, .Objects, .PriorityQueue, .Queue, org.h2.api.ErrorCode, org.h2.command.query.AllColumnsForPlan, org.h2.engine.Database, .SessionLocal, org.h2.index.Cursor, .IndexType, .SingleRowCursor, org.h2.message.DbException, org.h2.mvstore.MVMap, .MVStore, .MVStoreException, org.h2.mvstore.tx.Transaction, .TransactionMap, .TransactionMap.TMIterator, org.h2.mvstore.type.DataType, org.h2.result.Row, .RowFactory, .SearchRow, .SortOrder, org.h2.table.IndexColumn, .TableFilter, org.h2.value.Value, .ValueNull, .VersionedValue

An index stored in a MVStore.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
private static class

Field Summary

Modifier and TypeField and Description
private final TransactionMap<SearchRow, Value>
private final MVTable
mvTable

The multi-value table.

Constructor Summary

AccessConstructor and Description
public
MVSecondaryIndex(Database db, MVTable table, int id, String indexName, IndexColumn[] columns, int uniqueColumnCount, IndexType indexType)

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 boolean
canFindNext()

Overrides org.h2.index.Index.canFindNext.

Check if the index can get the next higher value.

public boolean
canGetFirstOrLast()

Overrides org.h2.index.Index.canGetFirstOrLast.

Check if the index can directly look up the lowest or highest value of a column.

private void
checkUnique(boolean repeatableRead, TransactionMap<SearchRow, Value> map, SearchRow row, long newKey)

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

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

Close this index.

private SearchRow
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.

private Cursor
find(SessionLocal session, SearchRow first, boolean bigger, SearchRow last, boolean reverse)

public Cursor
findFirstOrLast(SessionLocal
the session
session
,
boolean
true if the first (lowest for ascending indexes) or last value should be returned
first
)

Overrides org.h2.index.Index.findFirstOrLast.

Find the first (or last) value of this index.

public Cursor
findNext(SessionLocal
the session
session
,
SearchRow
the lower limit (excluding)
higherThan
,
SearchRow
the last row, or null for no limit
last
)

Overrides org.h2.index.Index.findNext.

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

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.

private TransactionMap<SearchRow, Value>

Returns:

the map
getMap
(SessionLocal
the session
session
)

Get the map to store the data.

public MVMap<SearchRow, 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.

private MVMap<SearchRow, Value>
openMap(String mapName)

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.

private boolean
public void
truncate(SessionLocal
the session
session
)

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

Remove all rows from the index.

public void
update(SessionLocal
the session
session
,
Row
row before the update
oldRow
,
Row
row after the update
newRow
)

Overrides org.h2.index.Index.update.

Update index after row change.

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

Field Detail

dataMapback to summary
private final TransactionMap<SearchRow, Value> dataMap
mvTableback to summary
private final MVTable mvTable

The multi-value table.

Constructor Detail

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

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
canFindNextback to summary
public boolean canFindNext()

Overrides org.h2.index.Index.canFindNext.

Doc from org.h2.index.Index.canFindNext.

Check if the index can get the next higher value.

Returns:boolean

true if it can

Annotations
@Override
canGetFirstOrLastback to summary
public boolean canGetFirstOrLast()

Overrides org.h2.index.Index.canGetFirstOrLast.

Doc from org.h2.index.Index.canGetFirstOrLast.

Check if the index can directly look up the lowest or highest value of a column.

Returns:boolean

true if it can

Annotations
@Override
checkUniqueback to summary
private void checkUnique(boolean repeatableRead, TransactionMap<SearchRow, Value> map, SearchRow row, long newKey)
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
convertToKeyback to summary
private SearchRow convertToKey(SearchRow r, Boolean minMax)
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
findback to summary
private Cursor find(SessionLocal session, SearchRow first, boolean bigger, SearchRow last, boolean reverse)
findFirstOrLastback to summary
public Cursor findFirstOrLast(SessionLocal session, boolean first)

Overrides org.h2.index.Index.findFirstOrLast.

Doc from org.h2.index.Index.findFirstOrLast.

Find the first (or last) value of this index. The cursor returned is positioned on the correct row, or on null if no row has been found.

Parameters
session:SessionLocal

the session

first:boolean

true if the first (lowest for ascending indexes) or last value should be returned

Returns:Cursor

a cursor (never null)

Annotations
@Override
findNextback to summary
public Cursor findNext(SessionLocal session, SearchRow higherThan, SearchRow last)

Overrides org.h2.index.Index.findNext.

Doc from org.h2.index.Index.findNext.

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

Parameters
session:SessionLocal

the session

higherThan:SearchRow

the lower limit (excluding)

last:SearchRow

the last row, or null for no limit

Returns:Cursor

the cursor

Annotations
@Override
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
getMapback to summary
private TransactionMap<SearchRow, Value> getMap(SessionLocal session)

Get the map to store the data.

Parameters
session:SessionLocal

the session

Returns:TransactionMap<SearchRow, Value>

the map

getMVMapback to summary
public MVMap<SearchRow, 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
openMapback to summary
private MVMap<SearchRow, Value> openMap(String mapName)
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
rowsAreEqualback to summary
private boolean rowsAreEqual(SearchRow rowOne, SearchRow rowTwo)
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
updateback to summary
public void update(SessionLocal session, Row oldRow, Row newRow)

Overrides org.h2.index.Index.update.

Doc from org.h2.index.Index.update.

Update index after row change.

Parameters
session:SessionLocal

the session

oldRow:Row

row before the update

newRow:Row

row after the update

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

pack-priv final Class MVSecondaryIndex.MVStoreCursor

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

A cursor.

Field Summary

Modifier and TypeField and Description
private SearchRow
private final TransactionMap.TMIterator<SearchRow, Value, SearchRow>
private final MVTable
private Row
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 SearchRow current
itback to summary
private final TransactionMap.TMIterator<SearchRow, Value, SearchRow> it
mvTableback to summary
private final MVTable mvTable
rowback to summary
private Row row
sessionback to summary
private final SessionLocal session

Constructor Detail

MVStoreCursorback to summary
pack-priv MVStoreCursor(SessionLocal session, TransactionMap.TMIterator<SearchRow, Value, SearchRow> 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 final Class MVSecondaryIndex.Source

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv SearchRow
private final Iterator<SearchRow>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public SearchRow
next()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

currentRowDataback to summary
pack-priv SearchRow currentRowData
iteratorback to summary
private final Iterator<SearchRow> iterator

Constructor Detail

Sourceback to summary
public Source(Iterator<SearchRow> iterator)

Method Detail

hasNextback to summary
public boolean hasNext()
nextback to summary
public SearchRow next()
org.h2.mvstore.db back to summary

pack-priv final Class MVSecondaryIndex.Source.Comparator

extends Object
implements Comparator<MVSecondaryIndex.Source>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Field Summary

Modifier and TypeField and Description
private final DataType<SearchRow>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
compare(MVSecondaryIndex.Source
the first object to be compared.
one
,
MVSecondaryIndex.Source
the second object to be compared.
two
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

typeback to summary
private final DataType<SearchRow> type

Constructor Detail

Comparatorback to summary
public Comparator(DataType<SearchRow> type)

Method Detail

compareback to summary
public int compare(MVSecondaryIndex.Source one, MVSecondaryIndex.Source two)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
one:MVSecondaryIndex.Source

the first object to be compared.

two:MVSecondaryIndex.Source

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override