Search in sources :

Example 6 with QueryEntity

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;
}
Also used : ArrayList(java.util.ArrayList) Country(org.apache.ignite.console.demo.model.Country) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 7 with QueryEntity

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;
}
Also used : ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) LinkedHashMap(java.util.LinkedHashMap) Employee(org.apache.ignite.console.demo.model.Employee) QueryIndex(org.apache.ignite.cache.QueryIndex) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 8 with QueryEntity

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;
}
Also used : ArrayList(java.util.ArrayList) QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 9 with QueryEntity

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;
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex) BinaryObject(org.apache.ignite.binary.BinaryObject) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 10 with QueryEntity

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();
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) QueryEntity(org.apache.ignite.cache.QueryEntity) Log4J2Logger(org.apache.ignite.logger.log4j2.Log4J2Logger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) BeforeClass(org.junit.BeforeClass)

Aggregations

QueryEntity (org.apache.ignite.cache.QueryEntity)221 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)115 QueryIndex (org.apache.ignite.cache.QueryIndex)87 LinkedHashMap (java.util.LinkedHashMap)83 ArrayList (java.util.ArrayList)53 Test (org.junit.Test)42 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)41 HashMap (java.util.HashMap)27 HashSet (java.util.HashSet)22 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)21 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)21 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)19 List (java.util.List)18 Ignite (org.apache.ignite.Ignite)18 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 SqlFieldsQuery (org.apache.ignite.cache.query.SqlFieldsQuery)13 Map (java.util.Map)12 BinaryObject (org.apache.ignite.binary.BinaryObject)12 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)12 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)12