Class ReduceIndex

  • All Implemented Interfaces:
    org.h2.engine.DbObject, org.h2.index.Index, org.h2.schema.SchemaObject

    public abstract class ReduceIndex
    extends org.h2.index.BaseIndex
    Merge index.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected Comparator<org.h2.result.SearchRow> firstRowCmp  
      protected Comparator<org.h2.result.SearchRow> lastRowCmp  
      • Fields inherited from class org.h2.index.BaseIndex

        columnIds, columns, indexColumns, indexType, isMultiVersion, table
      • Fields inherited from class org.h2.engine.DbObjectBase

        comment, database, trace
      • Fields inherited from interface org.h2.engine.DbObject

        AGGREGATE, COMMENT, CONSTANT, CONSTRAINT, FUNCTION_ALIAS, INDEX, RIGHT, ROLE, SCHEMA, SEQUENCE, SETTING, SYNONYM, TABLE_OR_VIEW, TRIGGER, USER, USER_DATATYPE
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(org.h2.engine.Session ses, org.h2.result.Row row)
      void addPage​(ReduceResultPage page)  
      protected abstract void addPage0​(ReduceResultPage page)  
      protected static int binarySearchRow​(List<org.h2.result.Row> rows, org.h2.result.SearchRow searchRow, Comparator<org.h2.result.SearchRow> cmp, boolean checkLast)  
      boolean canGetFirstOrLast()
      protected void checkBounds​(org.h2.result.Row lastEvictedRow, org.h2.result.SearchRow first, org.h2.result.SearchRow last)  
      void checkRename()
      void close​(org.h2.engine.Session ses)
      protected ReduceResultPage createDummyLastPage​(ReduceResultPage lastPage)  
      void fail​(UUID nodeId, javax.cache.CacheException e)  
      void fail​(javax.cache.CacheException e)  
      abstract boolean fetchedAll()  
      org.h2.index.Cursor find​(org.h2.engine.Session ses, org.h2.result.SearchRow first, org.h2.result.SearchRow last)
      protected abstract org.h2.index.Cursor findAllFetched​(List<org.h2.result.Row> fetched, @Nullable org.h2.result.SearchRow first, @Nullable org.h2.result.SearchRow last)  
      org.h2.index.Cursor findFirstOrLast​(org.h2.engine.Session ses, boolean first)
      protected abstract org.h2.index.Cursor findInStream​(@Nullable org.h2.result.SearchRow first, @Nullable org.h2.result.SearchRow last)  
      long getDiskSpaceUsed()
      long getRowCount​(org.h2.engine.Session ses)
      long getRowCountApproximation()
      boolean hasSource​(UUID nodeId)  
      static <Z> Z last​(List<Z> l)  
      boolean needRebuild()
      protected Iterator<org.h2.value.Value[]> pollNextIterator​(ReduceIndex.Pollable<ReduceResultPage> queue, Iterator<org.h2.value.Value[]> iter)  
      void remove​(org.h2.engine.Session ses)
      void remove​(org.h2.engine.Session ses, org.h2.result.Row row)
      void setPageSize​(int pageSize)  
      void setSources​(Collection<ClusterNode> nodes, int segmentsCnt)
      Set source nodes.
      Set<UUID> sources()  
      void truncate​(org.h2.engine.Session ses)
      • Methods inherited from class org.h2.index.BaseIndex

        canFindNext, canScan, checkIndexColumnTypes, commit, compareRows, createLookupBatch, find, findNext, getColumnIndex, getColumns, getCostRangeIndex, getCreateSQL, getCreateSQLForCopy, getDropSQL, getDuplicateKeyException, getIndexColumns, getIndexType, getPlanSQL, getRow, getTable, getType, initBaseIndex, isFindUsingFullTableScan, isFirstColumn, isHidden, isRowIdIndex, mayHaveNullDuplicates, removeChildrenAndResources, setSortedInsertMode
      • Methods inherited from class org.h2.schema.SchemaObjectBase

        getSchema, getSQL, initSchemaObjectBase
      • Methods inherited from class org.h2.engine.DbObjectBase

        getChildren, getComment, getDatabase, getId, getModificationId, getName, initDbObjectBase, invalidate, isTemporary, isValid, rename, setComment, setModified, setObjectName, setTemporary, toString
      • Methods inherited from interface org.h2.engine.DbObject

        getChildren, getComment, getDatabase, getId, getName, getSQL, isTemporary, rename, setComment, setTemporary
      • Methods inherited from interface org.h2.index.Index

        getCost
      • Methods inherited from interface org.h2.schema.SchemaObject

        getSchema
    • Field Detail

      • firstRowCmp

        protected final Comparator<org.h2.result.SearchRow> firstRowCmp
      • lastRowCmp

        protected final Comparator<org.h2.result.SearchRow> lastRowCmp
    • Constructor Detail

      • ReduceIndex

        protected ReduceIndex​(GridKernalContext ctx,
                              ReduceTable tbl,
                              String name,
                              org.h2.index.IndexType type,
                              org.h2.table.IndexColumn[] cols)
        Parameters:
        ctx - Context.
        tbl - Table.
        name - Index name.
        type - Type.
        cols - Columns.
      • ReduceIndex

        protected ReduceIndex​(GridKernalContext ctx)
        Parameters:
        ctx - Context.
    • Method Detail

      • sources

        public Set<UUID> sources()
        Returns:
        Return source nodes for this merge index.
      • hasSource

        public boolean hasSource​(UUID nodeId)
        Parameters:
        nodeId - Node ID.
        Returns:
        true If this index needs data from the given source node.
      • getRowCount

        public long getRowCount​(org.h2.engine.Session ses)
      • getRowCountApproximation

        public long getRowCountApproximation()
      • setSources

        public void setSources​(Collection<ClusterNode> nodes,
                               int segmentsCnt)
        Set source nodes.
        Parameters:
        nodes - Nodes.
        segmentsCnt - Index segments per table.
      • setPageSize

        public void setPageSize​(int pageSize)
        Parameters:
        pageSize - Page size.
      • pollNextIterator

        protected final Iterator<org.h2.value.Value[]> pollNextIterator​(ReduceIndex.Pollable<ReduceResultPage> queue,
                                                                        Iterator<org.h2.value.Value[]> iter)
        Parameters:
        queue - Queue to poll.
        iter - Current iterator.
        Returns:
        The same or new iterator.
      • fail

        public void fail​(javax.cache.CacheException e)
        Parameters:
        e - Error.
      • fail

        public void fail​(UUID nodeId,
                         javax.cache.CacheException e)
        Parameters:
        nodeId - Node ID.
        e - Exception.
      • addPage

        public final void addPage​(ReduceResultPage page)
        Parameters:
        page - Page.
      • createDummyLastPage

        protected final ReduceResultPage createDummyLastPage​(ReduceResultPage lastPage)
        Parameters:
        lastPage - Real last page.
        Returns:
        Created dummy page.
      • addPage0

        protected abstract void addPage0​(ReduceResultPage page)
        Parameters:
        page - Page.
      • find

        public final org.h2.index.Cursor find​(org.h2.engine.Session ses,
                                              org.h2.result.SearchRow first,
                                              org.h2.result.SearchRow last)
      • fetchedAll

        public abstract boolean fetchedAll()
        Returns:
        true If we have fetched all the remote rows into a fetched list.
      • checkBounds

        protected void checkBounds​(org.h2.result.Row lastEvictedRow,
                                   org.h2.result.SearchRow first,
                                   org.h2.result.SearchRow last)
        Parameters:
        lastEvictedRow - Last evicted fetched row.
        first - Lower bound.
        last - Upper bound.
      • findInStream

        protected abstract org.h2.index.Cursor findInStream​(@Nullable
                                                            @Nullable org.h2.result.SearchRow first,
                                                            @Nullable
                                                            @Nullable org.h2.result.SearchRow last)
        Parameters:
        first - Lower bound.
        last - Upper bound.
        Returns:
        Cursor. Usually it must be ReduceIndex.FetchingCursor instance.
      • findAllFetched

        protected abstract org.h2.index.Cursor findAllFetched​(List<org.h2.result.Row> fetched,
                                                              @Nullable
                                                              @Nullable org.h2.result.SearchRow first,
                                                              @Nullable
                                                              @Nullable org.h2.result.SearchRow last)
        Parameters:
        fetched - Fetched rows.
        first - Lower bound.
        last - Upper bound.
        Returns:
        Cursor.
      • checkRename

        public void checkRename()
        Specified by:
        checkRename in interface org.h2.engine.DbObject
        Specified by:
        checkRename in class org.h2.engine.DbObjectBase
      • close

        public void close​(org.h2.engine.Session ses)
      • add

        public void add​(org.h2.engine.Session ses,
                        org.h2.result.Row row)
      • remove

        public void remove​(org.h2.engine.Session ses,
                           org.h2.result.Row row)
      • remove

        public void remove​(org.h2.engine.Session ses)
      • truncate

        public void truncate​(org.h2.engine.Session ses)
      • canGetFirstOrLast

        public boolean canGetFirstOrLast()
      • findFirstOrLast

        public org.h2.index.Cursor findFirstOrLast​(org.h2.engine.Session ses,
                                                   boolean first)
      • needRebuild

        public boolean needRebuild()
      • getDiskSpaceUsed

        public long getDiskSpaceUsed()
      • binarySearchRow

        protected static int binarySearchRow​(List<org.h2.result.Row> rows,
                                             org.h2.result.SearchRow searchRow,
                                             Comparator<org.h2.result.SearchRow> cmp,
                                             boolean checkLast)
        Parameters:
        rows - Sorted rows list.
        searchRow - Search row.
        cmp - Comparator.
        checkLast - If we need to optimistically check the last row right away.
        Returns:
        Insertion point for the search row.
      • last

        public static <Z> Z last​(List<Z> l)
        Parameters:
        l - List.
        Returns:
        Last element.