mirror of
https://github.com/urbit/shrub.git
synced 2024-11-30 22:15:47 +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,228 +615,261 @@
|
|||||||
~/ %graph-store-peek
|
~/ %graph-store-peek
|
||||||
|= =path
|
|= =path
|
||||||
^- (unit (unit cage))
|
^- (unit (unit cage))
|
||||||
|^
|
|
||||||
?> (team:title our.bowl src.bowl)
|
|
||||||
?+ path (on-peek:def path)
|
?+ path (on-peek:def path)
|
||||||
[%x %graph-mark @ @ ~]
|
[%x %export ~] ``noun+!>(state)
|
||||||
=/ =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]
|
||||||
:: note: near-duplicate of /x/graph
|
[%tags ~] [%tags ~(key by tag-queries)]
|
||||||
|
==
|
||||||
::
|
::
|
||||||
[%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])
|
(~(get by graphs) [ship term])
|
||||||
?~ result
|
?~ marked-graph [~ ~]
|
||||||
~& no-archived-graph+[ship term]
|
=* 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-graph [ship term] `graph:store`p.u.result q.u.result %.y]
|
|
||||||
::
|
::
|
||||||
[%x %export ~]
|
[%x %update-log @ @ *]
|
||||||
``noun+!>(state)
|
|
||||||
::
|
|
||||||
[%x %graph-subset @ @ @ @ ~]
|
|
||||||
=/ =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
|
||||||
=/ start=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
=/ update-log
|
||||||
=/ end=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
(~(get by update-logs) [ship term])
|
||||||
=/ graph=(unit marked-graph:store)
|
?~ update-log [~ ~]
|
||||||
|
:- ~ :- ~ :- %noun
|
||||||
|
!>
|
||||||
|
?+ t.t.t.t.path (on-peek:def path)
|
||||||
|
~ `update-log:store`u.update-log
|
||||||
|
::
|
||||||
|
[%latest ~]
|
||||||
|
^- (unit time)
|
||||||
|
%+ biff update-log
|
||||||
|
|= =update-log:store
|
||||||
|
(bind (pry:orm-log:store update-log) head)
|
||||||
|
::
|
||||||
|
[%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 %graph @ @ *]
|
||||||
|
=/ =ship (slav %p i.t.t.path)
|
||||||
|
=/ =term i.t.t.t.path
|
||||||
|
=/ marked-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
|
||||||
|
?+ t.t.t.t.path (on-peek:def path)
|
||||||
|
~
|
||||||
|
:- ~ :- ~ :- %graph-update-2
|
||||||
|
!>(`update:store`[now.bowl [%add-graph [ship term] graph mark %.y]])
|
||||||
|
::
|
||||||
|
[%mark ~]
|
||||||
|
``noun+!>(`(unit ^mark)`mark)
|
||||||
|
::
|
||||||
|
[%subset ?(%lone %kith) @ @ ~]
|
||||||
|
=/ 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)
|
||||||
:- ~ :- ~ :- %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.u.graph start end))
|
%+ turn (tap:orm (lot:orm graph start end))
|
||||||
|= [=atom =node:store]
|
|= [=atom =node:store]
|
||||||
^- [index:store node:store]
|
^- [index:store node:store]
|
||||||
[~[atom] node]
|
:- atom^~
|
||||||
|
?: ?=(%kith i.t.t.t.t.t.path)
|
||||||
|
node
|
||||||
|
node(children [%empty ~])
|
||||||
::
|
::
|
||||||
[%x %node-exists @ @ @ *]
|
[%node *]
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|^
|
||||||
=/ =term i.t.t.t.path
|
=* pax t.t.t.t.t.path
|
||||||
|
?+ pax (on-peek:def path)
|
||||||
|
[%exists ^]
|
||||||
=/ =index:store
|
=/ =index:store
|
||||||
(turn t.t.t.t.path (cury slav %ud))
|
(turn t.pax (cury slav %ud))
|
||||||
=/ node=(unit node:store)
|
=/ node (get-node graph index)
|
||||||
(get-node ship term index)
|
|
||||||
``noun+!>(`?`?=(^ node))
|
``noun+!>(`?`?=(^ node))
|
||||||
::
|
::
|
||||||
[%x %node @ @ @ *]
|
[%index ?(%lone %kith) ^]
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ =index:store
|
=/ =index:store
|
||||||
(turn t.t.t.t.path (cury slav %ud))
|
(turn t.t.pax (cury slav %ud))
|
||||||
=/ node=(unit node:store) (get-node ship term index)
|
=/ node (get-node graph index)
|
||||||
?~ node [~ ~]
|
?~ node [~ ~]
|
||||||
:- ~ :- ~ :- %graph-update-2
|
:- ~ :- ~ :- %graph-update-2
|
||||||
!> ^- update:store
|
!> ^- update:store
|
||||||
:- now.bowl
|
:^ now.bowl %add-nodes [ship term]
|
||||||
:+ %add-nodes
|
%- ~(gas by *(map index:store node:store))
|
||||||
[ship term]
|
:_ ~ :- index
|
||||||
(~(gas by *(map index:store node:store)) [index u.node] ~)
|
?: ?=(%kith i.t.pax) u.node
|
||||||
|
u.node(children [%empty ~])
|
||||||
::
|
::
|
||||||
[%x %node-siblings ?(%older %younger) @ @ @ *]
|
[%children ?(%lone %kith) @ @ *]
|
||||||
|^
|
=/ start=(unit atom) (rush i.t.t.path dem:ag)
|
||||||
=/ older ?=(%older i.t.t.path)
|
=/ end=(unit atom) (rush i.t.t.t.path dem:ag)
|
||||||
=/ =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
|
=/ =index:store
|
||||||
(turn t.t.t.t.t.t.path (cury slav %ud))
|
(turn t.t.t.t.pax (cury slav %ud))
|
||||||
=/ parent=index:store
|
=/ node (get-node graph index)
|
||||||
(scag (dec (lent index)) index)
|
?: ?& ?=(~ node)
|
||||||
=/ graph
|
?=(^ index)
|
||||||
(get-node-children ship term parent)
|
==
|
||||||
?~ graph [~ ~]
|
[~ ~]
|
||||||
|
=/ children=graph:store
|
||||||
|
?~ node
|
||||||
|
graph
|
||||||
|
?: ?=(%empty -.children.u.node)
|
||||||
|
~
|
||||||
|
p.children.u.node
|
||||||
:- ~ :- ~ :- %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
|
%+ turn (tap:orm (lot:orm children end start))
|
||||||
?: 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]
|
|= [=atom =node:store]
|
||||||
^- [index:store node:store]
|
^- [index:store node:store]
|
||||||
[(snoc parent atom) node]
|
:- (snoc index atom)
|
||||||
|
?: ?=(%kith i.t.pax) node
|
||||||
|
node(children [%empty ~])
|
||||||
|
::
|
||||||
|
[%siblings ?(%older %newer %oldest %newest) ?(%lone %kith) @ *]
|
||||||
|
=/ count (slav %ud i.t.t.t.pax)
|
||||||
|
=/ =index:store
|
||||||
|
(turn t.t.t.t.pax (cury slav %ud))
|
||||||
|
=/ parent=index:store (snip index)
|
||||||
|
=/ node (get-node graph parent)
|
||||||
|
?: ?| ?& ?=(~ node)
|
||||||
|
?=(^ parent)
|
||||||
|
==
|
||||||
|
::
|
||||||
|
?& ?=(^ parent)
|
||||||
|
?| ?=(%oldest i.t.pax)
|
||||||
|
?=(%newest i.t.pax)
|
||||||
|
== == ==
|
||||||
|
[~ ~]
|
||||||
|
=/ children=graph:store
|
||||||
|
?~ node
|
||||||
|
graph
|
||||||
|
?: ?=(%empty -.children.u.node)
|
||||||
|
~
|
||||||
|
p.children.u.node
|
||||||
|
:- ~ :- ~ :- %graph-update-2
|
||||||
|
!> ^- update:store
|
||||||
|
:^ now.bowl %add-nodes [ship term]
|
||||||
|
%- ~(gas by *(map index:store node:store))
|
||||||
|
%+ turn
|
||||||
|
?- i.t.pax
|
||||||
|
%oldest (scag count (bap:orm children))
|
||||||
|
%older (tab:orm children `(rear index) count)
|
||||||
|
%newest (scag count (tap:orm children))
|
||||||
|
::
|
||||||
|
%newer
|
||||||
|
%+ slag (safe-sub (lent -) count)
|
||||||
|
(tap:orm (lot:orm children ~ `(rear index)))
|
||||||
|
==
|
||||||
|
|= [=atom =node:store]
|
||||||
|
^- [index:store node:store]
|
||||||
|
:- (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
|
++ safe-sub
|
||||||
|= [a=@ b=@]
|
|= [a=@ b=@]
|
||||||
^- @
|
^- @
|
||||||
?: (gte b a)
|
?:((gte b a) 0 (sub a b))
|
||||||
0
|
|
||||||
(sub a b)
|
|
||||||
--
|
--
|
||||||
::
|
::
|
||||||
[%x %shallow-children @ @ *]
|
[%depth-first @ @ ~]
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ =index:store
|
|
||||||
(turn 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 (tap:orm u.children)
|
|
||||||
|= [=atom =node:store]
|
|
||||||
^- [index:store node:store]
|
|
||||||
:- (snoc index atom)
|
|
||||||
node(children [%empty ~])
|
|
||||||
::
|
|
||||||
[%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
|
|
||||||
!> ^- update:store
|
|
||||||
:- now.bowl
|
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
%- ~(gas by *(map index:store node:store))
|
|
||||||
%+ turn (tap:orm `graph:store`(lot:orm p.children.u.node end start))
|
|
||||||
|= [=atom =node:store]
|
|
||||||
^- [index:store node:store]
|
|
||||||
[(snoc index atom) node]
|
|
||||||
==
|
|
||||||
::
|
|
||||||
[%x %deep-nodes-older-than @ @ @ @ ~]
|
|
||||||
=/ =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=(unit atom) (rush i.t.t.t.t.path dem:ag)
|
||||||
=/ start=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
=/ start=(unit atom) (rush i.t.t.t.t.t.path dem:ag)
|
||||||
?: ?=(~ count)
|
?: ?=(~ count)
|
||||||
[~ ~]
|
[~ ~]
|
||||||
=/ 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-nodes [ship term]
|
||||||
:+ %add-nodes
|
|
||||||
[ship term]
|
|
||||||
=* a u.count
|
=* a u.count
|
||||||
=/ b=(list (pair atom node:store))
|
=/ b=(list (pair atom node:store))
|
||||||
(tab:orm p.u.result start u.count)
|
(tab:orm graph start u.count)
|
||||||
=| c=index:store
|
=| c=index:store
|
||||||
=| d=(map index:store node:store)
|
=| d=(map index:store node:store)
|
||||||
=| e=@ud
|
=| e=@ud
|
||||||
@ -864,146 +894,10 @@
|
|||||||
c (snip c)
|
c (snip c)
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
::
|
|
||||||
[%x %firstborn @ @ @ *]
|
|
||||||
|^
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ =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
|
|
||||||
!> ^- update:store
|
|
||||||
[now.bowl [%add-nodes [ship term] mp]]
|
|
||||||
=/ item=[k=atom v=node:store]
|
|
||||||
(need (ram:orm p.children.node))
|
|
||||||
=. index (snoc index k.item)
|
|
||||||
$(mp (~(put by mp) index v.item(children empty+~)), node v.item)
|
|
||||||
--
|
|
||||||
::
|
|
||||||
[%x %update-log-subset @ @ @ @ ~]
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ start=(unit time) (slaw %da i.t.t.t.t.path)
|
|
||||||
=/ end=(unit time) (slaw %da i.t.t.t.t.t.path)
|
|
||||||
=/ update-log=(unit update-log:store) (~(get by update-logs) [ship term])
|
|
||||||
?~ update-log [~ ~]
|
|
||||||
:: orm-log is ordered backwards, so swap start and end
|
|
||||||
``noun+!>(`update-log:store`(lot:orm-log u.update-log end start))
|
|
||||||
::
|
|
||||||
[%x %update-log @ @ ~]
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ update-log=(unit update-log:store) (~(get by update-logs) [ship term])
|
|
||||||
?~ update-log [~ ~]
|
|
||||||
``noun+!>(`update-log:store`u.update-log)
|
|
||||||
::
|
|
||||||
[%x %peek-update-log @ @ ~]
|
|
||||||
=/ =ship (slav %p i.t.t.path)
|
|
||||||
=/ =term i.t.t.t.path
|
|
||||||
=/ m-update-log=(unit update-log:store)
|
|
||||||
(~(get by update-logs) [ship term])
|
|
||||||
:- ~ :- ~ :- %noun
|
|
||||||
!> ^- (unit time)
|
|
||||||
%+ biff m-update-log
|
|
||||||
|= =update-log:store
|
|
||||||
=/ result=(unit [=time =update:store])
|
|
||||||
(pry:orm-log:store update-log)
|
|
||||||
(bind result head)
|
|
||||||
==
|
|
||||||
::
|
|
||||||
++ get-node-children
|
|
||||||
|= [=ship =term =index:store]
|
|
||||||
^- (unit graph:store)
|
|
||||||
?: ?=(~ index)
|
|
||||||
=/ graph
|
|
||||||
(~(get by graphs) [ship term])
|
|
||||||
?~ graph ~
|
|
||||||
`p.u.graph
|
|
||||||
=/ node
|
|
||||||
(get-node ship term index)
|
|
||||||
?~ node ~
|
|
||||||
?: ?=(%empty -.children.u.node)
|
|
||||||
~
|
|
||||||
`p.children.u.node
|
|
||||||
::
|
|
||||||
++ get-node
|
|
||||||
|= [=ship =term =index:store]
|
|
||||||
^- (unit node:store)
|
|
||||||
=/ parent-graph=(unit marked-graph:store)
|
|
||||||
(~(get by graphs) [ship term])
|
|
||||||
?~ parent-graph ~
|
|
||||||
=/ node=(unit node:store) ~
|
|
||||||
=/ =graph:store p.u.parent-graph
|
|
||||||
|-
|
|
||||||
?~ index
|
|
||||||
node
|
|
||||||
?~ t.index
|
|
||||||
(get:orm graph i.index)
|
|
||||||
=. node (get:orm graph i.index)
|
|
||||||
?~ node ~
|
|
||||||
?- -.children.u.node
|
|
||||||
%empty ~
|
|
||||||
%graph $(graph p.children.u.node, index t.index)
|
|
||||||
==
|
|
||||||
--
|
|
||||||
::
|
|
||||||
++ 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