AMashenkov commented on a change in pull request #132:
URL: https://github.com/apache/ignite-3/pull/132#discussion_r635044650



##########
File path: 
modules/schema/src/main/java/org/apache/ignite/internal/schema/builder/SchemaTableBuilderImpl.java
##########
@@ -116,18 +121,20 @@ else if (PRIMARY_KEY_INDEX_NAME.equals(index.name()))
     /**
      * Validate indices.
      */
-    private void validateIndices() {
-        assert indices.values().stream()
+    public static void validateIndices(Collection<TableIndex> indices, 
Collection<Column> columns) {
+        Set<String> colNames = 
columns.stream().map(Column::name).collect(Collectors.toSet());
+        assert indices.stream()

Review comment:
       ```suggestion
           Set<String> colNames = 
columns.stream().map(Column::name).collect(Collectors.toSet());
           
           assert indices.stream()
   ```

##########
File path: 
modules/schema/src/main/java/org/apache/ignite/internal/schema/builder/SchemaTableBuilderImpl.java
##########
@@ -116,18 +121,20 @@ else if (PRIMARY_KEY_INDEX_NAME.equals(index.name()))
     /**
      * Validate indices.
      */
-    private void validateIndices() {
-        assert indices.values().stream()
+    public static void validateIndices(Collection<TableIndex> indices, 
Collection<Column> columns) {
+        Set<String> colNames = 
columns.stream().map(Column::name).collect(Collectors.toSet());
+        assert indices.stream()
             .filter(ColumnarIndex.class::isInstance)
             .map(ColumnarIndex.class::cast)
             .flatMap(idx -> idx.columns().stream())
             .map(IndexColumn::name)
-            .allMatch(columns::containsKey) : "Index column doesn't exists in 
schema.";
+            .allMatch(colNames::contains) : "Index column doesn't exists in 
schema.";
 
-        assert indices.containsKey(PRIMARY_KEY_INDEX_NAME) : "Primary key 
index is not configured.";
-        assert 
!((PrimaryIndex)indices.get(PRIMARY_KEY_INDEX_NAME)).affinityColumns().isEmpty()
 : "Primary key must have one affinity column at least.";
+        TableIndex pkIdx = indices.stream().filter(idx -> 
PRIMARY_KEY_INDEX_NAME.equals(idx.name())).findAny().orElse(null);
+        assert pkIdx != null : "Primary key index is not configured.";

Review comment:
       ```suggestion
           TableIndex pkIdx = indices.stream().filter(idx -> 
PRIMARY_KEY_INDEX_NAME.equals(idx.name())).findAny().orElse(null);
           
           assert pkIdx != null : "Primary key index is not configured.";
   ```




-- 
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]


Reply via email to