/** * Create data transfer object for given cache type metadata. * * @param q Actual cache query entities. */ private VisorQueryEntity(QueryEntity q) { assert q != null; keyType = q.getKeyType(); valType = q.getValueType(); keyFields = toList(q.getKeyFields()); LinkedHashMap<String, String> qryFields = q.getFields(); qryFlds = new LinkedHashMap<>(qryFields); aliases = U.copyMap(q.getAliases()); Collection<QueryIndex> qryIdxs = q.getIndexes(); grps = new ArrayList<>(qryIdxs.size()); for (QueryIndex qryIdx : qryIdxs) grps.add(new VisorQueryIndex(qryIdx)); tblName = q.getTableName(); keyFieldName = q.getKeyFieldName(); valFieldName = q.getValueFieldName(); }
/** * Add validate property to QueryTypeDescriptor. * * @param ctx Kernel context. * @param qryEntity Query entity. * @param d Descriptor. * @param name Field name. * @throws IgniteCheckedException */ private static void addKeyValueValidationProperty(GridKernalContext ctx, QueryEntity qryEntity, QueryTypeDescriptorImpl d, String name, boolean isKey) throws IgniteCheckedException { Map<String, Object> dfltVals = qryEntity.getDefaultFieldValues(); Map<String, Integer> precision = qryEntity.getFieldsPrecision(); Map<String, Integer> scale = qryEntity.getFieldsScale(); String typeName = isKey ? qryEntity.getKeyType() : qryEntity.getValueType(); Object dfltVal = dfltVals.get(name); QueryBinaryProperty prop = buildBinaryProperty( ctx, name, U.classForName(typeName, Object.class, true), d.aliases(), isKey, true, dfltVal, precision == null ? -1 : precision.getOrDefault(name, -1), scale == null ? -1 : scale.getOrDefault(name, -1)); d.addProperty(prop, true, false); }
assert qryEntity != null; writer.writeString(qryEntity.getKeyType()); writer.writeString(qryEntity.getValueType()); writer.writeString(qryEntity.getTableName());
CacheKeyConfiguration newKeyCfg = new CacheKeyConfiguration(newEntity.getKeyType(), affFieldName);
/** * @return Cache configuration for binary marshaller tests. */ final CacheConfiguration binaryCacheConfig() { CacheConfiguration<?,?> cache = defaultCacheConfiguration(); cache.setCacheMode(PARTITIONED); cache.setBackups(1); cache.setWriteSynchronizationMode(FULL_SYNC); QueryEntity e = new QueryEntity(); e.setKeyType(String.class.getName()); e.setValueType("Person"); e.setKeyFieldName(KEY_ALIAS); e.addQueryField(KEY_ALIAS, e.getKeyType(), null); e.addQueryField("id", Integer.class.getName(), null); e.addQueryField("age", Integer.class.getName(), null); e.addQueryField("firstName", String.class.getName(), null); e.addQueryField("lastName", String.class.getName(), null); e.addQueryField("data", byte[].class.getName(), null); cache.setQueryEntities(Collections.singletonList(e)); return cache; }
fields.put("age", Integer.class.getName()); fields.put(entity.getKeyFieldName(), entity.getKeyType()); fields.put(entity.getValueFieldName(), entity.getValueType());
cfg.getQueryEntities(), out, (unused, e) -> { w.writeString(e.getKeyType()); w.writeString(e.getValueType()); w.writeString(e.getTableName());
/** * @return Default cache configuration. */ protected CacheConfiguration<KeyClass, ValueClass> cacheConfiguration() { CacheConfiguration ccfg = new CacheConfiguration().setName(CACHE_NAME); QueryEntity entity = new QueryEntity(); entity.setKeyType(KeyClass.class.getName()); entity.setValueType(ValueClass.class.getName()); entity.setKeyFieldName(FIELD_KEY_ALIAS); entity.addQueryField(FIELD_KEY_ALIAS, entity.getKeyType(), null); entity.addQueryField(FIELD_KEY, Long.class.getName(), null); entity.addQueryField(FIELD_NAME_1_ESCAPED, Long.class.getName(), null); entity.addQueryField(FIELD_NAME_2_ESCAPED, Long.class.getName(), null); entity.setKeyFields(Collections.singleton(FIELD_KEY)); entity.setAliases(Collections.singletonMap(FIELD_NAME_2_ESCAPED, alias(FIELD_NAME_2_ESCAPED))); ccfg.setQueryEntities(Collections.singletonList(entity)); ccfg.setNodeFilter(new NodeFilter()); ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); ccfg.setBackups(1); ccfg.setAffinity(new RendezvousAffinityFunction(false, 128)); return ccfg; }
ccfg.setKeyConfiguration(new CacheKeyConfiguration(entity.getKeyType(), affinityKey));
normalEntity.setKeyType(entity.getKeyType()); normalEntity.setValueType(entity.getValueType()); normalEntity.setFields(entity.getFields());
assertEquals(keyTypeName, e.getKeyType()); else assertTrue(e.getKeyType().startsWith("SQL_PUBLIC")); BinaryObject key = client().binary().builder(e.getKeyType()).setField("ID", 1).build();
ccfg2.setQueryEntities(Collections.singletonList(entity2)); ccfg1.setKeyConfiguration(new CacheKeyConfiguration(entity1.getKeyType(), "k1")); ccfg2.setKeyConfiguration(new CacheKeyConfiguration(entity2.getKeyType(), "ak2"));
String keyType = qryEntity.getKeyType();
/** * Create data transfer object for given cache type metadata. * * @param q Actual cache query entities. */ private VisorQueryEntity(QueryEntity q) { assert q != null; keyType = q.getKeyType(); valType = q.getValueType(); keyFields = toList(q.getKeyFields()); LinkedHashMap<String, String> qryFields = q.getFields(); qryFlds = new LinkedHashMap<>(qryFields); aliases = U.copyMap(q.getAliases()); Collection<QueryIndex> qryIdxs = q.getIndexes(); grps = new ArrayList<>(qryIdxs.size()); for (QueryIndex qryIdx : qryIdxs) grps.add(new VisorQueryIndex(qryIdx)); tblName = q.getTableName(); keyFieldName = q.getKeyFieldName(); valFieldName = q.getValueFieldName(); }
/** * Add validate property to QueryTypeDescriptor. * * @param ctx Kernel context. * @param qryEntity Query entity. * @param d Descriptor. * @param name Field name. * @throws IgniteCheckedException */ private static void addKeyValueValidationProperty(GridKernalContext ctx, QueryEntity qryEntity, QueryTypeDescriptorImpl d, String name, boolean isKey) throws IgniteCheckedException { Map<String, Object> dfltVals = qryEntity.getDefaultFieldValues(); Map<String, Integer> precision = qryEntity.getFieldsPrecision(); Map<String, Integer> scale = qryEntity.getFieldsScale(); String typeName = isKey ? qryEntity.getKeyType() : qryEntity.getValueType(); Object dfltVal = dfltVals.get(name); QueryBinaryProperty prop = buildBinaryProperty( ctx, name, U.classForName(typeName, Object.class, true), d.aliases(), isKey, true, dfltVal, precision == null ? -1 : precision.getOrDefault(name, -1), scale == null ? -1 : scale.getOrDefault(name, -1)); d.addProperty(prop, true, false); }
assert qryEntity != null; writer.writeString(qryEntity.getKeyType()); writer.writeString(qryEntity.getValueType()); writer.writeString(qryEntity.getTableName());
for ( QueryEntity qe : (Collection<QueryEntity>) cacheConfig.getQueryEntities() ) { if ( qe.getValueType() != null && cacheType.equalsIgnoreCase( qe.getValueType() ) ) { result = qe.getKeyType(); break;
CacheKeyConfiguration newKeyCfg = new CacheKeyConfiguration(newEntity.getKeyType(), affFieldName);
ccfg.setKeyConfiguration(new CacheKeyConfiguration(entity.getKeyType(), affinityKey));
normalEntity.setKeyType(entity.getKeyType()); normalEntity.setValueType(entity.getValueType()); normalEntity.setFields(entity.getFields());