Skip to content

Commit

Permalink
Updated examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
linas committed Oct 24, 2019
1 parent 3e47623 commit 8ab0fa7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,18 @@ and "active" Atoms.

**Status**: Design alternatives are being explored. In the current
implementation:
* It is possible to save Atoms to IPFS, but not values.
* It is possible to save and restores Atoms to IPFS.
* AtomSpaces can be saved and restored in bulk. See the
[examples](examples).

The design for Values is unknown and likely to be challenging.
* Incoming-set query does not work.

After much thought: there does not seem to be any way of mapping the
AtomSpace into the current design of IPFS+IPNS without resorting to
a single, centralized file listing all of the Atoms in an AtomSpace.
Implementing a single, centralized file seems like a "really bad idea"
for all of the usual reasons:
* When it gets large, it does not scale.
* Impossible to optimze fetch of atoms-by-type.
* Impossible to optimize fetch of atoms-by-type.
* Update conflicts when there are multiple writers.
* Performance bottlenecks when there are multiple writers.
Despite this, a bad, hacky implementation, with the above obvious
Expand Down
13 changes: 11 additions & 2 deletions examples/values-restore.scm
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,17 @@
(format #t "Key ~A has value ~A\n" key (cog-value c key)))
(cog-keys c))

; Review the stats
(ipfs-stats)
; Fetch the previously-stored EvaluationLink
(define e
(ipfs-fetch-atom "bafyreiaak6j7psknn5id7d456jaxaqxq7xjczmi7boj4zg6pqhgr5oeuuu"))

(cog-keys e)

; Print them all, too.
(for-each
(lambda (key)
(format #t "Key ~A has value ~A\n" key (cog-value e key)))
(cog-keys e))

; Close the connection.
(ipfs-close)
Expand Down
13 changes: 4 additions & 9 deletions examples/values-save.scm
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
; http://localhost:5001/webui
(ipfs-atom-cid c)

; A more complex examle...
; A more complex example...
(cog-set-value! c (Predicate "position") (FloatValue 1.1 2.2 3.3))
(cog-set-value! c (Predicate "velocity") (FloatValue 4.4 5.5 6.6))
(store-atom c)
Expand All @@ -42,20 +42,15 @@
(Predicate "Some relationship")
(List (Concept "foo") (Concept "bar"))))

(cog-set-value! e (Predicate "position") (FloatValue 3 2 1))
(cog-set-value! e (Predicate "velocity") (FloatValue 42 41 40))
(store-atom e)
(barrier)

; Likewise, view the CID for the EvaluationLink:
(ipfs-atom-cid e)

; The expected CID for the EvaluationLink is:
;
; /ipfs/bafyreigll67ssepbqfhtooqobirodyyhsq3ptmxseuwxwnxs5aci75hpoq
; /ipfs/bafyreiaak6j7psknn5id7d456jaxaqxq7xjczmi7boj4zg6pqhgr5oeuuu
;

; Review the stats
(ipfs-stats)

; Close the connection.
(ipfs-close)

Expand Down

0 comments on commit 8ab0fa7

Please sign in to comment.