private Optional<MutableTimeSeriesValue> remove_(GroupName name) { final SimpleGroupPath path = name.getPath(); final Optional<MutableTimeSeriesValue> removed = Optional.ofNullable(data_.remove(name)); removed.ifPresent(r -> { Set<MutableTimeSeriesValue> set = data_by_path_.get(path); final boolean is_removed = set.remove(r); assert (is_removed); if (set.isEmpty()) data_by_path_.remove(path); }); return removed; }
@Override public Set<SimpleGroupPath> getGroupPaths(Predicate<? super SimpleGroupPath> filter) { return tsvSet.entrySet().stream() .filter(entry -> filter.test(entry.getKey().getPath())) .collect(Collectors.groupingBy(entry -> entry.getKey().getPath())).entrySet().stream() .filter(listing -> listing.getValue().stream().map(Map.Entry::getValue).anyMatch(Optional::isPresent)) .map(Map.Entry::getKey) .collect(Collectors.toSet()); }
@Override public TimeSeriesValueSet get(Predicate<? super SimpleGroupPath> pathFilter, Predicate<? super GroupName> groupFilter) { return new TimeSeriesValueSet(groupMap.entrySet().stream() .filter(entry -> pathFilter.test(entry.getKey().getPath())) .filter(entry -> groupFilter.test(entry.getKey())) .map(Map.Entry::getValue)); } }
public TimeSeriesValueSet(Stream<? extends TimeSeriesValue> tsv) { tsv_ = tsv .map(x -> { final TimeSeriesValue r = x; // Implicit cast return r; }) .collect(Collectors.groupingBy(v -> v.getGroup().getPath())); }
@Override public TimeSeriesValueSet get(Predicate<? super SimpleGroupPath> pathFilter, Predicate<? super GroupName> groupFilter) { return new TimeSeriesValueSet(groupMap.entrySet().stream() .filter(entry -> pathFilter.test(entry.getKey().getPath())) .filter(entry -> groupFilter.test(entry.getKey())) .map(Map.Entry::getValue)); } }
@Override public TimeSeriesValueSet getTSValue(SimpleGroupPath name) { return new TimeSeriesValueSet(tsvSet.entrySet().stream() .filter(entry -> Objects.equals(entry.getKey().getPath(), name)) .map(Map.Entry::getValue) .filter(Optional::isPresent) .map(Optional::get)); }
@Override public TimeSeriesValueSet get(Predicate<? super SimpleGroupPath> pathFilter, Predicate<? super GroupName> groupFilter) { return new TimeSeriesValueSet(tsvSet.entrySet().stream() .filter(entry -> pathFilter.test(entry.getKey().getPath())) .filter(entry -> groupFilter.test(entry.getKey())) .map(Map.Entry::getValue) .filter(Optional::isPresent) .map(Optional::get)); }
@Override public TimeSeriesValueSet get(Predicate<? super SimpleGroupPath> pathFilter, Predicate<? super GroupName> groupFilter) { return new TimeSeriesValueSet(interpolatedTsvMap.entrySet().stream() .filter(entry -> pathFilter.test(entry.getKey().getPath())) .filter(entry -> groupFilter.test(entry.getKey())) .map(Map.Entry::getValue)); }
private void add_(MutableTimeSeriesValue tsv) { final GroupName name = tsv.getGroup(); final SimpleGroupPath path = name.getPath(); final Optional<MutableTimeSeriesValue> removed = Optional.ofNullable(data_.put(name, tsv)); removed.ifPresent(r -> { final boolean is_removed = data_by_path_.get(path).remove(r); assert (is_removed); }); data_by_path_.computeIfAbsent(path, (p) -> new HashSet<>()) .add(tsv); }
public TimeSeriesValueSet(Stream<? extends TimeSeriesValue> tsv) { tsv_ = tsv .map(x -> { final TimeSeriesValue r = x; // Implicit cast return r; }) .collect(Collectors.groupingBy(v -> v.getGroup().getPath())); }
private static GroupName calculate_new_name_(GroupName oldname, Map<String, MetricValue> tagged_values) { return GroupName.valueOf(oldname.getPath(), Stream.concat( oldname.getTags().stream().filter((Map.Entry<String, MetricValue> entry) -> !tagged_values.keySet().contains(entry.getKey())), tagged_values.entrySet().stream())); }
/** * Construct a time series collection. * * @param timestamp The timestamp of the collection. * @param tsv A stream of values for the collection. The values stream may * not have duplicate group names. * @throws IllegalArgumentException if the time series values contain * duplicate group names. */ public SimpleTimeSeriesCollection(@NonNull DateTime timestamp, @NonNull Stream<? extends TimeSeriesValue> tsv) { this.timestamp = timestamp; groupMap = tsv.collect(Collectors.toMap(TimeSeriesValue::getGroup, v -> v, throwing_merger_(), hashmap_constructor_())); pathMap = groupMap.values().stream() .collect(Collectors.groupingBy(v -> v.getGroup().getPath(), hashmap_constructor_(), Collectors.toList())); }
/** * Construct a time series collection. * * @param timestamp The timestamp of the collection. * @param tsv A stream of values for the collection. The values stream may * not have duplicate group names. * @throws IllegalArgumentException if the time series values contain * duplicate group names. */ public SimpleTimeSeriesCollection(@NonNull DateTime timestamp, @NonNull Stream<? extends TimeSeriesValue> tsv) { this.timestamp = timestamp; groupMap = tsv.collect(Collectors.toMap(TimeSeriesValue::getGroup, v -> v, throwing_merger_(), hashmap_constructor_())); pathMap = groupMap.values().stream() .collect(Collectors.groupingBy(v -> v.getGroup().getPath(), hashmap_constructor_(), Collectors.toList())); }
@Override public TimeSeriesValueSet getTSValue(SimpleGroupPath name) { Stream<TimeSeriesValue> interpolatedValues = interpolatedTsvMap.keySet().stream() .filter(g -> g.getPath().equals(name)) .map(interpolatedTsvMap::get); Stream<TimeSeriesValue> currentValues = current.getTSValue(name).stream(); return new TimeSeriesValueSet(Stream.concat(interpolatedValues, currentValues)); }
public void putGroupAliasByName(String identifier, Supplier<GroupName> group) { putSupplied(identifier, TimeSeriesValueSet.class, (Context ctx) -> getTSData().getTSDeltaByName(group.get()), () -> group.get().getPath()); }