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