This is an automated email from the ASF dual-hosted git repository.

nizhikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new afd5adc9cfd IGNITE-28733 Move QueryEntityPatch to internal (#13190)
afd5adc9cfd is described below

commit afd5adc9cfdbd7af5b8f227802310b30ddd6c46e
Author: Nikolay <[email protected]>
AuthorDate: Thu May 28 11:29:31 2026 +0300

    IGNITE-28733 Move QueryEntityPatch to internal (#13190)
---
 .../java/org/apache/ignite/cache/QueryEntity.java  | 222 --------------
 .../org/apache/ignite/cache/QueryEntityPatch.java  | 117 --------
 .../processors/query/QueryEntityPatch.java         | 321 +++++++++++++++++++++
 .../internal/processors/query/QuerySchema.java     |   3 +-
 .../processors/query/QuerySchemaPatch.java         |   4 +-
 5 files changed, 324 insertions(+), 343 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java 
b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
index 567b8f1b15f..7ab4e306db0 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntity.java
@@ -27,11 +27,9 @@ import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
-import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
-import java.util.UUID;
 import javax.cache.CacheException;
 import org.apache.ignite.cache.query.annotations.QueryGroupIndex;
 import org.apache.ignite.cache.query.annotations.QuerySqlField;
@@ -39,11 +37,7 @@ import 
org.apache.ignite.cache.query.annotations.QueryTextField;
 import 
org.apache.ignite.internal.processors.cache.query.QueryEntityClassProperty;
 import 
org.apache.ignite.internal.processors.cache.query.QueryEntityTypeDescriptor;
 import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
-import org.apache.ignite.internal.processors.query.QueryField;
 import org.apache.ignite.internal.processors.query.QueryUtils;
-import 
org.apache.ignite.internal.processors.query.schema.operation.SchemaAbstractOperation;
-import 
org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableAddColumnOperation;
-import 
org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.F;
 import org.apache.ignite.internal.util.typedef.internal.A;
@@ -161,222 +155,6 @@ public class QueryEntity implements Serializable {
         this(convert(processKeyAndValueClasses(keyCls, valCls)));
     }
 
-    /**
-     * Make query entity patch. This patch can only add properties to entity 
and can't remove them.
-     * Other words, the patch will contain only add operations(e.g. add 
column, create index) and not remove ones.
-     *
-     * @param target Query entity to which this entity should be expanded.
-     * @return Patch which contains operations for expanding this entity.
-     */
-    @NotNull public QueryEntityPatch makePatch(QueryEntity target) {
-        if (target == null)
-            return QueryEntityPatch.empty();
-
-        StringBuilder conflicts = new StringBuilder();
-
-        checkEquals(conflicts, "keyType", keyType, target.keyType);
-        checkEquals(conflicts, "valType", valType, target.valType);
-        checkEquals(conflicts, "keyFieldName", keyFieldName, 
target.keyFieldName);
-        checkEquals(conflicts, "valueFieldName", valueFieldName, 
target.valueFieldName);
-        checkEquals(conflicts, "tableName", tableName, target.tableName);
-
-        List<QueryField> qryFieldsToAdd = checkFields(target, conflicts);
-
-        Collection<QueryIndex> indexesToAdd = checkIndexes(target, conflicts);
-
-        if (conflicts.length() != 0)
-            return QueryEntityPatch.conflict(tableName + " conflict: \n" + 
conflicts.toString());
-
-        Collection<SchemaAbstractOperation> patchOperations = new 
ArrayList<>();
-
-        if (!qryFieldsToAdd.isEmpty())
-            patchOperations.add(new SchemaAlterTableAddColumnOperation(
-                UUID.randomUUID(),
-                null,
-                null,
-                tableName,
-                qryFieldsToAdd,
-                true,
-                true
-            ));
-
-        if (!indexesToAdd.isEmpty()) {
-            for (QueryIndex idx : indexesToAdd) {
-                patchOperations.add(new SchemaIndexCreateOperation(
-                    UUID.randomUUID(),
-                    null,
-                    null,
-                    tableName,
-                    idx,
-                    true,
-                    0
-                ));
-            }
-        }
-
-        return QueryEntityPatch.patch(patchOperations);
-    }
-
-    /**
-     * Comparing local fields and target fields.
-     *
-     * @param target Query entity for check.
-     * @param conflicts Storage of conflicts.
-     * @return Indexes which exist in target and not exist in local.
-     */
-    @NotNull private Collection<QueryIndex> checkIndexes(QueryEntity target, 
StringBuilder conflicts) {
-        HashSet<QueryIndex> indexesToAdd = new HashSet<>();
-
-        Map<String, QueryIndex> curIndexes = new HashMap<>();
-
-        for (QueryIndex idx : getIndexes()) {
-            if (curIndexes.put(idx.getName(), idx) != null)
-                throw new IllegalStateException("Duplicate key");
-        }
-
-        for (QueryIndex qryIdx : target.getIndexes()) {
-            if (curIndexes.containsKey(qryIdx.getName())) {
-                checkEquals(
-                    conflicts,
-                    "index " + qryIdx.getName(),
-                    curIndexes.get(qryIdx.getName()),
-                    qryIdx
-                );
-            }
-            else
-                indexesToAdd.add(qryIdx);
-        }
-        return indexesToAdd;
-    }
-
-    /**
-     * Comparing local entity fields and target entity fields.
-     *
-     * @param target Query entity for check.
-     * @param conflicts Storage of conflicts.
-     * @return Fields which exist in target and not exist in local.
-     */
-    private List<QueryField> checkFields(QueryEntity target, StringBuilder 
conflicts) {
-        List<QueryField> qryFieldsToAdd = new ArrayList<>();
-
-        for (Map.Entry<String, String> targetField : 
target.getFields().entrySet()) {
-            String targetFieldName = targetField.getKey();
-            String targetFieldType = targetField.getValue();
-            String targetFieldAlias = target.getAliases().get(targetFieldName);
-
-            if (getFields().containsKey(targetFieldName)) {
-                checkEquals(
-                    conflicts,
-                    "alias of " + targetFieldName,
-                    getAliases().get(targetFieldName),
-                    targetFieldAlias
-                );
-
-                checkEquals(
-                    conflicts,
-                    "fieldType of " + targetFieldName,
-                    getFields().get(targetFieldName),
-                    targetFieldType
-                );
-
-                checkEquals(
-                    conflicts,
-                    "nullable of " + targetFieldName,
-                    contains(getNotNullFields(), targetFieldName),
-                    contains(target.getNotNullFields(), targetFieldName)
-                );
-
-                checkEquals(
-                    conflicts,
-                    "default value of " + targetFieldName,
-                    getFromMap(getDefaultFieldValues(), targetFieldName),
-                    getFromMap(target.getDefaultFieldValues(), targetFieldName)
-                );
-
-                checkEquals(conflicts,
-                    "precision of " + targetFieldName,
-                    getFromMap(getFieldsPrecision(), targetFieldName),
-                    getFromMap(target.getFieldsPrecision(), targetFieldName));
-
-                checkEquals(
-                    conflicts,
-                    "scale of " + targetFieldName,
-                    getFromMap(getFieldsScale(), targetFieldName),
-                    getFromMap(target.getFieldsScale(), targetFieldName));
-            }
-            else {
-                boolean isAliasConflictsFound = 
findAliasConflicts(targetFieldAlias, targetFieldName, conflicts);
-
-                if (!isAliasConflictsFound) {
-                    Integer precision = 
getFromMap(target.getFieldsPrecision(), targetFieldName);
-                    Integer scale = getFromMap(target.getFieldsScale(), 
targetFieldName);
-
-                    qryFieldsToAdd.add(new QueryField(
-                        targetFieldName,
-                        targetFieldType,
-                        targetFieldAlias,
-                        !contains(target.getNotNullFields(), targetFieldName),
-                        precision == null ? -1 : precision,
-                        scale == null ? -1 : scale
-                    ));
-                }
-            }
-        }
-
-        return qryFieldsToAdd;
-    }
-
-    /**
-     * Checks if received query entity field has the alias which is already 
used by a field on the local node.
-     *
-     * @return Whether conflicts were found.
-     */
-    private boolean findAliasConflicts(String targetFieldAlias, String 
targetFieldName, StringBuilder conflicts) {
-        for (Map.Entry<String, String> entry : getAliases().entrySet()) {
-            if (Objects.equals(entry.getValue(), targetFieldAlias)) {
-                conflicts.append(String.format(
-                    "multiple fields are associated with the same alias: 
alias=%s, localField=%s, receivedField=%s\n",
-                    targetFieldAlias,
-                    entry.getKey(),
-                    targetFieldName)
-                );
-
-                return true;
-            }
-        }
-
-        return false;
-    }
-
-    /**
-     * @param collection Collection for checking.
-     * @param elementToCheck Element for checking to containing in collection.
-     * @return {@code true} if collection contain elementToCheck.
-     */
-    private static boolean contains(Collection<String> collection, String 
elementToCheck) {
-        return collection != null && collection.contains(elementToCheck);
-    }
-
-    /**
-     * @return Value from sourceMap or null if map is null.
-     */
-    private static <V> V getFromMap(Map<String, V> sourceMap, String key) {
-        return sourceMap == null ? null : sourceMap.get(key);
-    }
-
-    /**
-     * Comparing two objects and add formatted text to conflicts if needed.
-     *
-     * @param conflicts Storage of conflicts resulting error message.
-     * @param name Name of comparing object.
-     * @param local Local object.
-     * @param received Received object.
-     */
-    private <V> void checkEquals(StringBuilder conflicts, String name, V 
local, V received) {
-        if (!Objects.equals(local, received))
-            conflicts.append(String.format("%s is different: local=%s, 
received=%s\n", name, local, received));
-    }
-
     /**
      * Gets key type for this query pair.
      *
diff --git 
a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntityPatch.java 
b/modules/core/src/main/java/org/apache/ignite/cache/QueryEntityPatch.java
deleted file mode 100644
index 5b515ff51b2..00000000000
--- a/modules/core/src/main/java/org/apache/ignite/cache/QueryEntityPatch.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache;
-
-import java.util.Collection;
-import 
org.apache.ignite.internal.processors.query.schema.operation.SchemaAbstractOperation;
-import org.apache.ignite.internal.util.typedef.internal.S;
-
-/**
- * Query entity patch which contain {@link SchemaAbstractOperation} operations 
for changing query entity.
- * This patch can only add properties to entity and can't remove them.
- * Other words, the patch will contain only add operations
- * (e.g.:
- * {@link 
org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableAddColumnOperation},
- * {@link 
org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation}
- * ) and not remove ones.
- *
- * It contain only add operation because at the moment we don't have history 
of schema operations
- * and by current state we can't understand some property was already deleted 
or it has not been added yet.
- */
-public class QueryEntityPatch {
-    /** Empty query entity patch. */
-    private static final QueryEntityPatch EMPTY_QUERY_ENTITY_PATCH = new 
QueryEntityPatch(null, null);
-
-    /** Message which described conflicts during creating this patch. */
-    private String conflictsMessage;
-
-    /** Operations for modification query entity. */
-    private Collection<SchemaAbstractOperation> patchOperations;
-
-    /**
-     * Create patch.
-     */
-    private QueryEntityPatch(String conflictsMessage, 
Collection<SchemaAbstractOperation> patchOperations) {
-        this.conflictsMessage = conflictsMessage;
-        this.patchOperations = patchOperations;
-    }
-
-    /**
-     * Builder method for patch with conflicts.
-     *
-     * @param conflicts Conflicts.
-     * @return Query entity patch with conflicts.
-     */
-    public static QueryEntityPatch conflict(String conflicts) {
-        return new QueryEntityPatch(conflicts, null);
-    }
-
-    /**
-     * Builder method for empty patch.
-     *
-     * @return Query entity patch.
-     */
-    public static QueryEntityPatch empty() {
-        return EMPTY_QUERY_ENTITY_PATCH;
-    }
-
-    /**
-     * Builder method for patch with operations.
-     *
-     * @param patchOperations Operations for modification.
-     * @return Query entity patch which contain {@link 
SchemaAbstractOperation} operations for changing query entity.
-     */
-    public static QueryEntityPatch patch(Collection<SchemaAbstractOperation> 
patchOperations) {
-        return new QueryEntityPatch(null, patchOperations);
-    }
-
-    /**
-     * Check for conflict in this patch.
-     *
-     * @return {@code true} if patch has conflict.
-     */
-    public boolean hasConflict() {
-        return conflictsMessage != null;
-    }
-
-    /**
-     * @return {@code true} if patch is empty and can't be applying.
-     */
-    public boolean isEmpty() {
-        return patchOperations == null || patchOperations.isEmpty();
-    }
-
-    /**
-     * @return Conflicts.
-     */
-    public String getConflictsMessage() {
-        return conflictsMessage;
-    }
-
-    /**
-     * @return Patch operations for applying.
-     */
-    public Collection<SchemaAbstractOperation> getPatchOperations() {
-        return patchOperations;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(QueryEntityPatch.class, this);
-    }
-}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityPatch.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityPatch.java
new file mode 100644
index 00000000000..65320fe1c5f
--- /dev/null
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QueryEntityPatch.java
@@ -0,0 +1,321 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.query;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.UUID;
+import org.apache.ignite.cache.QueryEntity;
+import org.apache.ignite.cache.QueryIndex;
+import 
org.apache.ignite.internal.processors.query.schema.operation.SchemaAbstractOperation;
+import 
org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableAddColumnOperation;
+import 
org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Query entity patch which contain {@link SchemaAbstractOperation} operations 
for changing query entity.
+ * This patch can only add properties to entity and can't remove them.
+ * Other words, the patch will contain only add operations
+ * (e.g.:
+ * {@link 
org.apache.ignite.internal.processors.query.schema.operation.SchemaAlterTableAddColumnOperation},
+ * {@link 
org.apache.ignite.internal.processors.query.schema.operation.SchemaIndexCreateOperation}
+ * ) and not remove ones.
+ *
+ * It contain only add operation because at the moment we don't have history 
of schema operations
+ * and by current state we can't understand some property was already deleted 
or it has not been added yet.
+ */
+class QueryEntityPatch {
+    /** Empty query entity patch. */
+    private static final QueryEntityPatch EMPTY_QUERY_ENTITY_PATCH = new 
QueryEntityPatch(null, null);
+
+    /** Message which described conflicts during creating this patch. */
+    private final String conflictsMessage;
+
+    /** Operations for modification query entity. */
+    private final Collection<SchemaAbstractOperation> patchOperations;
+
+    /**
+     * Create patch.
+     */
+    private QueryEntityPatch(String conflictsMessage, 
Collection<SchemaAbstractOperation> patchOperations) {
+        this.conflictsMessage = conflictsMessage;
+        this.patchOperations = patchOperations;
+    }
+
+    /**
+     * Make query entity patch. This patch can only add properties to entity 
and can't remove them.
+     * Other words, the patch will contain only add operations(e.g. add 
column, create index) and not remove ones.
+     *
+     * @param target Query entity to which this entity should be expanded.
+     * @return Patch which contains operations for expanding this entity.
+     */
+    @NotNull static QueryEntityPatch makePatch(QueryEntity locEntity, 
QueryEntity target) {
+        if (target == null)
+            return EMPTY_QUERY_ENTITY_PATCH;
+
+        StringBuilder conflicts = new StringBuilder();
+
+        checkEquals(conflicts, "keyType", locEntity.getKeyType(), 
target.getKeyType());
+        checkEquals(conflicts, "valType", locEntity.getValueType(), 
target.getValueType());
+        checkEquals(conflicts, "keyFieldName", locEntity.getKeyFieldName(), 
target.getKeyFieldName());
+        checkEquals(conflicts, "valueFieldName", 
locEntity.getValueFieldName(), target.getValueFieldName());
+        checkEquals(conflicts, "tableName", locEntity.getTableName(), 
target.getTableName());
+
+        List<QueryField> qryFieldsToAdd = checkFields(locEntity, target, 
conflicts);
+
+        Collection<QueryIndex> indexesToAdd = checkIndexes(locEntity, target, 
conflicts);
+
+        if (conflicts.length() != 0)
+            return new QueryEntityPatch(locEntity.getTableName() + " conflict: 
\n" + conflicts.toString(), null);
+
+        Collection<SchemaAbstractOperation> patchOperations = new 
ArrayList<>();
+
+        if (!qryFieldsToAdd.isEmpty())
+            patchOperations.add(new SchemaAlterTableAddColumnOperation(
+                UUID.randomUUID(),
+                null,
+                null,
+                locEntity.getTableName(),
+                qryFieldsToAdd,
+                true,
+                true
+            ));
+
+        if (!indexesToAdd.isEmpty()) {
+            for (QueryIndex idx : indexesToAdd) {
+                patchOperations.add(new SchemaIndexCreateOperation(
+                    UUID.randomUUID(),
+                    null,
+                    null,
+                    locEntity.getTableName(),
+                    idx,
+                    true,
+                    0
+                ));
+            }
+        }
+
+        return new QueryEntityPatch(null, patchOperations);
+    }
+
+    /**
+     * Comparing local entity fields and target entity fields.
+     *
+     * @param target Query entity for check.
+     * @param conflicts Storage of conflicts.
+     * @return Fields which exist in target and not exist in local.
+     */
+    @NotNull private static List<QueryField> checkFields(QueryEntity 
locEntity, QueryEntity target, StringBuilder conflicts) {
+        List<QueryField> qryFieldsToAdd = new ArrayList<>();
+
+        for (Map.Entry<String, String> targetField : 
target.getFields().entrySet()) {
+            String targetFieldName = targetField.getKey();
+            String targetFieldType = targetField.getValue();
+            String targetFieldAlias = target.getAliases().get(targetFieldName);
+
+            if (locEntity.getFields().containsKey(targetFieldName)) {
+                checkEquals(
+                    conflicts,
+                    "alias of " + targetFieldName,
+                    locEntity.getAliases().get(targetFieldName),
+                    targetFieldAlias
+                );
+
+                checkEquals(
+                    conflicts,
+                    "fieldType of " + targetFieldName,
+                    locEntity.getFields().get(targetFieldName),
+                    targetFieldType
+                );
+
+                checkEquals(
+                    conflicts,
+                    "nullable of " + targetFieldName,
+                    contains(locEntity.getNotNullFields(), targetFieldName),
+                    contains(target.getNotNullFields(), targetFieldName)
+                );
+
+                checkEquals(
+                    conflicts,
+                    "default value of " + targetFieldName,
+                    getFromMap(locEntity.getDefaultFieldValues(), 
targetFieldName),
+                    getFromMap(target.getDefaultFieldValues(), targetFieldName)
+                );
+
+                checkEquals(conflicts,
+                    "precision of " + targetFieldName,
+                    getFromMap(locEntity.getFieldsPrecision(), 
targetFieldName),
+                    getFromMap(target.getFieldsPrecision(), targetFieldName));
+
+                checkEquals(
+                    conflicts,
+                    "scale of " + targetFieldName,
+                    getFromMap(locEntity.getFieldsScale(), targetFieldName),
+                    getFromMap(target.getFieldsScale(), targetFieldName));
+            }
+            else {
+                boolean isAliasConflictsFound = findAliasConflicts(locEntity, 
targetFieldAlias, targetFieldName, conflicts);
+
+                if (!isAliasConflictsFound) {
+                    Integer precision = 
getFromMap(target.getFieldsPrecision(), targetFieldName);
+                    Integer scale = getFromMap(target.getFieldsScale(), 
targetFieldName);
+
+                    qryFieldsToAdd.add(new QueryField(
+                        targetFieldName,
+                        targetFieldType,
+                        targetFieldAlias,
+                        !contains(target.getNotNullFields(), targetFieldName),
+                        precision == null ? -1 : precision,
+                        scale == null ? -1 : scale
+                    ));
+                }
+            }
+        }
+
+        return qryFieldsToAdd;
+    }
+
+    /**
+     * Comparing local fields and target fields.
+     *
+     * @param target Query entity for check.
+     * @param conflicts Storage of conflicts.
+     * @return Indexes which exist in target and not exist in local.
+     */
+    @NotNull private static Collection<QueryIndex> checkIndexes(QueryEntity 
locEntity, QueryEntity target, StringBuilder conflicts) {
+        HashSet<QueryIndex> indexesToAdd = new HashSet<>();
+
+        Map<String, QueryIndex> curIndexes = new HashMap<>();
+
+        for (QueryIndex idx : locEntity.getIndexes()) {
+            if (curIndexes.put(idx.getName(), idx) != null)
+                throw new IllegalStateException("Duplicate key");
+        }
+
+        for (QueryIndex qryIdx : target.getIndexes()) {
+            if (curIndexes.containsKey(qryIdx.getName())) {
+                checkEquals(
+                    conflicts,
+                    "index " + qryIdx.getName(),
+                    curIndexes.get(qryIdx.getName()),
+                    qryIdx
+                );
+            }
+            else
+                indexesToAdd.add(qryIdx);
+        }
+        return indexesToAdd;
+    }
+
+    /**
+     * @param collection Collection for checking.
+     * @param elementToCheck Element for checking to containing in collection.
+     * @return {@code true} if collection contain elementToCheck.
+     */
+    private static boolean contains(Collection<String> collection, String 
elementToCheck) {
+        return collection != null && collection.contains(elementToCheck);
+    }
+
+    /**
+     * @return Value from sourceMap or null if map is null.
+     */
+    private static <V> V getFromMap(Map<String, V> sourceMap, String key) {
+        return sourceMap == null ? null : sourceMap.get(key);
+    }
+
+    /**
+     * Comparing two objects and add formatted text to conflicts if needed.
+     *
+     * @param conflicts Storage of conflicts resulting error message.
+     * @param name Name of comparing object.
+     * @param local Local object.
+     * @param received Received object.
+     */
+    private static <V> void checkEquals(StringBuilder conflicts, String name, 
V local, V received) {
+        if (!Objects.equals(local, received))
+            conflicts.append(String.format("%s is different: local=%s, 
received=%s\n", name, local, received));
+    }
+
+    /**
+     * Checks if received query entity field has the alias which is already 
used by a field on the local node.
+     *
+     * @return Whether conflicts were found.
+     */
+    private static boolean findAliasConflicts(
+        QueryEntity locEntity,
+        String targetFieldAlias,
+        String targetFieldName,
+        StringBuilder conflicts
+    ) {
+        for (Map.Entry<String, String> entry : 
locEntity.getAliases().entrySet()) {
+            if (Objects.equals(entry.getValue(), targetFieldAlias)) {
+                conflicts.append(String.format(
+                    "multiple fields are associated with the same alias: 
alias=%s, localField=%s, receivedField=%s\n",
+                    targetFieldAlias,
+                    entry.getKey(),
+                    targetFieldName)
+                );
+
+                return true;
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Check for conflict in this patch.
+     *
+     * @return {@code true} if patch has conflict.
+     */
+    boolean hasConflict() {
+        return conflictsMessage != null;
+    }
+
+    /**
+     * @return {@code true} if patch is empty and can't be applying.
+     */
+    boolean isEmpty() {
+        return patchOperations == null || patchOperations.isEmpty();
+    }
+
+    /**
+     * @return Conflicts.
+     */
+    String getConflictsMessage() {
+        return conflictsMessage;
+    }
+
+    /**
+     * @return Patch operations for applying.
+     */
+    Collection<SchemaAbstractOperation> getPatchOperations() {
+        return patchOperations;
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(QueryEntityPatch.class, this);
+    }
+}
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
index 6b5838ee824..945c36f8eab 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchema.java
@@ -30,7 +30,6 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.UUID;
 import org.apache.ignite.cache.QueryEntity;
-import org.apache.ignite.cache.QueryEntityPatch;
 import org.apache.ignite.cache.QueryIndex;
 import org.apache.ignite.configuration.CacheConfiguration;
 import 
org.apache.ignite.internal.processors.query.schema.message.SchemaFinishDiscoveryMessage;
@@ -140,7 +139,7 @@ public class QuerySchema implements Serializable {
                 if (locEntities.containsKey(qryEntity.getTableName())) {
                     QueryEntity locEntity = 
locEntities.get(qryEntity.getTableName());
 
-                    QueryEntityPatch entityPatch = 
locEntity.makePatch(qryEntity);
+                    QueryEntityPatch entityPatch = 
QueryEntityPatch.makePatch(locEntity, qryEntity);
 
                     if (entityPatch.hasConflict()) {
                         if (conflicts.length() > 0)
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchemaPatch.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchemaPatch.java
index 462b57ba6f4..dc2bac709e6 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchemaPatch.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/query/QuerySchemaPatch.java
@@ -25,11 +25,11 @@ import org.jetbrains.annotations.NotNull;
 
 /**
  * Query schema patch which contains {@link SchemaAbstractOperation} 
operations for changing query entities.
- * This patch is high level path on {@link 
org.apache.ignite.cache.QueryEntityPatch} but
+ * This patch is high level path on {@link QueryEntityPatch} but
  * it has operations for all {@link QueryEntity} in schema
  * and also contains {@link QueryEntity} for adding to schema by whole.
  *
- * @see org.apache.ignite.cache.QueryEntityPatch
+ * @see QueryEntityPatch
  */
 public class QuerySchemaPatch {
     /** Message which described conflicts during creating this patch. */

Reply via email to