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

Function join

packages/db-ivm/src/operators/join.ts:255–284  ·  view source on GitHub ↗
(
  other: IStreamBuilder<KeyValue<K, V2>>,
  type: JoinType = `inner`,
)

Source from the content-addressed store, hash-verified

253 * @param type - The type of join to perform
254 */
255export function join<
256 K,
257 V1 extends T extends KeyValue<infer _KT, infer VT> ? VT : never,
258 V2,
259 T,
260>(
261 other: IStreamBuilder<KeyValue<K, V2>>,
262 type: JoinType = `inner`,
263): PipedOperator<T, KeyValue<K, [V1 | null, V2 | null]>> {
264 return (
265 stream: IStreamBuilder<T>,
266 ): IStreamBuilder<KeyValue<K, [V1 | null, V2 | null]>> => {
267 if (stream.graph !== other.graph) {
268 throw new Error(`Cannot join streams from different graphs`)
269 }
270 const output = new StreamBuilder<KeyValue<K, [V1 | null, V2 | null]>>(
271 stream.graph,
272 new DifferenceStreamWriter<KeyValue<K, [V1 | null, V2 | null]>>(),
273 )
274 const operator = new JoinOperator<K, V1, V2>(
275 stream.graph.getNextOperatorId(),
276 stream.connectReader() as DifferenceStreamReader<KeyValue<K, V1>>,
277 other.connectReader(),
278 output.writer,
279 type,
280 )
281 stream.graph.addOperator(operator)
282 return output
283 }
284}
285
286/**
287 * Joins two input streams (inner join)

Callers 15

createHarnessFunction · 0.85
createHarnessFunction · 0.85
createTempDbPathFunction · 0.85
transactionMethod · 0.85
getPreloadPathFunction · 0.85
getRendererPagePathFunction · 0.85
transactionMethod · 0.85
createHarnessFunction · 0.85

Calls 3

getNextOperatorIdMethod · 0.80
connectReaderMethod · 0.80
addOperatorMethod · 0.80

Tested by 15

createHarnessFunction · 0.68
createHarnessFunction · 0.68
createTempDbPathFunction · 0.68
transactionMethod · 0.68
createHarnessFunction · 0.68
createTempSqlitePathFunction · 0.68
createDriverHarnessFunction · 0.68
createTempSqlitePathFunction · 0.68
createTempSqlitePathFunction · 0.68
createDriverHarnessFunction · 0.68