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

Function createSpanIterator

tempodb/encoding/vparquet3/block_traceql.go:1481–1797  ·  view source on GitHub ↗

createSpanIterator iterates through all span-level columns, groups them into rows representing one span each. Spans are returned that match any of the given conditions.

(makeIter, makeNilIter makeIterFn, primaryIter parquetquery.Iterator, conditions []traceql.Condition, allConditions bool, dedicatedColumns backend.DedicatedColumns, selectAll bool)

Source from the content-addressed store, hash-verified

1479// createSpanIterator iterates through all span-level columns, groups them into rows representing
1480// one span each. Spans are returned that match any of the given conditions.
1481func createSpanIterator(makeIter, makeNilIter makeIterFn, primaryIter parquetquery.Iterator, conditions []traceql.Condition, allConditions bool, dedicatedColumns backend.DedicatedColumns, selectAll bool) (parquetquery.Iterator, error) {
1482 var (
1483 columnSelectAs = map[string]string{}
1484 columnPredicates = map[string][]parquetquery.Predicate{}
1485 iters []parquetquery.Iterator
1486 genericConditions []traceql.Condition
1487 columnMapping = dedicatedColumnsToColumnMapping(dedicatedColumns, backend.DedicatedColumnScopeSpan)
1488 nestedSetLeftExplicit = false
1489 nestedSetRightExplicit = false
1490 nestedSetParentExplicit = false
1491 )
1492
1493 // todo: improve these methods. if addPredicate gets a nil predicate shouldn't it just wipe out the existing predicates instead of appending?
1494 // nil predicate matches everything. what's the point of also evaluating a "real" predicate?
1495 addPredicate := func(columnPath string, p parquetquery.Predicate) {
1496 columnPredicates[columnPath] = append(columnPredicates[columnPath], p)
1497 }
1498
1499 addNilPredicateIfNotAlready := func(path string) {
1500 preds := columnPredicates[path]
1501 foundOpNone := false
1502
1503 // check to see if there is a nil predicate and only add if it doesn't exist
1504 for _, pred := range preds {
1505 if pred == nil {
1506 foundOpNone = true
1507 break
1508 }
1509 }
1510
1511 if !foundOpNone {
1512 addPredicate(path, nil)
1513 columnSelectAs[path] = path
1514 }
1515 }
1516
1517 specialCase := func(cond traceql.Condition, columnPath string) (handled bool) {
1518 // Operands that need special handling.
1519 switch cond.Op {
1520 case traceql.OpNone:
1521 addPredicate(columnPath, nil) // No filtering
1522 columnSelectAs[columnPath] = cond.Attribute.Name
1523 return true
1524 case traceql.OpExists:
1525 addPredicate(columnPath, &parquetquery.SkipNilsPredicate{})
1526 columnSelectAs[columnPath] = cond.Attribute.Name
1527 return true
1528 case traceql.OpNotExists:
1529 iters = append(iters, makeIter(columnPath, parquetquery.NewNilValuePredicate(), cond.Attribute.Name))
1530 return true
1531 default:
1532 return false
1533 }
1534 }
1535
1536 for _, cond := range conditions {
1537 // Intrinsic?
1538 switch cond.Attribute.Intrinsic {

Callers 1

createAllIteratorFunction · 0.70

Calls 15

NewNilValuePredicateFunction · 0.92
NewLeftJoinIteratorFunction · 0.92
WithPoolFunction · 0.92
ToStaticTypeMethod · 0.80
createBytesPredicateFunction · 0.70
createIntPredicateFunction · 0.70
createStringPredicateFunction · 0.70
createDurationPredicateFunction · 0.70
isMatchingColumnTypeFunction · 0.70
operandTypeFunction · 0.70

Tested by

no test coverage detected