use of org.apache.ignite.internal.processors.cache.tree.SearchRow 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();
}
}
}
Aggregations