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_r267229995
##########
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) {
+ boolean copy = true;
+
+ for (IndexColumn idxCol : idxColumns) {
+ registredIdx = null;
+
+ for (IndexColumn curCol : curColumns) {
Review comment:
seems need to unwrap _KEY column before start of check. see
H2Utils.unwrapKeyColumns
----------------------------------------------------------------
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