MCPcopy
hub / github.com/grafana/tempo / createBytesPredicate

Function createBytesPredicate

tempodb/encoding/vparquet5/block_traceql.go:2749–2808  ·  view source on GitHub ↗
(op traceql.Operator, operands traceql.Operands, isSpan bool)

Source from the content-addressed store, hash-verified

2747}
2748
2749func createBytesPredicate(op traceql.Operator, operands traceql.Operands, isSpan bool) (parquetquery.Predicate, error) {
2750 if pred, handled := createExistencePredicate(op); handled {
2751 return pred, nil
2752 }
2753
2754 switch operands[0].Type {
2755 case traceql.TypeString:
2756 s := operands[0].EncodeToString(false)
2757
2758 var id []byte
2759 var err error
2760 if isSpan {
2761 id, err = util.HexStringToSpanID(s)
2762 } else {
2763 id, err = util.HexStringToTraceID(s)
2764 }
2765
2766 if err != nil {
2767 return nil, nil
2768 }
2769
2770 switch op {
2771 case traceql.OpEqual:
2772 return parquetquery.NewByteEqualPredicate(id), nil
2773 case traceql.OpNotEqual:
2774 return parquetquery.NewByteNotEqualPredicate(id), nil
2775 default:
2776 return nil, fmt.Errorf("operator not supported for IDs: %+v", op)
2777 }
2778 case traceql.TypeStringArray:
2779 strs, _ := operands[0].StringArray()
2780 ids := make([][]byte, 0, len(strs))
2781
2782 for _, s := range strs {
2783 var id []byte
2784 var err error
2785 if isSpan {
2786 id, err = util.HexStringToSpanID(s)
2787 } else {
2788 id, err = util.HexStringToTraceID(s)
2789 }
2790
2791 if err != nil {
2792 return nil, nil
2793 }
2794 ids = append(ids, id)
2795 }
2796
2797 switch op {
2798 case traceql.OpEqual, traceql.OpIn:
2799 return parquetquery.NewByteInPredicate(ids), nil
2800 case traceql.OpNotEqual, traceql.OpNotIn:
2801 return parquetquery.NewByteNotInPredicate(ids), nil
2802 default:
2803 return nil, fmt.Errorf("operator not supported for IDs: %+v", op)
2804 }
2805 default:
2806 return nil, fmt.Errorf("operand is not string or string array: %s", operands[0])

Callers 6

createLinkIteratorFunction · 0.70
createSpanIteratorFunction · 0.70
createTraceIteratorFunction · 0.70
createSpanIteratorsFunction · 0.70
createLinkIteratorsFunction · 0.70

Calls 9

HexStringToSpanIDFunction · 0.92
HexStringToTraceIDFunction · 0.92
NewByteEqualPredicateFunction · 0.92
NewByteNotEqualPredicateFunction · 0.92
NewByteInPredicateFunction · 0.92
NewByteNotInPredicateFunction · 0.92
EncodeToStringMethod · 0.80
StringArrayMethod · 0.80
createExistencePredicateFunction · 0.70

Tested by

no test coverage detected