/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull SimpleGroupPath prefixPath) { return getGroupName(prefixPath.getPath()); }
public LiteralNameResolver(List<String> names) { group_name_ = SimpleGroupPath.valueOf(names); }
public String getPathString() { return path_.getPathString(); }
@Override public int compareTo(GroupName o) { if (o == null) return 1; int cmp = 0; if (cmp == 0) cmp = getPath().compareTo(o.getPath()); if (cmp == 0) cmp = getTags().compareTo(o.getTags()); return cmp; }
buf .append(" as ") .append(((AcceptAsPath)builder).getAsPath().configString()); buf .append(" as ") .append(path.configString()); });
@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)); }
@Override public int compareTo(GroupName o) { if (o == null) return 1; int cmp = 0; if (cmp == 0) cmp = getPath().compareTo(o.getPath()); if (cmp == 0) cmp = getTags().compareTo(o.getTags()); return cmp; }
buf .append(" as ") .append(((AcceptAsPath)builder).getAsPath().configString()); buf .append(" as ") .append(path.configString()); });
public static GroupName valueOf(String... path) { return valueOf(SimpleGroupPath.valueOf(path)); }
/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull SimpleGroupPath prefixPath) { return getGroupName(prefixPath.getPath()); }
public String getPathString() { return path_.getPathString(); }
public static GroupName valueOf(String... path) { return valueOf(SimpleGroupPath.valueOf(path)); }
/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @param extraTags Additional tags to put in the tag set. The extraTags * argument will override any values present in the NamedResolverMap. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull SimpleGroupPath prefixPath, @NonNull Map<String, MetricValue> extraTags) { return getGroupName(prefixPath.getPath(), extraTags); }
@Override public Optional<Path> apply(Context<?> ctx) { return ctx.getAliasFromIdentifier(Path.class, identifier_) .map(path -> sub_select_.map(s -> s.apply(path)).orElseGet(() -> SimpleGroupPath.valueOf(path.getPath()))); }
/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @param extraTags Additional tags to put in the tag set. The extraTags * argument will override any values present in the NamedResolverMap. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull SimpleGroupPath prefixPath, @NonNull Map<String, MetricValue> extraTags) { return getGroupName(prefixPath.getPath(), extraTags); }
/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @param extraTags Additional tags to put in the tag set. The extraTags * argument will override any values present in the NamedResolverMap. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull List<String> prefixPath, @NonNull Map<String, MetricValue> extraTags) { final Stream<String> suffixPath = data.entrySet().stream() .filter(entry -> entry.getKey().getLeft().isPresent()) // Only retain int keys. .sorted(Comparator.comparing(entry -> entry.getKey().getLeft().get())) // Sort by int key. .map(Map.Entry::getValue) .map(value -> value.mapCombine(b -> b.toString(), i -> i.toString(), Function.identity())); final SimpleGroupPath path = SimpleGroupPath.valueOf(Stream.concat(prefixPath.stream(), suffixPath).collect(Collectors.toList())); final Map<String, MetricValue> tags = data.entrySet().stream() .filter(entry -> entry.getKey().getRight().isPresent()) // Only retain string keys. .collect(Collectors.toMap(entry -> entry.getKey().getRight().get(), entry -> entry.getValue().mapCombine(MetricValue::fromBoolean, MetricValue::fromIntValue, MetricValue::fromStrValue))); tags.putAll(extraTags); return GroupName.valueOf(path, tags); }
public boolean match(SimpleGroupPath grp) { return groups.match(grp.getPath()); }
/** * Create a GroupName from this NamedResolverMap. * * @param prefixPath Additional path elements to put in front of the * returned path. * @param extraTags Additional tags to put in the tag set. The extraTags * argument will override any values present in the NamedResolverMap. * @return A group name derived from this NamedResolverMap and the supplied * arguments. */ public GroupName getGroupName(@NonNull List<String> prefixPath, @NonNull Map<String, MetricValue> extraTags) { final Stream<String> suffixPath = data.entrySet().stream() .filter(entry -> entry.getKey().getLeft().isPresent()) // Only retain int keys. .sorted(Comparator.comparing(entry -> entry.getKey().getLeft().get())) // Sort by int key. .map(Map.Entry::getValue) .map(value -> value.mapCombine(b -> b.toString(), i -> i.toString(), Function.identity())); final SimpleGroupPath path = SimpleGroupPath.valueOf(Stream.concat(prefixPath.stream(), suffixPath).collect(Collectors.toList())); final Map<String, MetricValue> tags = data.entrySet().stream() .filter(entry -> entry.getKey().getRight().isPresent()) // Only retain string keys. .collect(Collectors.toMap(entry -> entry.getKey().getRight().get(), entry -> entry.getValue().mapCombine(MetricValue::fromBoolean, MetricValue::fromIntValue, MetricValue::fromStrValue))); tags.putAll(extraTags); return GroupName.valueOf(path, tags); }
@Override public Stream<Consumer<MutableContext>> map(Stream<Consumer<MutableContext>> in, Context ctx) { final Map<String, TimeSeriesValueSet> pathMapping = paths.entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, pmEntry -> { return ctx.getTSData() .getCurrentCollection() .get(p -> pmEntry.getValue().match(p.getPath()), x -> true); })); for (final Map.Entry<String, TimeSeriesValueSet> pm : pathMapping.entrySet()) { final String identifier = pm.getKey(); final List<Consumer<MutableContext>> applications = pm.getValue().stream() .map(group -> { Consumer<MutableContext> application = (nestedCtx) -> nestedCtx.putGroupAliasByName(identifier, group::getGroup); return application; }) .collect(Collectors.toList()); in = in.flatMap(inApplication -> applications.stream().map(inApplication::andThen)); } return in; } };
@Override public TimeSeriesValueSet getTSDelta(Context ctx) { return name_.apply(ctx) .map(path -> SimpleGroupPath.valueOf(path.getPath())) .map(name -> ctx.getTSData().getTSValue(name)) .orElse(TimeSeriesValueSet.EMPTY); }