use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class QueryEntityValidationSelfTest method testIndexNameDuplicate.
/**
* Test duplicated index name.
*
* @throws Exception If failed.
*/
public void testIndexNameDuplicate() throws Exception {
final CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME);
QueryEntity entity = new QueryEntity();
entity.setKeyType("Key");
entity.setValueType("Value");
LinkedHashMap<String, String> fields = new LinkedHashMap<>();
fields.put("a", Integer.class.getName());
fields.put("b", Integer.class.getName());
entity.setFields(fields);
LinkedHashMap<String, Boolean> idx1Fields = new LinkedHashMap<>();
LinkedHashMap<String, Boolean> idx2Fields = new LinkedHashMap<>();
idx1Fields.put("a", true);
idx1Fields.put("b", true);
QueryIndex idx1 = new QueryIndex().setName("idx").setFields(idx1Fields);
QueryIndex idx2 = new QueryIndex().setName("idx").setFields(idx2Fields);
List<QueryIndex> idxs = new ArrayList<>();
idxs.add(idx1);
idxs.add(idx2);
entity.setIndexes(idxs);
ccfg.setQueryEntities(Collections.singleton(entity));
GridTestUtils.assertThrows(log, new Callable<Void>() {
@Override
public Void call() throws Exception {
grid(0).createCache(ccfg);
return null;
}
}, IgniteCheckedException.class, "Duplicate index name");
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class IgniteSqlNotNullConstraintTest method checkNodeState.
/**
*/
private void checkNodeState(IgniteEx node, String schemaName, String tableName, String fieldName) {
String cacheName = F.eq(schemaName, QueryUtils.DFLT_SCHEMA) ? QueryUtils.createTableCacheName(schemaName, tableName) : schemaName;
DynamicCacheDescriptor desc = node.context().cache().cacheDescriptor(cacheName);
assertNotNull("Cache descriptor not found", desc);
QuerySchema schema = desc.schema();
assertNotNull(schema);
QueryEntity entity = null;
for (QueryEntity e : schema.entities()) {
if (F.eq(tableName, e.getTableName())) {
entity = e;
break;
}
}
assertNotNull(entity);
assertNotNull(entity.getNotNullFields());
assertTrue(entity.getNotNullFields().contains(fieldName));
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class IgniteSqlNotNullConstraintTest method testQueryEntityGetSetNotNullFields.
/**
*/
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());
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlFlagSelfTest method buildCacheConfiguration.
/**
* Creates a cache configuration.
*
* @param name Name of the cache.
* @return Cache configuration.
*/
private CacheConfiguration buildCacheConfiguration(String name) {
if (name.equals(CACHE_ACCOUNT)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_ACCOUNT);
ccfg.setCacheMode(CacheMode.PARTITIONED);
QueryEntity entity = new QueryEntity(Integer.class, Account.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
return ccfg;
}
if (name.equals(CACHE_STOCK)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_STOCK);
ccfg.setCacheMode(CacheMode.REPLICATED);
QueryEntity entity = new QueryEntity(Integer.class, Stock.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
return ccfg;
}
if (name.equals(CACHE_TRADE)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_TRADE);
ccfg.setCacheMode(CacheMode.PARTITIONED);
QueryEntity entity = new QueryEntity(Integer.class, Trade.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
return ccfg;
}
if (name.equals(CACHE_REPORT)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_REPORT);
ccfg.setCacheMode(CacheMode.PARTITIONED);
QueryEntity entity = new QueryEntity(Integer.class, Report.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
return ccfg;
}
if (name.equals(CACHE_LIST)) {
CacheConfiguration ccfg = new CacheConfiguration(CACHE_LIST);
ccfg.setCacheMode(CacheMode.PARTITIONED);
QueryEntity entity = new QueryEntity(Integer.class, String.class);
ccfg.setQueryEntities(Collections.singletonList(entity));
return ccfg;
}
assert false;
return null;
}
use of org.apache.ignite.cache.QueryEntity 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