net.opentsdb.core
public final class Tags extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
looksLikeInteger(String value)
Returns true if the given string looks like an integer.
|
static void |
parse(HashMap<String,String> tags,
String tag)
Parses a tag into a HashMap.
|
static long |
parseLong(CharSequence s)
Parses an integer value as a long from the given character sequence.
|
static String |
parseWithMetric(String metric,
HashMap<String,String> tags)
Parses the metric and tags out of the given string.
|
static String[] |
splitString(String s,
char c)
Optimized version of
String#split that doesn't use regexps. |
static void |
validateString(String what,
String s)
Ensures that a given string is a valid metric name or tag name/value.
|
public static String[] splitString(String s, char c)
String#split
that doesn't use regexps.
This function works in O(5n) where n is the length of the string to
split.s
- The string to split.c
- The separator to use to split the string.public static void parse(HashMap<String,String> tags, String tag)
tags
- The HashMap into which to store the tag.tag
- A String of the form "tag=value".IllegalArgumentException
- if the tag is malformed.IllegalArgumentException
- if the tag was already in tags with a
different value.public static String parseWithMetric(String metric, HashMap<String,String> tags)
metric
- A string of the form "metric" or "metric{tag=value,...}".tags
- The map to populate with the tags parsed out of the first
argument.IllegalArgumentException
- if the metric is malformed.public static long parseLong(CharSequence s)
This is equivalent to Long.parseLong(String)
except it's up to
100% faster on String
and always works in O(1) space even with
StringBuilder
buffers (where it's 2x to 5x faster).
s
- The character sequence containing the integer value to parse.NumberFormatException
- if the value is malformed or overflows.public static void validateString(String what, String s)
what
- A human readable description of what's being validated.s
- The string to validate.IllegalArgumentException
- if the string isn't valid.public static boolean looksLikeInteger(String value)
This function doesn't do any checking on the string other than looking for some characters that are generally found in floating point values such as '.' or 'e'.