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

## Class GridCacheOffheapManager.GridCacheDataStore

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

All Implemented Interfaces:
  `IgniteCacheOffheapManager.CacheDataStore`

Enclosing class:
  GridCacheOffheapManager

    public static class GridCacheOffheapManager.GridCacheDataStore
    extends Object
    implements IgniteCacheOffheapManager.CacheDataStore

### Constructor Summary

Constructors
`GridCacheDataStore​(CacheGroupContext grp, int partId, boolean exists, GridSpinBusyLock busyLock, IgniteLogger log)`

### Method Summary

All Methods Instance Methods Concrete Methods
`long` `cacheSize​(int cacheId)`
`Map<Integer,​Long>` `cacheSizes()`
`void` `clear​(int cacheId)` Clears all the records associated with logical cache with given ID.
`CacheDataRow` `createRow​(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, @Nullable CacheDataRow oldRow)`
`GridCursor<? extends CacheDataRow>` `cursor()`
`GridCursor<? extends CacheDataRow>` `cursor​(int cacheId)`
`GridCursor<? extends CacheDataRow>` `cursor​(int cacheId, KeyCacheObject lower, KeyCacheObject upper)`
`GridCursor<? extends CacheDataRow>` `cursor​(int cacheId, KeyCacheObject lower, KeyCacheObject upper, Object x)`
`GridCursor<? extends CacheDataRow>` `cursor​(Object x)`
`void` `destroy()` Destroys the tree associated with the store.
`boolean` `destroyed()`
`long` `expiredSize()` Gets the number of entries pending expire.
`GridLongList` `finalizeUpdateCounters()` Flushes pending update counters closing all possible gaps.
`CacheDataRow` `find​(GridCacheContext cctx, KeyCacheObject key)`
`long` `fullSize()`
`long` `getAndIncrementUpdateCounter​(long delta)` Returns current value and updates counter by delta.
`AbstractFreeList<CacheDataRow>` `getCacheStoreFreeList()`
`boolean` `hasEntriesPendingExpire​(int cacheId)` Checks if the cache has entries pending expire.
`long` `highestAppliedCounter()`
`boolean` `init()` Initialize data store if it exists.
`long` `initialUpdateCounter()`
`void` `insertRows​(Collection<DataRowCacheAware> rows, IgnitePredicateX<CacheDataRow> initPred)` Insert rows into page memory.
`void` `invoke​(GridCacheContext cctx, KeyCacheObject key, IgniteCacheOffheapManager.OffheapInvokeClosure c)`
`boolean` `isEmpty()`
`void` `markDestroyed()` Mark store as destroyed.
`long` `nextUpdateCounter()`
`int` `partId()`
`PartitionMetaStorage<SimpleDataRow>` `partStorage()` Partition storage.
`PartitionUpdateCounter` `partUpdateCounter()`
`PendingEntriesTree` `pendingTree()` Return PendingTree for data store.
`void` `preload()` Preload a store into page memory.
`int` `purgeExpired​(GridCacheContext cctx, IgniteInClosure2X<GridCacheEntryEx,​GridCacheVersion> c, long throttlingTimeout, int amount)` Try to remove expired entries from data store.
`void` `remove​(GridCacheContext cctx, KeyCacheObject key, int partId)`
`long` `reserve​(long delta)`
`long` `reservedCounter()`
`void` `resetInitialUpdateCounter()` Reset the initial value of the partition counter.
`void` `resetUpdateCounter()` Reset counter for partition.
`RowStore` `rowStore()`
`void` `setRowCacheCleaner​(GridQueryRowCacheCleaner rowCacheCleaner)` Inject rows cache cleaner.
`CacheDataTree` `tree()`
`void` `update​(GridCacheContext cctx, KeyCacheObject key, CacheObject val, GridCacheVersion ver, long expireTime, @Nullable CacheDataRow oldRow)`
`long` `updateCounter()`
`void` `updateCounter​(long val)`
`boolean` `updateCounter​(long start, long delta)` Updates counters from start value by delta value.
`void` `updateInitialCounter​(long start, long delta)`
`void` `updateSize​(int cacheId, long delta)` Updates size metric for particular cache.

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

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

### Constructor Detail

#### GridCacheDataStore

    public GridCacheDataStore​(CacheGroupContext grp,
                              int partId,
                              boolean exists,
                              GridSpinBusyLock busyLock,
                              IgniteLogger log)

Parameters:
  `partId` - Partition.
  `exists` - `True` if store exists.

### Method Detail

#### getCacheStoreFreeList

    public AbstractFreeList<CacheDataRow> getCacheStoreFreeList()

#### tree

    public CacheDataTree tree()

Specified by:
  `tree` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Cache data tree object.

#### init

    public boolean init()

Initialize data store if it exists.

Specified by:
  `init` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  `True` if initialized.

#### partId

    public int partId()

Specified by:
  `partId` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Partition ID.

#### rowStore

    public RowStore rowStore()

Specified by:
  `rowStore` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Row store.

#### fullSize

    public long fullSize()

