use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class DemoCachesLoadService method cacheCountry.
/**
* Configure cacheCountry.
*/
private static CacheConfiguration cacheCountry() {
CacheConfiguration ccfg = cacheConfiguration(COUNTRY_CACHE_NAME);
// Configure cacheCountry types.
Collection<QueryEntity> qryEntities = new ArrayList<>();
// COUNTRY.
QueryEntity type = new QueryEntity();
qryEntities.add(type);
type.setKeyType(Integer.class.getName());
type.setValueType(Country.class.getName());
// Query fields for COUNTRY.
LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
qryFlds.put("id", "java.lang.Integer");
qryFlds.put("name", "java.lang.String");
qryFlds.put("population", "java.lang.Integer");
type.setFields(qryFlds);
ccfg.setQueryEntities(qryEntities);
return ccfg;
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class DemoCachesLoadService method cacheEmployee.
/**
* Configure cacheEmployee.
*/
private static CacheConfiguration cacheEmployee() {
CacheConfiguration ccfg = cacheConfiguration(EMPLOYEE_CACHE_NAME);
ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
ccfg.setBackups(1);
// Configure cacheEmployee types.
Collection<QueryEntity> qryEntities = new ArrayList<>();
// EMPLOYEE.
QueryEntity type = new QueryEntity();
qryEntities.add(type);
type.setKeyType(Integer.class.getName());
type.setValueType(Employee.class.getName());
// Query fields for EMPLOYEE.
LinkedHashMap<String, String> qryFlds = new LinkedHashMap<>();
qryFlds.put("id", "java.lang.Integer");
qryFlds.put("departmentId", "java.lang.Integer");
qryFlds.put("managerId", "java.lang.Integer");
qryFlds.put("firstName", "java.lang.String");
qryFlds.put("lastName", "java.lang.String");
qryFlds.put("email", "java.lang.String");
qryFlds.put("phoneNumber", "java.lang.String");
qryFlds.put("hireDate", "java.sql.Date");
qryFlds.put("job", "java.lang.String");
qryFlds.put("salary", "java.lang.Double");
type.setFields(qryFlds);
// Indexes for EMPLOYEE.
QueryIndex idx = new QueryIndex();
idx.setName("EMP_NAMES");
idx.setIndexType(QueryIndexType.SORTED);
LinkedHashMap<String, Boolean> indFlds = new LinkedHashMap<>();
indFlds.put("firstName", Boolean.FALSE);
indFlds.put("lastName", Boolean.FALSE);
idx.setFields(indFlds);
Collection<QueryIndex> indexes = new ArrayList<>();
indexes.add(idx);
indexes.add(new QueryIndex("salary", QueryIndexType.SORTED, false, "EMP_SALARY"));
type.setIndexes(indexes);
ccfg.setQueryEntities(qryEntities);
return ccfg;
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class GridIndexingSpiAbstractSelfTest method cacheACfg.
/**
*/
private CacheConfiguration cacheACfg() {
CacheConfiguration<?, ?> cfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
cfg.setName("A");
QueryEntity eA = new QueryEntity(Integer.class.getName(), "A");
eA.setFields(fieldsAA);
QueryEntity eB = new QueryEntity(Integer.class.getName(), "B");
eB.setFields(fieldsAB);
List<QueryEntity> list = new ArrayList<>(2);
list.add(eA);
list.add(eB);
QueryIndex idx = new QueryIndex("txt");
idx.setIndexType(QueryIndexType.FULLTEXT);
eB.setIndexes(Collections.singleton(idx));
cfg.setQueryEntities(list);
return cfg;
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class IgniteCacheQueriesLoadTest1 method getDepositCfg.
/**
* @param parentCfg Parent config.
* @return Configuration.
*/
private static CacheConfiguration<Object, Object> getDepositCfg(CacheConfiguration<Object, Object> parentCfg) {
CacheConfiguration<Object, Object> depositCfg = new CacheConfiguration<>(parentCfg);
depositCfg.setName(DEPOSIT_CACHE);
String strCls = String.class.getCanonicalName();
String dblCls = Double.class.getCanonicalName();
String intCls = Integer.class.getCanonicalName();
LinkedHashMap<String, String> qryFields = new LinkedHashMap<>();
qryFields.put(ID, strCls);
qryFields.put(TRADER_ID, strCls);
qryFields.put(TRADER_LINK, intCls);
qryFields.put(BALANCE, dblCls);
qryFields.put(MARGIN_RATE, dblCls);
qryFields.put(BALANCE_ON_DAY_OPEN, dblCls);
QueryEntity qryEntity = new QueryEntity();
qryEntity.setValueType(DEPOSIT);
qryEntity.setKeyType(strCls);
qryEntity.setFields(qryFields);
qryEntity.setIndexes(Collections.singleton(new QueryIndex(ID, false)));
depositCfg.setQueryEntities(Collections.singleton(qryEntity));
return depositCfg;
}
use of org.apache.ignite.cache.QueryEntity in project YCSB by brianfrankcooper.
the class IgniteSqlClientTest method beforeTest.
/**
*/
@BeforeClass
public static void beforeTest() throws IgniteCheckedException {
IgniteConfiguration igcfg = new IgniteConfiguration();
igcfg.setIgniteInstanceName(SERVER_NODE_NAME);
igcfg.setClientMode(false);
TcpDiscoverySpi disco = new TcpDiscoverySpi();
Collection<String> adders = new LinkedHashSet<>();
adders.add(HOST + ":" + PORTS);
QueryEntity qe = new QueryEntity("java.lang.String", "UserTableType").addQueryField("ycsb_key", "java.lang.String", null).addQueryField("field0", "java.lang.String", null).addQueryField("field1", "java.lang.String", null).addQueryField("field2", "java.lang.String", null).addQueryField("field3", "java.lang.String", null).addQueryField("field4", "java.lang.String", null).addQueryField("field5", "java.lang.String", null).addQueryField("field6", "java.lang.String", null).addQueryField("field7", "java.lang.String", null).addQueryField("field8", "java.lang.String", null).addQueryField("field9", "java.lang.String", null).setKeyFieldName("ycsb_key");
qe.setTableName("usertable");
CacheConfiguration ccfg = new CacheConfiguration().setQueryEntities(Collections.singleton(qe)).setName(DEFAULT_CACHE_NAME);
igcfg.setCacheConfiguration(ccfg);
((TcpDiscoveryVmIpFinder) ipFinder).setAddresses(adders);
disco.setIpFinder(ipFinder);
igcfg.setDiscoverySpi(disco);
igcfg.setNetworkTimeout(2000);
Log4J2Logger logger = new Log4J2Logger(IgniteSqlClientTest.class.getClassLoader().getResource("log4j2.xml"));
igcfg.setGridLogger(logger);
cluster = Ignition.start(igcfg);
cluster.active();
}
Aggregations