[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-03 Thread GitBox
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_r331010446
 
 

 ##
 File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/metric/SqlViewExporterSpiTest.java
 ##
 @@ -332,6 +339,162 @@ public void testTransactions() throws Exception {
 assertTrue(res);
 }
 
+/** */
+@Test
+public void testSchemas() throws Exception {
+try (IgniteEx g = startGrid(new 
IgniteConfiguration().setSqlSchemas("MY_SCHEMA", "ANOTHER_SCHEMA"))) {
+SystemView schemasSysView = 
g.context().systemView().view(SQL_SCHEMA_VIEW);
+
+Set schemaFromSysView = new HashSet<>();
+
+schemasSysView.forEach(v -> schemaFromSysView.add(v.name()));
+
+HashSet expSchemas = new HashSet<>(asList("MY_SCHEMA", 
"ANOTHER_SCHEMA", "SYS", "PUBLIC"));
+
+assertEquals(schemaFromSysView, expSchemas);
+
+List> schemas = execute(g, "SELECT * FROM SYS.SCHEMAS");
+
+schemaFromSysView.clear();
+schemas.forEach(s -> schemaFromSysView.add(s.get(0).toString()));
+
+assertEquals(schemaFromSysView, expSchemas);
+}
+}
+
+/** */
+@Test
+public void testViews() throws Exception {
+Set expViews = new HashSet<>(asList(
+"METRICS",
+"SERVICES",
+"CACHE_GROUPS",
+"CACHES",
+"TASKS",
+"LOCAL_SQL_QUERY_HISTORY",
+"NODES",
+"SCHEMAS",
+"NODE_METRICS",
+"BASELINE_NODES",
+"INDEXES",
+"LOCAL_CACHE_GROUPS_IO",
+"LOCAL_SQL_RUNNING_QUERIES",
+"NODE_ATTRIBUTES",
+"TABLES",
+"CLIENT_CONNECTIONS",
+"VIEWS",
+"TABLE_COLUMNS",
+"VIEW_COLUMNS",
+"TRANSACTIONS"
+));
+
+Set actViews = new HashSet<>();
+
+List> res = execute(ignite, "SELECT * FROM SYS.VIEWS");
+
+for (List row : res)
+actViews.add(row.get(0).toString());
+
+assertEquals(expViews, actViews);
+}
+
+/** */
+@Test
+public void testTable() throws Exception {
+assertTrue(execute(ignite, "SELECT * FROM SYS.TABLES").isEmpty());
+
+execute(ignite, "CREATE TABLE T1(ID LONG PRIMARY KEY, NAME VARCHAR)");
+
+List> res = execute(ignite, "SELECT * FROM SYS.TABLES");
+
+assertEquals(1, res.size());
+
+List tbl = res.get(0);
+
+int cacheId = cacheId("SQL_PUBLIC_T1");
+String cacheName = "SQL_PUBLIC_T1";
+
+assertEquals("T1", tbl.get(0)); //TABLE_NAME
+assertEquals(DFLT_SCHEMA, tbl.get(1)); //SCHEMA_NAME
+assertEquals(cacheName, tbl.get(2)); //CACHE_NAME
+assertEquals(cacheId, tbl.get(3)); //CACHE_ID
+assertNull(tbl.get(4)); //AFFINITY_KEY_COLUMN
+assertEquals("ID", tbl.get(5)); //KEY_ALIAS
+assertNull(tbl.get(6)); //VALUE_ALIAS
+assertEquals("java.lang.Long", tbl.get(7)); //KEY_TYPE_NAME
+assertNotNull(tbl.get(8)); //VALUE_TYPE_NAME
+
+execute(ignite, "CREATE TABLE T2(ID LONG PRIMARY KEY, NAME VARCHAR)");
+
+assertEquals(2, execute(ignite, "SELECT * FROM SYS.TABLES").size());
+
+execute(ignite, "DROP TABLE T1");
+execute(ignite, "DROP TABLE T2");
+
+assertTrue(execute(ignite, "SELECT * FROM SYS.TABLES").isEmpty());
+}
+
+/** */
+@Test
+public void testTableColumns() throws Exception {
+assertTrue(execute(ignite, "SELECT * FROM 
SYS.TABLE_COLUMNS").isEmpty());
+
+execute(ignite, "CREATE TABLE T1(ID LONG PRIMARY KEY, NAME 
VARCHAR(40))");
+
+Set actCols = execute(ignite, "SELECT * FROM SYS.TABLE_COLUMNS")
+.stream()
+.map(l -> l.get(0))
+.collect(Collectors.toSet());
+
+assertEquals(new HashSet<>(asList("ID", "NAME", "_KEY", "_VAL")), 
actCols);
+
+execute(ignite, "CREATE TABLE T2(ID LONG PRIMARY KEY, NAME 
VARCHAR(50))");
+
+List> expRes = asList(
+asList("ID", "T1", "PUBLIC", false, false, "null", true, true, -1, 
-1, Long.class.getName()),
+asList("NAME", "T1", "PUBLIC", false, false, "null", true, false, 
40, -1, String.class.getName()),
+asList("_KEY", "T1", "PUBLIC", true, false, null, false, true, -1, 
-1, null),
+asList("_VAL", "T1", "PUBLIC", false, false, null, true, false, 
-1, -1, null),
+asList("ID", "T2", "PUBLIC", false, false, "null", true, true, -1, 
-1, Long.class.getName()),
+asList("NAME", "T2", "PUBLIC", false, false, "null", true, false, 
50, -1, String.class.getName()),
+asList("_KEY", "T2", "PUBLIC", true, false, null, false, true, -1, 
-1, null),
+asList("_VAL", "T2", "PUBLIC", false, false, null, true, false, 
-1, -1, null)
+);

[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-03 Thread GitBox
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_r331010217
 
 

 ##
 File path: 
modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/metric/SqlViewExporterSpiTest.java
 ##
 @@ -332,6 +339,162 @@ public void testTransactions() throws Exception {
 assertTrue(res);
 }
 
+/** */
+@Test
+public void testSchemas() throws Exception {
+try (IgniteEx g = startGrid(new 
IgniteConfiguration().setSqlSchemas("MY_SCHEMA", "ANOTHER_SCHEMA"))) {
+SystemView schemasSysView = 
g.context().systemView().view(SQL_SCHEMA_VIEW);
+
+Set schemaFromSysView = new HashSet<>();
+
+schemasSysView.forEach(v -> schemaFromSysView.add(v.name()));
+
+HashSet expSchemas = new HashSet<>(asList("MY_SCHEMA", 
"ANOTHER_SCHEMA", "SYS", "PUBLIC"));
+
+assertEquals(schemaFromSysView, expSchemas);
+
+List> schemas = execute(g, "SELECT * FROM SYS.SCHEMAS");
+
+schemaFromSysView.clear();
+schemas.forEach(s -> schemaFromSysView.add(s.get(0).toString()));
+
+assertEquals(schemaFromSysView, expSchemas);
+}
+}
+
+/** */
+@Test
+public void testViews() throws Exception {
+Set expViews = new HashSet<>(asList(
+"METRICS",
+"SERVICES",
+"CACHE_GROUPS",
+"CACHES",
+"TASKS",
+"LOCAL_SQL_QUERY_HISTORY",
+"NODES",
+"SCHEMAS",
+"NODE_METRICS",
+"BASELINE_NODES",
+"INDEXES",
+"LOCAL_CACHE_GROUPS_IO",
+"LOCAL_SQL_RUNNING_QUERIES",
+"NODE_ATTRIBUTES",
+"TABLES",
+"CLIENT_CONNECTIONS",
+"VIEWS",
+"TABLE_COLUMNS",
+"VIEW_COLUMNS",
+"TRANSACTIONS"
+));
+
+Set actViews = new HashSet<>();
+
+List> res = execute(ignite, "SELECT * FROM SYS.VIEWS");
+
+for (List row : res)
+actViews.add(row.get(0).toString());
+
+assertEquals(expViews, actViews);
+}
+
+/** */
+@Test
+public void testTable() throws Exception {
+assertTrue(execute(ignite, "SELECT * FROM SYS.TABLES").isEmpty());
+
+execute(ignite, "CREATE TABLE T1(ID LONG PRIMARY KEY, NAME VARCHAR)");
+
+List> res = execute(ignite, "SELECT * FROM SYS.TABLES");
+
+assertEquals(1, res.size());
+
+List tbl = res.get(0);
+
+int cacheId = cacheId("SQL_PUBLIC_T1");
+String cacheName = "SQL_PUBLIC_T1";
+
+assertEquals("T1", tbl.get(0)); //TABLE_NAME
 
 Review comment:
   Space after `//`


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-03 Thread GitBox
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_r331006612
 
 

 ##
 File path: 
modules/indexing/src/main/java/org/apache/ignite/spi/systemview/view/SqlIndexView.java
 ##
 @@ -0,0 +1,138 @@
+/*
+ * 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.cache.CacheGroupContext;
 
 Review comment:
   Unused import


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330462185
 
 

 ##
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/SystemViewArrayContainerAdapter.java
 ##
 @@ -0,0 +1,111 @@
+/*
+ * 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.internal.managers.systemview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * System view backed by {@code data} container.
+ * Each instance of {@code containers} collections should provide a array of 
data.
+ *
+ * @see SystemView
+ */
+public class SystemViewArrayContainerAdapter extends 
AbstractSystemView {
 
 Review comment:
   Also, perhaps these two classes can be replaced by one which iterates 
through iterables. Size method doesn't really mandatory if you return 
`canGetRowCount` as `false` for these views. In this case size will be 
calculated by H2.


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330451831
 
 

 ##
 File path: 
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/SchemaManager.java
 ##
 @@ -23,6 +23,7 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 Review comment:
   Unused import


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330454241
 
 

 ##
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/SystemViewArrayContainerAdapter.java
 ##
 @@ -0,0 +1,111 @@
+/*
+ * 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.internal.managers.systemview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * System view backed by {@code data} container.
+ * Each instance of {@code containers} collections should provide a array of 
data.
+ *
+ * @see SystemView
+ */
+public class SystemViewArrayContainerAdapter extends 
AbstractSystemView {
+/** Collections of the data containers */
+private final Collection containers;
+
+/** Function to extract collection of the data from container. */
+private final Function dataExtractor;
+
+/** Row function. */
+private final BiFunction rowFunc;
+
+/**
+ * @param name Name.
+ * @param desc Description.
+ * @param rowCls Row class.
+ * @param walker Walker.
+ * @param containers Container of data.
+ * @param dataExtractor Data extractor function.
+ * @param rowFunc Row function.
+ */
+public SystemViewArrayContainerAdapter(String name, String desc, Class 
rowCls,
+SystemViewRowAttributeWalker walker,
+Collection containers,
+Function dataExtractor,
+BiFunction rowFunc) {
+super(name, desc, rowCls, walker);
+
+this.containers = containers;
+this.dataExtractor = dataExtractor;
+this.rowFunc = rowFunc;
+}
+
+/** {@inheritDoc} */
+@Override public int size() {
+int sz = 0;
+
+for (C c : containers)
+sz += dataExtractor.apply(c).length;
+
+return sz;
+}
+
+/** {@inheritDoc} */
+@NotNull @Override public Iterator iterator() {
 
 Review comment:
   I think it can be simplified by using `F.concat(F.iterator(...))`


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330426434
 
 

 ##
 File path: 
modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java
 ##
 @@ -788,14 +790,45 @@ public void testGetAllColumns() throws Exception {
 "SYS.TRANSACTIONS.OTHER_NODE_ID.null.2147483647",
 "SYS.TRANSACTIONS.TOP_VER.null.2147483647",
 "SYS.TRANSACTIONS.KEYS_COUNT.null.10",
-"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647"
+"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647",
+"SYS.CLIENT_CONNECTIONS.VERSION.null.2147483647",
+"SYS.SCHEMAS.NAME.null.2147483647",
+"SYS.SCHEMAS.PREDEFINED.null.1",
+"SYS.TABLES.CACHE_GROUP_ID.null.10",
+"SYS.TABLES.CACHE_GROUP_NAME.null.2147483647",
+"SYS.TABLES.CACHE_ID.null.10",
+"SYS.TABLES.CACHE_NAME.null.2147483647",
+"SYS.TABLES.SCHEMA_NAME.null.2147483647",
+"SYS.TABLES.TABLE_NAME.null.2147483647",
+"SYS.TABLES.AFFINITY_KEY_COLUMN.null.2147483647",
+"SYS.TABLES.KEY_ALIAS.null.2147483647",
+"SYS.TABLES.VALUE_ALIAS.null.2147483647",
+"SYS.TABLES.KEY_TYPE_NAME.null.2147483647",
+"SYS.TABLES.VALUE_TYPE_NAME.null.2147483647",
+"SYS.VIEWS.NAME.null.2147483647",
+"SYS.VIEWS.DESCRIPTION.null.2147483647",
+"SYS.VIEWS.SCHEMA.null.2147483647",
+"SYS.TABLE_COLUMNS.AFFINITY_COLUMN.null.1",
+"SYS.TABLE_COLUMNS.COLUMN_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.SCALE.null.10",
+"SYS.TABLE_COLUMNS.PK.null.1",
+"SYS.TABLE_COLUMNS.TYPE.null.2147483647",
+"SYS.TABLE_COLUMNS.DEFATULT.null.2147483647",
 
 Review comment:
   DEFAULT


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330426551
 
 

 ##
 File path: 
modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java
 ##
 @@ -788,14 +790,45 @@ public void testGetAllColumns() throws Exception {
 "SYS.TRANSACTIONS.OTHER_NODE_ID.null.2147483647",
 "SYS.TRANSACTIONS.TOP_VER.null.2147483647",
 "SYS.TRANSACTIONS.KEYS_COUNT.null.10",
-"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647"
+"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647",
+"SYS.CLIENT_CONNECTIONS.VERSION.null.2147483647",
+"SYS.SCHEMAS.NAME.null.2147483647",
+"SYS.SCHEMAS.PREDEFINED.null.1",
+"SYS.TABLES.CACHE_GROUP_ID.null.10",
+"SYS.TABLES.CACHE_GROUP_NAME.null.2147483647",
+"SYS.TABLES.CACHE_ID.null.10",
+"SYS.TABLES.CACHE_NAME.null.2147483647",
+"SYS.TABLES.SCHEMA_NAME.null.2147483647",
+"SYS.TABLES.TABLE_NAME.null.2147483647",
+"SYS.TABLES.AFFINITY_KEY_COLUMN.null.2147483647",
+"SYS.TABLES.KEY_ALIAS.null.2147483647",
+"SYS.TABLES.VALUE_ALIAS.null.2147483647",
+"SYS.TABLES.KEY_TYPE_NAME.null.2147483647",
+"SYS.TABLES.VALUE_TYPE_NAME.null.2147483647",
+"SYS.VIEWS.NAME.null.2147483647",
+"SYS.VIEWS.DESCRIPTION.null.2147483647",
+"SYS.VIEWS.SCHEMA.null.2147483647",
+"SYS.TABLE_COLUMNS.AFFINITY_COLUMN.null.1",
+"SYS.TABLE_COLUMNS.COLUMN_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.SCALE.null.10",
+"SYS.TABLE_COLUMNS.PK.null.1",
+"SYS.TABLE_COLUMNS.TYPE.null.2147483647",
+"SYS.TABLE_COLUMNS.DEFATULT.null.2147483647",
+"SYS.TABLE_COLUMNS.SCHEMA_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.TABLE_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.NULLABLE.null.1",
+"SYS.TABLE_COLUMNS.PRECISION.null.10",
 
 Review comment:
   PRECE**SS**ION


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330453659
 
 

 ##
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/SystemViewCollectionContainerAdapter.java
 ##
 @@ -0,0 +1,109 @@
+/*
+ * 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.internal.managers.systemview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.jetbrains.annotations.NotNull;
+
+import static java.util.Collections.emptyIterator;
+
+/**
+ * System view backed by {@code data} container.
+ * Each instance of {@code containers} collections should provide a collection 
of data.
+ *
+ * @see SystemView
+ */
+public class SystemViewCollectionContainerAdapter extends 
AbstractSystemView {
+/** Collections of the data containers */
+private final Collection containers;
+
+/** Function to extract collection of the data from container. */
+private final Function> dataExtractor;
+
+/** Row function. */
+private final BiFunction rowFunc;
+
+/**
+ * @param name Name.
+ * @param desc Description.
+ * @param rowCls Row class.
+ * @param walker Walker.
+ * @param containers Container of data.
+ * @param dataExtractor Data extractor function.
+ * @param rowFunc Row function.
+ */
+public SystemViewCollectionContainerAdapter(String name, String desc, 
Class rowCls,
+SystemViewRowAttributeWalker walker,
+Collection containers,
+Function> dataExtractor,
+BiFunction rowFunc) {
+super(name, desc, rowCls, walker);
+
+this.containers = containers;
+this.dataExtractor = dataExtractor;
+this.rowFunc = rowFunc;
+}
+
+/** {@inheritDoc} */
+@Override public int size() {
+int sz = 0;
+
+for (C c : containers)
+sz += dataExtractor.apply(c).size();
+
+return sz;
+}
+
+/** {@inheritDoc} */
+@NotNull @Override public Iterator iterator() {
+return new Iterator() {
 
 Review comment:
   I think it can be simplified by using `F.concat(F.iterator(...))`


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330457656
 
 

 ##
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/managers/systemview/SystemViewArrayContainerAdapter.java
 ##
 @@ -0,0 +1,111 @@
+/*
+ * 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.internal.managers.systemview;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import org.apache.ignite.spi.systemview.view.SystemView;
+import org.apache.ignite.spi.systemview.view.SystemViewRowAttributeWalker;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * System view backed by {@code data} container.
+ * Each instance of {@code containers} collections should provide a array of 
data.
+ *
+ * @see SystemView
+ */
+public class SystemViewArrayContainerAdapter extends 
AbstractSystemView {
 
 Review comment:
   Personally, I don't like this name, because "array container" means 
something storing the array. Here you don't store the array, but iterates 
through the nested array. But I'm ok with this name if there is no better name 
for the class.
   The same for `SystemViewCollectionContainerAdapter` class and `register...` 
methods.


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330427224
 
 

 ##
 File path: 
modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java
 ##
 @@ -788,14 +790,45 @@ public void testGetAllColumns() throws Exception {
 "SYS.TRANSACTIONS.OTHER_NODE_ID.null.2147483647",
 "SYS.TRANSACTIONS.TOP_VER.null.2147483647",
 "SYS.TRANSACTIONS.KEYS_COUNT.null.10",
-"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647"
+"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647",
+"SYS.CLIENT_CONNECTIONS.VERSION.null.2147483647",
+"SYS.SCHEMAS.NAME.null.2147483647",
+"SYS.SCHEMAS.PREDEFINED.null.1",
+"SYS.TABLES.CACHE_GROUP_ID.null.10",
+"SYS.TABLES.CACHE_GROUP_NAME.null.2147483647",
+"SYS.TABLES.CACHE_ID.null.10",
+"SYS.TABLES.CACHE_NAME.null.2147483647",
+"SYS.TABLES.SCHEMA_NAME.null.2147483647",
+"SYS.TABLES.TABLE_NAME.null.2147483647",
+"SYS.TABLES.AFFINITY_KEY_COLUMN.null.2147483647",
+"SYS.TABLES.KEY_ALIAS.null.2147483647",
+"SYS.TABLES.VALUE_ALIAS.null.2147483647",
+"SYS.TABLES.KEY_TYPE_NAME.null.2147483647",
+"SYS.TABLES.VALUE_TYPE_NAME.null.2147483647",
+"SYS.VIEWS.NAME.null.2147483647",
+"SYS.VIEWS.DESCRIPTION.null.2147483647",
+"SYS.VIEWS.SCHEMA.null.2147483647",
+"SYS.TABLE_COLUMNS.AFFINITY_COLUMN.null.1",
+"SYS.TABLE_COLUMNS.COLUMN_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.SCALE.null.10",
+"SYS.TABLE_COLUMNS.PK.null.1",
+"SYS.TABLE_COLUMNS.TYPE.null.2147483647",
+"SYS.TABLE_COLUMNS.DEFATULT.null.2147483647",
+"SYS.TABLE_COLUMNS.SCHEMA_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.TABLE_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.NULLABLE.null.1",
+"SYS.TABLE_COLUMNS.PRECISION.null.10",
+"SYS.TABLE_COLUMNS.AUTO_INCREMENT.null.1",
+"SYS.VIEW_COLUMNS.NULLABLE.null.1",
+"SYS.VIEW_COLUMNS.SCHEMA_NAME.null.2147483647",
+"SYS.VIEW_COLUMNS.COLUMN_NAME.null.2147483647",
+"SYS.VIEW_COLUMNS.TYPE.null.2147483647",
+"SYS.VIEW_COLUMNS.PRECISION.null.19",
+"SYS.VIEW_COLUMNS.DEFATULT.null.2147483647",
 
 Review comment:
   DEFAULT


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330427311
 
 

 ##
 File path: 
modules/clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinMetadataSelfTest.java
 ##
 @@ -788,14 +790,45 @@ public void testGetAllColumns() throws Exception {
 "SYS.TRANSACTIONS.OTHER_NODE_ID.null.2147483647",
 "SYS.TRANSACTIONS.TOP_VER.null.2147483647",
 "SYS.TRANSACTIONS.KEYS_COUNT.null.10",
-"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647"
+"SYS.TRANSACTIONS.CACHE_IDS.null.2147483647",
+"SYS.CLIENT_CONNECTIONS.VERSION.null.2147483647",
+"SYS.SCHEMAS.NAME.null.2147483647",
+"SYS.SCHEMAS.PREDEFINED.null.1",
+"SYS.TABLES.CACHE_GROUP_ID.null.10",
+"SYS.TABLES.CACHE_GROUP_NAME.null.2147483647",
+"SYS.TABLES.CACHE_ID.null.10",
+"SYS.TABLES.CACHE_NAME.null.2147483647",
+"SYS.TABLES.SCHEMA_NAME.null.2147483647",
+"SYS.TABLES.TABLE_NAME.null.2147483647",
+"SYS.TABLES.AFFINITY_KEY_COLUMN.null.2147483647",
+"SYS.TABLES.KEY_ALIAS.null.2147483647",
+"SYS.TABLES.VALUE_ALIAS.null.2147483647",
+"SYS.TABLES.KEY_TYPE_NAME.null.2147483647",
+"SYS.TABLES.VALUE_TYPE_NAME.null.2147483647",
+"SYS.VIEWS.NAME.null.2147483647",
+"SYS.VIEWS.DESCRIPTION.null.2147483647",
+"SYS.VIEWS.SCHEMA.null.2147483647",
+"SYS.TABLE_COLUMNS.AFFINITY_COLUMN.null.1",
+"SYS.TABLE_COLUMNS.COLUMN_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.SCALE.null.10",
+"SYS.TABLE_COLUMNS.PK.null.1",
+"SYS.TABLE_COLUMNS.TYPE.null.2147483647",
+"SYS.TABLE_COLUMNS.DEFATULT.null.2147483647",
+"SYS.TABLE_COLUMNS.SCHEMA_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.TABLE_NAME.null.2147483647",
+"SYS.TABLE_COLUMNS.NULLABLE.null.1",
+"SYS.TABLE_COLUMNS.PRECISION.null.10",
+"SYS.TABLE_COLUMNS.AUTO_INCREMENT.null.1",
+"SYS.VIEW_COLUMNS.NULLABLE.null.1",
+"SYS.VIEW_COLUMNS.SCHEMA_NAME.null.2147483647",
+"SYS.VIEW_COLUMNS.COLUMN_NAME.null.2147483647",
+"SYS.VIEW_COLUMNS.TYPE.null.2147483647",
+"SYS.VIEW_COLUMNS.PRECISION.null.19",
 
 Review comment:
   PRECE**SS**ION


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330436267
 
 

 ##
 File path: 
modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridH2Table.java
 ##
 @@ -205,6 +205,8 @@ public GridH2Table(
 // Indexes must be created in the end when everything is ready.
 idxs = tblDesc.createSystemIndexes(this);
 
+//TODO: add idxs to SqlIndexView here!!!
 
 Review comment:
   ?


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


[GitHub] [ignite] alex-plekhanov commented on a change in pull request #6916: IGNITE-12213: Sql objects system views.

2019-10-02 Thread GitBox
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_r330453178
 
 

 ##
 File path: 
modules/core/src/main/java/org/apache/ignite/internal/util/lang/gridfunc/ReadOnlyCollectionViewN.java
 ##
 @@ -0,0 +1,111 @@
+/*
+ * 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.internal.util.lang.gridfunc;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.apache.ignite.internal.util.GridSerializableCollection;
+import org.apache.ignite.internal.util.GridSerializableIterator;
+import org.apache.ignite.internal.util.lang.GridFunc;
+import org.apache.ignite.internal.util.typedef.internal.A;
+import org.jetbrains.annotations.NotNull;
+
+/**
+ * Collections wrapper.
+ * A read-only view will be created over the element and given
+ * collections and no copying will happen.
+ *
+ * @param  Element type.
+ */
+public class ReadOnlyCollectionViewN extends GridSerializableCollection {
 
 Review comment:
   There is no usages of this class. Also, class functionality can be replaced 
by `F.flatCollection()`


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