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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations