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

## Class ReuseListImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.persistence.DataStructure
  - - org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList
    - - org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseListImpl

All Implemented Interfaces:
  ReuseList

    public class ReuseListImpl
    extends PagesList
    implements ReuseList

Reuse list.

### Nested Class Summary

### Nested classes/interfaces inherited from class org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList

`PagesList.PagesCache, PagesList.Stripe`

### Field Summary

### Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList

`bucketsSize, changed, DFLT_PAGES_LIST_TRY_LOCK_ATTEMPTS, IGNITE_PAGES_LIST_STRIPES_PER_BUCKET, IGNITE_PAGES_LIST_TRY_LOCK_ATTEMPTS, log, name, pageCacheChanged`

### Fields inherited from class org.apache.ignite.internal.processors.cache.persistence.DataStructure

`grpId, grpName, lockLsnr, metrics, NOOP_LSNR, pageFlag, pageIoRslvr, pageMem, reuseList, rnd, wal`

### Constructor Summary

Constructors
Constructor and Description
`ReuseListImpl(int cacheId, String name, PageMemory pageMem, IgniteWriteAheadLogManager wal, long metaPageId, boolean initNew, PageLockListener lockLsnr, GridKernalContext ctx, AtomicLong pageListCacheLimit, byte pageFlag)`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addForRecycle(ReuseBag bag)`
`protected boolean` `casBucket(int bucket, PagesList.Stripe[] exp, PagesList.Stripe[] upd)`
`protected PagesList.Stripe[]` `getBucket(int bucket)`
`protected PagesList.PagesCache` `getBucketCache(int bucket, boolean create)`
`protected int` `getBucketIndex(int freeSpace)` Gets bucket index by page freespace.
`long` `initRecycledPage(long pageId, byte flag, PageIO initIO)` Converts recycled page id back to a usable id.
`protected boolean` `isReuseBucket(int bucket)`
`long` `recycledPagesCount()`
`long` `takeRecycledPage()`
`String` `toString()`

### Methods inherited from class org.apache.ignite.internal.processors.cache.persistence.freelist.PagesList

`bucketsCount, bucketSize, cachedPagesCount, init, initRecycledPage0, initReusedPage, name, put, removeDataPage, saveMetadata, storedPagesCount, stripesCount, takeEmptyPage`

### Methods inherited from class org.apache.ignite.internal.processors.cache.persistence.DataStructure

`acquirePage, allocatePage, allocatePage, allocatePageNoReuse, groupId, init, needWalDeltaRecord, pageSize, randomInt, read, read, readLock, readUnlock, recyclePage, releasePage, tryWriteLock, write, write, write, write, writeLock, writeUnlock, writeUnlock`

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

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

### Constructor Detail

#### ReuseListImpl

    public ReuseListImpl(int cacheId,
                         String name,
                         PageMemory pageMem,
                         IgniteWriteAheadLogManager wal,
                         long metaPageId,
                         boolean initNew,
                         PageLockListener lockLsnr,
                         GridKernalContext ctx,
                         AtomicLong pageListCacheLimit,
                         byte pageFlag)
                  throws IgniteCheckedException

Parameters:
  `cacheId` - Cache ID.
  `name` - Name (for debug purpose).
  `pageMem` - Page memory.
  `wal` - Write ahead log manager.
  `metaPageId` - Metadata page ID.
  `initNew` - `True` if new metadata should be initialized.
  `pageFlag` - Default flag value for allocated pages.
Throws:
  `IgniteCheckedException` - If failed.

### Method Detail

#### isReuseBucket

    protected boolean isReuseBucket(int bucket)

Specified by:
  `isReuseBucket` in class `PagesList`
Parameters:
  `bucket` - Bucket index.
Returns:
  `true` If it is a reuse bucket.

#### addForRecycle

    public void addForRecycle(ReuseBag bag)
                       throws IgniteCheckedException

Specified by:
  `addForRecycle` in interface `ReuseList`
Parameters:
  `bag` - Reuse bag.
Throws:
  `IgniteCheckedException` - If failed.

#### takeRecycledPage

    public long takeRecycledPage()
                          throws IgniteCheckedException

Specified by:
  `takeRecycledPage` in interface `ReuseList`
Returns:
  Page ID or `0` if none available.
Throws:
  `IgniteCheckedException` - If failed.

#### initRecycledPage

    public long initRecycledPage(long pageId,
                                 byte flag,
                                 PageIO initIO)
                          throws IgniteCheckedException

Converts recycled page id back to a usable id. Might modify page content as well if flag is changing.

Specified by:
  `initRecycledPage` in interface `ReuseList`
Parameters:
  `pageId` - Id of the recycled page.
  `flag` - Flag value for the page. One of `PageIdAllocator.FLAG_DATA`, `PageIdAllocator.FLAG_IDX` or `PageIdAllocator.FLAG_AUX`.
  `initIO` - Page IO to reinit reused page.
Returns:
  Updated page id.
Throws:
  `IgniteCheckedException` - If failed.
See Also:
  `FullPageId`

#### recycledPagesCount

    public long recycledPagesCount()
                            throws IgniteCheckedException

Specified by:
  `recycledPagesCount` in interface `ReuseList`
Returns:
  Number of recycled pages it contains.
Throws:
  `IgniteCheckedException` - If failed.

#### getBucket

    protected PagesList.Stripe[] getBucket(int bucket)

Specified by:
  `getBucket` in class `PagesList`
Parameters:
  `bucket` - Bucket index.
Returns:
  Bucket.

#### getBucketIndex

    protected int getBucketIndex(int freeSpace)

Gets bucket index by page freespace.

Specified by:
  `getBucketIndex` in class `PagesList`
Returns:
  Bucket index or -1 if page doesn't belong to any bucket.

#### casBucket

    protected boolean casBucket(int bucket,
                                PagesList.Stripe[] exp,
                                PagesList.Stripe[] upd)

Specified by:
  `casBucket` in class `PagesList`
Parameters:
  `bucket` - Bucket index.
  `exp` - Expected bucket.
  `upd` - Updated bucket.
Returns:
  `true` If succeeded.

#### getBucketCache

    protected PagesList.PagesCache getBucketCache(int bucket,
                                                  boolean create)

Specified by:
  `getBucketCache` in class `PagesList`
Parameters:
  `bucket` - Bucket index.
Returns:
  Bucket cache.

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

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