Class MapLabels

java.lang.Object
io.nosqlbench.nb.api.labels.MapLabels
All Implemented Interfaces:
NBLabels

public class MapLabels extends Object implements NBLabels
  • Field Details

  • Constructor Details

  • Method Details

    • linearizeValues

      public String linearizeValues(char delim, String... included)
      Description copied from interface: NBLabels
      Create a string representation of the label data, including only the values. Each value is concatenated with the others using the delim character. If a specified label name is included in square brackets like , then it is considered optional, and will be skipped over gracefully if it is not present in the label set. Otherwise all names are considered required.
      Specified by:
      linearizeValues in interface NBLabels
      Parameters:
      delim - A single character
      included - Which fields from the label set to include in the rendered string. If none are specified then all are included.
      Returns:
      A string representation of the labels
    • linearize_bare

      public String linearize_bare(String... barewords)
      Specified by:
      linearize_bare in interface NBLabels
    • linearize

      public String linearize(String bareName, String... included)
      Description copied from interface: NBLabels
      Render a string representation of the label set according to the prometheus exposition naming format. This means that a label set which includes the JSON data:
      
       {
         "name": "fooname",
         "label1": "label1value"
       }
       
      would render to
      fooname{label1="label1value"}
      IF called as linearize("name").

      The included fields are added to the label set. If none are specified then all are included by default.

      Specified by:
      linearize in interface NBLabels
      Parameters:
      bareName - The field from the label set to use as the nominal metric family name part.
      included - Fields to be used in rendered label set.
      Returns:
      A string representation of the labels that is parsable in the prometheus exposition format.
    • linearizeAsMetrics

      public String linearizeAsMetrics()
      Specified by:
      linearizeAsMetrics in interface NBLabels
    • linearizeAsKvString

      public String linearizeAsKvString()
      Specified by:
      linearizeAsKvString in interface NBLabels
    • sanitize

      public static String sanitize(String word)
    • and

      public MapLabels and(Object... labelsAndValues)
      Description copied from interface: NBLabels
      Create a new NBLabels value with the additional keys and values appended.
      Specified by:
      and in interface NBLabels
      Parameters:
      labelsAndValues - Keys and values in "key1", "value1", "key2", "value2", ... form
      Returns:
      A new NBLabels instance
    • andDefault

      public NBLabels andDefault(String name, String value)
      Specified by:
      andDefault in interface NBLabels
    • andDefault

      public NBLabels andDefault(NBLabels defaults)
      Specified by:
      andDefault in interface NBLabels
    • and

      public MapLabels and(NBLabels labels)
      Specified by:
      and in interface NBLabels
    • modifyName

      public NBLabels modifyName(String nameToModify, Function<String,String> transform)
      Description copied from interface: NBLabels
      Return a new NBLabels value with the specified key transformed according to the provided Lambda. The associated value is not modified.
      Specified by:
      modifyName in interface NBLabels
      Parameters:
      nameToModify - The key to modify
      transform - A Lambda which will modify the existing key name.
      Returns:
      A new NBLabels value, separate from the original
    • modifyValue

      public NBLabels modifyValue(String labelName, Function<String,String> transform)
      Description copied from interface: NBLabels
      Return a new NBLabels value with the specified value transformed according to the provided Lambda. The associated key name is not modified.
      Specified by:
      modifyValue in interface NBLabels
      Parameters:
      labelName - The named label to modify
      transform - A Lambda which will modify the existing value.
      Returns:
      A new NBLabels value, separate from the original
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • valueOf

      public String valueOf(String name)
      Description copied from interface: NBLabels
      Return the value of the specified label key.
      Specified by:
      valueOf in interface NBLabels
      Parameters:
      name - The label name
      Returns:
      The named label's value
    • valueOfOptional

      public Optional<String> valueOfOptional(String name)
      Specified by:
      valueOfOptional in interface NBLabels
    • asMap

      public Map<String,String> asMap()
      Description copied from interface: NBLabels
      Return a map representation of the label set, regardless of the underlying form.
      Specified by:
      asMap in interface NBLabels
      Returns:
      a Map of keys and values, in deterministic order
    • and

      public NBLabels and(Map<String,String> moreLabels)
      Description copied from interface: NBLabels
      Create a new NBLabels value with the additional keys and values appended.
      Specified by:
      and in interface NBLabels
      Parameters:
      moreLabels - a map of keys and values
      Returns:
      A new NBLabels instance
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • intersection

      public NBLabels intersection(NBLabels otherLabels)
      Take the intersection of the two label sets, considering both key and value for each label entry. If both have the same label name but different values for it, then that label is not considered common and it is not retained in the intersection.
      Specified by:
      intersection in interface NBLabels
      Parameters:
      otherLabels - The label set to intersect
      Returns:
      a String
    • difference

      public NBLabels difference(NBLabels otherLabels)
      Subtract all matching labels from the other label set from this one, considering label names and values. If the other label set contains the same name but a different value, then it is not considered a match and thus not removed from the labels of this element.
      Specified by:
      difference in interface NBLabels
      Parameters:
      otherLabels - Labels to remove, where key and value matches
      Returns:
      The same, or a smaller set of labels for this element
    • isEmpty

      public boolean isEmpty()
      Specified by:
      isEmpty in interface NBLabels