Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-16009

Use column and index names as Named List keys

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0-alpha4
    • None

    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

              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));
                      })
      

      New approach

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

      Attachments

        Issue Links

          Activity

            People

              apolovtcev Aleksandr Polovtcev
              apolovtcev Aleksandr Polovtcev
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m