<commit_before>package org.apache.ignite.internal.processors.cache;

import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.spi.swapspace.inmemory.*;
import org.apache.ignite.testframework.junits.common.*;

import javax.cache.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;

import static org.apache.ignite.cache.CacheAtomicityMode.*;
import static org.apache.ignite.cache.CacheMode.*;

/**
 */
public class IgniteCacheOffheapEvictQueryTest extends GridCommonAbstractTest {
    /** */
    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);

    /** {@inheritDoc} */
    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
        IgniteConfiguration cfg = super.getConfiguration(gridName);

        TcpDiscoverySpi disco = new TcpDiscoverySpi();

        disco.setIpFinder(ipFinder);

        cfg.setDiscoverySpi(disco);

        cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());

        CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();

        cacheCfg.setCacheMode(PARTITIONED);
        cacheCfg.setAtomicityMode(TRANSACTIONAL);
        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        cacheCfg.setSwapEnabled(true);
        cacheCfg.setBackups(0);
        cacheCfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED);
        cacheCfg.setEvictionPolicy(null);
        cacheCfg.setNearConfiguration(null);

        cacheCfg.setSqlOnheapRowCacheSize(128);

        cacheCfg.setIndexedTypes(
            Integer.class, Integer.class
        );

        cacheCfg.setOffHeapMaxMemory(2000); // Small offheap for evictions from offheap to swap.

        cfg.setCacheConfiguration(cacheCfg);

        return cfg;
    }

    /**
     * @throws Exception If failed.
     */
    public void testEvictAndRemove() throws Exception {
        final int KEYS_CNT = 3000;
        final int THREADS_CNT = 256;

        final IgniteCache<Integer,Integer> c = startGrid().cache(null);

        for (int i = 0; i < KEYS_CNT; i++) {
            c.put(i, i);

            if ((i & 1) == 0)
                c.localEvict(F.asList(i));
        }

        X.println("___ Cache loaded...");

        final CyclicBarrier b = new CyclicBarrier(THREADS_CNT, new Runnable() {
            @Override public void run() {
                X.println("___ go!");
            }
        });

        final AtomicInteger keys = new AtomicInteger(KEYS_CNT);

        IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
            @Override public void run() {
                Random rnd = new GridRandom();

                try {
                    b.await();
                }
                catch (InterruptedException e) {
                    throw new IgniteInterruptedException(e);<commit_msg>#ignite-973 - minor<commit_after>package org.apache.ignite.internal.processors.cache;

import org.apache.ignite.*;
import org.apache.ignite.cache.*;
import org.apache.ignite.cache.query.*;
import org.apache.ignite.configuration.*;
import org.apache.ignite.internal.*;
import org.apache.ignite.internal.util.*;
import org.apache.ignite.internal.util.typedef.*;
import org.apache.ignite.internal.util.typedef.internal.*;
import org.apache.ignite.spi.discovery.tcp.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
import org.apache.ignite.spi.swapspace.inmemory.*;
import org.apache.ignite.testframework.junits.common.*;

import javax.cache.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;

import static org.apache.ignite.cache.CacheAtomicityMode.*;
import static org.apache.ignite.cache.CacheMode.*;

/**
 */
public class IgniteCacheOffheapEvictQueryTest extends GridCommonAbstractTest {
    /** */
    private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);

    /** {@inheritDoc} */
    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
        IgniteConfiguration cfg = super.getConfiguration(gridName);

        TcpDiscoverySpi disco = new TcpDiscoverySpi();

        disco.setIpFinder(ipFinder);

        cfg.setDiscoverySpi(disco);

        cfg.setSwapSpaceSpi(new GridTestSwapSpaceSpi());

        CacheConfiguration<?,?> cacheCfg = defaultCacheConfiguration();

        cacheCfg.setCacheMode(PARTITIONED);
        cacheCfg.setAtomicityMode(TRANSACTIONAL);
        cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
        cacheCfg.setSwapEnabled(true);
        cacheCfg.setBackups(0);
        cacheCfg.setMemoryMode(CacheMemoryMode.ONHEAP_TIERED);
        cacheCfg.setEvictionPolicy(null);
        cacheCfg.setNearConfiguration(null);

        cacheCfg.setSqlOnheapRowCacheSize(128);

        cacheCfg.setIndexedTypes(
            Integer.class, Integer.class
        );

        cacheCfg.setOffHeapMaxMemory(2000); // Small offheap for evictions from offheap to swap.

        cfg.setCacheConfiguration(cacheCfg);

        return cfg;
    }

    /**
     * @throws Exception If failed.
     */
    public void testEvictAndRemove() throws Exception {
        final int KEYS_CNT = 3000;
        final int THREADS_CNT = 50;

        final IgniteCache<Integer,Integer> c = startGrid().cache(null);

        for (int i = 0; i < KEYS_CNT; i++) {
            c.put(i, i);

            if ((i & 1) == 0)
                c.localEvict(F.asList(i));
        }

        X.println("___ Cache loaded...");

        final CyclicBarrier b = new CyclicBarrier(THREADS_CNT, new Runnable() {
            @Override public void run() {
                X.println("___ go!");
            }
        });

        final AtomicInteger keys = new AtomicInteger(KEYS_CNT);

        IgniteInternalFuture<?> fut = multithreadedAsync(new Runnable() {
            @Override public void run() {
                Random rnd = new GridRandom();

                try {
                    b.await();
                }
                catch (InterruptedException e) {
                    throw new IgniteInterruptedException(e);
{'fraction_non_alphanumeric': 0.11313039527487506, 'fraction_numerical': 0.005754959866727245, 'mean_word_length': 2.8019573978123202, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4561329', 'n_tokens_mistral': 1980, 'n_tokens_neox': 1883, 'n_words': 350}