/** * */ private static CacheConfiguration createBinCacheConfig() { CacheConfiguration ccfg = cacheConfig("S2P-bin", true, false); QueryEntity e = new QueryEntity(String.class.getName(), "Person"); LinkedHashMap<String, String> flds = new LinkedHashMap<>(); flds.put("id", Integer.class.getName()); flds.put("firstName", String.class.getName()); flds.put("secondName", String.class.getName()); e.setFields(flds); e.setIndexes(Collections.<QueryIndex>emptyList()); ccfg.setQueryEntities(Collections.singletonList(e)); return ccfg; }
/** * @param qryEntity Query entity. * @return Cache configuration. */ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { CacheConfiguration<?, ?> cache = defaultCacheConfiguration(); cache.setBackups(1); cache.setWriteSynchronizationMode(FULL_SYNC); cache.setQueryEntities(Collections.singletonList(qryEntity)); return cache; }
/** * @param idx Node index. * @return Client configuration. * @throws Exception if failed. */ protected IgniteConfiguration clientConfiguration(int idx) throws Exception { QueryEntity e = new QueryEntity(Integer.class.getName(), "Person"); LinkedHashMap<String, String> flds = new LinkedHashMap<>(); flds.put("name", String.class.getName()); e.setFields(flds); return commonConfiguration(idx).setClientMode(true).setCacheConfiguration( new CacheConfiguration<>("idx").setQueryEntities(Collections.singletonList(e)) ); }
/** * @return Cache configuration with query entities - unfortunately, we need this to enable indexing at all. */ private CacheConfiguration cacheConfigurationForIndexing() { CacheConfiguration<?, ?> ccfg = cacheConfiguration(); ccfg.setName(INDEXED_CACHE_NAME); ccfg.setQueryEntities(Collections.singletonList( new QueryEntity() .setKeyType(Integer.class.getName()) .setValueType(Integer.class.getName()) )); return ccfg; }
/** * @param qryEntity Query entity. * @return Cache configuration. */ protected CacheConfiguration cacheConfiguration(QueryEntity qryEntity) { CacheConfiguration<?,?> cache = defaultCacheConfiguration(); cache.setCacheMode(PARTITIONED); cache.setBackups(1); cache.setWriteSynchronizationMode(FULL_SYNC); cache.setQueryEntities(Collections.singletonList(qryEntity)); return cache; }
/** * Test that we can't use cache tables and system views in the same query. */ @Test public void testCacheToViewJoin() throws Exception { Ignite ignite = startGrid(); ignite.createCache(new CacheConfiguration<>().setName(DEFAULT_CACHE_NAME).setQueryEntities( Collections.singleton(new QueryEntity(Integer.class.getName(), String.class.getName())))); assertSqlError("SELECT * FROM \"" + DEFAULT_CACHE_NAME + "\".String JOIN IGNITE.NODES ON 1=1"); }
/** * @param node Ignite instance. * @return Cache. */ private static IgniteCache<Integer, Person> startPeopleCache(Ignite node) { CacheConfiguration<Integer, Person> cacheCfg = new CacheConfiguration<>("people"); QueryEntity qe = new QueryEntity(Integer.class, Person.class); qe.setTableName("people"); cacheCfg.setQueryEntities(Collections.singleton(qe)); cacheCfg.setSqlSchema("PUBLIC"); return node.getOrCreateCache(cacheCfg); }
/** * @return Cache configuration. */ private CacheConfiguration personCache() { CacheConfiguration ccfg = configuration(PERSON_CACHE, 0); // Person cache is replicated. ccfg.setCacheMode(REPLICATED); QueryEntity entity = new QueryEntity(); entity.setKeyType(Integer.class.getName()); entity.setValueType(Person.class.getName()); entity.addQueryField("name", String.class.getName(), null); ccfg.setQueryEntities(F.asList(entity)); return ccfg; }
/** * @param name Cache name. * @param enableOnheapCache Enable on-heal SQL rows cache. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration(String name, boolean enableOnheapCache) { return new CacheConfiguration() .setName(name) .setSqlOnheapCacheEnabled(enableOnheapCache) .setGroupName("group") .setQueryEntities(Collections.singleton( new QueryEntity(Integer.class, Value.class))); }
/** * @param cacheMode Cache mode. * @param atomicityMode Atomicity mode. * @param grpName Cache group name. */ private CacheConfiguration<Integer, Integer> cacheConfiguration(String name, CacheMode cacheMode, CacheAtomicityMode atomicityMode, String grpName) { return new CacheConfiguration<Integer, Integer>() .setName(name) .setCacheMode(cacheMode) .setAtomicityMode(atomicityMode) .setGroupName(grpName) .setQueryEntities(Collections.singletonList(new QueryEntity(Integer.class, Integer.class))); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCacheConfiguration( new CacheConfiguration(CACHE_NAME) .setAffinity(new RendezvousAffinityFunction().setPartitions(8)) .setQueryEntities(Collections.singletonList(new QueryEntity(Key.class, Value.class)))); return cfg; }
/** * @param grpName Group name. * @param cacheName Cache name. * @param queryEntity Query entity. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration(String grpName, String cacheName, QueryEntity queryEntity) { CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setWriteSynchronizationMode(FULL_SYNC); ccfg.setGroupName(grpName); ccfg.setName(cacheName); ccfg.setQueryEntities(F.asList(queryEntity)); return ccfg; }
/** * @param name Cache name. * @param sqlOnheapCacheEnabled sqlOnheapCacheEnabled flag. * @return Cache configuration. */ private CacheConfiguration cacheConfiguration(String name, boolean sqlOnheapCacheEnabled) { return new CacheConfiguration() .setName(name) .setSqlOnheapCacheEnabled(sqlOnheapCacheEnabled) .setDataRegionName(DATA_REGION_NAME) .setAffinity(new RendezvousAffinityFunction(false, 2)) .setQueryEntities(Collections.singleton( new QueryEntity(Integer.class, Value.class))); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { super.beforeTest(); newBarrier(1); ignite.destroyCache(DEFAULT_CACHE_NAME); IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(new CacheConfiguration<Integer, Integer>() .setName(DEFAULT_CACHE_NAME) .setQueryEntities(Collections.singletonList(new QueryEntity(Integer.class, Integer.class))) ); cache.put(100000, 0); }
/** {@inheritDoc} */ @Override protected void beforeTest() throws Exception { System.setProperty(IGNITE_SQL_RETRY_TIMEOUT, "5000"); startGridsMultiThreaded(NODES_COUNT, false); personCache = ignite(0).getOrCreateCache(new CacheConfiguration<String, Person>("pers") .setQueryEntities(JoinSqlTestHelper.personQueryEntity()) ); orgCache = ignite(0).getOrCreateCache(new CacheConfiguration<String, Organization>(ORG) .setCacheMode(CacheMode.REPLICATED) .setQueryEntities(JoinSqlTestHelper.organizationQueryEntity()) ); awaitPartitionMapExchange(); JoinSqlTestHelper.populateDataIntoOrg(orgCache); JoinSqlTestHelper.populateDataIntoPerson(personCache); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); cfg.setCacheConfiguration( new CacheConfiguration(CACHE_NAME) .setAffinity(new RendezvousAffinityFunction().setPartitions(8)) .setQueryEntities(Collections.singletonList(new QueryEntity(Key.class, Value.class)))) .setCacheKeyConfiguration(new CacheKeyConfiguration(Key.class)); return cfg; }
/** * Test don't using PK indexes for table created through cache API. */ @Test public void testIndexesForCachesCreatedThroughCashApi() { String tblName = TestValue.class.getSimpleName(); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setSqlSchema("PUBLIC"); ccfg.setName(tblName); QueryEntity qryEntity = new QueryEntity(TestKey.class, TestValue.class); ccfg.setQueryEntities(F.asList(qryEntity)); node().createCache(ccfg); List<List<?>> results = executeSql("explain SELECT * FROM " + tblName + " WHERE id=1"); assertDontUsingPkIndex(results); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { startGridsMultiThreaded(NODES_COUNT - 1, false); clientMode = true; startGrid(NODES_COUNT); orgCache = ignite(NODES_COUNT).getOrCreateCache(new CacheConfiguration<Integer, JoinSqlTestHelper.Organization>(ORG_CACHE_NAME) .setCacheMode(CacheMode.PARTITIONED) .setQueryEntities(organizationQueryEntity()) ); awaitPartitionMapExchange(); populateDataIntoOrg(); }
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { return super.getConfiguration(igniteInstanceName) .setDataStorageConfiguration(new DataStorageConfiguration()) .setCacheConfiguration(new <String, Person>CacheConfiguration("cache") .setQueryEntities(getIndexCfg()) .setAffinity(new RendezvousAffinityFunction(false, 16))); }
/** {@inheritDoc} */ @Override protected void beforeTestsStarted() throws Exception { super.beforeTestsStarted(); IgniteEx grid = startGrid(getConfiguration(getTestIgniteInstanceName(0)) .setCacheConfiguration(new CacheConfiguration("test") .setQueryEntities(Collections.singletonList(new QueryEntity(Integer.class, Integer.class))))); // add cache template for cache with enabled read-through cache store grid.addCacheConfiguration(new CacheConfiguration<>(CACHE_STORE_TEMPLATE) .setCacheStoreFactory(singletonFactory(new TestCacheStore())).setReadThrough(true)); // add cache template for cache with enabled cache interceptor grid.addCacheConfiguration(new CacheConfiguration<>(CACHE_INTERCEPTOR_TEMPLATE) .setInterceptor(new TestCacheInterceptor())); }