[
https://issues.apache.org/jira/browse/IGNITE-16009?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Aleksandr Polovtcev updated IGNITE-16009:
-----------------------------------------
Description:
Ignite 3 uses the Configuration framework to describe table schema and it
currently uses the following approach for storing columns and indices of a
particular table: both of these are represented as Named Lists, where keys are
sequentially ordered numbers converted into Strings and values are the
corresponding View classes.
This is most likely a legacy feature needed when Named Lists didn't have an
ordering guarantee and didn't have the functionality for retrieving values by
index.
I propose to change this approach to a more simple one: use column/index names
instead of sequentially ordered numbers in such Named Lists. This will make the
code, that uses it, more straightforward. Consider the following example:
*Old approach*
{code:java}
ColumnDefinition columnDefinition = SchemaBuilders.column("valStr2",
ColumnType.string())
.withDefaultValueExpression("default")
.build();
ignite0.tables().alterTable(TABLE_NAME,
tblChanger -> tblChanger.changeColumns(cols -> {
int colIdx = tblChanger.columns().namedListKeys().stream()
.mapToInt(Integer::parseInt).max().getAsInt() + 1;
cols.create(String.valueOf(colIdx), colChg ->
convert(columnDefinition, colChg));
})
{code}
*New approach*
{code:java}
ColumnDefinition columnDefinition = SchemaBuilders.column("valStr2",
ColumnType.string())
.withDefaultValueExpression("default")
.build();
ignite0.tables().alterTable(TABLE_NAME,
tblChanger -> tblChanger.changeColumns(cols ->
cols.create(columnDefinition.name(), colChg ->
convert(columnDefinition, colChg))
)
{code}
was:
Ignite 3 uses the Configuration framework to describe table schema and it
currently uses the following approach for storing columns and indices of a
particular table: both of these are represented as a Named List, where keys are
sequentially ordered numbers converted into Strings and values are the
corresponding View classes.
This is most likely a legacy feature needed when Named Lists didn't have an
ordering guarantee and didn't have the functionality for retrieving values by
index.
I propose to change this approach to a more simple one: use column/index names
instead of sequentially ordered numbers in such Named Lists. This will make the
code, that uses it, more straightforward. Consider the following example:
*Old approach*
{code:java}
ColumnDefinition columnDefinition = SchemaBuilders.column("valStr2",
ColumnType.string())
.withDefaultValueExpression("default")
.build();
ignite0.tables().alterTable(TABLE_NAME,
tblChanger -> tblChanger.changeColumns(cols -> {
int colIdx = tblChanger.columns().namedListKeys().stream()
.mapToInt(Integer::parseInt).max().getAsInt() + 1;
cols.create(String.valueOf(colIdx), colChg ->
convert(columnDefinition, colChg));
})
{code}
*New approach*
{code:java}
ColumnDefinition columnDefinition = SchemaBuilders.column("valStr2",
ColumnType.string())
.withDefaultValueExpression("default")
.build();
ignite0.tables().alterTable(TABLE_NAME,
tblChanger -> tblChanger.changeColumns(cols ->
cols.create(columnDefinition.name(), colChg ->
convert(columnDefinition, colChg))
)
{code}
> Use column and index names as Named List keys
> ---------------------------------------------
>
> Key: IGNITE-16009
> URL: https://issues.apache.org/jira/browse/IGNITE-16009
> Project: Ignite
> Issue Type: Improvement
> Reporter: Aleksandr Polovtcev
> Assignee: Aleksandr Polovtcev
> Priority: Major
> Labels: ignite-3
>
> Ignite 3 uses the Configuration framework to describe table schema and it
> currently uses the following approach for storing columns and indices of a
> particular table: both of these are represented as Named Lists, where keys
> are sequentially ordered numbers converted into Strings and values are the
> corresponding View classes.
> This is most likely a legacy feature needed when Named Lists didn't have an
> ordering guarantee and didn't have the functionality for retrieving values by
> index.
> I propose to change this approach to a more simple one: use column/index
> names instead of sequentially ordered numbers in such Named Lists. This will
> make the code, that uses it, more straightforward. Consider the following
> example:
> *Old approach*
> {code:java}
> ColumnDefinition columnDefinition = SchemaBuilders.column("valStr2",
> ColumnType.string())
> .withDefaultValueExpression("default")
> .build();
> ignite0.tables().alterTable(TABLE_NAME,
> tblChanger -> tblChanger.changeColumns(cols -> {
> int colIdx = tblChanger.columns().namedListKeys().stream()
> .mapToInt(Integer::parseInt).max().getAsInt() + 1;
> cols.create(String.valueOf(colIdx), colChg ->
> convert(columnDefinition, colChg));
> })
> {code}
>
> *New approach*
> {code:java}
> ColumnDefinition columnDefinition = SchemaBuilders.column("valStr2",
> ColumnType.string())
> .withDefaultValueExpression("default")
> .build();
> ignite0.tables().alterTable(TABLE_NAME,
> tblChanger -> tblChanger.changeColumns(cols ->
> cols.create(columnDefinition.name(), colChg ->
> convert(columnDefinition, colChg))
> )
> {code}
--
This message was sent by Atlassian Jira
(v8.20.1#820001)