org.apache.ignite.internal.cache.query.index

## Class IndexProcessor

- java.lang.Object
- - org.apache.ignite.internal.processors.GridProcessorAdapter
  - - org.apache.ignite.internal.cache.query.index.IndexProcessor

All Implemented Interfaces:
  GridComponent, GridProcessor

    public class IndexProcessor
    extends GridProcessorAdapter

Implementation of IndexingSpi that tracks all cache indexes.

### Nested Class Summary

### Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent

`GridComponent.DiscoveryDataExchangeType`

### Field Summary

Fields
`static Class<? extends IndexesRebuildTask>` `idxRebuildCls` For tests to emulate long rebuild process.
`static JavaObjectKeySerializer` `serializer` Serializer for representing JO as byte array in inline.

### Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`ctx, diagnosticLog, log`

### Constructor Summary

Constructors
Constructor and Description
`IndexProcessor(GridKernalContext ctx)`

### Method Summary

All Methods Instance Methods Concrete Methods
`Index` `createIndex(GridCacheContext<?,?> cctx, IndexFactory factory, IndexDefinition definition)` Creates a new index.
`Index` `createIndexDynamically(GridCacheContext cctx, IndexFactory factory, IndexDefinition definition, SchemaIndexCacheVisitor cacheVisitor)` Creates a new index.
`void` `defragment(CacheGroupContext grpCtx, CacheGroupContext newCtx, PageMemoryEx partPageMem, IntMap<LinkMap> mappingByPart, CheckpointTimeoutLock cpLock, Runnable cancellationChecker, IgniteThreadPoolExecutor defragmentationThreadPool)` Defragment index partition.
`void` `destroyOrphanIndex(GridKernalContext ctx, RootPage page, String indexName, int grpId, PageMemory pageMemory, GridAtomicLong removeId, ReuseList reuseList, boolean mvccEnabled)` Destroy founded index which belongs to stopped cache.
`IndexesRebuildTask` `idxRebuild()`
`IndexRowCacheRegistry` `idxRowCacheRegistry()` Index row cache registry.
`IndexDefinition` `indexDefinition(UUID idxId)` Returns IndexDefinition used for creating index specified id.
`Collection<Index>` `indexes(GridCacheContext<?,?> cctx)` Returns collection of indexes for specified cache.
`IgniteLogger` `logger()`
`void` `markRebuildIndexesForCache(GridCacheContext<?,?> cctx, boolean val)` Mark/unmark for rebuild indexes for a specific cache.
`@Nullable IgniteInternalFuture<?>` `rebuildIndexesForCache(GridCacheContext<?,?> cctx, boolean force)` Start rebuild of indexes for specified cache.
`void` `remove(String cacheName, @Nullable CacheDataRow prevRow)` Delete specified row from index.
`void` `removeIndex(GridCacheContext<?,?> cctx, IndexName idxName, boolean softDelete)` Removes an index.
`IndexRowCache` `rowCacheCleaner(int grpId)` Index row cache.
`void` `store(Collection<? extends Index> idxs, CacheDataRow newRow, @Nullable CacheDataRow prevRow, boolean prevRowAvailable)` Updates index with new row.
`void` `store(GridCacheContext<?,?> cctx, CacheDataRow newRow, @Nullable CacheDataRow prevRow, boolean prevRowAvailable)` Updates index with new row.
`List<InlineIndex>` `treeIndexes(GridCacheContext cctx, boolean createdOnly)` Collect indexes for rebuild.
`void` `unregisterCache(GridCacheContextInfo cacheInfo)` Unregisters cache.

### Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter

`assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, onKernalStart, onKernalStop, onReconnected, printMemoryStats, start, stop, toString, validateNode, validateNode`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### idxRebuildCls

    public static Class<? extends IndexesRebuildTask> idxRebuildCls

For tests to emulate long rebuild process.

#### serializer

    public static JavaObjectKeySerializer serializer

Serializer for representing JO as byte array in inline.

### Constructor Detail

#### IndexProcessor

    public IndexProcessor(GridKernalContext ctx)
                   throws IgniteCheckedException

Parameters:
  `ctx` - Kernal context.
Throws:
  `IgniteCheckedException`

### Method Detail

#### store

    public void store(GridCacheContext<?,?> cctx,
                      CacheDataRow newRow,
                      @Nullable
                      @Nullable CacheDataRow prevRow,
                      boolean prevRowAvailable)
               throws IgniteSpiException

Updates index with new row. Note that key is unique for cache, so if cache contains multiple indexes the key should be removed from indexes other than one being updated.

Parameters:
  `cctx` - Cache context.
  `newRow` - cache row to store in index.
  `prevRow` - optional cache row that will be replaced with new row.
Throws:
  `IgniteSpiException`

#### store

    public void store(Collection<? extends Index> idxs,
                      CacheDataRow newRow,
                      @Nullable
                      @Nullable CacheDataRow prevRow,
                      boolean prevRowAvailable)
               throws IgniteSpiException

Updates index with new row. Note that key is unique for cache, so if cache contains multiple indexes the key should be removed from indexes other than one being updated.

