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

Function NewLeftJoinIterator

pkg/parquetquery/iters.go:1242–1286  ·  view source on GitHub ↗
(definitionLevel int, required, optional []Iterator, pred GroupPredicate, opts ...LeftJoinIteratorOption)

Source from the content-addressed store, hash-verified

1240var _ Iterator = (*LeftJoinIterator)(nil)
1241
1242func NewLeftJoinIterator(definitionLevel int, required, optional []Iterator, pred GroupPredicate, opts ...LeftJoinIteratorOption) (*LeftJoinIterator, error) {
1243 j := &LeftJoinIterator{
1244 required: required,
1245 optional: optional,
1246 pool: DefaultPool,
1247 }
1248
1249 // Fill in config slices for the explicitly given iterators first.
1250 for range j.required {
1251 j.defLevelsRequired = append(j.defLevelsRequired, definitionLevel)
1252 j.paramsRequired = append(j.paramsRequired, nil)
1253 }
1254 for range j.optional {
1255 j.defLevelsOptional = append(j.defLevelsOptional, definitionLevel)
1256 j.paramsOptional = append(j.paramsOptional, nil)
1257 }
1258
1259 for _, opt := range opts {
1260 opt.applyToLeftJoinIterator(j)
1261 }
1262
1263 // Any join requires at least one required iterator. If there are no required iterators,
1264 // use a UnionIterator instead.
1265 if len(j.required) == 0 {
1266 return nil, fmt.Errorf("left join iterator requires at least one required iterator")
1267 }
1268
1269 if j.collector == nil {
1270 j.collector = newOldStyleCollector(j.pool, pred)
1271 }
1272
1273 j.peeksRequired = make([]*IteratorResult, len(j.required))
1274 j.peeksOptional = make([]*IteratorResult, len(j.optional))
1275 j.collectedThroughRequired = make([]RowNumber, len(j.required))
1276 j.collectedThroughOptional = make([]RowNumber, len(j.optional))
1277
1278 for i := range j.collectedThroughRequired {
1279 j.collectedThroughRequired[i] = EmptyRowNumber()
1280 }
1281 for i := range j.collectedThroughOptional {
1282 j.collectedThroughOptional[i] = EmptyRowNumber()
1283 }
1284
1285 return j, nil
1286}
1287
1288func (j *LeftJoinIterator) String() string {
1289 srequired := "required: "

Callers 15

keyNameIteratorFunction · 0.92
createEventIteratorFunction · 0.92
createLinkIteratorFunction · 0.92
createSpanIteratorFunction · 0.92
createResourceIteratorFunction · 0.92
createTraceIteratorFunction · 0.92
createAttributeIteratorFunction · 0.92
keyNameIteratorFunction · 0.92
createEventIteratorFunction · 0.92

Calls 3

newOldStyleCollectorFunction · 0.85
EmptyRowNumberFunction · 0.85

Tested by 2

TestLeftJoinUpFunction · 0.68
TestLeftJoinDownFunction · 0.68