Specified by:
  `fullSize` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Total size.

#### isEmpty

    public boolean isEmpty()

Specified by:
  `isEmpty` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  `True` if there are no items in the store.

#### cacheSize

    public long cacheSize​(int cacheId)

Specified by:
  `cacheSize` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cacheId` - Cache ID.
Returns:
  Size.

#### cacheSizes

    public Map<Integer,​Long> cacheSizes()

Specified by:
  `cacheSizes` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Cache sizes if store belongs to group containing multiple caches.

#### updateSize

    public void updateSize​(int cacheId,
                           long delta)

Updates size metric for particular cache.

Specified by:
  `updateSize` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cacheId` - Cache ID.
  `delta` - Size delta.

#### updateCounter

    public long updateCounter()

Specified by:
  `updateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Update counter (LWM).

#### highestAppliedCounter

    public long highestAppliedCounter()

Specified by:
  `highestAppliedCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Highest applied update counter.

#### reservedCounter

    public long reservedCounter()

Specified by:
  `reservedCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Reserved counter (HWM).

#### partUpdateCounter

    public PartitionUpdateCounter partUpdateCounter()

Specified by:
  `partUpdateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Update counter or `null` if store is not yet created.

#### getAndIncrementUpdateCounter

    public long getAndIncrementUpdateCounter​(long delta)

Returns current value and updates counter by delta.

Specified by:
  `getAndIncrementUpdateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `delta` - Delta.
Returns:
  Current value.

#### reserve

    public long reserve​(long delta)

Specified by:
  `reserve` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `delta` - Delta.

#### updateCounter

    public void updateCounter​(long val)

Specified by:
  `updateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `val` - Update counter.

#### updateCounter

    public boolean updateCounter​(long start,
                                 long delta)

Updates counters from start value by delta value.

Specified by:
  `updateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `start` - Start.
  `delta` - Delta.

#### finalizeUpdateCounters

    public GridLongList finalizeUpdateCounters()

Flushes pending update counters closing all possible gaps.

Specified by:
  `finalizeUpdateCounters` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Even-length array of pairs [start, end] for each gap.

#### nextUpdateCounter

    public long nextUpdateCounter()

Specified by:
  `nextUpdateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Next update counter.

#### initialUpdateCounter

    public long initialUpdateCounter()

Specified by:
  `initialUpdateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Initial update counter.

#### updateInitialCounter

    public void updateInitialCounter​(long start,
                                     long delta)

Specified by:
  `updateInitialCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `start` - Counter.
  `delta` - Delta.

#### setRowCacheCleaner

    public void setRowCacheCleaner​(GridQueryRowCacheCleaner rowCacheCleaner)

Inject rows cache cleaner.

Specified by:
  `setRowCacheCleaner` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `rowCacheCleaner` - Rows cache cleaner.

#### update

    public void update​(GridCacheContext cctx,
                       KeyCacheObject key,
                       CacheObject val,
                       GridCacheVersion ver,
                       long expireTime,
                       @Nullable
                       @Nullable CacheDataRow oldRow)
                throws IgniteCheckedException

Specified by:
  `update` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
  `val` - Value.
  `ver` - Version.
  `expireTime` - Expire time.
  `oldRow` - Old row if available.
Throws:
  `IgniteCheckedException` - If failed.

#### createRow

    public CacheDataRow createRow​(GridCacheContext cctx,
                                  KeyCacheObject key,
                                  CacheObject val,
                                  GridCacheVersion ver,
                                  long expireTime,
                                  @Nullable
                                  @Nullable CacheDataRow oldRow)
                           throws IgniteCheckedException

Specified by:
  `createRow` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
  `val` - Value.
  `ver` - Version.
  `expireTime` - Expire time.
  `oldRow` - Old row.
Returns:
  New row.
Throws:
  `IgniteCheckedException` - If failed.

#### insertRows

    public void insertRows​(Collection<DataRowCacheAware> rows,
                           IgnitePredicateX<CacheDataRow> initPred)
                    throws IgniteCheckedException

Insert rows into page memory.

Specified by:
  `insertRows` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `rows` - Rows.
  `initPred` - Applied to all rows. Each row that not matches the predicate is removed.
Throws:
  `IgniteCheckedException` - If failed.

#### invoke

    public void invoke​(GridCacheContext cctx,
                       KeyCacheObject key,
                       IgniteCacheOffheapManager.OffheapInvokeClosure c)
                throws IgniteCheckedException

Specified by:
  `invoke` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
  `c` - Closure.
Throws:
  `IgniteCheckedException` - If failed.

#### remove

    public void remove​(GridCacheContext cctx,
                       KeyCacheObject key,
                       int partId)
                throws IgniteCheckedException

Specified by:
  `remove` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
  `partId` - Partition number.
Throws:
  `IgniteCheckedException` - If failed.

#### find

    public CacheDataRow find​(GridCacheContext cctx,
                             KeyCacheObject key)
                      throws IgniteCheckedException

