func funcLabelJoin(vals []Value, args Expressions, enh *EvalNodeHelper) Vector {
	var (
		vector    = vals[0].(Vector)
		dst       = args[1].(*StringLiteral).Val
		sep       = args[2].(*StringLiteral).Val
		srcLabels = make([]string, len(args)-3)
	)

	if enh.dmn == nil {
		enh.dmn = make(map[uint64]labels.Labels, len(enh.out))
	}

	for i := 3; i < len(args); i++ {
		src := args[i].(*StringLiteral).Val
		if !model.LabelName(src).IsValid() {
			panic(errors.Errorf("invalid source label name in label_join(): %s", src))
		}
		srcLabels[i-3] = src
	}

	if !model.LabelName(dst).IsValid() {
		panic(errors.Errorf("invalid destination label name in label_join(): %s", dst))
	}

	srcVals := make([]string, len(srcLabels))
	for _, el := range vector {
		h := el.Metric.Hash()
		var outMetric labels.Labels
		if l, ok := enh.dmn[h]; ok {
			outMetric = l
		} else {

			for i, src := range srcLabels {
				srcVals[i] = el.Metric.Get(src)
			}

			lb := labels.NewBuilder(el.Metric)

			strval := strings.Join(srcVals, sep)
			if strval == "" {
				lb.Del(dst)
			} else {
				lb.Set(dst, strval)
			}

			outMetric = lb.Labels()
			enh.dmn[h] = outMetric
		}

		enh.out = append(enh.out, Sample{
			Metric: outMetric,
			Point:  Point{V: el.Point.V},
		})
	}
	return enh.out
}
func funcLabelJoin(vals []Value, args Expressions, enh *EvalNodeHelper) Vector {
	var (
		vector    = vals[0].(Vector)
		dst       = args[1].(*StringLiteral).Val
		sep       = args[2].(*StringLiteral).Val
		srcLabels = make([]string, len(args)-3)
	)

	if enh.dmn == nil {
		enh.dmn = make(map[uint64]labels.Labels, len(enh.out))
	}

	for i := 3; i < len(args); i++ {
		src := args[i].(*StringLiteral).Val
		if !model.LabelName(src).IsValid() {
			panic(errors.Errorf("invalid source label name in label_join(): %s", src))
		}
		srcLabels[i-3] = src
	}

	if !model.LabelName(dst).IsValid() {
		panic(errors.Errorf("invalid destination label name in label_join(): %s", dst))
	}

	srcVals := make([]string, len(srcLabels))
	for _, el := range vector {
		h := el.Metric.Hash()
		var outMetric labels.Labels
		if l, ok := enh.dmn[h]; ok {
			outMetric = l
		} else {

			for i, src := range srcLabels {
				srcVals[i] = el.Metric.Get(src)
			}

			lb := labels.NewBuilder(el.Metric)

			strval := strings.Join(srcVals, sep)
			if strval == "" {
				lb.Del(dst)
			} else {
				lb.Set(dst, strval)
			}

			outMetric = lb.Labels()
			enh.dmn[h] = outMetric
		}

		enh.out = append(enh.out, Sample{
			Metric: outMetric,
			Point:  Point{V: el.Point.V},
		})
	}
	return enh.out
}
func funcLabelJoin ( vals [ ] Value , args Expressions , enh * EvalNodeHelper ) Vector { var ( vector = vals [ 0 ] . ( Vector ) dst = args [ 1 ] . ( * StringLiteral ) . Val sep = args [ 2 ] . ( * StringLiteral ) . Val srcLabels = make ( [ ] string , len ( args ) - 3 ) ) if enh . dmn == nil { enh . dmn = make ( map [ uint64 ] labels . Labels , len ( enh . out ) ) } for i := 3 ; i < len ( args ) ; i ++ { src := args [ i ] . ( * StringLiteral ) . Val if ! model . LabelName ( src ) . IsValid ( ) { panic ( errors . Errorf ( " " , src ) ) } srcLabels [ i - 3 ] = src } if ! model . LabelName ( dst ) . IsValid ( ) { panic ( errors . Errorf ( " " , dst ) ) } srcVals := make ( [ ] string , len ( srcLabels ) ) for _ , el := range vector { h := el . Metric . Hash ( ) var outMetric labels . Labels if l , ok := enh . dmn [ h ] ; ok { outMetric = l } else { for i , src := range srcLabels { srcVals [ i ] = el . Metric . Get ( src ) } lb := labels . NewBuilder ( el . Metric ) strval := strings . Join ( srcVals , sep ) if strval == " " { lb . Del ( dst ) } else { lb . Set ( dst , strval ) } outMetric = lb . Labels ( ) enh . dmn [ h ] = outMetric } enh . out = append ( enh . out , Sample { Metric : outMetric , Point : Point { V : el . Point . V } , } ) } return enh . out }
// === label_join(vector model.ValVector, dest_labelname, separator, src_labelname...) Vector ===
=== label_join ( vector model . ValVector dest_labelname separator src_labelname ... ) Vector ===