joooger 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_r267229561
 
 

 ##########
 File path: 
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
 ##########
 @@ -822,6 +841,70 @@ 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 {@code True} if equal 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();
+
+            if (idxColumns.length == curColumns.length) {
 
 Review comment:
   we can't skip check if lengths are diffrent, due to we can have special _KEY 
column for composite key with few columns
   as example: _KEY = ID1, ID2
   index   IDX_1(VAL, _KEY)
   index   IDX_2(VAL, ID1, ID2)
   
   IDX_1 eqauls IDX_2

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to