MCPcopy Create free account
hub / github.com/TanStack/db / compilePipeline

Method compilePipeline

packages/db/src/query/effect.ts:404–440  ·  view source on GitHub ↗

Compile the D2 graph and query pipeline

()

Source from the content-addressed store, hash-verified

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 {

Callers 1

constructorMethod · 0.95

Calls 8

outputFunction · 0.90
compileQueryFunction · 0.85
newInputMethod · 0.80
pipeMethod · 0.80
getInnerMethod · 0.80
finalizeMethod · 0.80
mapMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected