org.h2.index
Interface IndexLookupBatch


public interface IndexLookupBatch

Support for asynchronous batched lookups in indexes. The flow is the following: H2 engine will be calling addSearchRows(SearchRow, SearchRow) until method isBatchFull() will return true or there are no more search rows to add. Then method find() will be called to execute batched lookup. Note that a single instance of IndexLookupBatch can be reused for multiple sequential batched lookups, moreover it can be reused for multiple queries for the same prepared statement.

See Also:
Index.createLookupBatch(org.h2.table.TableFilter)

Method Summary
 boolean addSearchRows(SearchRow first, SearchRow last)
          Add search row pair to the batch.
 java.util.List<java.util.concurrent.Future<Cursor>> find()
          Execute batched lookup and return future cursor for each provided search row pair.
 java.lang.String getPlanSQL()
          Get plan for EXPLAIN.
 boolean isBatchFull()
          Check if this batch is full.
 void reset(boolean beforeQuery)
          Reset this batch to clear state.
 

Method Detail

addSearchRows

boolean addSearchRows(SearchRow first,
                      SearchRow last)
Add search row pair to the batch.

Parameters:
first - the first row, or null for no limit
last - the last row, or null for no limit
Returns:
false if this search row pair is known to produce no results and thus the given row pair was not added
See Also:
Index.find(org.h2.table.TableFilter, SearchRow, SearchRow)

isBatchFull

boolean isBatchFull()
Check if this batch is full.

Returns:
true If batch is full, will not accept any more rows and find() can be executed.

find

java.util.List<java.util.concurrent.Future<Cursor>> find()
Execute batched lookup and return future cursor for each provided search row pair. Note that this method must return exactly the same number of future cursors in result list as number of addSearchRows(SearchRow, SearchRow) calls has been done before find() call exactly in the same order.

Returns:
List of future cursors for collected search rows.

getPlanSQL

java.lang.String getPlanSQL()
Get plan for EXPLAIN.

Returns:
plan

reset

void reset(boolean beforeQuery)
Reset this batch to clear state. This method will be called before and after each query execution.

Parameters:
beforeQuery - if it is being called before query execution