mirror of
https://github.com/urbit/shrub.git
synced 2024-11-28 05:22:27 +03:00
Merge pull request #5030 from urbit/la/graph-scry
graph-store: rework scry format to be more succinct and consistent
This commit is contained in:
commit
092d2f30cf
@ -180,10 +180,7 @@
|
|||||||
==
|
==
|
||||||
::
|
::
|
||||||
++ add-nodes
|
++ add-nodes
|
||||||
|= $: =time
|
|= [=time =resource:store nodes=(map index:store node:store)]
|
||||||
=resource:store
|
|
||||||
nodes=(map index:store node:store)
|
|
||||||
==
|
|
||||||
^- (quip card _state)
|
^- (quip card _state)
|
||||||
|^
|
|^
|
||||||
=/ [=graph:store mark=(unit mark:store)]
|
=/ [=graph:store mark=(unit mark:store)]
|
||||||
@ -618,392 +615,289 @@
|
|||||||
~/ %graph-store-peek
|
~/ %graph-store-peek
|
||||||
|= =path
|
|= =path
|
||||||
^- (unit (unit cage))
|
^- (unit (unit cage))
|
||||||
|^
|
?+ path (on-peek:def path)
|
||||||
?> (team:title our.bowl src.bowl)
|
[%x %export ~] ``noun+!>(state)
|
||||||
?+ path (on-peek:def path)
|
|
||||||
[%x %graph-mark @ @ ~]
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ result=(unit marked-graph:store)
|
|
||||||
(~(get by graphs) [ship term])
|
|
||||||
?~ result [~ ~]
|
|
||||||
``noun+!>(`(unit mark)`q.u.result)
|
|
||||||
::
|
::
|
||||||
[%x %keys ~]
|
[%x %keys ~]
|
||||||
:- ~ :- ~ :- %graph-update-2
|
:- ~ :- ~ :- %graph-update-2
|
||||||
!>(`update:store`[now.bowl [%keys ~(key by graphs)]])
|
!>(`update:store`[now.bowl [%keys ~(key by graphs)]])
|
||||||
::
|
::
|
||||||
[%x %tags ~]
|
[%x %tag-queries *]
|
||||||
:- ~ :- ~ :- %graph-update-2
|
|
||||||
!>(`update:store`[now.bowl [%tags ~(key by tag-queries)]])
|
|
||||||
::
|
|
||||||
[%x %tag-queries ~]
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
|
||||||
!>(`update:store`[now.bowl [%tag-queries tag-queries]])
|
|
||||||
::
|
|
||||||
[%x %graph @ @ ~]
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ result=(unit marked-graph:store)
|
|
||||||
(~(get by graphs) [ship term])
|
|
||||||
?~ result [~ ~]
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
:- ~ :- ~ :- %graph-update-2
|
||||||
!> ^- update:store
|
!> ^- update:store
|
||||||
:- now.bowl
|
:- now.bowl
|
||||||
[%add-graph [ship term] `graph:store`p.u.result q.u.result %.y]
|
?+ t.t.path (on-peek:def path)
|
||||||
|
~ [%tag-queries tag-queries]
|
||||||
|
[%tags ~] [%tags ~(key by tag-queries)]
|
||||||
|
==
|
||||||
::
|
::
|
||||||
:: note: near-duplicate of /x/graph
|
|
||||||
::
|
|
||||||
[%x %archive @ @ ~]
|
[%x %archive @ @ ~]
|
||||||
=/ =ship (slav %p i.t.t.path)
|
=/ =ship (slav %p i.t.t.path)
|
||||||
=/ =term i.t.t.t.path
|
=/ =term i.t.t.t.path
|
||||||
=/ result=(unit marked-graph:store)
|
=/ marked-graph=(unit marked-graph:store)
|
||||||
(~(get by archive) [ship term])
|
|
||||||
?~ result
|
|
||||||
~& no-archived-graph+[ship term]
|
|
||||||
[~ ~]
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
|
||||||
!> ^- update:store
|
|
||||||
:- now.bowl
|
|
||||||
[%add-graph [ship term] `graph:store`p.u.result q.u.result %.y]
|
|
||||||
::
|
|
||||||
[%x %export ~]
|
|
||||||
``noun+!>(state)
|
|
||||||
::
|
|
||||||
[%x %graph-subset @ @ @ @ ~]
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ start=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
|
||||||
=/ end=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
|
||||||
=/ graph=(unit marked-graph:store)
|
|
||||||
(~(get by graphs) [ship term])
|
(~(get by graphs) [ship term])
|
||||||
?~ graph [~ ~]
|
?~ marked-graph [~ ~]
|
||||||
|
=* graph p.u.marked-graph
|
||||||
|
=* mark q.u.marked-graph
|
||||||
:- ~ :- ~ :- %graph-update-2
|
:- ~ :- ~ :- %graph-update-2
|
||||||
!> ^- update:store
|
!>(`update:store`[now.bowl [%add-graph [ship term] graph mark %.y]])
|
||||||
:- now.bowl
|
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
%- ~(gas by *(map index:store node:store))
|
|
||||||
%+ turn (tap:orm `graph:store`(lot:orm p.u.graph start end))
|
|
||||||
|= [=atom =node:store]
|
|
||||||
^- [index:store node:store]
|
|
||||||
[~[atom] node]
|
|
||||||
::
|
::
|
||||||
[%x %node-exists @ @ @ *]
|
[%x %update-log @ @ *]
|
||||||
=/ =ship (slav %p i.t.t.path)
|
=/ =ship (slav %p i.t.t.path)
|
||||||
=/ =term i.t.t.t.path
|
=/ =term i.t.t.t.path
|
||||||
=/ =index:store
|
=/ update-log
|
||||||
(turn t.t.t.t.path (cury slav %ud))
|
(~(get by update-logs) [ship term])
|
||||||
=/ node=(unit node:store)
|
?~ update-log [~ ~]
|
||||||
(get-node ship term index)
|
:- ~ :- ~ :- %noun
|
||||||
``noun+!>(`?`?=(^ node))
|
!>
|
||||||
::
|
?+ t.t.t.t.path (on-peek:def path)
|
||||||
[%x %node @ @ @ *]
|
~ `update-log:store`u.update-log
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ =index:store
|
|
||||||
(turn t.t.t.t.path (cury slav %ud))
|
|
||||||
=/ node=(unit node:store) (get-node ship term index)
|
|
||||||
?~ node [~ ~]
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
|
||||||
!> ^- update:store
|
|
||||||
:- now.bowl
|
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
(~(gas by *(map index:store node:store)) [index u.node] ~)
|
|
||||||
::
|
|
||||||
[%x %node-siblings ?(%older %younger) @ @ @ *]
|
|
||||||
|^
|
|
||||||
=/ older ?=(%older i.t.t.path)
|
|
||||||
=/ =ship (slav %p i.t.t.t.path)
|
|
||||||
=/ =term i.t.t.t.t.path
|
|
||||||
=/ count (slav %ud i.t.t.t.t.t.path)
|
|
||||||
=/ =index:store
|
|
||||||
(turn t.t.t.t.t.t.path (cury slav %ud))
|
|
||||||
=/ parent=index:store
|
|
||||||
(scag (dec (lent index)) index)
|
|
||||||
=/ graph
|
|
||||||
(get-node-children ship term parent)
|
|
||||||
?~ graph [~ ~]
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
|
||||||
!> ^- update:store
|
|
||||||
:- now.bowl
|
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
%- ~(gas by *(map index:store node:store))
|
|
||||||
%+ turn
|
|
||||||
?: older
|
|
||||||
(tab:orm u.graph `(rear index) count)
|
|
||||||
:: TODO time complexity not desirable for %younger case
|
|
||||||
::
|
|
||||||
%+ slag (safe-sub (lent -) count)
|
|
||||||
%- tap:orm
|
|
||||||
%+ lot:orm u.graph
|
|
||||||
[~ `(snag (dec (lent index)) index)]
|
|
||||||
|= [=atom =node:store]
|
|
||||||
^- [index:store node:store]
|
|
||||||
[(snoc parent atom) node]
|
|
||||||
::
|
::
|
||||||
++ safe-sub
|
[%latest ~]
|
||||||
|= [a=@ b=@]
|
^- (unit time)
|
||||||
^- @
|
%+ biff update-log
|
||||||
?: (gte b a)
|
|= =update-log:store
|
||||||
0
|
(bind (pry:orm-log:store update-log) head)
|
||||||
(sub a b)
|
::
|
||||||
--
|
[%subset @ @ ~]
|
||||||
|
^- update-log:store
|
||||||
|
=* start i.t.t.t.t.t.path
|
||||||
|
=* end i.t.t.t.t.t.t.path
|
||||||
|
%^ lot:orm-log
|
||||||
|
u.update-log
|
||||||
|
(slaw %da start)
|
||||||
|
(slaw %da end)
|
||||||
|
==
|
||||||
::
|
::
|
||||||
[%x %shallow-children @ @ *]
|
[%x %graph @ @ *]
|
||||||
=/ =ship (slav %p i.t.t.path)
|
=/ =ship (slav %p i.t.t.path)
|
||||||
=/ =term i.t.t.t.path
|
=/ =term i.t.t.t.path
|
||||||
=/ =index:store
|
=/ marked-graph=(unit marked-graph:store)
|
||||||
(turn t.t.t.t.path (cury slav %ud))
|
(~(get by graphs) [ship term])
|
||||||
=/ children
|
?~ marked-graph [~ ~]
|
||||||
(get-node-children ship term index)
|
=* graph p.u.marked-graph
|
||||||
?~ children [~ ~]
|
=* mark q.u.marked-graph
|
||||||
:- ~ :- ~ :- %graph-update-2
|
?+ t.t.t.t.path (on-peek:def path)
|
||||||
!> ^- update:store
|
~
|
||||||
:+ now.bowl %add-nodes
|
:- ~ :- ~ :- %graph-update-2
|
||||||
:- [ship term]
|
!>(`update:store`[now.bowl [%add-graph [ship term] graph mark %.y]])
|
||||||
%- ~(gas by *(map index:store node:store))
|
::
|
||||||
%+ turn (tap:orm u.children)
|
[%mark ~]
|
||||||
|= [=atom =node:store]
|
``noun+!>(`(unit ^mark)`mark)
|
||||||
^- [index:store node:store]
|
::
|
||||||
:- (snoc index atom)
|
[%subset ?(%lone %kith) @ @ ~]
|
||||||
node(children [%empty ~])
|
=/ start=(unit atom) (rush i.t.t.t.t.t.t.path dem:ag)
|
||||||
::
|
=/ end=(unit atom) (rush i.t.t.t.t.t.t.t.path dem:ag)
|
||||||
[%x ?(%newest %oldest) @ @ @ *]
|
|
||||||
=/ newest ?=(%newest i.t.path)
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ count=@ud
|
|
||||||
(slav %ud i.t.t.t.t.path)
|
|
||||||
=/ =index:store
|
|
||||||
(turn t.t.t.t.t.path (cury slav %ud))
|
|
||||||
=/ children
|
|
||||||
(get-node-children ship term index)
|
|
||||||
?~ children [~ ~]
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
|
||||||
!> ^- update:store
|
|
||||||
:- now.bowl
|
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
%- ~(gas by *(map index:store node:store))
|
|
||||||
%+ turn
|
|
||||||
%+ scag count
|
|
||||||
?: newest
|
|
||||||
(tap:orm u.children)
|
|
||||||
(bap:orm u.children)
|
|
||||||
|= [=atom =node:store]
|
|
||||||
^- [index:store node:store]
|
|
||||||
[(snoc index atom) node]
|
|
||||||
::
|
|
||||||
[%x %node-children-subset @ @ @ @ @ *]
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ start=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
|
||||||
=/ end=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
|
||||||
=/ =index:store
|
|
||||||
(turn t.t.t.t.t.t.path |=(=cord (slav %ud cord)))
|
|
||||||
=/ node=(unit node:store) (get-node ship term index)
|
|
||||||
?~ node [~ ~]
|
|
||||||
?- -.children.u.node
|
|
||||||
%empty [~ ~]
|
|
||||||
%graph
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
:- ~ :- ~ :- %graph-update-2
|
||||||
!> ^- update:store
|
!> ^- update:store
|
||||||
:- now.bowl
|
:^ now.bowl %add-nodes [ship term]
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
%- ~(gas by *(map index:store node:store))
|
%- ~(gas by *(map index:store node:store))
|
||||||
%+ turn (tap:orm `graph:store`(lot:orm p.children.u.node end start))
|
%+ turn (tap:orm (lot:orm graph start end))
|
||||||
|= [=atom =node:store]
|
|= [=atom =node:store]
|
||||||
^- [index:store node:store]
|
^- [index:store node:store]
|
||||||
[(snoc index atom) node]
|
:- atom^~
|
||||||
==
|
?: ?=(%kith i.t.t.t.t.t.path)
|
||||||
::
|
node
|
||||||
[%x %deep-nodes-older-than @ @ @ @ ~]
|
node(children [%empty ~])
|
||||||
=/ =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)
|
|
||||||
=/ start=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
|
||||||
?: ?=(~ count)
|
|
||||||
[~ ~]
|
|
||||||
=/ result=(unit marked-graph:store)
|
|
||||||
(~(get by graphs) [ship term])
|
|
||||||
?~ result
|
|
||||||
[~ ~]
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
|
||||||
!> ^- update:store
|
|
||||||
:- now.bowl
|
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
=* a u.count
|
|
||||||
=/ b=(list (pair atom node:store))
|
|
||||||
(tab:orm p.u.result start u.count)
|
|
||||||
=| c=index:store
|
|
||||||
=| d=(map index:store node:store)
|
|
||||||
=| e=@ud
|
|
||||||
=- d
|
|
||||||
|- ^- [e=@ud d=(map index:store node:store)]
|
|
||||||
?: ?|(?=(~ b) =(e a))
|
|
||||||
[e d]
|
|
||||||
=* atom p.i.b
|
|
||||||
=* node q.i.b
|
|
||||||
=. c (snoc c atom)
|
|
||||||
?- -.children.node
|
|
||||||
%empty
|
|
||||||
$(b t.b, e +(e), d (~(put by d) c node), c (snip c))
|
|
||||||
::
|
::
|
||||||
%graph
|
[%node *]
|
||||||
=/ f $(b (tab:orm p.children.node ~ (sub a e)))
|
|^
|
||||||
?: =(e.f a) f
|
=* pax t.t.t.t.t.path
|
||||||
%_ $
|
?+ pax (on-peek:def path)
|
||||||
b t.b
|
[%exists ^]
|
||||||
e +(e.f)
|
=/ =index:store
|
||||||
d (~(put by d.f) c node(children [%empty ~]))
|
(turn t.pax (cury slav %ud))
|
||||||
c (snip c)
|
=/ node (get-node graph index)
|
||||||
==
|
``noun+!>(`?`?=(^ node))
|
||||||
==
|
::
|
||||||
::
|
[%index ?(%lone %kith) ^]
|
||||||
[%x %firstborn @ @ @ *]
|
=/ =index:store
|
||||||
|^
|
(turn t.t.pax (cury slav %ud))
|
||||||
=/ =ship (slav %p i.t.t.path)
|
=/ node (get-node graph index)
|
||||||
=/ =term i.t.t.t.path
|
?~ node [~ ~]
|
||||||
=/ =index:store
|
|
||||||
(turn t.t.t.t.path (cury slav %ud))
|
|
||||||
?> ?=(^ index)
|
|
||||||
=/ result=(unit marked-graph:store)
|
|
||||||
(~(get by graphs) [ship term])
|
|
||||||
?~ result
|
|
||||||
[~ ~]
|
|
||||||
%- (bond |.(`(unit (unit cage))`[~ ~]))
|
|
||||||
%+ biff
|
|
||||||
(collect-parents p.u.result index ship term)
|
|
||||||
(corl some collect-firstborn)
|
|
||||||
::
|
|
||||||
++ collect-parents
|
|
||||||
|= [=graph:store =index:store =ship =term]
|
|
||||||
^- %- unit
|
|
||||||
[node:store index:store (map index:store node:store) ^ship ^term]
|
|
||||||
=| =(map index:store node:store)
|
|
||||||
=| =node:store
|
|
||||||
=| ind=index:store
|
|
||||||
=/ len (lent index)
|
|
||||||
|-
|
|
||||||
?: (gte (lent ind) len)
|
|
||||||
`[node ind map ship term]
|
|
||||||
?> ?=(^ index)
|
|
||||||
=* atom i.index
|
|
||||||
?. (has:orm graph atom)
|
|
||||||
~
|
|
||||||
=: node (got:orm graph atom)
|
|
||||||
ind (snoc ind atom)
|
|
||||||
==
|
|
||||||
?: ?=(%empty -.children.node)
|
|
||||||
?. (gte (lent ind) len)
|
|
||||||
~
|
|
||||||
:- ~
|
|
||||||
:* node ind
|
|
||||||
(~(put by map) ind node)
|
|
||||||
ship term
|
|
||||||
==
|
|
||||||
%_ $
|
|
||||||
index t.index
|
|
||||||
graph p.children.node
|
|
||||||
map (~(put by map) ind node(children empty+~))
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ collect-firstborn
|
|
||||||
|= [=node:store =index:store mp=(map index:store node:store) =ship =term]
|
|
||||||
^- (unit (unit cage))
|
|
||||||
?: ?=(%empty -.children.node)
|
|
||||||
:- ~ :- ~ :- %graph-update-2
|
:- ~ :- ~ :- %graph-update-2
|
||||||
!> ^- update:store
|
!> ^- update:store
|
||||||
[now.bowl [%add-nodes [ship term] mp]]
|
:^ now.bowl %add-nodes [ship term]
|
||||||
=/ item=[k=atom v=node:store]
|
%- ~(gas by *(map index:store node:store))
|
||||||
(need (ram:orm p.children.node))
|
:_ ~ :- index
|
||||||
=. index (snoc index k.item)
|
?: ?=(%kith i.t.pax) u.node
|
||||||
$(mp (~(put by mp) index v.item(children empty+~)), node v.item)
|
u.node(children [%empty ~])
|
||||||
--
|
::
|
||||||
::
|
[%children ?(%lone %kith) @ @ *]
|
||||||
[%x %update-log-subset @ @ @ @ ~]
|
=/ start=(unit atom) (rush i.t.t.path dem:ag)
|
||||||
=/ =ship (slav %p i.t.t.path)
|
=/ end=(unit atom) (rush i.t.t.t.path dem:ag)
|
||||||
=/ =term i.t.t.t.path
|
=/ =index:store
|
||||||
=/ start=(unit time) (slaw %da i.t.t.t.t.path)
|
(turn t.t.t.t.pax (cury slav %ud))
|
||||||
=/ end=(unit time) (slaw %da i.t.t.t.t.t.path)
|
=/ node (get-node graph index)
|
||||||
=/ update-log=(unit update-log:store) (~(get by update-logs) [ship term])
|
?: ?& ?=(~ node)
|
||||||
?~ update-log [~ ~]
|
?=(^ index)
|
||||||
:: orm-log is ordered backwards, so swap start and end
|
==
|
||||||
``noun+!>(`update-log:store`(lot:orm-log u.update-log end start))
|
[~ ~]
|
||||||
::
|
=/ children=graph:store
|
||||||
[%x %update-log @ @ ~]
|
?~ node
|
||||||
=/ =ship (slav %p i.t.t.path)
|
graph
|
||||||
=/ =term i.t.t.t.path
|
?: ?=(%empty -.children.u.node)
|
||||||
=/ update-log=(unit update-log:store) (~(get by update-logs) [ship term])
|
~
|
||||||
?~ update-log [~ ~]
|
p.children.u.node
|
||||||
``noun+!>(`update-log:store`u.update-log)
|
:- ~ :- ~ :- %graph-update-2
|
||||||
::
|
!> ^- update:store
|
||||||
[%x %peek-update-log @ @ ~]
|
:^ now.bowl %add-nodes [ship term]
|
||||||
=/ =ship (slav %p i.t.t.path)
|
%- ~(gas by *(map index:store node:store))
|
||||||
=/ =term i.t.t.t.path
|
%+ turn (tap:orm (lot:orm children end start))
|
||||||
=/ m-update-log=(unit update-log:store)
|
|= [=atom =node:store]
|
||||||
(~(get by update-logs) [ship term])
|
^- [index:store node:store]
|
||||||
:- ~ :- ~ :- %noun
|
:- (snoc index atom)
|
||||||
!> ^- (unit time)
|
?: ?=(%kith i.t.pax) node
|
||||||
%+ biff m-update-log
|
node(children [%empty ~])
|
||||||
|= =update-log:store
|
::
|
||||||
=/ result=(unit [=time =update:store])
|
[%siblings ?(%older %newer %oldest %newest) ?(%lone %kith) @ *]
|
||||||
(pry:orm-log:store update-log)
|
=/ count (slav %ud i.t.t.t.pax)
|
||||||
(bind result head)
|
=/ =index:store
|
||||||
==
|
(turn t.t.t.t.pax (cury slav %ud))
|
||||||
::
|
=/ parent=index:store (snip index)
|
||||||
++ get-node-children
|
=/ node (get-node graph parent)
|
||||||
|= [=ship =term =index:store]
|
?: ?| ?& ?=(~ node)
|
||||||
^- (unit graph:store)
|
?=(^ parent)
|
||||||
?: ?=(~ index)
|
==
|
||||||
=/ graph
|
::
|
||||||
(~(get by graphs) [ship term])
|
?& ?=(^ parent)
|
||||||
?~ graph ~
|
?| ?=(%oldest i.t.pax)
|
||||||
`p.u.graph
|
?=(%newest i.t.pax)
|
||||||
=/ node
|
== == ==
|
||||||
(get-node ship term index)
|
[~ ~]
|
||||||
?~ node ~
|
=/ children=graph:store
|
||||||
?: ?=(%empty -.children.u.node)
|
?~ node
|
||||||
~
|
graph
|
||||||
`p.children.u.node
|
?: ?=(%empty -.children.u.node)
|
||||||
::
|
~
|
||||||
++ get-node
|
p.children.u.node
|
||||||
|= [=ship =term =index:store]
|
:- ~ :- ~ :- %graph-update-2
|
||||||
^- (unit node:store)
|
!> ^- update:store
|
||||||
=/ parent-graph=(unit marked-graph:store)
|
:^ now.bowl %add-nodes [ship term]
|
||||||
(~(get by graphs) [ship term])
|
%- ~(gas by *(map index:store node:store))
|
||||||
?~ parent-graph ~
|
%+ turn
|
||||||
=/ node=(unit node:store) ~
|
?- i.t.pax
|
||||||
=/ =graph:store p.u.parent-graph
|
%oldest (scag count (bap:orm children))
|
||||||
|-
|
%older (tab:orm children `(rear index) count)
|
||||||
?~ index
|
%newest (scag count (tap:orm children))
|
||||||
node
|
::
|
||||||
?~ t.index
|
%newer
|
||||||
(get:orm graph i.index)
|
%+ slag (safe-sub (lent -) count)
|
||||||
=. node (get:orm graph i.index)
|
(tap:orm (lot:orm children ~ `(rear index)))
|
||||||
?~ node ~
|
==
|
||||||
?- -.children.u.node
|
|= [=atom =node:store]
|
||||||
%empty ~
|
^- [index:store node:store]
|
||||||
%graph $(graph p.children.u.node, index t.index)
|
:- (snoc parent atom)
|
||||||
|
?: ?=(%kith i.t.t.pax) node
|
||||||
|
node(children [%empty ~])
|
||||||
|
::
|
||||||
|
[%firstborn ^]
|
||||||
|
|^
|
||||||
|
=/ =index:store
|
||||||
|
(turn t.pax (cury slav %ud))
|
||||||
|
%- (bond |.(`(unit (unit cage))`[~ ~]))
|
||||||
|
%+ biff
|
||||||
|
(collect-parents graph index)
|
||||||
|
(corl some collect-firstborn)
|
||||||
|
::
|
||||||
|
++ collect-parents
|
||||||
|
|= [=graph:store =index:store]
|
||||||
|
^- (unit [node:store index:store (map index:store node:store)])
|
||||||
|
=| =(map index:store node:store)
|
||||||
|
=| =node:store
|
||||||
|
=| ind=index:store
|
||||||
|
=/ len (lent index)
|
||||||
|
|-
|
||||||
|
?: (gte (lent ind) len)
|
||||||
|
`[node ind map]
|
||||||
|
?> ?=(^ index)
|
||||||
|
=* atom i.index
|
||||||
|
?. (has:orm graph atom)
|
||||||
|
~
|
||||||
|
=: node (got:orm graph atom)
|
||||||
|
ind (snoc ind atom)
|
||||||
|
==
|
||||||
|
?: ?=(%empty -.children.node)
|
||||||
|
?. (gte (lent ind) len)
|
||||||
|
~
|
||||||
|
`[node ind (~(put by map) ind node)]
|
||||||
|
%_ $
|
||||||
|
index t.index
|
||||||
|
graph p.children.node
|
||||||
|
map (~(put by map) ind node(children empty+~))
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ collect-firstborn
|
||||||
|
|= [=node:store =index:store =(map index:store node:store)]
|
||||||
|
^- (unit (unit cage))
|
||||||
|
?: ?=(%empty -.children.node)
|
||||||
|
:- ~ :- ~ :- %graph-update-2
|
||||||
|
!>(`update:store`[now.bowl [%add-nodes [ship term] map]])
|
||||||
|
=/ item=[k=atom v=node:store]
|
||||||
|
(need (ram:orm p.children.node))
|
||||||
|
=. index (snoc index k.item)
|
||||||
|
$(map (~(put by map) index v.item(children empty+~)), node v.item)
|
||||||
|
--
|
||||||
|
==
|
||||||
|
::
|
||||||
|
++ get-node
|
||||||
|
|= [=graph:store =index:store]
|
||||||
|
^- (unit node:store)
|
||||||
|
=| node=(unit node:store)
|
||||||
|
|-
|
||||||
|
?~ index node
|
||||||
|
?~ t.index (get:orm graph i.index)
|
||||||
|
=. node (get:orm graph i.index)
|
||||||
|
?~ node ~
|
||||||
|
?: ?=(%empty -.children.u.node)
|
||||||
|
~
|
||||||
|
$(graph p.children.u.node, index t.index)
|
||||||
|
::
|
||||||
|
++ safe-sub
|
||||||
|
|= [a=@ b=@]
|
||||||
|
^- @
|
||||||
|
?:((gte b a) 0 (sub a b))
|
||||||
|
--
|
||||||
|
::
|
||||||
|
[%depth-first @ @ ~]
|
||||||
|
=/ count=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
||||||
|
=/ start=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
||||||
|
?: ?=(~ count)
|
||||||
|
[~ ~]
|
||||||
|
:- ~ :- ~ :- %graph-update-2
|
||||||
|
!> ^- update:store
|
||||||
|
:^ now.bowl %add-nodes [ship term]
|
||||||
|
=* a u.count
|
||||||
|
=/ b=(list (pair atom node:store))
|
||||||
|
(tab:orm graph start u.count)
|
||||||
|
=| c=index:store
|
||||||
|
=| d=(map index:store node:store)
|
||||||
|
=| e=@ud
|
||||||
|
=- d
|
||||||
|
|- ^- [e=@ud d=(map index:store node:store)]
|
||||||
|
?: ?|(?=(~ b) =(e a))
|
||||||
|
[e d]
|
||||||
|
=* atom p.i.b
|
||||||
|
=* node q.i.b
|
||||||
|
=. c (snoc c atom)
|
||||||
|
?- -.children.node
|
||||||
|
%empty
|
||||||
|
$(b t.b, e +(e), d (~(put by d) c node), c (snip c))
|
||||||
|
::
|
||||||
|
%graph
|
||||||
|
=/ f $(b (tab:orm p.children.node ~ (sub a e)))
|
||||||
|
?: =(e.f a) f
|
||||||
|
%_ $
|
||||||
|
b t.b
|
||||||
|
e +(e.f)
|
||||||
|
d (~(put by d.f) c node(children [%empty ~]))
|
||||||
|
c (snip c)
|
||||||
|
==
|
||||||
|
==
|
||||||
==
|
==
|
||||||
--
|
|
||||||
::
|
|
||||||
++ on-arvo
|
|
||||||
|= [=wire =sign-arvo]
|
|
||||||
^- (quip card _this)
|
|
||||||
?+ wire (on-arvo:def wire sign-arvo)
|
|
||||||
::
|
|
||||||
:: old wire, do nothing
|
|
||||||
[%graph *] [~ this]
|
|
||||||
[%validator @ ~] [~ this]
|
|
||||||
[%try-rejoin @ *] [~ this]
|
|
||||||
==
|
==
|
||||||
::
|
::
|
||||||
|
++ on-arvo on-arvo:def
|
||||||
++ on-agent on-agent:def
|
++ on-agent on-agent:def
|
||||||
++ on-leave on-leave:def
|
++ on-leave on-leave:def
|
||||||
++ on-fail on-fail:def
|
++ on-fail on-fail:def
|
||||||
|
@ -285,7 +285,7 @@
|
|||||||
^- $-(indexed-post:graph-store (unit notif-kind:hook))
|
^- $-(indexed-post:graph-store (unit notif-kind:hook))
|
||||||
=+ %^ scry [our now]:bowl
|
=+ %^ scry [our now]:bowl
|
||||||
,mark=(unit mark)
|
,mark=(unit mark)
|
||||||
/gx/graph-store/graph-mark/(scot %p entity.rid)/[name.rid]/noun
|
/gx/graph-store/graph/(scot %p entity.rid)/[name.rid]/mark/noun
|
||||||
?~ mark
|
?~ mark
|
||||||
|=(=indexed-post:graph-store ~)
|
|=(=indexed-post:graph-store ~)
|
||||||
(scry-notif-conversion [our now]:bowl q.byk.bowl u.mark)
|
(scry-notif-conversion [our now]:bowl q.byk.bowl u.mark)
|
||||||
|
@ -96,22 +96,12 @@
|
|||||||
?> ?=(%add-graph -.q.update)
|
?> ?=(%add-graph -.q.update)
|
||||||
graph.q.update
|
graph.q.update
|
||||||
::
|
::
|
||||||
++ gut-younger-node-siblings
|
|
||||||
|= [res=resource =index:store]
|
|
||||||
^- (map index:store node:store)
|
|
||||||
=+ %+ scry-for ,=update:store
|
|
||||||
%+ weld
|
|
||||||
/node-siblings/younger/(scot %p entity.res)/[name.res]/all
|
|
||||||
(turn index (cury scot %ud))
|
|
||||||
?> ?=(%add-nodes -.q.update)
|
|
||||||
nodes.q.update
|
|
||||||
::
|
|
||||||
++ got-node
|
++ got-node
|
||||||
|= [res=resource =index:store]
|
|= [res=resource =index:store]
|
||||||
^- node:store
|
^- node:store
|
||||||
=+ %+ scry-for ,=update:store
|
=+ %+ scry-for ,=update:store
|
||||||
%+ weld
|
%+ weld
|
||||||
/node/(scot %p entity.res)/[name.res]
|
/graph/(scot %p entity.res)/[name.res]/node/index/kith
|
||||||
(turn index (cury scot %ud))
|
(turn index (cury scot %ud))
|
||||||
?> ?=(%add-nodes -.q.update)
|
?> ?=(%add-nodes -.q.update)
|
||||||
?> ?=(^ nodes.q.update)
|
?> ?=(^ nodes.q.update)
|
||||||
@ -122,7 +112,7 @@
|
|||||||
^- ?
|
^- ?
|
||||||
%+ scry-for ,?
|
%+ scry-for ,?
|
||||||
%+ weld
|
%+ weld
|
||||||
/node-exists/(scot %p entity.res)/[name.res]
|
/graph/(scot %p entity.res)/[name.res]/node/exists
|
||||||
(turn index (cury scot %ud))
|
(turn index (cury scot %ud))
|
||||||
::
|
::
|
||||||
++ get-update-log
|
++ get-update-log
|
||||||
@ -134,13 +124,13 @@
|
|||||||
++ peek-update-log
|
++ peek-update-log
|
||||||
|= res=resource
|
|= res=resource
|
||||||
^- (unit time)
|
^- (unit time)
|
||||||
(scry-for (unit time) /peek-update-log/(scot %p entity.res)/[name.res])
|
(scry-for (unit time) /update-log/(scot %p entity.res)/[name.res]/latest)
|
||||||
::
|
::
|
||||||
++ get-update-log-subset
|
++ get-update-log-subset
|
||||||
|= [res=resource start=@da]
|
|= [res=resource start=@da]
|
||||||
^- update-log:store
|
^- update-log:store
|
||||||
%+ scry-for update-log:store
|
%+ scry-for update-log:store
|
||||||
/update-log-subset/(scot %p entity.res)/[name.res]/(scot %da start)/'~'
|
/update-log/(scot %p entity.res)/[name.res]/subset/(scot %da start)/'~'
|
||||||
::
|
::
|
||||||
++ get-keys
|
++ get-keys
|
||||||
^- resources
|
^- resources
|
||||||
@ -183,5 +173,5 @@
|
|||||||
::
|
::
|
||||||
++ get-mark
|
++ get-mark
|
||||||
|= res=resource
|
|= res=resource
|
||||||
(scry-for ,(unit mark) /graph-mark/(scot %p entity.res)/[name.res])
|
(scry-for ,(unit mark) /graph/(scot %p entity.res)/[name.res]/mark)
|
||||||
--
|
--
|
||||||
|
@ -400,7 +400,8 @@ export const getNewest = (
|
|||||||
index = ''
|
index = ''
|
||||||
): Scry => ({
|
): Scry => ({
|
||||||
app: 'graph-store',
|
app: 'graph-store',
|
||||||
path: `/newest/${ship}/${name}/${count}${encodeIndex(index)}`
|
path: `/graph/${ship}/${name}/node/siblings` +
|
||||||
|
`/newest/lone/${count}${encodeIndex(index)}`
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -419,7 +420,7 @@ export const getOlderSiblings = (
|
|||||||
index: string
|
index: string
|
||||||
): Scry => ({
|
): Scry => ({
|
||||||
app: 'graph-store',
|
app: 'graph-store',
|
||||||
path: `/node-siblings/older/${ship}/${name}/${count}${encodeIndex(index)}`
|
path: `/graph/${ship}/${name}/node/siblings/older/lone/${count}${encodeIndex(index)}`
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -438,7 +439,7 @@ export const getYoungerSiblings = (
|
|||||||
index: string
|
index: string
|
||||||
): Scry => ({
|
): Scry => ({
|
||||||
app: 'graph-store',
|
app: 'graph-store',
|
||||||
path: `/node-siblings/younger/${ship}/${name}/${count}${encodeIndex(index)}`
|
path: `/graph/${ship}/${name}/node/siblings/newer/lone/${count}${encodeIndex(index)}`
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -450,7 +451,7 @@ export const getYoungerSiblings = (
|
|||||||
*/
|
*/
|
||||||
export const getShallowChildren = (ship: string, name: string, index = '') => ({
|
export const getShallowChildren = (ship: string, name: string, index = '') => ({
|
||||||
app: 'graph-store',
|
app: 'graph-store',
|
||||||
path: `/shallow-children/${ship}/${name}${encodeIndex(index)}`
|
path: `/graph/${ship}/${name}/node/children/lone/~/~/${encodeIndex(index)}`
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -470,7 +471,9 @@ export const getDeepOlderThan = (
|
|||||||
start?: string
|
start?: string
|
||||||
) => ({
|
) => ({
|
||||||
app: 'graph-store',
|
app: 'graph-store',
|
||||||
path: `/deep-nodes-older-than/${ship}/${name}/${count}/${start ? decToUd(start) : 'null'}`
|
path: `/graph/${ship}/${name}/node/siblings` +
|
||||||
|
`/${start ? 'older' : 'oldest'}` +
|
||||||
|
`/kith/${count}/${start ? decToUd(start) : '~'}`
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -487,7 +490,7 @@ export const getFirstborn = (
|
|||||||
index: string
|
index: string
|
||||||
): Scry => ({
|
): Scry => ({
|
||||||
app: 'graph-store',
|
app: 'graph-store',
|
||||||
path: `/firstborn/${ship}/${name}${encodeIndex(index)}`
|
path: `/graph/${ship}/${name}/node/firstborn${encodeIndex(index)}`
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -504,7 +507,7 @@ export const getNode = (
|
|||||||
index: string
|
index: string
|
||||||
): Scry => ({
|
): Scry => ({
|
||||||
app: 'graph-store',
|
app: 'graph-store',
|
||||||
path: `/node/${ship}/${name}${encodeIndex(index)}`
|
path: `/graph/${ship}/${name}/node/index/kith${encodeIndex(index)}`
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user