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

Support renaming in named list configuration elements

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0-alpha2
    • 3.0.0-alpha3
    • None

    Description

      Motivation

      Current NamedListChange API does not allow you to perform rename operation. Best that you can do is to manually copy the required element and then delete the original. This is bad for several reasons:

      • inconvenient both in Java API and CLI tool;
      • results in "onDelete" and "onCreate" events, which is probably not what people want.

      There must be a way to rename elements in Java API at least so that "ALTER ..." DDL command could be properly implemented.

      Java API

      NamedListChange is a right place to add "rename" method. It should have two parameters and following restrictions:

      • "old" and "new" names are not null;
      • element with "old" name must exist;
      • element with "new" name must not exist.

      New method must be added to ConfigurationNamedListListener, named "onRename". It should have "onUpdate" semantics, but with two new parameters: "oldKey" and "newKey". Names are a subject to change.

      CLI

      This is a little less obvious since HOCON/JSON describe data, not operations. We already have specific syntax for "delete" operation. I suggest making "rename" look similar:

      root.namedList {
        oldName = newName
      }

      In short, now we can assign 3 things to the element:

      • regular composite object with its inner values;
      • "null" for deletion;
      • "String" for renaming.

      HOCON/JSON format will have no alterations for this feature. DDL commands are to be used for these operations instead.

      Implementation hints

      This will be similar to how we store ordering of named list elements. But this time we have to assign each element a unique identifier. This can be a String or a number. Laziest solution is to use UUID with hyphens removed from it. That'll do it.

      NamedListNode object will store these ids. In short, following algorithms will have to be altered:

      • conversion of update tree to the flat map - this one should be easy;
      • applying the flat map to the tree - a bit trickier. Matching from ids to keys will be required, we have to make sure that it won't cost too much;
      • matching old list with a new one to properly invoke listeners - should be partially solved by the code from the issue above, but still, might be tricky as well.

      HOCON / JSON "parsers" will have to be altered as well to support "rename" operation. That should be easy.

      Attachments

        Issue Links

          Activity

            People

              ibessonov Ivan Bessonov
              ibessonov Ivan Bessonov
              Aleksandr Polovtsev Aleksandr Polovtsev
              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 - 6h 50m
                  6h 50m