Search in sources :

Example 86 with QueryEntity

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

the class IgniteCacheDuplicateEntityConfigurationSelfTest method testClassDuplicatesQueryReverse.

/**
 * @throws Exception If failed.
 */
public void testClassDuplicatesQueryReverse() throws Exception {
    String cacheName = "duplicate";
    CacheConfiguration ccfg = new CacheConfiguration(cacheName);
    QueryEntity entity = new QueryEntity();
    entity.setKeyType(Integer.class.getName());
    entity.setValueType(Person.class.getName());
    LinkedHashMap<String, String> fields = new LinkedHashMap<>();
    fields.put("name", String.class.getName());
    entity.setFields(fields);
    ccfg.setQueryEntities(Arrays.asList(entity));
    ccfg.setIndexedTypes(Integer.class, Person.class);
    try {
        ignite(0).getOrCreateCache(ccfg);
    } finally {
        ignite(0).destroyCache(cacheName);
    }
}
Also used : QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 87 with QueryEntity

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

the class BinarySerializationQuerySelfTest method entityForClass.

/**
 * Create type metadata for class.
 *
 * @param cls Class.
 * @return Type metadata.
 */
private static QueryEntity entityForClass(Class cls) {
    QueryEntity entity = new QueryEntity(Integer.class.getName(), cls.getName());
    entity.addQueryField("val", Integer.class.getName(), null);
    entity.setIndexes(Collections.singletonList(new QueryIndex("val", true)));
    return entity;
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity)

Example 88 with QueryEntity

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

the class IgniteBinaryObjectQueryArgumentsTest method getCacheConfiguration.

/**
 * @param cacheName Cache name.
 * @return Cache config.
 */
protected CacheConfiguration getCacheConfiguration(final String cacheName) {
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    QueryEntity person = new QueryEntity();
    person.setKeyType(TestKey.class.getName());
    person.setValueType(Person.class.getName());
    person.addQueryField("name", String.class.getName(), null);
    ccfg.setQueryEntities(Collections.singletonList(person));
    ccfg.setName(cacheName);
    return ccfg;
}
Also used : QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 89 with QueryEntity

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

the class IgniteCacheAbstractSqlDmlQuerySelfTest method createBinCacheConfig.

/**
 */
private static CacheConfiguration createBinCacheConfig() {
    CacheConfiguration ccfg = cacheConfig("S2P-bin", true, false);
    QueryEntity e = new QueryEntity(String.class.getName(), "Person");
    LinkedHashMap<String, String> flds = new LinkedHashMap<>();
    flds.put("id", Integer.class.getName());
    flds.put("firstName", String.class.getName());
    flds.put("secondName", String.class.getName());
    e.setFields(flds);
    e.setIndexes(Collections.<QueryIndex>emptyList());
    ccfg.setQueryEntities(Collections.singletonList(e));
    return ccfg;
}
Also used : QueryEntity(org.apache.ignite.cache.QueryEntity) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) LinkedHashMap(java.util.LinkedHashMap)

Example 90 with QueryEntity

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

the class IgniteCacheGroupsSqlTest method accountCacheConfiguration.

/**
 * @param grpName Group name.
 * @param cacheName Cache name.
 * @return Account cache configuration.
 */
private CacheConfiguration accountCacheConfiguration(String grpName, String cacheName) {
    QueryEntity entity = new QueryEntity();
    entity.setKeyType(AffinityKey.class.getName());
    entity.setValueType(Account.class.getName());
    entity.addQueryField("personId", Integer.class.getName(), null);
    entity.addQueryField("attr", String.class.getName(), null);
    entity.setIndexes(F.asList(new QueryIndex("personId")));
    return cacheConfiguration(grpName, cacheName, entity);
}
Also used : QueryIndex(org.apache.ignite.cache.QueryIndex) QueryEntity(org.apache.ignite.cache.QueryEntity) AffinityKey(org.apache.ignite.internal.binary.AffinityKey)

Aggregations

QueryEntity (org.apache.ignite.cache.QueryEntity)97 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)59 QueryIndex (org.apache.ignite.cache.QueryIndex)46 LinkedHashMap (java.util.LinkedHashMap)38 ArrayList (java.util.ArrayList)33 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)17 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)12 HashSet (java.util.HashSet)8 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)8 HashMap (java.util.HashMap)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 CacheKeyConfiguration (org.apache.ignite.cache.CacheKeyConfiguration)7 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 BinaryObject (org.apache.ignite.binary.BinaryObject)5 DynamicCacheDescriptor (org.apache.ignite.internal.processors.cache.DynamicCacheDescriptor)5 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)4 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)4 SchemaOperationException (org.apache.ignite.internal.processors.query.schema.SchemaOperationException)4 List (java.util.List)3 Map (java.util.Map)3