You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "rpuch (via GitHub)" <gi...@apache.org> on 2023/09/29 11:41:18 UTC

[GitHub] [ignite-3] rpuch opened a new pull request, #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

rpuch opened a new pull request, #2643:
URL: https://github.com/apache/ignite-3/pull/2643

   https://issues.apache.org/jira/browse/IGNITE-20518
   
   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1341456520


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();
 
-        List<String> keyColNames = Arrays.stream(registry.schema().keyColumns().columns())
-                .map(Column::name)
-                .collect(Collectors.toList());
+        List<String> keyColNames = new ArrayList<>(tbl.primaryKeyColumns());

Review Comment:
   To make sure that, if `tbl.primaryKeyColumns()` is modifiable, we don't give it away



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1341455472


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();

Review Comment:
   Probably, when we rename a table, we'll also (atomically) rename the corresponding PK. Should I file an issue?



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1342347378


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();
 
-        List<String> keyColNames = Arrays.stream(registry.schema().keyColumns().columns())
-                .map(Column::name)
-                .collect(Collectors.toList());
+        List<String> keyColNames = new ArrayList<>(tbl.primaryKeyColumns());

Review Comment:
   > The pattern is called 'defensive copy', it's widely used.
   
   You know that's bad for performance, right? How hot is this code?
   I guess it's not hot, but generally speaking, it's component's responsibility to return immutable list. If we will wrap every returned collection in an explicit copy, it will be a disaster



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1341463190


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();
 
-        List<String> keyColNames = Arrays.stream(registry.schema().keyColumns().columns())
-                .map(Column::name)
-                .collect(Collectors.toList());
+        List<String> keyColNames = new ArrayList<>(tbl.primaryKeyColumns());

Review Comment:
   I disagree. Noone reads documentation. The pattern is called 'defensive copy', it's widely used. Also, please note that this code is not on the hot path. A couple of instances on the heap will not crash the server.



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1342347378


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();
 
-        List<String> keyColNames = Arrays.stream(registry.schema().keyColumns().columns())
-                .map(Column::name)
-                .collect(Collectors.toList());
+        List<String> keyColNames = new ArrayList<>(tbl.primaryKeyColumns());

Review Comment:
   > The pattern is called 'defensive copy', it's widely used.
   
   You know that's bad for performance, right? How hot is this code?



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1341461447


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();
 
-        List<String> keyColNames = Arrays.stream(registry.schema().keyColumns().columns())
-                .map(Column::name)
-                .collect(Collectors.toList());
+        List<String> keyColNames = new ArrayList<>(tbl.primaryKeyColumns());

Review Comment:
   I assume that if the list is returned from a method to external user, we can be user that it can be used for reading. Such issues are solved by documentation. Making copies of data, just to be sure, might not be the best solution



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-20518 Use CatalogService in JdbcMetadataCatalog [ignite-3]

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov merged PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643


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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] rpuch commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "rpuch (via GitHub)" <gi...@apache.org>.
rpuch commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1341459162


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();
 
-        List<String> keyColNames = Arrays.stream(registry.schema().keyColumns().columns())
-                .map(Column::name)
-                .collect(Collectors.toList());
+        List<String> keyColNames = new ArrayList<>(tbl.primaryKeyColumns());

Review Comment:
   Replaced it with `List.copyOf()` which will not allocate anything if the original list is immutable



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1341459918


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();

Review Comment:
   I don't know, we should discuss this behavior with someone else too



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [ignite-3] ibessonov commented on a diff in pull request #2643: IGNITE-20518 Use CatalogService in JdbcMetadataCatalog

Posted by "ibessonov (via GitHub)" <gi...@apache.org>.
ibessonov commented on code in PR #2643:
URL: https://github.com/apache/ignite-3/pull/2643#discussion_r1341440122


##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();
 
-        List<String> keyColNames = Arrays.stream(registry.schema().keyColumns().columns())
-                .map(Column::name)
-                .collect(Collectors.toList());
+        List<String> keyColNames = new ArrayList<>(tbl.primaryKeyColumns());

Review Comment:
   Any particular reason of creating the new list?



##########
modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/jdbc/JdbcMetadataCatalog.java:
##########
@@ -182,28 +202,24 @@ public CompletableFuture<Collection<String>> getSchemasMeta(String schemaNamePtr
             schemas.add(DEFAULT_SCHEMA_NAME);
         }
 
-        return tables.tablesAsync().thenApply(tablesList ->
-                tablesList.stream()
+        return tablesAtNow().thenApply(tables ->
+                tables.stream()
                     .map(tbl -> DEFAULT_SCHEMA_NAME)
                     .filter(schema -> matches(schema, schemaNameRegex))
-                    .collect(Collectors.toCollection(() -> schemas))
+                    .collect(toCollection(() -> schemas))
         );
     }
 
     /**
-     * Creates primary key metadata from table object.
+     * Creates primary key metadata from a table descriptor.
      *
      * @param tbl Table.
      * @return Jdbc primary key metadata.
      */
-    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(Table tbl) {
-        final String keyName = PK + tbl.name();
-
-        SchemaRegistry registry = ((TableImpl) tbl).schemaView();
+    private JdbcPrimaryKeyMeta createPrimaryKeyMeta(CatalogTableDescriptor tbl) {
+        String keyName = PK + tbl.name();

Review Comment:
   Unrelated question: what happens after table rename? Do we lose the ability to access the PK index?



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

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org