@@ -356,15 +356,12 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
356
356
- Add {incrementalDataRecord} to {graph} as a new Pending Data node directed
357
357
from the {pendingResults} that it completes, adding each of {pendingResults}
358
358
to {graph} as new nodes, if necessary, each directed from its {parent}, if
359
- defined, recursively adding each {parent} as necessary.
360
- - Prune root nodes of {graph} containing no direct child Incremental Data
361
- Records, repeatedly if necessary, promoting any direct child Deferred
362
- Fragments of the pruned nodes to root nodes. (This ensures that no empty
363
- fragments are reported as pending).
364
- - Let {newPendingResults} be the set of root nodes in {graph}.
365
- - Let {pending} be the result of {GetPending(newPendingResults)}.
366
- - Let {hasNext} be {true}.
367
- - Yield an unordered map containing {data}, {errors}, {pending}, and {hasNext}.
359
+ defined, recursively adding each {parent} as necessary until
360
+ {incrementalDataRecord} is connected to {graph}.
361
+ - Let {pendingResults} be the result of {GetNonEmptyNewPending(graph)}.
362
+ - Prune root nodes from {graph} not in {pendingResults}, repeating as necessary
363
+ until all root nodes in {graph} are also in {pendingResults}.
364
+ - Yield the result of {GetInitialResult(data, errors, pending)}.
368
365
- For each completed child Pending Incremental Data node of a root node in
369
366
{graph}:
370
367
- Let {incrementalDataRecord} be the Pending Incremental Data for that node;
@@ -380,7 +377,7 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
380
377
parents.
381
378
- Let {hasNext} be {false}, if {graph} is empty.
382
379
- Yield an unordered map containing {completed} and {hasNext}.
383
- - Continue to the next completed child Incremental Data node in {graph} .
380
+ - Continue to the next completed Pending Incremental Data node.
384
381
- Replace {node} in {graph} with a new node corresponding to the Completed
385
382
Incremental Data for {result}.
386
383
- Add each {incrementalDataRecord} of {incrementalDataRecords} on {result} to
@@ -390,7 +387,7 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
390
387
- Let {completedIncrementalDataNodes} be the set of completed Incremental Data
391
388
nodes that are children of {completedDeferredFragments}.
392
389
- If {completedIncrementalDataNodes} is empty, continue to the next completed
393
- child Incremental Data node in {graph} .
390
+ Pending Incremental Data Node .
394
391
- Initialize {incremental} to an empty list.
395
392
- For each {node} of {completedIncrementalDataNodes}:
396
393
- Let {incrementalDataRecord} be the corresponding record for {node}.
@@ -402,32 +399,57 @@ YieldIncrementalResults(data, errors, incrementalDataRecords):
402
399
- Append {GetCompletedEntry(pendingResult)} to {completed}.
403
400
- Remove {pendingResult} from {graph}, promoting its child nodes to root
404
401
nodes.
405
- - Prune root nodes of {graph} containing no direct child Incremental Data
406
- Records, as above.
407
- - Let {hasNext} be {false} if {graph} is empty.
408
- - Let {incrementalResult} be an unordered map containing {hasNext}.
409
- - If {incremental} is not empty, set the corresponding entry on
410
- {incrementalResult} to {incremental}.
411
- - If {completed} is not empty, set the corresponding entry on
412
- {incrementalResult} to {completed}.
413
- - Let {newPendingResults} be the set of new root nodes in {graph}, promoted by
414
- the above steps.
415
- - If {newPendingResults} is not empty:
416
- - Let {pending} be the result of {GetPending(newPendingResults)}.
417
- - Set the corresponding entry on {incrementalResult} to {pending}.
418
- - Yield {incrementalResult}.
402
+ - Let {newPendingResults} be a new set containing the result of
403
+ {GetNonEmptyNewPending(graph, pendingResults)}.
404
+ - Add all nodes in {newPendingResults} to {pendingResults}.
405
+ - Prune root nodes from {graph} not in {pendingResults}, repeating as
406
+ necessary until all root nodes in {graph} are also in {pendingResults}.
407
+ - Let {pending} be the result of {GetPendingEntry(newPendingResults)}.
408
+ - Yield the result of {GetIncrementalResult(graph, incremental, completed,
409
+ pending)}.
419
410
- Complete this incremental result stream.
420
411
421
- GetPending(newPendingResults):
412
+ GetNonEmptyNewPending(graph, oldPendingResults):
413
+
414
+ - If not provided, initialize {oldPendingResults} to the empty set.
415
+ - Let {rootNodes} be the set of root nodes in {graph}.
416
+ - For each {rootNode} of {rootNodes}:
417
+ - If {rootNodes} is in {oldPendingResults}:
418
+ - Continue to the next {rootNode}.
419
+ - If {rootNode} has no children Pending Incremental Data nodes:
420
+ - Let {children} be the set of child Deferred Fragment nodes of {rootNode}.
421
+ - Remove {rootNode} from {rootNodes}.
422
+ - Add each of the nodes in {children} to {rootNodes}.
423
+ - Return {rootNodes}.
424
+
425
+ GetInitialResult(data, errors, pendingResults):
426
+
427
+ - Let {pending} be the result of {GetPendingEntry(pendingResults)}.
428
+ - Let {hasNext} be {true}.
429
+ - Return an unordered map containing {data}, {errors}, {pending}, and {hasNext}.
430
+
431
+ GetPendingEntry(pendingResults):
422
432
423
433
- Initialize {pending} to an empty list.
424
- - For each {newPendingResult } of {newPendingResults }:
425
- - Let {id} be a unique identifier for {newPendingResult }.
426
- - Let {path} and {label} be the corresponding entries on {newPendingResult }.
434
+ - For each {pendingResult } of {pendingResult }:
435
+ - Let {id} be a unique identifier for {pendingResult }.
436
+ - Let {path} and {label} be the corresponding entries on {pendingResult }.
427
437
- Let {pendingEntry} be an unordered map containing {id}, {path}, and {label}.
428
438
- Append {pendingEntry} to {pending}.
429
439
- Return {pending}.
430
440
441
+ GetIncrementalResult(graph, incremental, completed, pending):
442
+
443
+ - Let {hasNext} be {false} if {graph} is empty, otherwise, {true}.
444
+ - Let {incrementalResult} be an unordered map containing {hasNext}.
445
+ - If {incremental} is not empty:
446
+ - Set the corresponding entry on {incrementalResult} to {incremental}.
447
+ - If {completed} is not empty:
448
+ - Set the corresponding entry on {incrementalResult} to {completed}.
449
+ - If {pending} is not empty:
450
+ - Set the corresponding entry on {incrementalResult} to {pending}.
451
+ - Return {incrementalResult}.
452
+
431
453
GetIncrementalEntry(incrementalDataRecord, graph):
432
454
433
455
- Let {deferredFragments} be the Deferred Fragments incrementally completed by
0 commit comments