Compile the D2 graph and query pipeline
()
| 402 | |
| 403 | /** Compile the D2 graph and query pipeline */ |
| 404 | private compilePipeline(): void { |
| 405 | this.graph = new D2() |
| 406 | this.inputs = Object.fromEntries( |
| 407 | Object.keys(this.collectionByAlias).map((alias) => [ |
| 408 | alias, |
| 409 | this.graph!.newInput<any>(), |
| 410 | ]), |
| 411 | ) |
| 412 | |
| 413 | const compilation = compileQuery( |
| 414 | this.query, |
| 415 | this.inputs as Record<string, KeyedStream>, |
| 416 | this.collections, |
| 417 | // These mutable objects are captured by reference. The join compiler |
| 418 | // reads them later when the graph runs, so they must be populated |
| 419 | // (in start()) before the first graph run. |
| 420 | this.subscriptions, |
| 421 | this.lazySourcesCallbacks, |
| 422 | this.lazySources, |
| 423 | this.optimizableOrderByCollections, |
| 424 | () => {}, // setWindowFn (no-op — effects don't paginate) |
| 425 | ) |
| 426 | |
| 427 | this.pipeline = compilation.pipeline |
| 428 | this.sourceWhereClauses = compilation.sourceWhereClauses |
| 429 | this.compiledAliasToCollectionId = compilation.aliasToCollectionId |
| 430 | |
| 431 | // Attach the output operator that accumulates changes |
| 432 | this.pipeline.pipe( |
| 433 | output((data) => { |
| 434 | const messages = data.getInner() |
| 435 | messages.reduce(accumulateEffectChanges<TRow>, this.pendingChanges) |
| 436 | }), |
| 437 | ) |
| 438 | |
| 439 | this.graph.finalize() |
| 440 | } |
| 441 | |
| 442 | /** Subscribe to source collections and start processing */ |
| 443 | start(): void { |
no test coverage detected