KeepGroup applies resource-level data and filtering to the spans yielded from the span-level iterators. It updates the spans in-place in the OtherEntries slice. Creation of the spanset is delayed until the traceCollector.
(res *parquetquery.IteratorResult)
| 3336 | // the span-level iterators. It updates the spans in-place in the OtherEntries slice. |
| 3337 | // Creation of the spanset is delayed until the traceCollector. |
| 3338 | func (c *batchCollector) KeepGroup(res *parquetquery.IteratorResult) bool { |
| 3339 | // First pass over spans and attributes from the AttributeCollector |
| 3340 | spans := res.OtherEntries[:0] |
| 3341 | c.resAttrs = c.resAttrs[:0] |
| 3342 | |
| 3343 | for _, kv := range res.OtherEntries { |
| 3344 | switch v := kv.Value.(type) { |
| 3345 | case *span: |
| 3346 | spans = append(spans, kv) |
| 3347 | case traceql.Static: |
| 3348 | c.resAttrs = append(c.resAttrs, attrVal{newResAttr(kv.Key), v}) |
| 3349 | } |
| 3350 | } |
| 3351 | res.OtherEntries = spans |
| 3352 | |
| 3353 | // Throw out batches without any candidate spans |
| 3354 | if len(res.OtherEntries) == 0 { |
| 3355 | return false |
| 3356 | } |
| 3357 | |
| 3358 | // Gather Attributes from dedicated resource-level columns |
| 3359 | for _, e := range res.Entries { |
| 3360 | switch e.Value.Kind() { |
| 3361 | case parquet.Int64: |
| 3362 | c.resAttrs = append(c.resAttrs, attrVal{newResAttr(e.Key), traceql.NewStaticInt(int(e.Value.Int64()))}) |
| 3363 | case parquet.ByteArray: |
| 3364 | c.resAttrs = append(c.resAttrs, attrVal{newResAttr(e.Key), traceql.NewStaticString(unsafeToString(e.Value.Bytes()))}) |
| 3365 | default: |
| 3366 | // This is a null value, indicating the attribute doesn't exist |
| 3367 | if e.Value.IsNull() { |
| 3368 | c.resAttrs = append(c.resAttrs, attrVal{newResAttr(e.Key), traceql.NewStaticString("nil")}) |
| 3369 | } |
| 3370 | } |
| 3371 | } |
| 3372 | |
| 3373 | if c.minAttributes > 0 { |
| 3374 | if len(c.resAttrs) < c.minAttributes { |
| 3375 | return false |
| 3376 | } |
| 3377 | } |
| 3378 | |
| 3379 | // Second pass. Update and further filter the spans |
| 3380 | if len(c.resAttrs) > 0 || c.requireAtLeastOneMatchOverall { |
| 3381 | mightFilter := c.requireAtLeastOneMatchOverall |
| 3382 | |
| 3383 | // If we might filter, then rebuild the slice of kept |
| 3384 | // spans, in place with the same underlying buffer. |
| 3385 | // If not filtering, then skip this work. |
| 3386 | var spans []struct { |
| 3387 | Key string |
| 3388 | Value interface{} |
| 3389 | } |
| 3390 | if mightFilter { |
| 3391 | spans = res.OtherEntries[:0] |
| 3392 | } |
| 3393 | |
| 3394 | for _, e := range res.OtherEntries { |
| 3395 | span, ok := e.Value.(*span) |
nothing calls this directly
no test coverage detected