use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class GridCacheQuerySqlFieldInlineSizeSelfTest method testSingleFieldIndexes.
/**
* @throws Exception If failed.
*/
public void testSingleFieldIndexes() throws Exception {
CacheConfiguration ccfg = defaultCacheConfiguration();
ccfg.setIndexedTypes(Integer.class, TestValueSingleFieldIndexes.class);
assertEquals(1, ccfg.getQueryEntities().size());
QueryEntity ent = (QueryEntity) ccfg.getQueryEntities().iterator().next();
assertEquals(2, ent.getIndexes().size());
for (QueryIndex idx : ent.getIndexes()) {
if (idx.getFields().containsKey("val0"))
assertEquals(10, idx.getInlineSize());
else if (idx.getFields().containsKey("val1"))
assertEquals(20, idx.getInlineSize());
}
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class ClientCacheConfigurationSerializer method read.
/**
* Reads the cache configuration.
*
* @param reader Reader.
* @return Configuration.
*/
static CacheConfiguration read(BinaryRawReader reader) {
// Skip length.
reader.readInt();
short propCnt = reader.readShort();
CacheConfiguration cfg = new CacheConfiguration();
for (int i = 0; i < propCnt; i++) {
short code = reader.readShort();
switch(code) {
case ATOMICITY_MODE:
cfg.setAtomicityMode(CacheAtomicityMode.fromOrdinal(reader.readInt()));
break;
case BACKUPS:
cfg.setBackups(reader.readInt());
break;
case CACHE_MODE:
cfg.setCacheMode(CacheMode.fromOrdinal(reader.readInt()));
break;
case COPY_ON_READ:
cfg.setCopyOnRead(reader.readBoolean());
break;
case DATA_REGION_NAME:
cfg.setDataRegionName(reader.readString());
break;
case EAGER_TTL:
cfg.setEagerTtl(reader.readBoolean());
break;
case STATISTICS_ENABLED:
cfg.setStatisticsEnabled(reader.readBoolean());
break;
case GROUP_NAME:
cfg.setGroupName(reader.readString());
break;
case DEFAULT_LOCK_TIMEOUT:
cfg.setDefaultLockTimeout(reader.readLong());
break;
case MAX_CONCURRENT_ASYNC_OPERATIONS:
cfg.setMaxConcurrentAsyncOperations(reader.readInt());
break;
case MAX_QUERY_ITERATORS_COUNT:
cfg.setMaxQueryIteratorsCount(reader.readInt());
break;
case NAME:
cfg.setName(reader.readString());
break;
case ONHEAP_CACHE_ENABLED:
cfg.setOnheapCacheEnabled(reader.readBoolean());
break;
case PARTITION_LOSS_POLICY:
cfg.setPartitionLossPolicy(PartitionLossPolicy.fromOrdinal((byte) reader.readInt()));
break;
case QUERY_DETAIL_METRICS_SIZE:
cfg.setQueryDetailMetricsSize(reader.readInt());
break;
case QUERY_PARALLELISM:
cfg.setQueryParallelism(reader.readInt());
break;
case READ_FROM_BACKUP:
cfg.setReadFromBackup(reader.readBoolean());
break;
case REBALANCE_BATCH_SIZE:
cfg.setRebalanceBatchSize(reader.readInt());
break;
case REBALANCE_BATCHES_PREFETCH_COUNT:
cfg.setRebalanceBatchesPrefetchCount(reader.readLong());
break;
case REBALANCE_DELAY:
cfg.setRebalanceDelay(reader.readLong());
break;
case REBALANCE_MODE:
cfg.setRebalanceMode(CacheRebalanceMode.fromOrdinal(reader.readInt()));
break;
case REBALANCE_ORDER:
cfg.setRebalanceOrder(reader.readInt());
break;
case REBALANCE_THROTTLE:
cfg.setRebalanceThrottle(reader.readLong());
break;
case REBALANCE_TIMEOUT:
cfg.setRebalanceTimeout(reader.readLong());
break;
case SQL_ESCAPE_ALL:
cfg.setSqlEscapeAll(reader.readBoolean());
break;
case SQL_INDEX_MAX_INLINE_SIZE:
cfg.setSqlIndexMaxInlineSize(reader.readInt());
break;
case SQL_SCHEMA:
cfg.setSqlSchema(reader.readString());
break;
case WRITE_SYNCHRONIZATION_MODE:
cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.fromOrdinal(reader.readInt()));
break;
case KEY_CONFIGURATION:
int keyCnt = reader.readInt();
if (keyCnt > 0) {
CacheKeyConfiguration[] keys = new CacheKeyConfiguration[keyCnt];
for (int j = 0; j < keyCnt; j++) {
keys[j] = new CacheKeyConfiguration(reader.readString(), reader.readString());
}
cfg.setKeyConfiguration(keys);
}
break;
case QUERY_ENTITIES:
int qryEntCnt = reader.readInt();
if (qryEntCnt > 0) {
Collection<QueryEntity> entities = new ArrayList<>(qryEntCnt);
for (int j = 0; j < qryEntCnt; j++) entities.add(readQueryEntity(reader));
cfg.setQueryEntities(entities);
}
break;
}
}
return cfg;
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class ClientCacheConfigurationSerializer method write.
/**
* Writes the cache configuration.
* @param writer Writer.
* @param cfg Configuration.
*/
static void write(BinaryRawWriterEx writer, CacheConfiguration cfg) {
assert writer != null;
assert cfg != null;
// Reserve for length.
int pos = writer.reserveInt();
writeEnumInt(writer, cfg.getAtomicityMode(), CacheConfiguration.DFLT_CACHE_ATOMICITY_MODE);
writer.writeInt(cfg.getBackups());
writeEnumInt(writer, cfg.getCacheMode(), CacheConfiguration.DFLT_CACHE_MODE);
writer.writeBoolean(cfg.isCopyOnRead());
writer.writeString(cfg.getDataRegionName());
writer.writeBoolean(cfg.isEagerTtl());
writer.writeBoolean(cfg.isStatisticsEnabled());
writer.writeString(cfg.getGroupName());
writer.writeLong(cfg.getDefaultLockTimeout());
writer.writeInt(cfg.getMaxConcurrentAsyncOperations());
writer.writeInt(cfg.getMaxQueryIteratorsCount());
writer.writeString(cfg.getName());
writer.writeBoolean(cfg.isOnheapCacheEnabled());
writer.writeInt(cfg.getPartitionLossPolicy().ordinal());
writer.writeInt(cfg.getQueryDetailMetricsSize());
writer.writeInt(cfg.getQueryParallelism());
writer.writeBoolean(cfg.isReadFromBackup());
writer.writeInt(cfg.getRebalanceBatchSize());
writer.writeLong(cfg.getRebalanceBatchesPrefetchCount());
writer.writeLong(cfg.getRebalanceDelay());
writeEnumInt(writer, cfg.getRebalanceMode(), CacheConfiguration.DFLT_REBALANCE_MODE);
writer.writeInt(cfg.getRebalanceOrder());
writer.writeLong(cfg.getRebalanceThrottle());
writer.writeLong(cfg.getRebalanceTimeout());
writer.writeBoolean(cfg.isSqlEscapeAll());
writer.writeInt(cfg.getSqlIndexMaxInlineSize());
writer.writeString(cfg.getSqlSchema());
writeEnumInt(writer, cfg.getWriteSynchronizationMode());
CacheKeyConfiguration[] keys = cfg.getKeyConfiguration();
if (keys != null) {
writer.writeInt(keys.length);
for (CacheKeyConfiguration key : keys) {
writer.writeString(key.getTypeName());
writer.writeString(key.getAffinityKeyFieldName());
}
} else {
writer.writeInt(0);
}
// noinspection unchecked
Collection<QueryEntity> qryEntities = cfg.getQueryEntities();
if (qryEntities != null) {
writer.writeInt(qryEntities.size());
for (QueryEntity e : qryEntities) writeQueryEntity(writer, e);
} else
writer.writeInt(0);
// Write length (so that part of the config can be skipped).
writer.writeInt(pos, writer.out().position() - pos - 4);
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class CacheClientBinaryQueryExample method createOrganizationQueryEntity.
/**
* Create cache type metadata for {@link Organization}.
*
* @return Cache type metadata.
*/
private static QueryEntity createOrganizationQueryEntity() {
QueryEntity organizationEntity = new QueryEntity();
organizationEntity.setValueType(Organization.class.getName());
organizationEntity.setKeyType(Integer.class.getName());
LinkedHashMap<String, String> fields = new LinkedHashMap<>();
fields.put("name", String.class.getName());
fields.put("address.street", String.class.getName());
organizationEntity.setFields(fields);
organizationEntity.setIndexes(Arrays.asList(new QueryIndex("name")));
return organizationEntity;
}
use of org.apache.ignite.cache.QueryEntity in project ignite by apache.
the class IgniteExcludeInConfigurationTest method testExclude.
/**
* Spring should exclude properties by list and ignore beans with class not existing in classpath.
*/
public void testExclude() throws Exception {
IgniteSpringHelper spring = SPRING.create(false);
Collection<IgniteConfiguration> cfgs = spring.loadConfigurations(cfgLocation, "fileSystemConfiguration", "queryEntities").get1();
assertNotNull(cfgs);
assertEquals(1, cfgs.size());
IgniteConfiguration cfg = cfgs.iterator().next();
assertEquals(1, cfg.getCacheConfiguration().length);
assertTrue(F.isEmpty(cfg.getCacheConfiguration()[0].getQueryEntities()));
assertNull(cfg.getFileSystemConfiguration());
cfgs = spring.loadConfigurations(cfgLocation, "keyType").get1();
assertNotNull(cfgs);
assertEquals(1, cfgs.size());
cfg = cfgs.iterator().next();
assertEquals(1, cfg.getCacheConfiguration().length);
Collection<QueryEntity> queryEntities = cfg.getCacheConfiguration()[0].getQueryEntities();
assertEquals(1, queryEntities.size());
assertNull(queryEntities.iterator().next().getKeyType());
}
Aggregations