move Tags.asString() to StringCompressor
This commit is contained in:
@@ -37,7 +37,8 @@ public class Entry {
|
||||
public String toString() {
|
||||
|
||||
final OffsetDateTime date = Instant.ofEpochMilli(epochMilli).atOffset(ZoneOffset.UTC);
|
||||
return date.format(DateTimeFormatter.ISO_ZONED_DATE_TIME) + " = " + value + " (" + tags.asString() + ")";
|
||||
return date.format(DateTimeFormatter.ISO_ZONED_DATE_TIME) + " = " + value + " ("
|
||||
+ Tags.STRING_COMPRESSOR.asString(tags) + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -135,4 +135,21 @@ public class StringCompressor {
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public String asString(final Tags tags) {
|
||||
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
for (final Tag tag : tags.toTags()) {
|
||||
if (result.length() > 0) {
|
||||
result.append(", ");
|
||||
}
|
||||
|
||||
result.append(get(tag.getKey()));
|
||||
result.append("=");
|
||||
result.append(get(tag.getValue()));
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.lucares.utils.byteencoder.VariableByteEncoder;
|
||||
|
||||
public class Tags implements Comparable<Tags> {
|
||||
|
||||
private static final String DEFAULT_GROUP = "<none>";
|
||||
public static StringCompressor STRING_COMPRESSOR = null;
|
||||
private static final byte[] EMPTY_BYTES = new byte[0];
|
||||
public static final Tags EMPTY = new Tags();
|
||||
@@ -246,45 +245,4 @@ public class Tags implements Comparable<Tags> {
|
||||
keyValueConsumer.accept(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User facing readable representation
|
||||
*/
|
||||
// TODO move
|
||||
// to StringCompressor
|
||||
|
||||
public String asString() {
|
||||
|
||||
final StringBuilder result = new StringBuilder();
|
||||
|
||||
for (final Tag tag : tags) {
|
||||
if (result.length() > 0) {
|
||||
result.append(", ");
|
||||
}
|
||||
|
||||
result.append(STRING_COMPRESSOR.get(tag.getKey()));
|
||||
result.append("=");
|
||||
result.append(STRING_COMPRESSOR.get(tag.getValue()));
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
// TODO move
|
||||
// to StringCompressor
|
||||
//
|
||||
// public String asValueString() {
|
||||
// final StringBuilder result = new StringBuilder();
|
||||
// if (isEmpty()) {
|
||||
// result.append(DEFAULT_GROUP);
|
||||
// } else {
|
||||
// forEach((k, v) -> {
|
||||
// if (result.length() > 0) {
|
||||
// result.append(" / ");
|
||||
// }
|
||||
// result.append(v);
|
||||
// });
|
||||
// }
|
||||
// return result.toString();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ public class Plotter {
|
||||
|
||||
METRICS_LOGGER.debug("wrote {} values to csv in: {}ms (ignored {} values) use millis: {}, grouping={}",
|
||||
plottedValues, (System.nanoTime() - start) / 1_000_000.0, ignoredValues, Boolean.toString(useMillis),
|
||||
groupResult.getGroupedBy().asString());
|
||||
Tags.STRING_COMPRESSOR.asString(groupResult.getGroupedBy()));
|
||||
return new CsvSummary(count, statsMaxValue, statsCurrentAverage, aggregator);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user