org.apache.ignite.internal.processors.cache.persistence

## Class IndexStorageImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.persistence.IndexStorageImpl

All Implemented Interfaces:
  IndexStorage

    public class IndexStorageImpl
    extends Object
    implements IndexStorage

Metadata storage.

### Nested Class Summary

Nested Classes
`static class` `IndexStorageImpl.IndexItem`
`static class` `IndexStorageImpl.MetaStoreInnerIO`
`static class` `IndexStorageImpl.MetaStoreLeafIO`

### Field Summary

Fields
`static int` `MAX_IDX_NAME_LEN` Max index name length (bytes num)
`static int` `RESERVED_IDX_NAME_LEN` Reserved size for index name.

### Constructor Summary

Constructors
Constructor and Description
`IndexStorageImpl(String treeName, PageMemory pageMem, @Nullable IgniteWriteAheadLogManager wal, AtomicLong globalRmvId, int grpId, boolean grpShared, int allocPartId, byte allocSpace, ReuseList reuseList, long rootPageId, boolean initNew, @Nullable FailureProcessor failureProcessor, PageLockTrackerManager pageLockTrackerManager)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`RootPage` `allocateCacheIndex(Integer cacheId, String idxName, int segment)` Allocate page for cache index.
`RootPage` `allocateIndex(String idxName)` Get or allocate initial page for an index.
`static void` `checkIndexName(byte[] idxName)` Checking the name of the index.
`void` `destroy()` Destroy this meta store.
`@Nullable RootPage` `dropCacheIndex(Integer cacheId, String idxName, int segment)` Deallocate index page and remove from tree.
`@Nullable RootPage` `dropIndex(String idxName)` Deallocate index page and remove from tree.
`@Nullable RootPage` `findCacheIndex(Integer cacheId, String idxName, int segment)` Find index root.
`Collection<String>` `getIndexNames()`
`boolean` `nameIsAssosiatedWithCache(String idxName, int cacheId)`
`@Nullable RootPage` `renameCacheIndex(Integer cacheId, String oldIdxName, String newIdxName, int segment)` Renaming the root page of the index tree.

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

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

### Field Detail

#### MAX_IDX_NAME_LEN

    public static final int MAX_IDX_NAME_LEN

Max index name length (bytes num)

See Also:
  Constant Field Values

#### RESERVED_IDX_NAME_LEN

    public static final int RESERVED_IDX_NAME_LEN

Reserved size for index name. Needed for backward compatibility.

See Also:
  Constant Field Values

### Constructor Detail

#### IndexStorageImpl

    public IndexStorageImpl(String treeName,
                            PageMemory pageMem,
                            @Nullable
                            @Nullable IgniteWriteAheadLogManager wal,
                            AtomicLong globalRmvId,
                            int grpId,
                            boolean grpShared,
                            int allocPartId,
                            byte allocSpace,
                            ReuseList reuseList,
                            long rootPageId,
                            boolean initNew,
                            @Nullable
                            @Nullable FailureProcessor failureProcessor,
                            PageLockTrackerManager pageLockTrackerManager)

Parameters:
  `treeName` - Tree name.
  `pageMem` - Page memory.
  `wal` - Write ahead log manager.
  `globalRmvId` - Global remove id.
  `grpId` - Group id.
  `grpShared` - Group shared.
  `allocPartId` - Alloc partition id.
  `allocSpace` - Alloc space.
  `reuseList` - Reuse list.
  `rootPageId` - Root page id.
  `initNew` - If index tree should be (re)created.
  `pageLockTrackerManager` - Page lock tracker manager.

### Method Detail

#### allocateCacheIndex

    public RootPage allocateCacheIndex(Integer cacheId,
                                       String idxName,
                                       int segment)
                                throws IgniteCheckedException

Allocate page for cache index. Index name will be masked if needed.

Specified by:
  `allocateCacheIndex` in interface `IndexStorage`
Parameters:
  `cacheId` - Cache ID.
  `idxName` - Index name.
  `segment` - Segment.
Returns:
  Root page.
Throws:
  `IgniteCheckedException` - If failed.

#### allocateIndex

    public RootPage allocateIndex(String idxName)
                           throws IgniteCheckedException

Get or allocate initial page for an index.

Specified by:
  `allocateIndex` in interface `IndexStorage`
Parameters:
  `idxName` - Index name.
Returns:
  `RootPage` that keeps pageId, allocated flag that shows whether the page was newly allocated, and rootId that is counter which increments each time new page allocated.
Throws:
  `IgniteCheckedException` - If failed.

#### findCacheIndex

    @Nullable
    public @Nullable RootPage findCacheIndex(Integer cacheId,
                                                       String idxName,
                                                       int segment)
                                                throws IgniteCheckedException

Find index root.

Specified by:
  `findCacheIndex` in interface `IndexStorage`
Parameters:
  `cacheId` - Cache ID.
  `idxName` - Index name.
  `segment` - Segment.
Returns:
  Root ID or null if no page was found.
Throws:
  `IgniteCheckedException` - If failed.

#### dropCacheIndex

    @Nullable
    public @Nullable RootPage dropCacheIndex(Integer cacheId,
                                                       String idxName,
                                                       int segment)
                                                throws IgniteCheckedException

Deallocate index page and remove from tree.

Specified by:
  `dropCacheIndex` in interface `IndexStorage`
Parameters:
  `cacheId` - Cache ID.
  `idxName` - Index name.
  `segment` - Segment number.
Returns:
  Root ID or `null` if no page was removed.
Throws:
  `IgniteCheckedException` - If failed.

#### dropIndex

    @Nullable
    public @Nullable RootPage dropIndex(String idxName)
                                           throws IgniteCheckedException

Deallocate index page and remove from tree.

Specified by:
  `dropIndex` in interface `IndexStorage`
Parameters:
  `idxName` - Index name.
Returns:
  Root ID or `null` if no page was removed.
Throws:
  `IgniteCheckedException` - If failed.

#### renameCacheIndex

    @Nullable
    public @Nullable RootPage renameCacheIndex(Integer cacheId,
                                                         String oldIdxName,
                                                         String newIdxName,
                                                         int segment)
                                                  throws IgniteCheckedException

Renaming the root page of the index tree.

Specified by:
  `renameCacheIndex` in interface `IndexStorage`
Parameters:
  `cacheId` - Cache id.
  `oldIdxName` - Old name of the index tree.
  `newIdxName` - New name of the index tree.
  `segment` - Segment index.
Returns:
  Renamed root page of the index tree.
Throws:
  `IgniteCheckedException` - If failed.

#### destroy

    public void destroy()
                 throws IgniteCheckedException

Destroy this meta store.

Specified by:
  `destroy` in interface `IndexStorage`
Throws:
  `IgniteCheckedException` - If failed.

#### getIndexNames

    public Collection<String> getIndexNames()
                                     throws IgniteCheckedException

Specified by:
  `getIndexNames` in interface `IndexStorage`
Returns:
  Index names of all indexes which this storage keeps.
Throws:
  `IgniteCheckedException` - If failed.

#### nameIsAssosiatedWithCache

    public boolean nameIsAssosiatedWithCache(String idxName,
                                             int cacheId)

Specified by:
  `nameIsAssosiatedWithCache` in interface `IndexStorage`
Parameters:
  `idxName` - Index name to check.
  `cacheId` - Cache id to check.
Returns:
  True if the given idxName could be assosiated with the given cacheId (existing is not checked).

#### checkIndexName

    public static void checkIndexName(byte[] idxName)

Checking the name of the index.

Parameters:
  `idxName` - Index name bytes.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.14.0
Release Date | : September 29 2022