Accumulo
  1. Accumulo
  2. ACCUMULO-2832

Improve DefaultFormatter for reuse and object creation

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.5.1, 1.6.0
    • Fix Version/s: 1.5.2, 1.6.1, 1.7.0
    • Component/s: shell
    • Labels:

      Description

      The DefaultFormatter is the class that is used to convert an Entry<Key,Value> to the line of text displayed in the shell. Most notably, it encodes non-printable ASCII data as hex.

      For users who want to implement their own Formatter, they do not have access to the same formatting methods that the DefaultFormatter uses because of the visibility modifiers on the methods. These methods should be available for use by other classes. Letting classes extend the DefaultFormatter would be even better.

      Additionally, in the DefaultFormatter, in the method public static String formatEntry(Entry<Key,Value>, DateFormat), a StringBuilder is used to reduce the number of intermediate String objects that are created for each concatenation; however, the methods to get each component of the Key will create a new Text object each time.

      Method invocations like

      key.getRow()
      

      Should be replaced with:

      Text buffer = new Text();
      key.getRow(buffer);
      

      Where a single Text object is reused for the entire method.

        Activity

        Hide
        Jacob Meisler added a comment -

        Fixed the DefaultFormatter to use a single Text object.

        Show
        Jacob Meisler added a comment - Fixed the DefaultFormatter to use a single Text object.
        Hide
        ASF subversion and git services added a comment -

        Commit 59591273317147600a4299e215114fcf1fc1c341 in accumulo's branch refs/heads/1.5.2-SNAPSHOT from Jacob Meisler
        [ https://git-wip-us.apache.org/repos/asf?p=accumulo.git;h=5959127 ]

        ACCUMULO-2832 fixed object creation in Defaultformatter. Uses single Text object.

        Signed-off-by: Josh Elser <elserj@apache.org>

        Show
        ASF subversion and git services added a comment - Commit 59591273317147600a4299e215114fcf1fc1c341 in accumulo's branch refs/heads/1.5.2-SNAPSHOT from Jacob Meisler [ https://git-wip-us.apache.org/repos/asf?p=accumulo.git;h=5959127 ] ACCUMULO-2832 fixed object creation in Defaultformatter. Uses single Text object. Signed-off-by: Josh Elser <elserj@apache.org>
        Hide
        ASF subversion and git services added a comment -

        Commit 59591273317147600a4299e215114fcf1fc1c341 in accumulo's branch refs/heads/1.6.1-SNAPSHOT from Jacob Meisler
        [ https://git-wip-us.apache.org/repos/asf?p=accumulo.git;h=5959127 ]

        ACCUMULO-2832 fixed object creation in Defaultformatter. Uses single Text object.

        Signed-off-by: Josh Elser <elserj@apache.org>

        Show
        ASF subversion and git services added a comment - Commit 59591273317147600a4299e215114fcf1fc1c341 in accumulo's branch refs/heads/1.6.1-SNAPSHOT from Jacob Meisler [ https://git-wip-us.apache.org/repos/asf?p=accumulo.git;h=5959127 ] ACCUMULO-2832 fixed object creation in Defaultformatter. Uses single Text object. Signed-off-by: Josh Elser <elserj@apache.org>
        Hide
        ASF subversion and git services added a comment -

        Commit 59591273317147600a4299e215114fcf1fc1c341 in accumulo's branch refs/heads/master from Jacob Meisler
        [ https://git-wip-us.apache.org/repos/asf?p=accumulo.git;h=5959127 ]

        ACCUMULO-2832 fixed object creation in Defaultformatter. Uses single Text object.

        Signed-off-by: Josh Elser <elserj@apache.org>

        Show
        ASF subversion and git services added a comment - Commit 59591273317147600a4299e215114fcf1fc1c341 in accumulo's branch refs/heads/master from Jacob Meisler [ https://git-wip-us.apache.org/repos/asf?p=accumulo.git;h=5959127 ] ACCUMULO-2832 fixed object creation in Defaultformatter. Uses single Text object. Signed-off-by: Josh Elser <elserj@apache.org>

          People

          • Assignee:
            Jacob Meisler
            Reporter:
            Josh Elser
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development