Specified by:
  `find` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cctx` - Cache context.
  `key` - Key.
Returns:
  Data row.
Throws:
  `IgniteCheckedException` - If failed.

#### cursor

    public GridCursor<? extends CacheDataRow> cursor()
                                              throws IgniteCheckedException

Specified by:
  `cursor` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  Data cursor.
Throws:
  `IgniteCheckedException` - If failed.

#### cursor

    public GridCursor<? extends CacheDataRow> cursor​(Object x)
                                              throws IgniteCheckedException

Specified by:
  `cursor` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `x` - Implementation specific argument, `null` always means that we need to return full detached data row.
Returns:
  Data cursor.
Throws:
  `IgniteCheckedException` - If failed.

#### cursor

    public GridCursor<? extends CacheDataRow> cursor​(int cacheId,
                                                     KeyCacheObject lower,
                                                     KeyCacheObject upper)
                                              throws IgniteCheckedException

Specified by:
  `cursor` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cacheId` - Cache ID.
  `lower` - Lower bound.
  `upper` - Upper bound.
Returns:
  Data cursor.
Throws:
  `IgniteCheckedException` - If failed.

#### cursor

    public GridCursor<? extends CacheDataRow> cursor​(int cacheId,
                                                     KeyCacheObject lower,
                                                     KeyCacheObject upper,
                                                     Object x)
                                              throws IgniteCheckedException

Specified by:
  `cursor` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cacheId` - Cache ID.
  `lower` - Lower bound.
  `upper` - Upper bound.
  `x` - Implementation specific argument, `null` always means that we need to return full detached data row.
Returns:
  Data cursor.
Throws:
  `IgniteCheckedException` - If failed.

#### destroy

    public void destroy()
                 throws IgniteCheckedException

Destroys the tree associated with the store.

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

#### markDestroyed

    public void markDestroyed()
                       throws IgniteCheckedException

Mark store as destroyed.

Specified by:
  `markDestroyed` in interface `IgniteCacheOffheapManager.CacheDataStore`
Throws:
  `IgniteCheckedException`

#### destroyed

    public boolean destroyed()

Specified by:
  `destroyed` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  `true` If marked as destroyed.

#### cursor

    public GridCursor<? extends CacheDataRow> cursor​(int cacheId)
                                              throws IgniteCheckedException

Specified by:
  `cursor` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cacheId` - Cache ID.
Returns:
  Data cursor.
Throws:
  `IgniteCheckedException` - If failed.

#### clear

    public void clear​(int cacheId)
               throws IgniteCheckedException

Clears all the records associated with logical cache with given ID.

Specified by:
  `clear` in interface `IgniteCacheOffheapManager.CacheDataStore`
Parameters:
  `cacheId` - Cache ID.
Throws:
  `IgniteCheckedException` - If failed.

#### expiredSize

    public long expiredSize()
                     throws IgniteCheckedException

Gets the number of entries pending expire.

Returns:
  Number of pending entries.
Throws:
  `IgniteCheckedException` - If failed to get number of pending entries.

#### hasEntriesPendingExpire

    public boolean hasEntriesPendingExpire​(int cacheId)
                                    throws IgniteCheckedException

Checks if the cache has entries pending expire.

Returns:
  `True` if there are entries pending expire.
Throws:
  `IgniteCheckedException` - If failed to get number of pending entries.

#### purgeExpired

    public int purgeExpired​(GridCacheContext cctx,
                            IgniteInClosure2X<GridCacheEntryEx,​GridCacheVersion> c,
                            long throttlingTimeout,
                            int amount)
                     throws IgniteCheckedException

Try to remove expired entries from data store.

Parameters:
  `cctx` - Cache context.
  `c` - Expiry closure that should be applied to expired entry. See `GridCacheTtlManager` for details.
  `amount` - Limit of processed entries by single call, `-1` for no limit.
Returns:
  cleared entries count.
Throws:
  `IgniteCheckedException` - If failed.

#### pendingTree

    public PendingEntriesTree pendingTree()

Return PendingTree for data store.

Specified by:
  `pendingTree` in interface `IgniteCacheOffheapManager.CacheDataStore`
Returns:
  PendingTree instance.

#### preload

    public void preload()
                 throws IgniteCheckedException

Preload a store into page memory.

Specified by:
  `preload` in interface `IgniteCacheOffheapManager.CacheDataStore`
Throws:
  `IgniteCheckedException` - If failed.

#### resetUpdateCounter

    public void resetUpdateCounter()

Reset counter for partition.

Specified by:
  `resetUpdateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`

#### resetInitialUpdateCounter

    public void resetInitialUpdateCounter()

Reset the initial value of the partition counter.

Specified by:
  `resetInitialUpdateCounter` in interface `IgniteCacheOffheapManager.CacheDataStore`

#### partStorage

    public PartitionMetaStorage<SimpleDataRow> partStorage()

Description copied from interface: `IgniteCacheOffheapManager.CacheDataStore`
Partition storage.

Specified by:
  `partStorage` in interface `IgniteCacheOffheapManager.CacheDataStore`