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

Function createEventIterator

tempodb/encoding/vparquet4/block_traceql.go:1745–1824  ·  view source on GitHub ↗
(makeIter, makeNilIter makeIterFn, conditions []traceql.Condition, allConditions bool, selectAll bool)

Source from the content-addressed store, hash-verified

1743}
1744
1745func createEventIterator(makeIter, makeNilIter makeIterFn, conditions []traceql.Condition, allConditions bool, selectAll bool) (parquetquery.Iterator, error) {
1746 if len(conditions) == 0 {
1747 return nil, nil
1748 }
1749
1750 eventIters := make([]parquetquery.Iterator, 0, len(conditions))
1751 var genericConditions []traceql.Condition
1752
1753 for _, cond := range conditions {
1754 switch cond.Attribute.Intrinsic {
1755 case traceql.IntrinsicEventName:
1756 pred, err := createStringPredicate(cond.Op, cond.Operands)
1757 if err != nil {
1758 return nil, err
1759 }
1760 eventIters = append(eventIters, makeIter(ColumnPathEventName, pred, ColumnPathEventName))
1761 continue
1762 case traceql.IntrinsicEventTimeSinceStart:
1763 pred, err := createIntPredicate(cond.Op, cond.Operands)
1764 if err != nil {
1765 return nil, err
1766 }
1767 eventIters = append(eventIters, makeIter(columnPathEventTimeSinceStart, pred, columnPathEventTimeSinceStart))
1768 continue
1769 }
1770
1771 if cond.Op == traceql.OpNotExists {
1772 // Generic attr doesn't exist
1773 pred := parquetquery.NewIncludeNilStringEqualPredicate([]byte(cond.Attribute.Name))
1774 eventIters = append(eventIters, makeNilIter(columnPathEventAttrKey, pred, cond.Attribute.Name))
1775 continue
1776 }
1777
1778 genericConditions = append(genericConditions, cond)
1779 }
1780
1781 attrIter, err := createAttributeIterator(makeIter, genericConditions, DefinitionLevelResourceSpansILSSpanEventAttrs,
1782 columnPathEventAttrKey, columnPathEventAttrString, columnPathEventAttrInt, columnPathEventAttrDouble, columnPathEventAttrBool, allConditions, selectAll)
1783 if err != nil {
1784 return nil, fmt.Errorf("creating event attribute iterator: %w", err)
1785 }
1786
1787 if attrIter != nil {
1788 eventIters = append(eventIters, attrIter)
1789 }
1790
1791 var required []parquetquery.Iterator
1792
1793 minCount := 0
1794
1795 if allConditions {
1796 // The final number of expected attributes.
1797 distinct := map[string]struct{}{}
1798 for _, cond := range conditions {
1799 distinct[cond.Attribute.Name] = struct{}{}
1800 }
1801 minCount = len(distinct)
1802 }

Callers 1

createAllIteratorFunction · 0.70

Calls 6

NewLeftJoinIteratorFunction · 0.92
WithPoolFunction · 0.92
createStringPredicateFunction · 0.70
createIntPredicateFunction · 0.70
createAttributeIteratorFunction · 0.70

Tested by

no test coverage detected