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

Function createBytesPredicate

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

Source from the content-addressed store, hash-verified

2666}
2667
2668func createBytesPredicate(op traceql.Operator, operands traceql.Operands, isSpan bool) (parquetquery.Predicate, error) {
2669 if pred, handled := createExistencePredicate(op); handled {
2670 return pred, nil
2671 }
2672
2673 switch operands[0].Type {
2674 case traceql.TypeString:
2675 s := operands[0].EncodeToString(false)
2676
2677 var id []byte
2678 var err error
2679 if isSpan {
2680 id, err = util.HexStringToSpanID(s)
2681 } else {
2682 id, err = util.HexStringToTraceID(s)
2683 }
2684
2685 if err != nil {
2686 return nil, nil
2687 }
2688
2689 switch op {
2690 case traceql.OpEqual:
2691 return parquetquery.NewByteEqualPredicate(id), nil
2692 case traceql.OpNotEqual:
2693 return parquetquery.NewByteNotEqualPredicate(id), nil
2694 default:
2695 return nil, fmt.Errorf("operator not supported for IDs: %+v", op)
2696 }
2697 case traceql.TypeStringArray:
2698 strs, _ := operands[0].StringArray()
2699 ids := make([][]byte, 0, len(strs))
2700
2701 for _, s := range strs {
2702 var id []byte
2703 var err error
2704 if isSpan {
2705 id, err = util.HexStringToSpanID(s)
2706 } else {
2707 id, err = util.HexStringToTraceID(s)
2708 }
2709
2710 if err != nil {
2711 return nil, nil
2712 }
2713 ids = append(ids, id)
2714 }
2715
2716 switch op {
2717 case traceql.OpEqual, traceql.OpIn:
2718 return parquetquery.NewByteInPredicate(ids), nil
2719 case traceql.OpNotEqual, traceql.OpNotIn:
2720 return parquetquery.NewByteNotInPredicate(ids), nil
2721 default:
2722 return nil, fmt.Errorf("operator not supported for IDs: %+v", op)
2723 }
2724 default:
2725 return nil, fmt.Errorf("operand is not string or string array: %s", operands[0])

Callers 4

createLinkIteratorFunction · 0.70
createSpanIteratorFunction · 0.70
createTraceIteratorFunction · 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