You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2019/06/03 15:25:18 UTC

[GitHub] [ignite] ygerzhedovich commented on a change in pull request #5676: IGNITE-10654 Print warn message in case of index creating with already existing fields.

ygerzhedovich commented on a change in pull request #5676: IGNITE-10654 Print warn message in case of index creating with already existing fields.
URL: https://github.com/apache/ignite/pull/5676#discussion_r289890885
 
 

 ##########
 File path: modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
 ##########
 @@ -822,6 +840,67 @@ public boolean rebuildFromHashInProgress() {
         return commitUserIndex(ses, idxName);
     }
 
+    /**
+     * Checks and replace if provided column id matches value alias column.
+     *
+     * @param col Input column.
+     * @return Transformed result if needed.
+     */
+    private String aliasNameTransformer(IndexColumn col) {
+        if (desc.isKeyAliasColumn(col.column.getColumnId()))
+            return QueryUtils.KEY_FIELD_NAME;
+        else if (desc.isValueAliasColumn(col.column.getColumnId()))
+            return QueryUtils.VAL_FIELD_NAME;
+
+        return col.columnName;
+    }
+
+    /**
+     * Check index presence, throw exception if index with same name already exist or return {@code True} if
+     * index with same fields and search direction found.
+     *
+     * @param curIdx Index to check.
+     * @return Index if equal or subset index exist.
+     * @throws IgniteCheckedException If failed.
+     */
+    private @Nullable Index checkIndexPresence(Index curIdx) throws IgniteCheckedException {
+        IndexColumn[] curColumns = curIdx.getIndexColumns();
+
+        Index registredIdx = null;
+
+        for (Index idx : idxs) {
+            if (!(idx instanceof H2TreeIndex))
+                continue;
+
+            if (F.eq(curIdx.getName(), idx.getName()))
+                throw new IgniteCheckedException("Index already exists: " + idx.getName());
+
+            IndexColumn[] idxColumns = idx.getIndexColumns();
+
+            for (int i = 0; i < Math.min(idxColumns.length, curColumns.length); ++i) {
+                IndexColumn idxCol = idxColumns[i];
+                IndexColumn curCol = curColumns[i];
+
+                // pk attach at the end of listed fields.
+                if (curCol.column.getColumnId() == 0 && registredIdx != null)
+                    continue;
+
+                if (idxCol.column.getColumnId() == curCol.column.getColumnId() && idxCol.sortType == curCol.sortType)
 
 Review comment:
   There is H2Utils.equals(IndexColumn c1, IndexColumn c2) method

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services