Parameters:
  `idxs` - List of indexes to update.
  `newRow` - cache row to store in index.
  `prevRow` - optional cache row that will be replaced with new row.
Throws:
  `IgniteSpiException`

#### remove

    public void remove(String cacheName,
                       @Nullable
                       @Nullable CacheDataRow prevRow)
                throws IgniteSpiException

Delete specified row from index.

Parameters:
  `cacheName` - Cache name.
  `prevRow` - Cache row to delete from index.
Throws:
  `IgniteSpiException`

#### createIndexDynamically

    public Index createIndexDynamically(GridCacheContext cctx,
                                        IndexFactory factory,
                                        IndexDefinition definition,
                                        SchemaIndexCacheVisitor cacheVisitor)

Creates a new index.

Parameters:
  `cctx` - Cache context.
  `factory` - Index factory.
  `definition` - Description of an index to create.
  `cacheVisitor` - Enable to cancel dynamic index populating.

#### createIndex

    public Index createIndex(GridCacheContext<?,?> cctx,
                             IndexFactory factory,
                             IndexDefinition definition)

Creates a new index.

Parameters:
  `cctx` - Cache context.
  `factory` - Index factory.
  `definition` - Description of an index to create.

#### removeIndex

    public void removeIndex(GridCacheContext<?,?> cctx,
                            IndexName idxName,
                            boolean softDelete)

Removes an index.

Parameters:
  `cctx` - Cache context.
  `idxName` - Index name.
  `softDelete` - whether it's required to delete underlying structures.

#### rowCacheCleaner

    public IndexRowCache rowCacheCleaner(int grpId)

Index row cache.

Parameters:
  `grpId` - Cache group id.
Returns:
  Index row cache.

#### idxRowCacheRegistry

    public IndexRowCacheRegistry idxRowCacheRegistry()

Index row cache registry.

Returns:
  Index row cache registry.

#### markRebuildIndexesForCache

    public void markRebuildIndexesForCache(GridCacheContext<?,?> cctx,
                                           boolean val)

Mark/unmark for rebuild indexes for a specific cache.

#### rebuildIndexesForCache

    @Nullable
    public @Nullable IgniteInternalFuture<?> rebuildIndexesForCache(GridCacheContext<?,?> cctx,
                                                                              boolean force)

Start rebuild of indexes for specified cache.

Parameters:
  `cctx` - Cache context.
  `force` - Force rebuild indexes.
Returns:
  A future of rebuilding cache indexes.

#### idxRebuild

    public IndexesRebuildTask idxRebuild()

#### indexes

    public Collection<Index> indexes(GridCacheContext<?,?> cctx)

Returns collection of indexes for specified cache.

Parameters:
  `cctx` - Cache context.
Returns:
  Collection of indexes for specified cache.

#### indexDefinition

    public IndexDefinition indexDefinition(UUID idxId)

Returns IndexDefinition used for creating index specified id.

Parameters:
  `idxId` - UUID of index.
Returns:
  IndexDefinition used for creating index with id `idxId`.

#### unregisterCache

    public void unregisterCache(GridCacheContextInfo cacheInfo)

Unregisters cache.

Parameters:
  `cacheInfo` - Cache context info.

#### destroyOrphanIndex

    public void destroyOrphanIndex(GridKernalContext ctx,
                                   RootPage page,
                                   String indexName,
                                   int grpId,
                                   PageMemory pageMemory,
                                   GridAtomicLong removeId,
                                   ReuseList reuseList,
                                   boolean mvccEnabled)
                            throws IgniteCheckedException

Destroy founded index which belongs to stopped cache.

Parameters:
  `page` - Root page.
  `indexName` - Index name.
  `grpId` - Group id which contains garbage.
  `pageMemory` - Page memory to work with.
  `removeId` - Global remove id.
  `reuseList` - Reuse list where free pages should be stored.
  `mvccEnabled` - Whether mvcc is enabled.
Throws:
  `IgniteCheckedException` - If failed.

#### defragment

    public void defragment(CacheGroupContext grpCtx,
                           CacheGroupContext newCtx,
                           PageMemoryEx partPageMem,
                           IntMap<LinkMap> mappingByPart,
                           CheckpointTimeoutLock cpLock,
                           Runnable cancellationChecker,
                           IgniteThreadPoolExecutor defragmentationThreadPool)
                    throws IgniteCheckedException

Defragment index partition.

Parameters:
  `grpCtx` - Old group context.
  `newCtx` - New group context.
  `partPageMem` - Partition page memory.
  `mappingByPart` - Mapping page memory.
  `cpLock` - Defragmentation checkpoint read lock.
  `cancellationChecker` - Cancellation checker.
  `defragmentationThreadPool` - Thread pool for defragmentation.
Throws:
  `IgniteCheckedException` - If failed.

#### treeIndexes

    public List<InlineIndex> treeIndexes(GridCacheContext cctx,
                                         boolean createdOnly)

Collect indexes for rebuild.

Parameters:
  `cctx` - Cache context.
  `createdOnly` - Get only created indexes (not restored from dick).

#### logger

    public IgniteLogger logger()

Returns:
  Logger.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.11.0
Release Date | : September 11 2021