public LiteralNameResolver(List<String> names) { group_name_ = SimpleGroupPath.valueOf(names); }
public static GroupName valueOf(String... path) { return valueOf(SimpleGroupPath.valueOf(path)); }
public static GroupName valueOf(String... path) { return valueOf(SimpleGroupPath.valueOf(path)); }
@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 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); }
/** * 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 TimeSeriesValueSet getTSDelta(Context ctx) { return name_.apply(ctx) .map(path -> SimpleGroupPath.valueOf(path.getPath())) .map(name -> ctx.getTSData().getTSValue(name)) .orElse(TimeSeriesValueSet.EMPTY); }
@Override public void transform(Context ctx) { final SimpleGroupPath group_name = getGroup().apply(ctx) .map(path -> SimpleGroupPath.valueOf(path.getPath())) .orElseThrow(() -> new IllegalArgumentException("unable to resolve group name")); final TagData tagData = new TagData(ctx, tags); resolveMapping(ctx, mapping, name -> resolveMetricName(ctx, name)) .forEach(metric_expr -> { final MetricName metric = metric_expr.getKey(); metric_expr.getValue().streamAsMap() .forEach((Map.Entry<Tags, MetricValue> resolvedMetric) -> addMetricMappingToCtx(ctx, group_name, metric, tagData, resolvedMetric)); }); }
@Override public void transform(Context ctx) { final MutableContext m_ctx = (MutableContext)ctx; final TimeSeriesCollectionPair ts_data = ctx.getTSData(); m_ctx.putGroupAlias(identifier_, group_.apply(ctx).map(path -> SimpleGroupPath.valueOf(path.getPath()))); }
public Stream<Alert> create_alert_(Context ctx) { final TimeSeriesCollectionPair ts_data = ctx.getTSData(); final Map<String, Any2<TimeSeriesMetricDeltaSet, List<TimeSeriesMetricDeltaSet>>> attr_map = calculate_attributes_(ctx); return alert_defn_.getName().apply(ctx) .map(path -> SimpleGroupPath.valueOf(path.getPath())) .map((name) -> { return alert_defn_.getPredicate().apply(ctx) .streamAsMap() .map((tag_val) -> SimpleMapEntry.create(tag_val.getKey(), tag_val.getValue().asBool())) .map((tag_bool) -> { final GroupName alert_name = GroupName.valueOf(name, tag_bool.getKey()); final Optional<Boolean> triggering = tag_bool.getValue(); Map<String, Any2<MetricValue, List<MetricValue>>> attrs = lookup_attributes_(alert_name.getTags(), attr_map); return new Alert(ts_data.getCurrentCollection().getTimestamp(), alert_name, alert_defn_::configString, triggering, alert_defn_.getFireDuration(), alert_defn_.getMessage(), attrs); }); }) .orElseGet(Stream::empty); }
public final Lit_group_nameContext lit_group_name() throws RecognitionException { Lit_group_nameContext _localctx = new Lit_group_nameContext(_ctx, getState()); enterRule(_localctx, 50, RULE_lit_group_name); try { enterOuterAlt(_localctx, 1); { setState(471); ((Lit_group_nameContext)_localctx).s1 = raw_dotted_identifier(); ((Lit_group_nameContext)_localctx).s = SimpleGroupPath.valueOf(((Lit_group_nameContext)_localctx).s1.s); } } catch (RecognitionException re) { _localctx.exception = re; _errHandler.reportError(this, re); _errHandler.recover(this, re); } finally { exitRule(); } return _localctx; }