Search in sources :

Example 11 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class CacheQueryBuildValueTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setMarshaller(null);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    CacheConfiguration<Object, Object> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
    QueryEntity entity = new QueryEntity();
    entity.setKeyType(Integer.class.getName());
    entity.setValueType(TestBuilderValue.class.getName());
    ArrayList<QueryIndex> idxs = new ArrayList<>();
    QueryIndex idx = new QueryIndex("iVal");
    idxs.add(idx);
    LinkedHashMap<String, String> fields = new LinkedHashMap<>();
    fields.put("iVal", Integer.class.getName());
    entity.setFields(fields);
    entity.setIndexes(idxs);
    ccfg.setQueryEntities(Collections.singleton(entity));
    cfg.setCacheConfiguration(ccfg);
    BinaryConfiguration binaryCfg = new BinaryConfiguration();
    BinaryTypeConfiguration typeCfg = new BinaryTypeConfiguration();
    typeCfg.setTypeName(TestBuilderValue.class.getName());
    binaryCfg.setTypeConfigurations(Collections.singletonList(typeCfg));
    cfg.setBinaryConfiguration(binaryCfg);
    return cfg;
}
Also used : ArrayList(java.util.ArrayList) QueryEntity(org.apache.ignite.cache.QueryEntity) LinkedHashMap(java.util.LinkedHashMap) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) BinaryConfiguration(org.apache.ignite.configuration.BinaryConfiguration) QueryIndex(org.apache.ignite.cache.QueryIndex) BinaryTypeConfiguration(org.apache.ignite.binary.BinaryTypeConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 12 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class IgniteCacheDistributedJoinCollocatedAndNotTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheKeyConfiguration keyCfg = new CacheKeyConfiguration(PersonKey.class.getName(), "affKey");
    cfg.setCacheKeyConfiguration(keyCfg);
    TcpDiscoverySpi spi = ((TcpDiscoverySpi) cfg.getDiscoverySpi());
    spi.setIpFinder(IP_FINDER);
    List<CacheConfiguration> ccfgs = new ArrayList<>();
    {
        CacheConfiguration ccfg = configuration(PERSON_CACHE);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(PersonKey.class.getName());
        entity.setValueType(Person.class.getName());
        entity.addQueryField("id", Integer.class.getName(), null);
        entity.addQueryField("affKey", Integer.class.getName(), null);
        entity.addQueryField("name", String.class.getName(), null);
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    {
        CacheConfiguration ccfg = configuration(ORG_CACHE);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Organization.class.getName());
        entity.addQueryField("name", String.class.getName(), null);
        entity.setIndexes(F.asList(new QueryIndex("name")));
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    {
        CacheConfiguration ccfg = configuration(ACCOUNT_CACHE);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Account.class.getName());
        entity.addQueryField("personId", Integer.class.getName(), null);
        entity.addQueryField("name", String.class.getName(), null);
        entity.setIndexes(F.asList(new QueryIndex("personId"), new QueryIndex("name")));
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    cfg.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
    cfg.setClientMode(client);
    return cfg;
}
Also used : CacheKeyConfiguration(org.apache.ignite.cache.CacheKeyConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ArrayList(java.util.ArrayList) QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 13 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class IgniteCacheDistributedJoinCustomAffinityMapper method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    List<CacheConfiguration> ccfgs = new ArrayList<>();
    {
        CacheConfiguration ccfg = configuration(PERSON_CACHE);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Person.class.getName());
        entity.addQueryField("orgId", Integer.class.getName(), null);
        entity.setIndexes(F.asList(new QueryIndex("orgId")));
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    {
        CacheConfiguration ccfg = configuration(PERSON_CACHE_CUSTOM_AFF);
        ccfg.setAffinityMapper(new TestMapper());
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Person.class.getName());
        entity.addQueryField("orgId", Integer.class.getName(), null);
        entity.setIndexes(F.asList(new QueryIndex("orgId")));
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    {
        CacheConfiguration ccfg = configuration(ORG_CACHE);
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Organization.class.getName());
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    {
        CacheConfiguration ccfg = configuration(ORG_CACHE_REPL_CUSTOM);
        ccfg.setCacheMode(REPLICATED);
        ccfg.setAffinityMapper(new TestMapper());
        QueryEntity entity = new QueryEntity();
        entity.setKeyType(Integer.class.getName());
        entity.setValueType(Organization.class.getName());
        ccfg.setQueryEntities(F.asList(entity));
        ccfgs.add(ccfg);
    }
    cfg.setCacheConfiguration(ccfgs.toArray(new CacheConfiguration[ccfgs.size()]));
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ArrayList(java.util.ArrayList) QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 14 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class IgniteCacheDistributedJoinQueryConditionsTest method organizationEntity.

/**
     * @param idxName Name index flag.
     * @return Entity.
     */
private QueryEntity organizationEntity(boolean idxName) {
    QueryEntity entity = new QueryEntity();
    entity.setKeyType(Integer.class.getName());
    entity.setValueType(Organization.class.getName());
    entity.addQueryField("name", String.class.getName(), null);
    if (idxName) {
        QueryIndex idx = new QueryIndex("name");
        entity.setIndexes(F.asList(idx));
    }
    return entity;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity)

Example 15 with QueryIndex

use of org.apache.ignite.cache.QueryIndex in project ignite by apache.

the class IgniteCacheDistributedJoinQueryConditionsTest method personEntity.

/**
     * @param idxName Name index flag.
     * @param idxOrgId Org ID index flag.
     * @return Entity.
     */
private QueryEntity personEntity(boolean idxName, boolean idxOrgId) {
    QueryEntity entity = new QueryEntity();
    entity.setKeyType(Integer.class.getName());
    entity.setValueType(Person.class.getName());
    entity.addQueryField("orgId", Integer.class.getName(), null);
    entity.addQueryField("name", String.class.getName(), null);
    List<QueryIndex> idxs = new ArrayList<>();
    if (idxName) {
        QueryIndex idx = new QueryIndex("name");
        idxs.add(idx);
    }
    if (idxOrgId) {
        QueryIndex idx = new QueryIndex("orgId");
        idxs.add(idx);
    }
    entity.setIndexes(idxs);
    return entity;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity)

Aggregations

QueryIndex (org.apache.ignite.cache.QueryIndex)69 QueryEntity (org.apache.ignite.cache.QueryEntity)35 LinkedHashMap (java.util.LinkedHashMap)25 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)21 ArrayList (java.util.ArrayList)18 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)16 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)15 Ignite (org.apache.ignite.Ignite)13 IgniteException (org.apache.ignite.IgniteException)8 IgniteSQLException (org.apache.ignite.internal.processors.query.IgniteSQLException)8 HashMap (java.util.HashMap)7 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)7 CacheException (javax.cache.CacheException)6 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)6 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)6 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)5 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 HashSet (java.util.HashSet)4 Map (java.util.Map)4 BinaryObject (org.apache.ignite.binary.BinaryObject)4