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)
| 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. |
| 1481 | func 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 { |
no test coverage detected