alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql 
objects system views.
URL: https://github.com/apache/ignite/pull/6916#discussion_r330448055
 
 

 ##########
 File path: 
modules/indexing/src/main/java/org/apache/ignite/spi/systemview/view/SqlTableView.java
 ##########
 @@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.spi.systemview.view;
+
+import org.apache.ignite.internal.managers.systemview.walker.Order;
+import org.apache.ignite.internal.processors.query.h2.opt.GridH2Table;
+import org.h2.table.IndexColumn;
+
+/**
+ * Sql table representation for a {@link SystemView}.
+ */
+public class SqlTableView {
+    /** Table. */
+    private final GridH2Table tbl;
+
+    /** Affinity column name. */
+    private String affColName;
+
+    public SqlTableView(GridH2Table tbl) {
+        this.tbl = tbl;
+
+        IndexColumn affCol = tbl.getAffinityKeyColumn();
+
+        if (affCol != null) {
+            // Only explicit affinity column should be shown. Do not do this 
for _KEY or it's alias.
+            if (!tbl.rowDescriptor().isKeyColumn(affCol.column.getColumnId())) 
{
+                affColName = affCol.columnName;
+            }
+        }
+    }
+
+    /** @return Cache group id. */
+    @Order(3)
+    public int cacheGroupId() {
+        return tbl.cacheInfo().groupId();
+    }
+
+    /** @return Cache group name. */
+    @Order(4)
+    public String cacheGroupName() {
+        return tbl.cacheInfo().cacheContext().group().cacheOrGroupName();
 
 Review comment:
   You should not rely on cache context since it's possible that cache context 
for some caches is absent on some nodes. All information must be retrieved from 
cache descriptors.
   Also, I don't think "cache group id" and "cache group name" fields is needed 
here and in `SqlIndexView` at all. They don't related to SQL table directly 
(related via cache) and can be easily retrieved by join with the caches view (I 
know that these fields already was in Ignite, but AFAIK there was no Ignite 
release since table view was added, so perhaps we can fix it now).

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to