/** * @return Query entity for Organization. */ private static Collection<QueryEntity> organizationQueryEntity() { QueryEntity entity = new QueryEntity(Integer.class, JoinSqlTestHelper.Organization.class); entity.setKeyFieldName("ID"); entity.getFields().put("ID", String.class.getName()); return Collections.singletonList(entity); }
/** * @return Query entity for Organization. */ static Collection<QueryEntity> organizationQueryEntity() { QueryEntity entity = new QueryEntity(String.class, Organization.class); entity.setKeyFieldName("ID"); entity.getFields().put("ID", String.class.getName()); return Collections.singletonList(entity); }
/** * @return Query entity for Organization. */ static Collection<QueryEntity> personQueryEntity() { QueryEntity entity = new QueryEntity(String.class, Person.class); entity.setKeyFieldName("ID"); entity.getFields().put("ID", String.class.getName()); return Collections.singletonList(entity); }
/** * @return Query entity for Organization. */ private static Collection<QueryEntity> organizationQueryEntity() { QueryEntity entity = new QueryEntity(Integer.class, JoinSqlTestHelper.Organization.class); entity.setKeyFieldName("ID"); entity.getFields().put("ID", String.class.getName()); return Collections.singletonList(entity); }
/** * @return Query entity for Person. */ private static Collection<QueryEntity> personQueryEntity() { QueryEntity entity = new QueryEntity(Integer.class, JoinSqlTestHelper.Person.class); entity.setKeyFieldName("ID"); entity.getFields().put("ID", String.class.getName()); return Collections.singletonList(entity); }
/** * Create type metadata for class. * * @param cls Class. * @return Type metadata. */ private static QueryEntity entityForClass(Class cls) { QueryEntity entity = new QueryEntity(Integer.class.getName(), cls.getName()); entity.addQueryField("val", Integer.class.getName(), null); entity.setIndexes(Collections.singletonList(new QueryIndex("val", true))); return entity; }
/** * @param grpName Group name. * @param cacheName Cache name. * @return Person cache configuration. */ private CacheConfiguration personCacheConfiguration(String grpName, String cacheName) { QueryEntity entity = new QueryEntity(); entity.setKeyType(Integer.class.getName()); entity.setValueType(Person.class.getName()); entity.addQueryField("name", String.class.getName(), null); return cacheConfiguration(grpName, cacheName, entity); }
/** * @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; }
/** */ @Test public void testQueryEntityEquals() throws Exception { QueryEntity a = new QueryEntity(); QueryEntity b = new QueryEntity(); assertEquals(a, b); a.setNotNullFields(Collections.singleton("test")); assertFalse(a.equals(b)); b.setNotNullFields(Collections.singleton("test")); assertTrue(a.equals(b)); }
/** * 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); }
@Override public Object call() throws Exception { QueryEntity e = new QueryEntity(); e.setTableName("City"); e.setKeyFields(Collections.singleton("name")); e.setFields(new LinkedHashMap<>(Collections.singletonMap("name", String.class.getName()))); e.setIndexes(Collections.singleton(new QueryIndex("name").setName("idx"))); e.setKeyType("CityKey"); e.setValueType("City"); queryProcessor(client()).dynamicTableCreate("PUBLIC", e, CacheMode.PARTITIONED.name(), null, null, null, null, CacheAtomicityMode.ATOMIC, null, 10, false, false); return null; } }, SchemaOperationException.class, "Index already exists: idx");
/** * @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))); }
/** */ @Test public void testQueryEntityGetSetNotNullFields() throws Exception { QueryEntity qe = new QueryEntity(); assertNull(qe.getNotNullFields()); Set<String> val = Collections.singleton("test"); qe.setNotNullFields(val); assertEquals(val, Collections.singleton("test")); qe.setNotNullFields(null); assertNull(qe.getNotNullFields()); }
/** * @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; }
/** {@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 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; }
/** {@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())); }