mirror of
https://github.com/urbit/shrub.git
synced 2024-12-21 09:51:36 +03:00
graph-store: add deep-subset scry that allows one to scry for an upper
bound of ordered items by time
This commit is contained in:
parent
0ed09b7a29
commit
28a94d9b25
@ -1029,6 +1029,47 @@
|
||||
^- [index:store node:store]
|
||||
[(snoc index atom) node]
|
||||
==
|
||||
::
|
||||
[%x %graph-deep-subset @ @ @ ~]
|
||||
=/ =ship (slav %p i.t.t.path)
|
||||
=/ =term i.t.t.t.path
|
||||
=/ count=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
||||
?: ?=(~ count)
|
||||
[~ ~]
|
||||
=/ result=(unit marked-graph:store)
|
||||
(~(get by graphs) [ship term])
|
||||
?~ result
|
||||
[~ ~]
|
||||
=* graph p.u.result
|
||||
=/ =(list [atom node:store]) (tap:orm graph)
|
||||
:- ~ :- ~ :- %graph-update-2
|
||||
!> ^- update:store
|
||||
:- now.bowl
|
||||
:+ %add-nodes
|
||||
[ship term]
|
||||
=| deep-map=(map index:store node:store)
|
||||
=| iter=@ud
|
||||
=| =index:store
|
||||
|- ^- (map index:store node:store)
|
||||
?: ?|(?=(~ list) =(iter count))
|
||||
deep-map
|
||||
=* atom -.i.list
|
||||
=* node +.i.list
|
||||
=. index (snoc index atom)
|
||||
:: check children first, then check parent
|
||||
?- -.children.node
|
||||
%empty
|
||||
=. deep-map (~(put by deep-map) index node(children [%empty ~]))
|
||||
$(list t.list, iter +(iter), index ~)
|
||||
::
|
||||
%graph
|
||||
=. deep-map $(list (tap:orm p.children.node))
|
||||
=. iter ~(wyt by deep-map)
|
||||
?: =(iter count)
|
||||
deep-map
|
||||
=. deep-map (~(put by deep-map) index node(children [%empty ~]))
|
||||
$(list t.list, iter +(iter), index ~)
|
||||
==
|
||||
::
|
||||
[%x %update-log-subset @ @ @ @ ~]
|
||||
=/ =ship (slav %p i.t.t.path)
|
||||
|
Loading…
Reference in New Issue
Block a user