You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Maksim Zhuravkov (Jira)" <ji...@apache.org> on 2023/08/28 05:41:00 UTC
[jira] [Commented] (IGNITE-20018) Introduce system view definition API
[ https://issues.apache.org/jira/browse/IGNITE-20018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17759451#comment-17759451 ]
Maksim Zhuravkov commented on IGNITE-20018:
-------------------------------------------
[~zstan], [~amashenkov] Could you please review this PR?
> Introduce system view definition API
> ------------------------------------
>
> Key: IGNITE-20018
> URL: https://issues.apache.org/jira/browse/IGNITE-20018
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Reporter: Konstantin Orlov
> Assignee: Maksim Zhuravkov
> Priority: Major
> Labels: ignite-3
> Fix For: 3.0.0-beta2
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Let's introduce API to define a system view. Below is a few examples of how it may look like:
> {code:java}
> SystemView.<Table>clusterViewBuilder()
> .name("USERS")
> .addColumn("ID", Integer.class, Table::id)
> .addColumn("SCHEMA_ID", Integer.class, Table::schemaId)
> .addColumn("NAME", String.class, Table::name)
> .addColumn("COLUMN_NAMES", String.class, Table::columnNames)
> .dataProvider(() -> toAsyncCursor(tableManager.allTables()))
> .build();
> SystemView.<Connection>nodeViewBuilder()
> .name("CONNECTIONS")
> .addColumn("USER", String.class, Connection::user)
> .addColumn("ADDRESS", String.class, Connection::address)
> .addColumn("ATTRS", String.class, Connection::attrs)
> .localNodeColumnAlias("NODE_ID")
> .dataProvider(() -> toAsyncCursor(connManager.connections()))
> .build();
> {code}
> Explanation of the code snippet above:
> * We need to distinguish between views exposing data with cluster-wide semantic and views exposing data with node-specific semantic. Such segregation is required to properly map queries' fragments to nodes owning data.
> * *name* attribute – is a name of the view under which it will be available in sql
> * *addColumn* attribute – appends a column to the view definition. View definition should have columns in the order of invocation of addColumn method. This method accepts three parameters: name, column type represented by class, and property reader. Name is a name of the column, under which the column under which it will be available in sql. Class is required to properly build the view's description. Property reader is a function which accepts objects of type specified in generic of builder, and returns value for the column of interest.
> * *dataProvider* attribute – provides an access to data this view is supposed to expose. Data provider accepts the supplier of AsyncCursor (see org.apache.ignite.internal.sql.engine.AsyncCursor; should be moved to core). AsyncCursor is required, because some of the data may be not stored locally, thus remote call will be required. To avoid blocking of query engine threads, it's better to integrate with async primitives, rather than force every module to store required state in local collections.
> * *localNodeColumnAlias* attribute – alias for the column exposing node id. This attribute is available only for nodeView’s, since node id will be injected automatically only for this type of view.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)