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 Modifier and Type Field Description static Class<? extends IndexesRebuildTask>idxRebuildClsFor tests to emulate long rebuild process.static JavaObjectKeySerializerserializerSerializer 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 Description IndexProcessor(GridKernalContext ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexcreateIndex(GridCacheContext<?,?> cctx, IndexFactory factory, IndexDefinition definition)Creates a new index.IndexcreateIndexDynamically(GridCacheContext cctx, IndexFactory factory, IndexDefinition definition, SchemaIndexCacheVisitor cacheVisitor)Creates a new index.voiddefragment(CacheGroupContext grpCtx, CacheGroupContext newCtx, PageMemoryEx partPageMem, IntMap<LinkMap> mappingByPart, CheckpointTimeoutLock cpLock, Runnable cancellationChecker, IgniteThreadPoolExecutor defragmentationThreadPool)Defragment index partition.voiddestroyOrphanIndex(GridKernalContext ctx, RootPage page, String indexName, int grpId, PageMemory pageMemory, GridAtomicLong removeId, ReuseList reuseList)Destroy founded index which belongs to stopped cache.IndexesRebuildTaskidxRebuild()IndexRowCacheRegistryidxRowCacheRegistry()Index row cache registry.@Nullable Indexindex(IndexName idxName)Returns index for specified name.IndexDefinitionindexDefinition(UUID idxId)Returns IndexDefinition used for creating index specified id.Collection<Index>indexes(String cacheName)Returns collection of indexes for specified cache.IndexKeyTypeSettingskeyTypeSettings()IgniteLoggerlogger()voidmarkRebuildIndexesForCache(GridCacheContext<?,?> cctx, boolean val)Mark/unmark for rebuild indexes for a specific cache.@Nullable IgniteInternalFuture<?>rebuildIndexesForCache(GridCacheContext<?,?> cctx, boolean force, IndexRebuildCancelToken cancelTok)Start rebuild of indexes for specified cache.static voidregisterIO()Register inline IOs for sorted indexes.voidremove(String cacheName, @Nullable CacheDataRow prevRow)Delete specified row from index.voidremoveIndex(IndexName idxName, boolean softDelete)Removes an index.IndexRowCacherowCacheCleaner(int grpId)Index row cache.Map<String,Integer>secondaryIndexesInlineSize()Information about secondary indexes efficient (actual) inline size.voidstore(Collection<? extends Index> idxs, CacheDataRow newRow, @Nullable CacheDataRow prevRow, boolean prevRowAvailable)Updates index with new row.voidstore(GridCacheContext<?,?> cctx, CacheDataRow newRow, @Nullable CacheDataRow prevRow, boolean prevRowAvailable)Updates index with new row.List<InlineIndex>treeIndexes(String cacheName, boolean createdOnly)Collect indexes for rebuild.voidunregisterCache(GridCacheContextInfo cacheInfo)Unregisters cache.booleanuseUnwrappedPk(GridCacheContext<?,?> cctx, String treeName)-
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
-
-
-
-
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
-
registerIO
public static void registerIO()
Register inline IOs for sorted indexes.
-
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(IndexName idxName, boolean softDelete)
Removes an index.- Parameters:
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, IndexRebuildCancelToken cancelTok)
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(String cacheName)
Returns collection of indexes for specified cache.- Parameters:
cacheName- Cache name.- Returns:
- Collection of indexes for specified cache.
-
index
@Nullable public @Nullable Index index(IndexName idxName)
Returns index for specified name.- Parameters:
idxName- Index name.- Returns:
- Index for specified index name or
nullif not found.
-
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) 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.- Throws:
IgniteCheckedException- If failed.
-
keyTypeSettings
public IndexKeyTypeSettings keyTypeSettings()
- Returns:
- Default key type settings.
-
useUnwrappedPk
public boolean useUnwrappedPk(GridCacheContext<?,?> cctx, String treeName)
- Returns:
trueIn case of use an unwrapped PK for the index.
-
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(String cacheName, boolean createdOnly)
Collect indexes for rebuild.- Parameters:
cacheName- Cache name.createdOnly- Get only created indexes (not restored from dick).
-
logger
public IgniteLogger logger()
- Returns:
- Logger.
-
-