Search in sources :

Example 1 with CacheDataRowStore

use of org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore in project ignite by apache.

the class IgniteCacheOffheapManagerImpl method createCacheDataStore0.

/**
 * @param p Partition.
 * @return Cache data store.
 * @throws IgniteCheckedException If failed.
 */
protected CacheDataStore createCacheDataStore0(int p) throws IgniteCheckedException {
    long rootPage = allocateForTree();
    CacheDataRowStore rowStore = new CacheDataRowStore(grp, grp.freeList(), p);
    String dataTreeName = grp.cacheOrGroupName() + "-" + treeName(p);
    CacheDataTree dataTree = new CacheDataTree(grp, dataTreeName, grp.reuseList(), rowStore, rootPage, true, ctx.diagnostic().pageLockTracker(), FLAG_IDX);
    return new CacheDataStoreImpl(p, rowStore, dataTree, () -> pendingEntries, grp, busyLock, log, null);
}
Also used : CacheDataTree(org.apache.ignite.internal.processors.cache.tree.CacheDataTree) CacheDataRowStore(org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore)

Example 2 with CacheDataRowStore

use of org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore in project ignite by apache.

the class GridCommandHandlerIndexingUtils method breakCacheDataTree.

/**
 * Deleting a rows from the cache without updating indexes.
 *
 * @param log Logger.
 * @param internalCache Cache.
 * @param partId Partition number.
 * @param filter Entry filter.
 */
static <K, V> void breakCacheDataTree(IgniteLogger log, IgniteInternalCache<K, V> internalCache, int partId, @Nullable BiPredicate<Integer, Entry<K, V>> filter) {
    requireNonNull(log);
    requireNonNull(internalCache);
    GridCacheContext<K, V> cacheCtx = internalCache.context();
    CacheDataStore cacheDataStore = cacheCtx.dht().topology().localPartition(partId).dataStore();
    String delegate = "delegate";
    if (hasField(cacheDataStore, delegate))
        cacheDataStore = field(cacheDataStore, delegate);
    CacheDataRowStore cacheDataRowStore = field(cacheDataStore, "rowStore");
    CacheDataTree cacheDataTree = field(cacheDataStore, "dataTree");
    String cacheName = internalCache.name();
    QueryCursor<Entry<K, V>> qryCursor = cacheCtx.kernalContext().grid().cache(cacheName).withKeepBinary().query(new ScanQuery<>(partId));
    Iterator<Entry<K, V>> cacheEntryIter = qryCursor.iterator();
    IgniteCacheDatabaseSharedManager db = cacheCtx.shared().database();
    int cacheId = CU.cacheId(cacheName);
    int i = 0;
    while (cacheEntryIter.hasNext()) {
        Entry<K, V> entry = cacheEntryIter.next();
        if (nonNull(filter) && !filter.test(i++, entry))
            continue;
        db.checkpointReadLock();
        try {
            CacheDataRow oldRow = cacheDataTree.remove(new SearchRow(cacheId, cacheCtx.toCacheKeyObject(entry.getKey())));
            if (nonNull(oldRow))
                cacheDataRowStore.removeRow(oldRow.link(), INSTANCE);
        } catch (IgniteCheckedException e) {
            throw new IgniteException("Failed to remove key skipping indexes: " + entry, e);
        } finally {
            db.checkpointReadUnlock();
        }
    }
}
Also used : CacheDataRow(org.apache.ignite.internal.processors.cache.persistence.CacheDataRow) CacheDataRowStore(org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore) Entry(javax.cache.Cache.Entry) CacheDataStore(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager.CacheDataStore) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) CacheDataTree(org.apache.ignite.internal.processors.cache.tree.CacheDataTree) IgniteException(org.apache.ignite.IgniteException) SearchRow(org.apache.ignite.internal.processors.cache.tree.SearchRow) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)

Aggregations

CacheDataRowStore (org.apache.ignite.internal.processors.cache.tree.CacheDataRowStore)2 CacheDataTree (org.apache.ignite.internal.processors.cache.tree.CacheDataTree)2 Entry (javax.cache.Cache.Entry)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteException (org.apache.ignite.IgniteException)1 CacheDataStore (org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager.CacheDataStore)1 CacheDataRow (org.apache.ignite.internal.processors.cache.persistence.CacheDataRow)1 IgniteCacheDatabaseSharedManager (org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager)1 SearchRow (org.apache.ignite.internal.processors.cache.tree.SearchRow)1