/** * Constructs a new Builder * * @param metric the metric name */ public Builder(String metric) { straceTimeSeries = new StraceTimeSeries(); straceTimeSeries.metric = metric; }
/** * Adds all the given points to the time series * * @param timestamps the timestamps * @param values the values */ public final void addAll(List<Long> timestamps, List<String> values) { for (int i = 0; i < timestamps.size(); i++) { add(timestamps.get(i), values.get(i)); } }
@Override public int hashCode() { return new HashCodeBuilder() .append(getMetric()) .toHashCode(); }
/** * Sorts the time series values. */ public void sort() { if (timestamps.size() > 1) { LongList sortedTimes = new LongList(timestamps.size()); ArrayList<String> sortedValues = new ArrayList<>(values.size()); points().sorted((o1, o2) -> Long.compare(o1.getTimestamp(), o2.getTimestamp())).forEachOrdered(p -> { sortedTimes.add(p.getTimestamp()); sortedValues.add(p.getValue()); }); timestamps = sortedTimes; values = sortedValues; } }