/** Serialization constructor. */ QueryField(QueryEntity e, Map.Entry<String, String> nameAndTypeName) { name = nameAndTypeName.getKey(); typeName = nameAndTypeName.getValue(); Set<String> keys = e.getKeyFields(); Set<String> notNulls = e.getNotNullFields(); Map<String, Object> dflts = e.getDefaultFieldValues(); Map<String, Integer> fldsPrecision = e.getFieldsPrecision(); Map<String, Integer> fldsScale = e.getFieldsScale(); isKey = keys != null && keys.contains(name); isNotNull = notNulls != null && notNulls.contains(name); dfltVal = dflts == null ? null : dflts.get(name); precision = fldsPrecision == null ? -1 : fldsPrecision.getOrDefault(name, -1); scale = fldsScale == null? -1 : fldsScale.getOrDefault(name, -1); }
/** * 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(); }
/** * Checks if given column can be removed from table using its {@link QueryEntity}. * * @param entity Query entity. * @param fieldName Name of the field of the key or value object. * @param colName Name of the column. * @return {@code null} if it's OK to remove the column and exception otherwise. */ public static SchemaOperationException validateDropColumn(QueryEntity entity, String fieldName, String colName) { if (F.eq(fieldName, entity.getKeyFieldName()) || KEY_FIELD_NAME.equalsIgnoreCase(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because it represents an entire cache key"); if (F.eq(fieldName, entity.getValueFieldName()) || VAL_FIELD_NAME.equalsIgnoreCase(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because it represents an entire cache value"); Set<String> keyFields = entity.getKeyFields(); if (keyFields != null && keyFields.contains(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because it is a part of a cache key"); Collection<QueryIndex> indexes = entity.getIndexes(); if (indexes != null) { for (QueryIndex idxDesc : indexes) { if (idxDesc.getFields().containsKey(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because an index exists (\"" + idxDesc.getName() + "\") that uses the column."); } } return null; }
throws IgniteCheckedException { LinkedHashMap<String, String> fields = qryEntity.getFields(); Set<String> keyFields = qryEntity.getKeyFields(); Set<String> notNulls = qryEntity.getNotNullFields(); Map<String, Object> dlftVals = qryEntity.getDefaultFieldValues();
Set<String> keyFields = qryEntity.getKeyFields(); Set<String> notNullFields = qryEntity.getNotNullFields(); Map<String, Object> defVals = qryEntity.getDefaultFieldValues();
normalEntity.setValueType(entity.getValueType()); normalEntity.setFields(entity.getFields()); normalEntity.setKeyFields(entity.getKeyFields()); normalEntity.setKeyFieldName(entity.getKeyFieldName()); normalEntity.setValueFieldName(entity.getValueFieldName());
String affField0 = field.name(); if (!F.isEmpty(qryEntity.getKeyFields()) && qryEntity.getKeyFields().contains(affField0)) { affField = affField0;
/** Serialization constructor. */ QueryField(QueryEntity e, Map.Entry<String, String> nameAndTypeName) { name = nameAndTypeName.getKey(); typeName = nameAndTypeName.getValue(); Set<String> keys = e.getKeyFields(); Set<String> notNulls = e.getNotNullFields(); Map<String, Object> dflts = e.getDefaultFieldValues(); Map<String, Integer> fldsPrecision = e.getFieldsPrecision(); Map<String, Integer> fldsScale = e.getFieldsScale(); isKey = keys != null && keys.contains(name); isNotNull = notNulls != null && notNulls.contains(name); dfltVal = dflts == null ? null : dflts.get(name); precision = fldsPrecision == null ? -1 : fldsPrecision.getOrDefault(name, -1); scale = fldsScale == null? -1 : fldsScale.getOrDefault(name, -1); }
throws IgniteCheckedException { LinkedHashMap<String, String> fields = qryEntity.getFields(); Set<String> keyFields = qryEntity.getKeyFields(); Set<String> notNulls = qryEntity.getNotNullFields(); Map<String, Object> dlftVals = qryEntity.getDefaultFieldValues();
/** * 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(); }
/** * Checks if given column can be removed from table using its {@link QueryEntity}. * * @param entity Query entity. * @param fieldName Name of the field of the key or value object. * @param colName Name of the column. * @return {@code null} if it's OK to remove the column and exception otherwise. */ public static SchemaOperationException validateDropColumn(QueryEntity entity, String fieldName, String colName) { if (F.eq(fieldName, entity.getKeyFieldName()) || KEY_FIELD_NAME.equalsIgnoreCase(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because it represents an entire cache key"); if (F.eq(fieldName, entity.getValueFieldName()) || VAL_FIELD_NAME.equalsIgnoreCase(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because it represents an entire cache value"); Set<String> keyFields = entity.getKeyFields(); if (keyFields != null && keyFields.contains(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because it is a part of a cache key"); Collection<QueryIndex> indexes = entity.getIndexes(); if (indexes != null) { for (QueryIndex idxDesc : indexes) { if (idxDesc.getFields().containsKey(fieldName)) return new SchemaOperationException("Cannot drop column \"" + colName + "\" because an index exists (\"" + idxDesc.getName() + "\") that uses the column."); } } return null; }
Set<String> keyFields = qryEntity.getKeyFields(); Set<String> notNullFields = qryEntity.getNotNullFields(); Map<String, Object> defVals = qryEntity.getDefaultFieldValues();
normalEntity.setValueType(entity.getValueType()); normalEntity.setFields(entity.getFields()); normalEntity.setKeyFields(entity.getKeyFields()); normalEntity.setKeyFieldName(entity.getKeyFieldName()); normalEntity.setValueFieldName(entity.getValueFieldName());