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, innerIterators []parquetquery.Iterator, conditions []traceql.Condition, allConditions bool, dedicatedColumns backend.DedicatedColumns, selectAll bool, sampler traceql.Sampler, )
| 1905 | // createSpanIterator iterates through all span-level columns, groups them into rows representing |
| 1906 | // one span each. Spans are returned that match any of the given conditions. |
| 1907 | func createSpanIterator(makeIter, makeNilIter makeIterFn, innerIterators []parquetquery.Iterator, conditions []traceql.Condition, allConditions bool, dedicatedColumns backend.DedicatedColumns, selectAll bool, |
| 1908 | sampler traceql.Sampler, |
| 1909 | ) (parquetquery.Iterator, error) { |
| 1910 | var ( |
| 1911 | columnSelectAs = map[string]string{} |
| 1912 | columnPredicates = map[string][]parquetquery.Predicate{} |
| 1913 | iters []parquetquery.Iterator |
| 1914 | genericConditions []traceql.Condition |
| 1915 | columnMapping = dedicatedColumnsToColumnMapping(dedicatedColumns, backend.DedicatedColumnScopeSpan) |
| 1916 | nestedSetLeftExplicit = false |
| 1917 | nestedSetRightExplicit = false |
| 1918 | nestedSetParentExplicit = false |
| 1919 | ) |
| 1920 | |
| 1921 | // todo: improve these methods. if addPredicate gets a nil predicate shouldn't it just wipe out the existing predicates instead of appending? |
| 1922 | // nil predicate matches everything. what's the point of also evaluating a "real" predicate? |
| 1923 | addPredicate := func(columnPath string, p parquetquery.Predicate) { |
| 1924 | columnPredicates[columnPath] = append(columnPredicates[columnPath], p) |
| 1925 | } |
| 1926 | |
| 1927 | addNilPredicateIfNotAlready := func(path string) { |
| 1928 | preds := columnPredicates[path] |
| 1929 | foundOpNone := false |
| 1930 | |
| 1931 | // check to see if there is a nil predicate and only add if it doesn't exist |
| 1932 | for _, pred := range preds { |
| 1933 | if pred == nil { |
| 1934 | foundOpNone = true |
| 1935 | break |
| 1936 | } |
| 1937 | } |
| 1938 | |
| 1939 | if !foundOpNone { |
| 1940 | addPredicate(path, nil) |
| 1941 | columnSelectAs[path] = path |
| 1942 | } |
| 1943 | } |
| 1944 | |
| 1945 | specialCase := func(cond traceql.Condition, columnPath string) (handled bool) { |
| 1946 | // Operands that need special handling. |
| 1947 | switch cond.Op { |
| 1948 | case traceql.OpNone: |
| 1949 | addPredicate(columnPath, nil) // No filtering |
| 1950 | columnSelectAs[columnPath] = cond.Attribute.Name |
| 1951 | return true |
| 1952 | case traceql.OpExists: |
| 1953 | addPredicate(columnPath, &parquetquery.SkipNilsPredicate{}) |
| 1954 | columnSelectAs[columnPath] = cond.Attribute.Name |
| 1955 | return true |
| 1956 | case traceql.OpNotExists: |
| 1957 | iters = append(iters, makeIter(columnPath, parquetquery.NewNilValuePredicate(), cond.Attribute.Name)) |
| 1958 | return true |
| 1959 | default: |
| 1960 | return false |
| 1961 | } |
| 1962 | } |
| 1963 | |
| 1964 | for _, cond := range conditions { |
no test coverage detected