use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.
the class AbstractPartitionPruningBaseTest method createCacheTable.
/**
* Create table with the QueryEntity API.
*
* @param name Name.
* @param replicated Replicated table flag.
* @param mvcc MVCC flag.
* @param cols Columns.
*/
private void createCacheTable(String name, boolean replicated, boolean mvcc, Object... cols) {
QueryEntity e = new QueryEntity().setValueType(name).setTableName(name);
List<String> pkCols = new ArrayList<>();
String affCol = null;
for (Object col : cols) {
Column col0 = col instanceof Column ? (Column) col : new Column((String) col);
e.addQueryField(col0.name, String.class.getName(), col0.alias);
if (col0.pk())
pkCols.add(col0.name());
if (col0.affinity()) {
if (affCol != null)
throw new IllegalStateException("Only one affinity column is allowed: " + col0.name());
affCol = col0.name();
pkCols.add(affCol);
}
}
if (pkCols.isEmpty())
throw new IllegalStateException("No PKs!");
e.setKeyFields(new HashSet<>(pkCols));
if (pkCols.size() == 1)
e.setKeyFieldName(pkCols.get(0));
String keyTypeName = pkCols.size() == 1 ? String.class.getName() : name + "_key";
e.setKeyType(keyTypeName);
CacheConfiguration<?, ?> ccfg = new CacheConfiguration<>().setName(name).setSqlSchema(DFLT_SCHEMA).setAtomicityMode(mvcc ? CacheAtomicityMode.TRANSACTIONAL_SNAPSHOT : CacheAtomicityMode.TRANSACTIONAL).setCacheMode(replicated ? CacheMode.REPLICATED : CacheMode.PARTITIONED).setQueryEntities(Collections.singletonList(e));
if (affCol != null)
ccfg.setKeyConfiguration(new CacheKeyConfiguration().setTypeName(keyTypeName).setAffinityKeyFieldName(affCol));
client().createCache(ccfg);
}
use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.
the class IgniteSqlRoutingTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration c = super.getConfiguration(gridName);
c.setMarshaller(new BinaryMarshaller());
List<CacheConfiguration> ccfgs = new ArrayList<>();
CacheConfiguration ccfg = buildCacheConfiguration(gridName);
if (ccfg != null)
ccfgs.add(ccfg);
ccfgs.add(buildCacheConfiguration(CACHE_PERSON));
ccfgs.add(buildCacheConfiguration(CACHE_CALL));
c.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
c.setCacheKeyConfiguration(new CacheKeyConfiguration(CallKey.class));
c.setIncludeEventTypes(EventType.EVTS_ALL);
return c;
}
use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.
the class IgniteSqlSplitterSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(TestKey.class.getName(), "affKey");
cfg.setCacheKeyConfiguration(keyCfg);
cfg.setPeerClassLoadingEnabled(false);
return cfg;
}
use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.
the class IgniteSqlGroupConcatCollocatedTest method getConfiguration.
/**
* {@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;
}
use of org.apache.ignite.cache.CacheKeyConfiguration in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlSelfTest method buildCacheConfiguration.
/**
* Creates cache configuration.
*
* @param name Cache name.
* @return Cache configuration.
*/
private CacheConfiguration buildCacheConfiguration(String name) {
if (name.equals(CACHE_ORG)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_ORG);
ccfg.setCacheMode(CacheMode.PARTITIONED);
QueryEntity entity = new QueryEntity(Integer.class, Organization.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
ccfg.setSqlFunctionClasses(IgniteSqlSkipReducerOnUpdateDmlSelfTest.class);
return ccfg;
}
if (name.equals(CACHE_PERSON)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_PERSON);
ccfg.setCacheMode(CacheMode.PARTITIONED);
QueryEntity entity = new QueryEntity(PersonKey.class, Person.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
ccfg.setKeyConfiguration(new CacheKeyConfiguration(PersonKey.class));
ccfg.setSqlFunctionClasses(IgniteSqlSkipReducerOnUpdateDmlSelfTest.class);
return ccfg;
}
if (name.equals(CACHE_POSITION)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_POSITION);
ccfg.setCacheMode(CacheMode.REPLICATED);
QueryEntity entity = new QueryEntity(Integer.class, Position.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
ccfg.setSqlFunctionClasses(IgniteSqlSkipReducerOnUpdateDmlSelfTest.class);
return ccfg;
}
assert false;
return null;
}
Aggregations