urbit/pkg/arvo/lib/graph.hoon

188 lines
4.3 KiB
Plaintext
Raw Normal View History

/- *resource
/+ store=graph-store
|_ =bowl:gall
2021-04-23 04:03:06 +03:00
++ cg
|%
++ update
|= =update:store
^- cage
[%graph-update-1 !>(update)]
--
::
2020-06-27 00:13:12 +03:00
++ scry-for
|* [=mold =path]
.^ mold
%gx
(scot %p our.bowl)
%graph-store
(scot %da now.bowl)
(snoc `^path`path %noun)
==
::
++ resource-for-update
|= =vase
^- (list resource)
=/ =update:store !<(update:store vase)
?- -.q.update
%add-graph ~[resource.q.update]
%remove-graph ~[resource.q.update]
%add-nodes ~[resource.q.update]
%remove-posts ~[resource.q.update]
%add-signatures ~[resource.uid.q.update]
%remove-signatures ~[resource.uid.q.update]
%archive-graph ~[resource.q.update]
%unarchive-graph ~
%add-tag ~
%remove-tag ~
%keys ~
%tags ~
%tag-queries ~
%run-updates ~[resource.q.update]
==
::
2021-03-18 10:02:39 +03:00
++ upgrade
|* [pst=mold out-pst=mold]
=>
|%
++ orm
((ordered-map atom node) gth)
+$ node
[post=pst children=internal-graph]
+$ graph
((mop atom node) gth)
+$ internal-graph
$~ [%empty ~]
$% [%graph p=graph]
[%empty ~]
==
::
++ out-orm
((ordered-map atom out-node) gth)
+$ out-node
[post=out-pst children=out-internal-graph]
+$ out-graph
((mop atom out-node) gth)
+$ out-internal-graph
$~ [%empty ~]
$% [%graph p=out-graph]
[%empty ~]
==
--
|= $: gra=graph
fn=$-(pst out-pst)
==
^- out-graph
%- gas:out-orm
%+ turn (tap:orm gra)
|= [=atom =node]
:- (fn post.node)
?: ?=(%empty -.children.node)
[%empty ~]
$(gra p.children.node)
::
2020-06-27 00:13:12 +03:00
++ get-graph
|= res=resource
2020-09-04 10:42:20 +03:00
^- update:store
=- -(p *time)
2020-09-04 10:42:20 +03:00
%+ scry-for update:store
2020-07-07 03:02:15 +03:00
/graph/(scot %p entity.res)/[name.res]
::
++ get-graph-mop
|= res=resource
^- graph:store
=/ =update:store
(get-graph res)
?> ?=(%add-graph -.q.update)
graph.q.update
::
2020-12-01 08:46:28 +03:00
++ 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
::
2020-11-03 21:10:57 +03:00
++ got-node
2020-11-03 03:19:58 +03:00
|= [res=resource =index:store]
^- node:store
=+ %+ scry-for ,=update:store
%+ weld
/node/(scot %p entity.res)/[name.res]
(turn index (cury scot %ud))
?> ?=(%add-nodes -.q.update)
?> ?=(^ nodes.q.update)
q.n.nodes.q.update
::
2021-01-11 02:51:36 +03:00
++ check-node-existence
|= [res=resource =index:store]
^- ?
%+ scry-for ,?
%+ weld
/node-exists/(scot %p entity.res)/[name.res]
(turn index (cury scot %ud))
::
2020-09-04 10:42:20 +03:00
++ get-update-log
|= rid=resource
^- update-log:store
%+ scry-for update-log:store
/update-log/(scot %p entity.rid)/[name.rid]
::
2020-08-19 22:22:20 +03:00
++ peek-update-log
|= res=resource
^- (unit time)
(scry-for (unit time) /peek-update-log/(scot %p entity.res)/[name.res])
2020-08-19 22:22:20 +03:00
::
++ get-update-log-subset
|= [res=resource start=@da]
^- update-log:store
%+ scry-for update-log:store
/update-log-subset/(scot %p entity.res)/[name.res]/(scot %da start)/'~'
2020-11-03 10:20:01 +03:00
::
++ get-keys
^- resources
=+ %+ scry-for ,=update:store
/keys
?> ?=(%keys -.q.update)
resources.q.update
2020-12-01 08:46:28 +03:00
::
++ tap-deep
|= [=index:store =graph:store]
2020-12-01 08:46:28 +03:00
^- (list [index:store node:store])
%+ roll (tap:orm:store graph)
|= $: [=atom =node:store]
lis=(list [index:store node:store])
==
=/ child-index (snoc index atom)
=/ childless-node node(children [%empty ~])
?: ?=(%empty -.children.node)
(snoc lis [child-index childless-node])
%+ weld
(snoc lis [child-index childless-node])
(tap-deep child-index p.children.node)
2021-01-26 05:42:44 +03:00
::
++ got-deep
|= [=graph:store =index:store]
^- node:store
=/ ind index
?> ?=(^ index)
=/ =node:store (need (get:orm:store graph `atom`i.index))
=. ind t.index
|- ^- node:store
?~ ind
node
?: ?=(%empty -.children.node)
!!
%_ $
ind t.ind
node (need (get:orm:store p.children.node i.ind))
==
::
2021-01-26 05:42:44 +03:00
++ get-mark
|= res=resource
(scry-for ,(unit mark) /graph-mark/(scot %p entity.res)/[name.res])
2020-06-27 00:13:12 +03:00
--