Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1681

Introduce interfaces IndexedStringMap and IndexedReadOnlyStringMap

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7
    • Fix Version/s: 2.8
    • Component/s: API
    • Labels:
      None

      Description

      This ticket proposes to introduce a public interface that imposes a total ordering over the keys of a (ReadOnly)StringMap. This interface views all key-value pairs as a sequence ordered by key, and allows keys and values to be accessed by their index in the sequence.

      interface IndexedReadOnlyStringMap extends ReadOnlyStringMap {
          String getKeyAt(final int index);
          <V> V getValueAt(final int index);
          int indexOfKey(final String key);
      }
      
      interface IndexedStringMap extends IndexedReadOnlyStringMap, StringMap {}
      

      The intention is to let SortedArrayStringMap implement these interfaces. (It already implements the necessary methods; the visibility of these methods will change from package-protected to public.)

      These interfaces help reduce log4j's dependency on the JDK Map interface: the JDK Map interface does not provide a garbage-free way to iterate over all its keys or key-value pairs.

      For example, these interfaces can be used to make MapFilter and its subclasses garbage-free, and reduce allocation of temporary objects in MapMessage and subclasses.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                remkop@yahoo.com Remko Popma
                Reporter:
                remkop@yahoo.com Remko Popma
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: