| … | … | @@ -168,7 +168,7 @@ |
| 168 | 168 | (define (check-equal MSG A B) |
| 169 | 169 | (format #t "For ~A, expecting: ~A-- Got: ~A\n" MSG A B)) |
| 170 | 170 | |
| 171 | (define (get-val ATM) (cog-vale ATM (Predicate "key"))) | |
| 171 | (define (get-val ATM) (cog-value ATM (Predicate "key"))) | |
| 172 | 172 | |
| 173 | 173 | ; Lets take a look at the TV on `foo` in the base space. |
| 174 | 174 | (cog-set-atomspace! base-space) |
| … | … | @@ -27,9 +27,9 @@ |
| 27 | 27 | |
| 28 | 28 | ; Store the content. Store only the top-most link. |
| 29 | 29 | (define storage (MonoStorageNode "monospace:///tmp/cog-mono-value-store-test")) |
| 30 | (cog-open storage) | |
| 31 | (store-atom (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 32 | (cog-close storage) | |
| 30 | (cog-set-value! storage (*-open-*)) | |
| 31 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 32 | (cog-set-value! storage (*-close-*)) | |
| 33 | 33 | |
| 34 | 34 | ; Clear out the space, start with a clean slate. |
| 35 | 35 | (cog-atomspace-clear (cog-atomspace)) |
| … | … | @@ -46,11 +46,11 @@ |
| 46 | 46 | |
| 47 | 47 | ; Load everything. |
| 48 | 48 | (define storage (MonoStorageNode "monospace:///tmp/cog-mono-value-store-test")) |
| 49 | (cog-open storage) | |
| 49 | (cog-set-value! storage (*-open-*)) | |
| 50 | 50 | ; (cog-mono-stats storage) |
| 51 | 51 | ; (cog-mono-print storage "") |
| 52 | (load-atomspace) | |
| 53 | (cog-close storage) | |
| 52 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 53 | (cog-set-value! storage (*-close-*)) | |
| 54 | 54 | |
| 55 | 55 | ; Verify the ListLink is as expected. |
| 56 | 56 | (define lilly (ListLink (Concept "foo") (List (Concept "bar")))) |
| … | … | @@ -17,13 +17,13 @@ |
| 17 | 17 | (test-begin test-close-open) |
| 18 | 18 | |
| 19 | 19 | (define rsn (RocksStorageNode "rocks:///tmp/cog-rocks-dtor-close-test")) |
| 20 | (cog-open rsn) | |
| 20 | (cog-set-value! rsn (*-open-*)) | |
| 21 | 21 | |
| 22 | 22 | ; Create and store some data. |
| 23 | 23 | (List (Concept "A") (Concept "B")) |
| 24 | 24 | (Set (Concept "A") (Concept "B")) |
| 25 | 25 | (Set (Concept "A") (Concept "B") (Concept "C")) |
| 26 | (store-atomspace) | |
| 26 | (cog-set-value! rsn (*-store-atomspace-*) (cog-atomspace)) | |
| 27 | 27 | |
| 28 | 28 | ; The user should call (cog-close rsn) right now, but doesn't. |
| 29 | 29 | ; And this is what we're testing, here: some quasi-reasonable |
| … | … | @@ -89,12 +89,12 @@ |
| 89 | 89 | (test-equal #f (cog-atom? rsn)) |
| 90 | 90 | |
| 91 | 91 | (define rsn (RocksStorageNode "rocks:///tmp/cog-rocks-dtor-close-test")) |
| 92 | (cog-open rsn) | |
| 93 | (load-atomspace) | |
| 92 | (cog-set-value! rsn (*-open-*)) | |
| 93 | (cog-set-value! rsn (*-load-atomspace-*) (cog-atomspace)) | |
| 94 | 94 | |
| 95 | 95 | (test-equal #t (cog-atom? rsn)) |
| 96 | 96 | |
| 97 | (cog-close rsn) | |
| 97 | (cog-set-value! rsn (*-close-*)) | |
| 98 | 98 | (test-end test-close-open) |
| 99 | 99 | |
| 100 | 100 | ; =================================================================== |
| … | … | @@ -40,17 +40,17 @@ |
| 40 | 40 | ; Store the content. Store the Concepts as well as the link, |
| 41 | 41 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 42 | 42 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-fetch-frame-test")) |
| 43 | (cog-open storage) | |
| 44 | (store-frames surface-space) | |
| 45 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 46 | (store-atom (Concept "bar")) | |
| 47 | (store-atom (Concept "foo")) | |
| 43 | (cog-set-value! storage (*-open-*)) | |
| 44 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 45 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 46 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 47 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 48 | 48 | (cog-set-atomspace! mid1-space) |
| 49 | (store-atom (Concept "foo")) | |
| 49 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 50 | 50 | (cog-set-atomspace! base-space) |
| 51 | (store-atom (Concept "foo")) | |
| 51 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 52 | 52 | |
| 53 | (cog-close storage) | |
| 53 | (cog-set-value! storage (*-close-*)) | |
| 54 | 54 | |
| 55 | 55 | ; Clear out the spaces, start with a clean slate. |
| 56 | 56 | (cog-atomspace-clear surface-space) |
| … | … | @@ -75,11 +75,11 @@ |
| 75 | 75 | |
| 76 | 76 | ; Load everything. |
| 77 | 77 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-fetch-frame-test")) |
| 78 | (cog-open storage) | |
| 79 | (define top-space (car (load-frames))) | |
| 78 | (cog-set-value! storage (*-open-*)) | |
| 79 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 80 | 80 | (cog-set-atomspace! top-space) |
| 81 | (fetch-atom (Concept "foo")) | |
| 82 | (cog-close storage) | |
| 81 | (cog-set-value! storage (*-fetch-atom-*) (LinkValue top-space (Concept "foo"))) | |
| 82 | (cog-set-value! storage (*-close-*)) | |
| 83 | 83 | |
| 84 | 84 | ; Grab references into the inheritance hierarchy |
| 85 | 85 | (define surface-space top-space) |
| … | … | @@ -126,11 +126,11 @@ |
| 126 | 126 | |
| 127 | 127 | ; Load everything. |
| 128 | 128 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-fetch-frame-test")) |
| 129 | (cog-open storage) | |
| 130 | (define top-space (car (load-frames))) | |
| 129 | (cog-set-value! storage (*-open-*)) | |
| 130 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 131 | 131 | (cog-set-atomspace! top-space) |
| 132 | (load-atoms-of-type 'Concept) | |
| 133 | (cog-close storage) | |
| 132 | (cog-set-value! storage (*-load-atoms-of-type-*) (Type 'Concept)) | |
| 133 | (cog-set-value! storage (*-close-*)) | |
| 134 | 134 | |
| 135 | 135 | ; Grab references into the inheritance hierarchy |
| 136 | 136 | (define surface-space top-space) |
| … | … | @@ -181,12 +181,12 @@ |
| 181 | 181 | |
| 182 | 182 | ; Load incoming set of just one atom. |
| 183 | 183 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-fetch-frame-test")) |
| 184 | (cog-open storage) | |
| 185 | (define top-space (car (load-frames))) | |
| 184 | (cog-set-value! storage (*-open-*)) | |
| 185 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 186 | 186 | (cog-set-atomspace! top-space) |
| 187 | (fetch-incoming-set (Concept "foo")) | |
| 187 | (cog-set-value! storage (*-fetch-incoming-set-*) (LinkValue top-space (Concept "foo"))) | |
| 188 | 188 | |
| 189 | (cog-close storage) | |
| 189 | (cog-set-value! storage (*-close-*)) | |
| 190 | 190 | |
| 191 | 191 | ; Grab references into the inheritance hierarchy |
| 192 | 192 | (define surface-space top-space) |
| … | … | @@ -40,7 +40,7 @@ |
| 40 | 40 | (cog-set-atomspace! surface-space) |
| 41 | 41 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-delete-test")) |
| 42 | 42 | (cog-open storage) |
| 43 | (store-frames surface-space) | |
| 43 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 44 | 44 | |
| 45 | 45 | ; Repeatedly add and remove the same atom |
| 46 | 46 | (cog-set-atomspace! base-space) |
| … | … | @@ -61,16 +61,16 @@ |
| 61 | 61 | ; Store the content. Store the Concepts as well as the link, |
| 62 | 62 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 63 | 63 | (cog-set-atomspace! base-space) |
| 64 | (store-atomspace) | |
| 64 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 65 | 65 | (cog-set-atomspace! mid1-space) |
| 66 | (store-atomspace) | |
| 66 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 67 | 67 | (cog-set-atomspace! mid2-space) |
| 68 | (store-atomspace) | |
| 68 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 69 | 69 | (cog-set-atomspace! mid3-space) |
| 70 | (store-atomspace) | |
| 70 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 71 | 71 | (cog-set-atomspace! surface-space) |
| 72 | (store-atomspace) | |
| 73 | (cog-close storage) | |
| 72 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 73 | (cog-set-value! storage (*-close-*)) | |
| 74 | 74 | |
| 75 | 75 | ; Return the surface space |
| 76 | 76 | surface-space |
| … | … | @@ -93,20 +93,20 @@ |
| 93 | 93 | |
| 94 | 94 | ; Load everything. |
| 95 | 95 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-delete-test")) |
| 96 | (cog-open storage) | |
| 96 | (cog-set-value! storage (*-open-*)) | |
| 97 | 97 | |
| 98 | 98 | ; Load all of the AtomSpace Frames. |
| 99 | 99 | ; There are two frames at the top, and we want the newer one. |
| 100 | 100 | ; The second one is the root space; it doesn't have the stack. |
| 101 | 101 | ; This is awkward. I don't entirely like it. For now, it works. |
| 102 | (define the-frames (load-frames)) | |
| 102 | (define the-frames (cog-value->list (cog-value storage (*-load-frames-*)))) | |
| 103 | 103 | ; (format #t "The frames are ~A\n" the-frames) |
| 104 | 104 | (define top-space (car the-frames)) |
| 105 | 105 | |
| 106 | 106 | ; Load all atoms in all frames |
| 107 | 107 | (cog-set-atomspace! top-space) |
| 108 | (load-atomspace) | |
| 109 | (cog-close storage) | |
| 108 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 109 | (cog-set-value! storage (*-close-*)) | |
| 110 | 110 | |
| 111 | 111 | ; Grab references into the inheritance hierarchy |
| 112 | 112 | (define surface-space top-space) |
| … | … | @@ -165,7 +165,7 @@ |
| 165 | 165 | |
| 166 | 166 | (cog-set-atomspace! surface-space) |
| 167 | 167 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-delete-test")) |
| 168 | (cog-open storage) | |
| 168 | (cog-set-value! storage (*-open-*)) | |
| 169 | 169 | |
| 170 | 170 | ; Repeatedly add and remove the same atom |
| 171 | 171 | (cog-set-atomspace! base-space) |
| … | … | @@ -180,18 +180,18 @@ |
| 180 | 180 | ; Store the changed content. Toggle through all the atomspaces, |
| 181 | 181 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 182 | 182 | ; Do NOT store frames a second time! This will mess it up. |
| 183 | ; (store-frames surface-space) | |
| 183 | ; (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 184 | 184 | (cog-set-atomspace! base-space) |
| 185 | (store-atomspace) | |
| 185 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 186 | 186 | (cog-set-atomspace! mid1-space) |
| 187 | (store-atomspace) | |
| 187 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 188 | 188 | (cog-set-atomspace! mid2-space) |
| 189 | (store-atomspace) | |
| 189 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 190 | 190 | (cog-set-atomspace! mid3-space) |
| 191 | (store-atomspace) | |
| 191 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 192 | 192 | (cog-set-atomspace! surface-space) |
| 193 | (store-atomspace) | |
| 194 | (cog-close storage) | |
| 193 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 194 | (cog-set-value! storage (*-close-*)) | |
| 195 | 195 | ) |
| 196 | 196 | |
| 197 | 197 | (define (test-deep-change DELETE) |
| … | … | @@ -204,15 +204,15 @@ |
| 204 | 204 | |
| 205 | 205 | ; Load everything. |
| 206 | 206 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-delete-test")) |
| 207 | (cog-open storage) | |
| 207 | (cog-set-value! storage (*-open-*)) | |
| 208 | 208 | |
| 209 | 209 | ; Load all of the AtomSpace Frames. |
| 210 | (define top-space (car (load-frames))) | |
| 210 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 211 | 211 | |
| 212 | 212 | ; Load all atoms in all frames |
| 213 | 213 | (cog-set-atomspace! top-space) |
| 214 | (load-atomspace) | |
| 215 | (cog-close storage) | |
| 214 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 215 | (cog-set-value! storage (*-close-*)) | |
| 216 | 216 | |
| 217 | 217 | ; Grab references into the inheritance hierarchy |
| 218 | 218 | (define surface-space top-space) |
| … | … | @@ -272,7 +272,7 @@ |
| 272 | 272 | (cog-set-atomspace! surface-space) |
| 273 | 273 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-delete-test")) |
| 274 | 274 | (cog-open storage) |
| 275 | (store-frames surface-space) | |
| 275 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 276 | 276 | |
| 277 | 277 | ; Repeatedly add and remove the same atom |
| 278 | 278 | (cog-set-atomspace! base-space) |
| … | … | @@ -294,18 +294,18 @@ |
| 294 | 294 | ; Store the changed content. Toggle through all the atomspaces, |
| 295 | 295 | ; as otherwise, the TV's on the Atoms aren't stored. |
| 296 | 296 | ; Do NOT store frames a second time! This will mess it up. |
| 297 | ; (store-frames surface-space) | |
| 297 | ; (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 298 | 298 | (cog-set-atomspace! base-space) |
| 299 | (store-atomspace) | |
| 299 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 300 | 300 | (cog-set-atomspace! mid1-space) |
| 301 | (store-atomspace) | |
| 301 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 302 | 302 | (cog-set-atomspace! mid2-space) |
| 303 | (store-atomspace) | |
| 303 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 304 | 304 | (cog-set-atomspace! mid3-space) |
| 305 | (store-atomspace) | |
| 305 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 306 | 306 | (cog-set-atomspace! surface-space) |
| 307 | (store-atomspace) | |
| 308 | (cog-close storage) | |
| 307 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 308 | (cog-set-value! storage (*-close-*)) | |
| 309 | 309 | ) |
| 310 | 310 | |
| 311 | 311 | (define (test-deep-link DELETE-REC) |
| … | … | @@ -317,15 +317,15 @@ |
| 317 | 317 | |
| 318 | 318 | ; Load everything. |
| 319 | 319 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-delete-test")) |
| 320 | (cog-open storage) | |
| 320 | (cog-set-value! storage (*-open-*)) | |
| 321 | 321 | |
| 322 | 322 | ; Load all of the AtomSpace Frames. |
| 323 | (define top-space (car (load-frames))) | |
| 323 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 324 | 324 | |
| 325 | 325 | ; Load all atoms in all frames |
| 326 | 326 | (cog-set-atomspace! top-space) |
| 327 | (load-atomspace) | |
| 328 | (cog-close storage) | |
| 327 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 328 | (cog-set-value! storage (*-close-*)) | |
| 329 | 329 | |
| 330 | 330 | ; Grab references into the inheritance hierarchy |
| 331 | 331 | (define surface-space top-space) |
| … | … | @@ -57,23 +57,23 @@ |
| 57 | 57 | |
| 58 | 58 | ; Store all content. |
| 59 | 59 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-links-test")) |
| 60 | (cog-open storage) | |
| 61 | (store-frames surface-space) | |
| 60 | (cog-set-value! storage (*-open-*)) | |
| 61 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 62 | 62 | (cog-set-atomspace! base-space) |
| 63 | (store-atomspace) | |
| 63 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 64 | 64 | (cog-set-atomspace! mid1-space) |
| 65 | (store-atomspace) | |
| 65 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 66 | 66 | (cog-set-atomspace! mid2-space) |
| 67 | (store-atomspace) | |
| 67 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 68 | 68 | (cog-set-atomspace! mid3-space) |
| 69 | (store-atomspace) | |
| 69 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 70 | 70 | (cog-set-atomspace! mid4-space) |
| 71 | (store-atomspace) | |
| 71 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 72 | 72 | (cog-set-atomspace! mid5-space) |
| 73 | (store-atomspace) | |
| 73 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 74 | 74 | (cog-set-atomspace! surface-space) |
| 75 | (store-atomspace) | |
| 76 | (cog-close storage) | |
| 75 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 76 | (cog-set-value! storage (*-close-*)) | |
| 77 | 77 | ) |
| 78 | 78 | |
| 79 | 79 | ; ------------------------------------------------------------------- |
| … | … | @@ -92,11 +92,11 @@ |
| 92 | 92 | |
| 93 | 93 | ; Load everything. |
| 94 | 94 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-links-test")) |
| 95 | (cog-open storage) | |
| 96 | (define top-space (car (load-frames))) | |
| 95 | (cog-set-value! storage (*-open-*)) | |
| 96 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 97 | 97 | (cog-set-atomspace! top-space) |
| 98 | (load-atomspace) | |
| 99 | (cog-close storage) | |
| 98 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 99 | (cog-set-value! storage (*-close-*)) | |
| 100 | 100 | |
| 101 | 101 | ; Grab references into the inheritance hierarchy |
| 102 | 102 | (define surface-space top-space) |
| … | … | @@ -38,11 +38,11 @@ |
| 38 | 38 | |
| 39 | 39 | (cog-set-atomspace! c) |
| 40 | 40 | (define rsn (RocksStorageNode "rocks:///tmp/cog-rocks-frame-print-test")) |
| 41 | (cog-open rsn) | |
| 42 | (store-atomspace) | |
| 41 | (cog-set-value! rsn (*-open-*)) | |
| 42 | (cog-set-value! rsn (*-store-atomspace-*) (cog-atomspace)) | |
| 43 | 43 | (cog-prt-atomspace) |
| 44 | 44 | |
| 45 | (cog-close rsn) | |
| 45 | (cog-set-value! rsn (*-close-*)) | |
| 46 | 46 | ) |
| 47 | 47 | |
| 48 | 48 | (define test-name "test print") |
| … | … | @@ -26,33 +26,33 @@ |
| 26 | 26 | ;; These atoms are in COW spaces, and thus, in order for the store |
| 27 | 27 | ;; to work correctly, we must store the COW atom, returned by the |
| 28 | 28 | ;; value setter. This is unintuitive to the casual user! |
| 29 | (define (store-stuff N) | |
| 29 | (define (store-stuff storage N) | |
| 30 | 30 | (define x (Concept "foo")) |
| 31 | 31 | (define x1 (cog-set-value! x (Predicate "gee") (FloatValue 1 0 N))) |
| 32 | (store-atom x1) | |
| 32 | (cog-set-value! storage (*-store-atom-*) x1) | |
| 33 | 33 | |
| 34 | 34 | (define y (Concept "bar")) |
| 35 | 35 | (define y1 (cog-set-value! y (Predicate "gosh") (FloatValue 1 0 (+ 1 N)))) |
| 36 | (store-atom y1) | |
| 36 | (cog-set-value! storage (*-store-atom-*) y1) | |
| 37 | 37 | |
| 38 | 38 | (define z (List x y)) |
| 39 | 39 | (define z1 (cog-set-value! z (Predicate "bang") (FloatValue 1 0 (+ 2 N)))) |
| 40 | (store-atom z1) | |
| 40 | (cog-set-value! storage (*-store-atom-*) z1) | |
| 41 | 41 | |
| 42 | 42 | (define w (List z x)) |
| 43 | 43 | (define w1 (cog-set-value! w (Predicate "bash") (FloatValue 1 0 (+ 3 N)))) |
| 44 | (store-atom w1) | |
| 44 | (cog-set-value! storage (*-store-atom-*) w1) | |
| 45 | 45 | ) |
| 46 | 46 | |
| 47 | 47 | ; Recursive calls to above |
| 48 | (define (recompute N NLOOP) | |
| 48 | (define (recompute storage N NLOOP) | |
| 49 | 49 | (when (< 0 NLOOP) |
| 50 | (store-stuff N) | |
| 50 | (store-stuff storage N) | |
| 51 | 51 | (cog-set-atomspace! (AtomSpace (cog-atomspace))) |
| 52 | 52 | (cog-delete-recursive! (Concept "bar")) |
| 53 | 53 | (cog-extract-recursive! (Concept "bar")) |
| 54 | 54 | (cog-set-atomspace! (AtomSpace (cog-atomspace))) |
| 55 | (recompute (+ N 3) (- NLOOP 1))) | |
| 55 | (recompute storage (+ N 3) (- NLOOP 1))) | |
| 56 | 56 | ) |
| 57 | 57 | |
| 58 | 58 | (define (progressive-store N) |
| … | … | @@ -67,12 +67,12 @@ |
| 67 | 67 | ; We plan to store multiple atomspaces. |
| 68 | 68 | ; Let this be stated in advance. |
| 69 | 69 | (cog-atomspace-cow! #t) |
| 70 | (store-frames base-space) | |
| 70 | (cog-set-value! storage (*-store-frames-*) base-space) | |
| 71 | 71 | |
| 72 | 72 | ; Repeatedly add and remove the same atom |
| 73 | (recompute 1 N) | |
| 73 | (recompute storage 1 N) | |
| 74 | 74 | |
| 75 | (cog-close storage) | |
| 75 | (cog-set-value! storage (*-close-*)) | |
| 76 | 76 | ) |
| 77 | 77 | |
| 78 | 78 | ; Verify expected contents |
| … | … | @@ -143,15 +143,15 @@ |
| 143 | 143 | |
| 144 | 144 | ; Load everything. |
| 145 | 145 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-progressive-test")) |
| 146 | (cog-open storage) | |
| 146 | (cog-set-value! storage (*-open-*)) | |
| 147 | 147 | |
| 148 | 148 | ; Load all of the AtomSpace Frames. |
| 149 | (define top-space (car (load-frames))) | |
| 149 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 150 | 150 | |
| 151 | 151 | ; Load all atoms in all frames |
| 152 | 152 | (cog-set-atomspace! top-space) |
| 153 | (load-atomspace) | |
| 154 | (cog-close storage) | |
| 153 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 154 | (cog-set-value! storage (*-close-*)) | |
| 155 | 155 | |
| 156 | 156 | ; Check the rest of them, recursing downwards. |
| 157 | 157 | (progressive-check (- STACK-DEPTH 1)) |
| … | … | @@ -54,23 +54,23 @@ |
| 54 | 54 | |
| 55 | 55 | ; Store all content. |
| 56 | 56 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-values-test")) |
| 57 | (cog-open storage) | |
| 58 | (store-frames surface-space) | |
| 57 | (cog-set-value! storage (*-open-*)) | |
| 58 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 59 | 59 | (cog-set-atomspace! base-space) |
| 60 | (store-atomspace) | |
| 60 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 61 | 61 | (cog-set-atomspace! mid1-space) |
| 62 | (store-atomspace) | |
| 62 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 63 | 63 | (cog-set-atomspace! mid2-space) |
| 64 | (store-atomspace) | |
| 64 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 65 | 65 | (cog-set-atomspace! mid3-space) |
| 66 | (store-atomspace) | |
| 66 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 67 | 67 | (cog-set-atomspace! mid4-space) |
| 68 | (store-atomspace) | |
| 68 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 69 | 69 | (cog-set-atomspace! mid5-space) |
| 70 | (store-atomspace) | |
| 70 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 71 | 71 | (cog-set-atomspace! surface-space) |
| 72 | (store-atomspace) | |
| 73 | (cog-close storage) | |
| 72 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 73 | (cog-set-value! storage (*-close-*)) | |
| 74 | 74 | ) |
| 75 | 75 | |
| 76 | 76 | (define (get-cnt ATOM) (inexact->exact (cog-count ATOM))) |
| … | … | @@ -94,11 +94,11 @@ |
| 94 | 94 | |
| 95 | 95 | ; Load everything. |
| 96 | 96 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-frame-values-test")) |
| 97 | (cog-open storage) | |
| 98 | (define top-space (car (load-frames))) | |
| 97 | (cog-set-value! storage (*-open-*)) | |
| 98 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 99 | 99 | (cog-set-atomspace! top-space) |
| 100 | (load-atomspace) | |
| 101 | (cog-close storage) | |
| 100 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 101 | (cog-set-value! storage (*-close-*)) | |
| 102 | 102 | |
| 103 | 103 | ; Grab references into the inheritance hierarchy |
| 104 | 104 | (define surface-space top-space) |
| … | … | @@ -54,12 +54,12 @@ |
| 54 | 54 | (cog-set-atomspace! as-main) |
| 55 | 55 | |
| 56 | 56 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-many-spaces-test")) |
| 57 | (cog-open storage) | |
| 58 | (store-atomspace as-one) | |
| 59 | (store-atomspace as-two) | |
| 60 | (store-atomspace as-three) | |
| 61 | (store-atomspace as-main) | |
| 62 | (cog-close storage) | |
| 57 | (cog-set-value! storage (*-open-*)) | |
| 58 | (cog-set-value! storage (*-store-atomspace-*) as-one) | |
| 59 | (cog-set-value! storage (*-store-atomspace-*) as-two) | |
| 60 | (cog-set-value! storage (*-store-atomspace-*) as-three) | |
| 61 | (cog-set-value! storage (*-store-atomspace-*) as-main) | |
| 62 | (cog-set-value! storage (*-close-*)) | |
| 63 | 63 | |
| 64 | 64 | ; Return the spaces for verification before clear |
| 65 | 65 | (list as-main as-one as-two as-three) |
| … | … | @@ -80,12 +80,12 @@ |
| 80 | 80 | (cog-set-atomspace! as-main) |
| 81 | 81 | |
| 82 | 82 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-many-spaces-test")) |
| 83 | (cog-open storage) | |
| 83 | (cog-set-value! storage (*-open-*)) | |
| 84 | 84 | |
| 85 | 85 | ; Load and verify space two first (out of order) |
| 86 | 86 | (define as-two (AtomSpace "bar")) |
| 87 | 87 | (cog-set-atomspace! as-two) |
| 88 | (load-atomspace as-two) | |
| 88 | (cog-set-value! storage (*-load-atomspace-*) as-two) | |
| 89 | 89 | |
| 90 | 90 | (test-assert "two-has-resident" |
| 91 | 91 | (cog-node 'Concept "Resident of Two, here!")) |
| … | … | @@ -101,7 +101,7 @@ |
| 101 | 101 | ; Load and verify space one |
| 102 | 102 | (define as-one (AtomSpace "foo")) |
| 103 | 103 | (cog-set-atomspace! as-one) |
| 104 | (load-atomspace as-one) | |
| 104 | (cog-set-value! storage (*-load-atomspace-*) as-one) | |
| 105 | 105 | |
| 106 | 106 | (test-assert "one-has-content" |
| 107 | 107 | (cog-node 'Concept "I am in Space One!")) |
| … | … | @@ -115,7 +115,7 @@ |
| 115 | 115 | ; Load and verify space three |
| 116 | 116 | (define as-three (AtomSpace "bing")) |
| 117 | 117 | (cog-set-atomspace! as-three) |
| 118 | (load-atomspace as-three) | |
| 118 | (cog-set-value! storage (*-load-atomspace-*) as-three) | |
| 119 | 119 | |
| 120 | 120 | (test-assert "three-has-edge" |
| 121 | 121 | (cog-link 'EdgeLink |
| … | … | @@ -124,7 +124,7 @@ |
| 124 | 124 | (test-assert "three-has-company" |
| 125 | 125 | (cog-node 'Concept "Three's company")) |
| 126 | 126 | |
| 127 | (cog-close storage) | |
| 127 | (cog-set-value! storage (*-close-*)) | |
| 128 | 128 | ) |
| 129 | 129 | |
| 130 | 130 | (define basic-multispace "test basic-multispace") |
| … | … | @@ -148,10 +148,10 @@ |
| 148 | 148 | (cog-set-atomspace! as-main) |
| 149 | 149 | |
| 150 | 150 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-many-spaces-test")) |
| 151 | (cog-open storage) | |
| 151 | (cog-set-value! storage (*-open-*)) | |
| 152 | 152 | |
| 153 | 153 | ; Load main space which contains the index |
| 154 | (load-atomspace as-main) | |
| 154 | (cog-set-value! storage (*-load-atomspace-*) as-main) | |
| 155 | 155 | |
| 156 | 156 | ; Verify the bundle index exists |
| 157 | 157 | (test-assert "bundle-predicate-exists" |
| … | … | @@ -179,7 +179,7 @@ |
| 179 | 179 | (Predicate "bundle") |
| 180 | 180 | (List (Item "Bundle Beta") as-three))) |
| 181 | 181 | |
| 182 | (cog-close storage) | |
| 182 | (cog-set-value! storage (*-close-*)) | |
| 183 | 183 | ) |
| 184 | 184 | |
| 185 | 185 | (define space-index "test space-index") |
| … | … | @@ -203,7 +203,7 @@ |
| 203 | 203 | (cog-set-atomspace! as-main) |
| 204 | 204 | |
| 205 | 205 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-many-spaces-test")) |
| 206 | (cog-open storage) | |
| 206 | (cog-set-value! storage (*-open-*)) | |
| 207 | 207 | |
| 208 | 208 | ; Create all spaces but only load one |
| 209 | 209 | (define as-one (AtomSpace "foo")) |
| … | … | @@ -211,7 +211,7 @@ |
| 211 | 211 | (define as-three (AtomSpace "bing")) |
| 212 | 212 | |
| 213 | 213 | ; Load only space one |
| 214 | (load-atomspace as-one) | |
| 214 | (cog-set-value! storage (*-load-atomspace-*) as-one) | |
| 215 | 215 | |
| 216 | 216 | ; Verify space two doesn't have space one's content |
| 217 | 217 | (cog-set-atomspace! as-two) |
| … | … | @@ -224,7 +224,7 @@ |
| 224 | 224 | (not (cog-node 'Concept "I am in Space One!"))) |
| 225 | 225 | |
| 226 | 226 | ; Now load space two and verify it has correct content |
| 227 | (load-atomspace as-two) | |
| 227 | (cog-set-value! storage (*-load-atomspace-*) as-two) | |
| 228 | 228 | (cog-set-atomspace! as-two) |
| 229 | 229 | (test-assert "two-loaded-has-content" |
| 230 | 230 | (cog-node 'Concept "Resident of Two, here!")) |
| … | … | @@ -236,7 +236,7 @@ |
| 236 | 236 | (test-assert "three-no-two-list" |
| 237 | 237 | (not (cog-link 'List (Concept "two-a") (Concept "two-b")))) |
| 238 | 238 | |
| 239 | (cog-close storage) | |
| 239 | (cog-set-value! storage (*-close-*)) | |
| 240 | 240 | ) |
| 241 | 241 | |
| 242 | 242 | (define no-leakage "test no-leakage") |
| … | … | @@ -260,7 +260,7 @@ |
| 260 | 260 | (cog-set-atomspace! as-main) |
| 261 | 261 | |
| 262 | 262 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-many-spaces-test")) |
| 263 | (cog-open storage) | |
| 263 | (cog-set-value! storage (*-open-*)) | |
| 264 | 264 | |
| 265 | 265 | ; Create space three and set it as current |
| 266 | 266 | (define as-three (AtomSpace "bing")) |
| … | … | @@ -270,7 +270,7 @@ |
| 270 | 270 | (test-equal "three-initially-empty" '() (cog-get-all-roots)) |
| 271 | 271 | |
| 272 | 272 | ; Load without argument - should load current space (as-three) |
| 273 | (load-atomspace) | |
| 273 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 274 | 274 | |
| 275 | 275 | ; Verify content was loaded |
| 276 | 276 | (test-assert "three-loaded-via-no-arg" |
| … | … | @@ -280,7 +280,7 @@ |
| 280 | 280 | (Predicate "three-ness") |
| 281 | 281 | (Item "Just an old lump of coal"))) |
| 282 | 282 | |
| 283 | (cog-close storage) | |
| 283 | (cog-set-value! storage (*-close-*)) | |
| 284 | 284 | ) |
| 285 | 285 | |
| 286 | 286 | (define load-current "test load-current") |
| … | … | @@ -29,22 +29,22 @@ |
| 29 | 29 | |
| 30 | 30 | ; Store the content. Store only the top-most link. |
| 31 | 31 | (define mstorage (MonoStorageNode "monospace:///tmp/cog-rocks-promote-test")) |
| 32 | (cog-open mstorage) | |
| 33 | (store-atom (Concept "foo")) | |
| 34 | (store-atom (Concept "bar")) | |
| 35 | (store-atom (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 36 | (cog-close mstorage) | |
| 32 | (cog-set-value! mstorage (*-open-*)) | |
| 33 | (cog-set-value! mstorage (*-store-atom-*) (Concept "foo")) | |
| 34 | (cog-set-value! mstorage (*-store-atom-*) (Concept "bar")) | |
| 35 | (cog-set-value! mstorage (*-store-atom-*) (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 36 | (cog-set-value! mstorage (*-close-*)) | |
| 37 | 37 | |
| 38 | 38 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-promote-test")) |
| 39 | (cog-open storage) | |
| 40 | (store-frames (cog-atomspace)) | |
| 39 | (cog-set-value! storage (*-open-*)) | |
| 40 | (cog-set-value! storage (*-store-frames-*) (cog-atomspace)) | |
| 41 | 41 | (cog-set-atomspace! (AtomSpace (cog-atomspace))) |
| 42 | 42 | (set-cnt! (Concept "foo") (FloatValue 1 0 7)) |
| 43 | (store-atom (Concept "foo")) | |
| 44 | (store-atom (Concept "bar")) | |
| 43 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 44 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 45 | 45 | (set-cnt! (ListLink (Concept "foo") (List (Concept "bar"))) (FloatValue 1 0 8)) |
| 46 | (store-atom (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 47 | (cog-close storage) | |
| 46 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 47 | (cog-set-value! storage (*-close-*)) | |
| 48 | 48 | |
| 49 | 49 | ; Clear out the space, start with a clean slate. |
| 50 | 50 | (cog-atomspace-clear (cog-atomspace)) |
| … | … | @@ -61,13 +61,13 @@ |
| 61 | 61 | |
| 62 | 62 | ; Load everything. |
| 63 | 63 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-promote-test")) |
| 64 | (cog-open storage) | |
| 64 | (cog-set-value! storage (*-open-*)) | |
| 65 | 65 | ; (cog-rocks-stats storage) |
| 66 | 66 | ; (cog-rocks-print storage "") |
| 67 | (define top-space (car (load-frames))) | |
| 67 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 68 | 68 | (cog-set-atomspace! top-space) |
| 69 | (load-atomspace) | |
| 70 | (cog-close storage) | |
| 69 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 70 | (cog-set-value! storage (*-close-*)) | |
| 71 | 71 | |
| 72 | 72 | ; Verify the ListLink is as expected. |
| 73 | 73 | (define lilly (ListLink (Concept "foo") (List (Concept "bar")))) |
| … | … | @@ -95,12 +95,12 @@ |
| 95 | 95 | |
| 96 | 96 | ; Load enough to get started. |
| 97 | 97 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-promote-test")) |
| 98 | (cog-open storage) | |
| 98 | (cog-set-value! storage (*-open-*)) | |
| 99 | 99 | ; (cog-rocks-stats storage) |
| 100 | 100 | ; (cog-rocks-print storage "") |
| 101 | (define top-space (car (load-frames))) | |
| 102 | (delete-frame! top-space) | |
| 103 | (cog-close storage) | |
| 101 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 102 | (cog-set-value! storage (*-delete-frame-*) top-space) | |
| 103 | (cog-set-value! storage (*-close-*)) | |
| 104 | 104 | ) |
| 105 | 105 | |
| 106 | 106 | ; Verify what's left a the bottom |
| … | … | @@ -111,13 +111,13 @@ |
| 111 | 111 | |
| 112 | 112 | ; Load everything. |
| 113 | 113 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-promote-test")) |
| 114 | (cog-open storage) | |
| 114 | (cog-set-value! storage (*-open-*)) | |
| 115 | 115 | ; (cog-rocks-stats storage) |
| 116 | 116 | ; (cog-rocks-print storage "") |
| 117 | (define top-space (car (load-frames))) | |
| 117 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 118 | 118 | (cog-set-atomspace! top-space) |
| 119 | (load-atomspace) | |
| 120 | (cog-close storage) | |
| 119 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 120 | (cog-set-value! storage (*-close-*)) | |
| 121 | 121 | |
| 122 | 122 | ; Verify the ListLink is as expected. |
| 123 | 123 | (define lilly (ListLink (Concept "foo") (List (Concept "bar")))) |
| … | … | @@ -31,9 +31,9 @@ |
| 31 | 31 | |
| 32 | 32 | ; Store to disk |
| 33 | 33 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-query-storage-test")) |
| 34 | (cog-open storage) | |
| 35 | (store-atomspace) | |
| 36 | (cog-close storage) | |
| 34 | (cog-set-value! storage (*-open-*)) | |
| 35 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 36 | (cog-set-value! storage (*-close-*)) | |
| 37 | 37 | |
| 38 | 38 | ; Clear and reopen |
| 39 | 39 | (cog-atomspace-clear) |
| … | … | @@ -49,14 +49,14 @@ |
| 49 | 49 | (setup-and-store) |
| 50 | 50 | |
| 51 | 51 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-query-storage-test")) |
| 52 | (cog-open storage) | |
| 52 | (cog-set-value! storage (*-open-*)) | |
| 53 | 53 | |
| 54 | 54 | ; Define query to find tail of (List A ?) |
| 55 | 55 | (define get-tail (Meet (List (Concept "A") (Variable "tail")))) |
| 56 | 56 | (define results-key (Predicate "results")) |
| 57 | 57 | |
| 58 | 58 | ; Run query |
| 59 | (fetch-query get-tail results-key) | |
| 59 | (cog-set-value! storage (*-fetch-query-*) get-tail results-key) | |
| 60 | 60 | (define result (cog-value get-tail results-key)) |
| 61 | 61 | |
| 62 | 62 | ; Verify result contains (Concept "B") |
| … | … | @@ -73,7 +73,7 @@ |
| 73 | 73 | (test-assert "ListLink-not-in-atomspace" |
| 74 | 74 | (not (member (List (Concept "A") (Concept "B")) roots))) |
| 75 | 75 | |
| 76 | (cog-close storage) | |
| 76 | (cog-set-value! storage (*-close-*)) | |
| 77 | 77 | ) |
| 78 | 78 | |
| 79 | 79 | (define basic-meet "test basic-meet") |
| … | … | @@ -91,13 +91,13 @@ |
| 91 | 91 | (setup-and-store) |
| 92 | 92 | |
| 93 | 93 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-query-storage-test")) |
| 94 | (cog-open storage) | |
| 94 | (cog-set-value! storage (*-open-*)) | |
| 95 | 95 | |
| 96 | 96 | (define get-tail (Meet (List (Concept "A") (Variable "tail")))) |
| 97 | 97 | (define results-key (Predicate "results")) |
| 98 | 98 | |
| 99 | 99 | ; Initial query - should return B |
| 100 | (fetch-query get-tail results-key) | |
| 100 | (cog-set-value! storage (*-fetch-query-*) get-tail results-key) | |
| 101 | 101 | (define result1 (cog-value get-tail results-key)) |
| 102 | 102 | (test-equal "initial-result-B" |
| 103 | 103 | (list (Concept "B")) |
| … | … | @@ -105,11 +105,11 @@ |
| 105 | 105 | |
| 106 | 106 | ; Add new data and store |
| 107 | 107 | (List (Concept "A") (Concept "F")) |
| 108 | (store-atomspace) | |
| 108 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 109 | 109 | (cog-extract-recursive! (Concept "F")) |
| 110 | 110 | |
| 111 | 111 | ; Re-run query - should get cached (stale) result |
| 112 | (fetch-query get-tail results-key) | |
| 112 | (cog-set-value! storage (*-fetch-query-*) get-tail results-key) | |
| 113 | 113 | (define cached-result (cog-value get-tail results-key)) |
| 114 | 114 | (test-equal "cached-result-still-B" |
| 115 | 115 | (list (Concept "B")) |
| … | … | @@ -117,8 +117,8 @@ |
| 117 | 117 | |
| 118 | 118 | ; Clear cache and re-run |
| 119 | 119 | (cog-set-value! get-tail results-key #f) |
| 120 | (store-value get-tail results-key) | |
| 121 | (fetch-query get-tail results-key) | |
| 120 | (cog-set-value! storage (*-store-value-*) get-tail results-key) | |
| 121 | (cog-set-value! storage (*-fetch-query-*) get-tail results-key) | |
| 122 | 122 | (define fresh-result (cog-value get-tail results-key)) |
| 123 | 123 | (define fresh-list (cog-value->list fresh-result)) |
| 124 | 124 | |
| … | … | @@ -126,7 +126,7 @@ |
| 126 | 126 | (test-assert "fresh-contains-B" (member (Concept "B") fresh-list)) |
| 127 | 127 | (test-assert "fresh-contains-F" (member (Concept "F") fresh-list)) |
| 128 | 128 | |
| 129 | (cog-close storage) | |
| 129 | (cog-set-value! storage (*-close-*)) | |
| 130 | 130 | ) |
| 131 | 131 | |
| 132 | 132 | (define query-caching "test query-caching") |
| … | … | @@ -145,21 +145,21 @@ |
| 145 | 145 | (setup-and-store) |
| 146 | 146 | |
| 147 | 147 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-query-storage-test")) |
| 148 | (cog-open storage) | |
| 148 | (cog-set-value! storage (*-open-*)) | |
| 149 | 149 | |
| 150 | 150 | (define get-tail (Meet (List (Concept "A") (Variable "tail")))) |
| 151 | 151 | (define results-key (Predicate "results")) |
| 152 | 152 | |
| 153 | 153 | ; Initial query |
| 154 | (fetch-query get-tail results-key) | |
| 154 | (cog-set-value! storage (*-fetch-query-*) get-tail results-key) | |
| 155 | 155 | |
| 156 | 156 | ; Add new data |
| 157 | 157 | (List (Concept "A") (Concept "G")) |
| 158 | (store-atomspace) | |
| 158 | (cog-set-value! storage (*-store-atomspace-*) (cog-atomspace)) | |
| 159 | 159 | (cog-extract-recursive! (Concept "G")) |
| 160 | 160 | |
| 161 | 161 | ; Stale cache - should NOT have G yet |
| 162 | (fetch-query get-tail results-key) | |
| 162 | (cog-set-value! storage (*-fetch-query-*) get-tail results-key) | |
| 163 | 163 | (define stale-result (cog-value get-tail results-key)) |
| 164 | 164 | (define stale-list (cog-value->list stale-result)) |
| 165 | 165 | (test-assert "stale-missing-G" |
| … | … | @@ -167,14 +167,14 @@ |
| 167 | 167 | |
| 168 | 168 | ; Request fresh with metadata |
| 169 | 169 | (define metadata (Predicate "my metadata")) |
| 170 | (fetch-query get-tail results-key metadata #t) | |
| 170 | (cog-set-value! storage (*-fetch-query-*) (LinkValue (cog-atomspace) get-tail results-key metadata (BoolValue #t))) | |
| 171 | 171 | |
| 172 | 172 | (define fresh-result (cog-value get-tail results-key)) |
| 173 | 173 | (define fresh-list (cog-value->list fresh-result)) |
| 174 | 174 | (test-assert "fresh-contains-G" (member (Concept "G") fresh-list)) |
| 175 | 175 | |
| 176 | 176 | ; Check metadata exists and is a timestamp |
| 177 | (fetch-value get-tail metadata) | |
| 177 | (cog-set-value! storage (*-fetch-value-*) get-tail metadata) | |
| 178 | 178 | (define meta-value (cog-value get-tail metadata)) |
| 179 | 179 | (test-assert "metadata-exists" meta-value) |
| 180 | 180 | (test-assert "metadata-is-float" |
| … | … | @@ -184,7 +184,7 @@ |
| 184 | 184 | (define timestamp (car (cog-value->list meta-value))) |
| 185 | 185 | (test-assert "timestamp-reasonable" (> timestamp 1577836800)) |
| 186 | 186 | |
| 187 | (cog-close storage) | |
| 187 | (cog-set-value! storage (*-close-*)) | |
| 188 | 188 | ) |
| 189 | 189 | |
| 190 | 190 | (define query-metadata "test query-metadata") |
| … | … | @@ -202,13 +202,13 @@ |
| 202 | 202 | (setup-and-store) |
| 203 | 203 | |
| 204 | 204 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-query-storage-test")) |
| 205 | (cog-open storage) | |
| 205 | (cog-set-value! storage (*-open-*)) | |
| 206 | 206 | |
| 207 | 207 | (define results-key (Predicate "results")) |
| 208 | 208 | |
| 209 | 209 | ; Find all structures containing (Concept "B") |
| 210 | 210 | (define b-holders (MaximalJoin (Concept "B"))) |
| 211 | (fetch-query b-holders results-key) | |
| 211 | (cog-set-value! storage (*-fetch-query-*) b-holders results-key) | |
| 212 | 212 | (define result (cog-value b-holders results-key)) |
| 213 | 213 | |
| 214 | 214 | (test-assert "join-result-exists" result) |
| … | … | @@ -229,7 +229,7 @@ |
| 229 | 229 | (test-assert "SetAB-in-atomspace" |
| 230 | 230 | (member (Set (Concept "A") (Concept "B")) roots)) |
| 231 | 231 | |
| 232 | (cog-close storage) | |
| 232 | (cog-set-value! storage (*-close-*)) | |
| 233 | 233 | ) |
| 234 | 234 | |
| 235 | 235 | (define join-link "test join-link") |
| … | … | @@ -247,7 +247,7 @@ |
| 247 | 247 | (setup-and-store) |
| 248 | 248 | |
| 249 | 249 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-query-storage-test")) |
| 250 | (cog-open storage) | |
| 250 | (cog-set-value! storage (*-open-*)) | |
| 251 | 251 | |
| 252 | 252 | (define results-key (Predicate "results")) |
| 253 | 253 | |
| … | … | @@ -258,7 +258,7 @@ |
| 258 | 258 | (OrderedLink (Variable "tail") (Concept "by") (Variable "tail")) |
| 259 | 259 | )) |
| 260 | 260 | |
| 261 | (fetch-query tail-by-tail results-key) | |
| 261 | (cog-set-value! storage (*-fetch-query-*) tail-by-tail results-key) | |
| 262 | 262 | (define result (cog-value tail-by-tail results-key)) |
| 263 | 263 | |
| 264 | 264 | (test-assert "querylink-result-exists" result) |
| … | … | @@ -269,7 +269,7 @@ |
| 269 | 269 | (member (OrderedLink (Concept "B") (Concept "by") (Concept "B")) |
| 270 | 270 | rewrite-list)) |
| 271 | 271 | |
| 272 | (cog-close storage) | |
| 272 | (cog-set-value! storage (*-close-*)) | |
| 273 | 273 | ) |
| 274 | 274 | |
| 275 | 275 | (define query-link "test query-link") |
| … | … | @@ -38,12 +38,12 @@ |
| 38 | 38 | ; Store the content. Store the Concepts as well as the link, |
| 39 | 39 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 40 | 40 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-delete-test")) |
| 41 | (cog-open storage) | |
| 42 | (store-frames surface-space) | |
| 43 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 44 | (store-atom (Concept "foo")) | |
| 45 | (store-atom (Concept "bar")) | |
| 46 | (cog-close storage) | |
| 41 | (cog-set-value! storage (*-open-*)) | |
| 42 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 43 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 44 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 45 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 46 | (cog-set-value! storage (*-close-*)) | |
| 47 | 47 | |
| 48 | 48 | ; Clear out the spaces, start with a clean slate. |
| 49 | 49 | (cog-atomspace-clear surface-space) |
| … | … | @@ -62,12 +62,12 @@ |
| 62 | 62 | |
| 63 | 63 | ; Load everything. |
| 64 | 64 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-delete-test")) |
| 65 | (cog-open storage) | |
| 65 | (cog-set-value! storage (*-open-*)) | |
| 66 | 66 | ; (cog-rocks-print storage "") |
| 67 | 67 | |
| 68 | (define top-space (car (load-frames))) | |
| 69 | (delete-frame! top-space) | |
| 70 | (cog-close storage) | |
| 68 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 69 | (cog-set-value! storage (*-delete-frame-*) top-space) | |
| 70 | (cog-set-value! storage (*-close-*)) | |
| 71 | 71 | ) |
| 72 | 72 | |
| 73 | 73 | ; ------------------------------------------------------------------- |
| … | … | @@ -101,11 +101,11 @@ |
| 101 | 101 | |
| 102 | 102 | ; Load everything. |
| 103 | 103 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-delete-test")) |
| 104 | (cog-open storage) | |
| 105 | (define top-space (car (load-frames))) | |
| 104 | (cog-set-value! storage (*-open-*)) | |
| 105 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 106 | 106 | (cog-set-atomspace! top-space) |
| 107 | (load-atomspace) | |
| 108 | (cog-close storage) | |
| 107 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 108 | (cog-set-value! storage (*-close-*)) | |
| 109 | 109 | |
| 110 | 110 | (test-equal "top-depth" 4 (count-depth top-space 1)) |
| 111 | 111 | |
| … | … | @@ -113,11 +113,11 @@ |
| 113 | 113 | |
| 114 | 114 | ; Load everything. Again. |
| 115 | 115 | (cog-set-atomspace! (AtomSpace)) |
| 116 | (cog-open storage) | |
| 117 | (set! top-space (car (load-frames))) | |
| 116 | (cog-set-value! storage (*-open-*)) | |
| 117 | (set! top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 118 | 118 | (cog-set-atomspace! top-space) |
| 119 | (load-atomspace) | |
| 120 | (cog-close storage) | |
| 119 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 120 | (cog-set-value! storage (*-close-*)) | |
| 121 | 121 | |
| 122 | 122 | (test-equal "top-depth" 3 (count-depth top-space 1)) |
| 123 | 123 | |
| … | … | @@ -125,11 +125,11 @@ |
| 125 | 125 | |
| 126 | 126 | ; Load everything. Again. |
| 127 | 127 | (cog-set-atomspace! (AtomSpace)) |
| 128 | (cog-open storage) | |
| 129 | (set! top-space (car (load-frames))) | |
| 128 | (cog-set-value! storage (*-open-*)) | |
| 129 | (set! top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 130 | 130 | (cog-set-atomspace! top-space) |
| 131 | (load-atomspace) | |
| 132 | (cog-close storage) | |
| 131 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 132 | (cog-set-value! storage (*-close-*)) | |
| 133 | 133 | |
| 134 | 134 | (test-equal "top-depth" 2 (count-depth top-space 1)) |
| 135 | 135 |
| … | … | @@ -40,18 +40,18 @@ |
| 40 | 40 | ; Store the content. Store the Concepts as well as the link, |
| 41 | 41 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 42 | 42 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-diamond-test")) |
| 43 | (cog-open storage) | |
| 44 | (store-frames top-space) | |
| 45 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 46 | (store-atom (Concept "foo")) | |
| 43 | (cog-set-value! storage (*-open-*)) | |
| 44 | (cog-set-value! storage (*-store-frames-*) top-space) | |
| 45 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 46 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 47 | 47 | |
| 48 | 48 | ; Store the two variants, with the explicit spaces in which |
| 49 | 49 | ; they come from. |
| 50 | 50 | (cog-set-atomspace! left-space) |
| 51 | (store-atom (Concept "bar")) | |
| 51 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 52 | 52 | (cog-set-atomspace! right-space) |
| 53 | (store-atom (Concept "bar")) | |
| 54 | (cog-close storage) | |
| 53 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 54 | (cog-set-value! storage (*-close-*)) | |
| 55 | 55 | ) |
| 56 | 56 | |
| 57 | 57 | ; ------------------------------------------------------------------- |
| … | … | @@ -65,15 +65,15 @@ |
| 65 | 65 | |
| 66 | 66 | ; Load everything. |
| 67 | 67 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-diamond-test")) |
| 68 | (cog-open storage) | |
| 68 | (cog-set-value! storage (*-open-*)) | |
| 69 | 69 | |
| 70 | 70 | ; Load all of the AtomSpaces. |
| 71 | (define top-space (car (load-frames))) | |
| 71 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 72 | 72 | (cog-set-atomspace! top-space) |
| 73 | 73 | |
| 74 | 74 | ; Now load the AtomSpace itself |
| 75 | (load-atomspace) | |
| 76 | (cog-close storage) | |
| 75 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 76 | (cog-set-value! storage (*-close-*)) | |
| 77 | 77 | |
| 78 | 78 | ; Verify that a diamond pattern was created. |
| 79 | 79 | (define left-space (cog-outgoing-atom top-space 0)) |
| … | … | @@ -69,11 +69,11 @@ |
| 69 | 69 | |
| 70 | 70 | ; Dump all three AtomSpaces to the same file. |
| 71 | 71 | (define rsn (RocksStorageNode "rocks:///tmp/cog-rocks-space-episodic-test")) |
| 72 | (cog-open rsn) | |
| 73 | (store-atomspace) | |
| 74 | (store-atomspace (AtomSpace "happy thoughts")) | |
| 75 | (store-atomspace (AtomSpace "crushing defeat")) | |
| 76 | (cog-close rsn) | |
| 72 | (cog-set-value! rsn (*-open-*)) | |
| 73 | (cog-set-value! rsn (*-store-atomspace-*) (cog-atomspace)) | |
| 74 | (cog-set-value! rsn (*-store-atomspace-*) (AtomSpace "happy thoughts")) | |
| 75 | (cog-set-value! rsn (*-store-atomspace-*) (AtomSpace "crushing defeat")) | |
| 76 | (cog-set-value! rsn (*-close-*)) | |
| 77 | 77 | |
| 78 | 78 | ; Verify that the contents are as expected |
| 79 | 79 | (cog-prt-atomspace) |
| … | … | @@ -92,8 +92,8 @@ |
| 92 | 92 | |
| 93 | 93 | (define gsn (RocksStorageNode "rocks:///tmp/cog-rocks-space-episodic-test")) |
| 94 | 94 | |
| 95 | (cog-open gsn) | |
| 96 | (load-atomspace) | |
| 95 | (cog-set-value! gsn (*-open-*)) | |
| 96 | (cog-set-value! gsn (*-load-atomspace-*) (cog-atomspace)) | |
| 97 | 97 | (format #t "Loaded Atom counts ~A ~A ~A\n" |
| 98 | 98 | (count-all) |
| 99 | 99 | (count-all (cog-value (ConceptNode "foo") (Predicate "real life"))) |
| … | … | @@ -112,9 +112,9 @@ |
| 112 | 112 | (count-all (cog-value (ConceptNode "foo") (Predicate "repressed mem"))))) |
| 113 | 113 | |
| 114 | 114 | ; Now, restore the two batches of episodic memories. |
| 115 | (load-atomspace (AtomSpace "happy thoughts")) | |
| 116 | (load-atomspace (AtomSpace "crushing defeat")) | |
| 117 | (cog-close gsn) | |
| 115 | (cog-set-value! gsn (*-load-atomspace-*) (AtomSpace "happy thoughts")) | |
| 116 | (cog-set-value! gsn (*-load-atomspace-*) (AtomSpace "crushing defeat")) | |
| 117 | (cog-set-value! gsn (*-close-*)) | |
| 118 | 118 | |
| 119 | 119 | ; +1 for (Predicate "*-IsKeyFlag-*") |
| 120 | 120 | (test-assert "base-count" (equal? 19 (count-all))) |
| … | … | @@ -38,12 +38,12 @@ |
| 38 | 38 | ; Store the content. Store the Concepts as well as the link, |
| 39 | 39 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 40 | 40 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-frame-test")) |
| 41 | (cog-open storage) | |
| 42 | (store-frames surface-space) | |
| 43 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 44 | (store-atom (Concept "foo")) | |
| 45 | (store-atom (Concept "bar")) | |
| 46 | (cog-close storage) | |
| 41 | (cog-set-value! storage (*-open-*)) | |
| 42 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 43 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 44 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 45 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 46 | (cog-set-value! storage (*-close-*)) | |
| 47 | 47 | |
| 48 | 48 | ; Clear out the spaces, start with a clean slate. |
| 49 | 49 | (cog-atomspace-clear surface-space) |
| … | … | @@ -68,11 +68,11 @@ |
| 68 | 68 | |
| 69 | 69 | ; Load everything. |
| 70 | 70 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-frame-test")) |
| 71 | (cog-open storage) | |
| 72 | (define top-space (car (load-frames))) | |
| 71 | (cog-set-value! storage (*-open-*)) | |
| 72 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 73 | 73 | (cog-set-atomspace! top-space) |
| 74 | (load-atomspace) | |
| 75 | (cog-close storage) | |
| 74 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 75 | (cog-set-value! storage (*-close-*)) | |
| 76 | 76 | |
| 77 | 77 | ; Grab references into the inheritance hierarchy |
| 78 | 78 | (define surface-space top-space) |
| … | … | @@ -24,18 +24,18 @@ |
| 24 | 24 | |
| 25 | 25 | ; Store it |
| 26 | 26 | (define rsn (RocksStorageNode "rocks:///tmp/cog-rocks-space-link-test")) |
| 27 | (cog-open rsn) | |
| 28 | (store-atomspace) | |
| 29 | (cog-close rsn) | |
| 27 | (cog-set-value! rsn (*-open-*)) | |
| 28 | (cog-set-value! rsn (*-store-atomspace-*) (cog-atomspace)) | |
| 29 | (cog-set-value! rsn (*-close-*)) | |
| 30 | 30 | |
| 31 | 31 | ; Start fresh |
| 32 | 32 | (cog-atomspace-clear) |
| 33 | 33 | |
| 34 | 34 | ; Load |
| 35 | 35 | (set! rsn (RocksStorageNode "rocks:///tmp/cog-rocks-space-link-test")) |
| 36 | (cog-open rsn) | |
| 37 | (load-atomspace) | |
| 38 | (cog-close rsn) | |
| 36 | (cog-set-value! rsn (*-open-*)) | |
| 37 | (cog-set-value! rsn (*-load-atomspace-*) (cog-atomspace)) | |
| 38 | (cog-set-value! rsn (*-close-*)) | |
| 39 | 39 | (cog-prt-atomspace) |
| 40 | 40 | |
| 41 | 41 | ; Was the Item loaded? |
| … | … | @@ -36,12 +36,12 @@ |
| 36 | 36 | ; Store the content. Store the Concepts as well as the link, |
| 37 | 37 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 38 | 38 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-wye-test")) |
| 39 | (cog-open storage) | |
| 40 | (store-frames top-space) | |
| 41 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 42 | (store-atom (Concept "foo")) | |
| 43 | (store-atom (Concept "bar")) | |
| 44 | (cog-close storage) | |
| 39 | (cog-set-value! storage (*-open-*)) | |
| 40 | (cog-set-value! storage (*-store-frames-*) top-space) | |
| 41 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 42 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 43 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 44 | (cog-set-value! storage (*-close-*)) | |
| 45 | 45 | ) |
| 46 | 46 | |
| 47 | 47 | ; ------------------------------------------------------------------- |
| … | … | @@ -60,15 +60,15 @@ |
| 60 | 60 | |
| 61 | 61 | ; Load everything. |
| 62 | 62 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-wye-test")) |
| 63 | (cog-open storage) | |
| 63 | (cog-set-value! storage (*-open-*)) | |
| 64 | 64 | |
| 65 | 65 | ; Load all of the AtomSpaces. |
| 66 | (define top-space (car (load-frames))) | |
| 66 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 67 | 67 | (cog-set-atomspace! top-space) |
| 68 | 68 | |
| 69 | 69 | ; Now load the AtomSpace itself |
| 70 | (load-atomspace) | |
| 71 | (cog-close storage) | |
| 70 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 71 | (cog-set-value! storage (*-close-*)) | |
| 72 | 72 | |
| 73 | 73 | ; Verify that a wye pattern was created. |
| 74 | 74 | (define left-space (cog-outgoing-atom top-space 0)) |
| … | … | @@ -44,18 +44,18 @@ |
| 44 | 44 | ; Store the content. Store the Concepts as well as the link, |
| 45 | 45 | ; as otherwise, the TV's on the Concepts aren't stored. |
| 46 | 46 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-x-test")) |
| 47 | (cog-open storage) | |
| 48 | (store-frames top1-space) | |
| 49 | (store-frames top2-space) | |
| 47 | (cog-set-value! storage (*-open-*)) | |
| 48 | (cog-set-value! storage (*-store-frames-*) top1-space) | |
| 49 | (cog-set-value! storage (*-store-frames-*) top2-space) | |
| 50 | 50 | (cog-set-atomspace! top1-space) |
| 51 | (store-atom (Concept "bar")) | |
| 51 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 52 | 52 | (cog-set-atomspace! top2-space) |
| 53 | (store-atom (Concept "bar")) | |
| 54 | (store-atom (Concept "foo")) | |
| 53 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 54 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 55 | 55 | (cog-set-atomspace! mid-space) |
| 56 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 57 | (store-atom (Concept "bar")) | |
| 58 | (cog-close storage) | |
| 56 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 57 | (cog-set-value! storage (*-store-atom-*) (Concept "bar")) | |
| 58 | (cog-set-value! storage (*-close-*)) | |
| 59 | 59 | ) |
| 60 | 60 | |
| 61 | 61 | ; ------------------------------------------------------------------- |
| … | … | @@ -74,21 +74,21 @@ |
| 74 | 74 | |
| 75 | 75 | ; Load everything. |
| 76 | 76 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-space-x-test")) |
| 77 | (cog-open storage) | |
| 77 | (cog-set-value! storage (*-open-*)) | |
| 78 | 78 | |
| 79 | 79 | ; Load all of the Frames. |
| 80 | (define top-spaces (load-frames)) | |
| 80 | (define top-spaces (cog-value->list (cog-value storage (*-load-frames-*)))) | |
| 81 | 81 | ; (format #t "The top spaces are ~A\n" top-spaces) |
| 82 | 82 | (define top1-space (first top-spaces)) |
| 83 | 83 | (define top2-space (second top-spaces)) |
| 84 | 84 | |
| 85 | 85 | ; Load all of the AtomSpaces. |
| 86 | 86 | (cog-set-atomspace! top1-space) |
| 87 | (load-atomspace) | |
| 87 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 88 | 88 | (cog-set-atomspace! top2-space) |
| 89 | (load-atomspace) | |
| 89 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 90 | 90 | |
| 91 | (cog-close storage) | |
| 91 | (cog-set-value! storage (*-close-*)) | |
| 92 | 92 | |
| 93 | 93 | (test-assert "exe-top-unequal" (not (equal? top1-space top2-space))) |
| 94 | 94 |
| … | … | @@ -42,10 +42,10 @@ |
| 42 | 42 | |
| 43 | 43 | ; Store only the top link, nothing else. |
| 44 | 44 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-frame-test")) |
| 45 | (cog-open storage) | |
| 46 | (store-frames surface-space) | |
| 47 | (store-atom (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 48 | (cog-close storage) | |
| 45 | (cog-set-value! storage (*-open-*)) | |
| 46 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 47 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 48 | (cog-set-value! storage (*-close-*)) | |
| 49 | 49 | |
| 50 | 50 | ; Clear out the spaces, start with a clean slate. |
| 51 | 51 | (cog-atomspace-clear surface-space) |
| … | … | @@ -66,13 +66,13 @@ |
| 66 | 66 | |
| 67 | 67 | ; Load everything. |
| 68 | 68 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-frame-test")) |
| 69 | (cog-open storage) | |
| 70 | (define top-space (car (load-frames))) | |
| 69 | (cog-set-value! storage (*-open-*)) | |
| 70 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 71 | 71 | (cog-set-atomspace! top-space) |
| 72 | (load-atomspace) | |
| 72 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 73 | 73 | ; (cog-rocks-stats storage) |
| 74 | 74 | ; (cog-rocks-print storage "") |
| 75 | (cog-close storage) | |
| 75 | (cog-set-value! storage (*-close-*)) | |
| 76 | 76 | |
| 77 | 77 | ; Grab references into the inheritance hierarchy |
| 78 | 78 | (define surface-space top-space) |
| … | … | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-readd-test")) |
| 24 | 24 | (cog-open storage) |
| 25 | (store-frames (cog-atomspace)) | |
| 25 | (cog-set-value! storage (*-store-frames-*) (cog-atomspace)) | |
| 26 | 26 | |
| 27 | 27 | ; Splatter some atoms into the various spaces. |
| 28 | 28 | (set-cnt! (Concept "foo") (FloatValue 1 0 3)) |
| … | … | @@ -33,7 +33,7 @@ |
| 33 | 33 | |
| 34 | 34 | (cog-set-atomspace! mid1-space) |
| 35 | 35 | (set-cnt! (List (Concept "foo") (Concept "bar")) (FloatValue 1 0 5)) |
| 36 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 36 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 37 | 37 | |
| 38 | 38 | (define mid2-space (AtomSpace mid1-space)) |
| 39 | 39 | (cog-set-atomspace! mid2-space) |
| … | … | @@ -43,18 +43,18 @@ |
| 43 | 43 | (cog-delete-recursive! (Concept "foo")) |
| 44 | 44 | (cog-extract-recursive! (Concept "foo")) |
| 45 | 45 | (set-cnt! (Concept "foo") (FloatValue 1 0 6)) |
| 46 | (store-atom (ListLink (Concept "foo") (Concept "faa"))) | |
| 46 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "faa"))) | |
| 47 | 47 | |
| 48 | 48 | (define mid3-space (AtomSpace mid2-space)) |
| 49 | 49 | (cog-set-atomspace! mid3-space) |
| 50 | 50 | (set-cnt! (List (Concept "foo") (Concept "bar")) (FloatValue 1 0 7)) |
| 51 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 51 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 52 | 52 | |
| 53 | 53 | (define surface-space (AtomSpace mid3-space)) |
| 54 | 54 | (cog-set-atomspace! surface-space) |
| 55 | (store-frames surface-space) | |
| 55 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 56 | 56 | |
| 57 | (cog-close storage) | |
| 57 | (cog-set-value! storage (*-close-*)) | |
| 58 | 58 | |
| 59 | 59 | ; Clear out the spaces, start with a clean slate. |
| 60 | 60 | (cog-atomspace-clear surface-space) |
| … | … | @@ -75,13 +75,13 @@ |
| 75 | 75 | |
| 76 | 76 | ; Load everything. |
| 77 | 77 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-readd-test")) |
| 78 | (cog-open storage) | |
| 79 | (define top-space (car (load-frames))) | |
| 78 | (cog-set-value! storage (*-open-*)) | |
| 79 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 80 | 80 | (cog-set-atomspace! top-space) |
| 81 | (load-atomspace) | |
| 81 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 82 | 82 | ; (cog-rocks-stats storage) |
| 83 | 83 | ; (cog-rocks-print storage "") |
| 84 | (cog-close storage) | |
| 84 | (cog-set-value! storage (*-close-*)) | |
| 85 | 85 | |
| 86 | 86 | ; Grab references into the inheritance hierarchy |
| 87 | 87 | (define surface-space top-space) |
| … | … | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-resave-test")) |
| 24 | 24 | (cog-open storage) |
| 25 | (store-frames (cog-atomspace)) | |
| 25 | (cog-set-value! storage (*-store-frames-*) (cog-atomspace)) | |
| 26 | 26 | |
| 27 | 27 | ; Splatter some atoms into the various spaces. |
| 28 | 28 | (set-cnt! (Concept "foo") (FloatValue 1 0 3)) |
| … | … | @@ -33,7 +33,7 @@ |
| 33 | 33 | |
| 34 | 34 | (cog-set-atomspace! mid1-space) |
| 35 | 35 | (set-cnt! (List (Concept "foo") (Concept "bar")) (FloatValue 1 0 5)) |
| 36 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 36 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 37 | 37 | |
| 38 | 38 | (define mid2-space (AtomSpace mid1-space)) |
| 39 | 39 | (cog-set-atomspace! mid2-space) |
| … | … | @@ -43,18 +43,18 @@ |
| 43 | 43 | (cog-delete-recursive! (Concept "foo")) |
| 44 | 44 | (cog-extract-recursive! (Concept "foo")) |
| 45 | 45 | (set-cnt! (Concept "foo") (FloatValue 1 0 6)) |
| 46 | (store-atom (Concept "foo")) | |
| 46 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 47 | 47 | |
| 48 | 48 | (define mid3-space (AtomSpace mid2-space)) |
| 49 | 49 | (cog-set-atomspace! mid3-space) |
| 50 | 50 | (set-cnt! (List (Concept "foo") (Concept "bar")) (FloatValue 1 0 7)) |
| 51 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 51 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 52 | 52 | |
| 53 | 53 | (define surface-space (AtomSpace mid3-space)) |
| 54 | 54 | (cog-set-atomspace! surface-space) |
| 55 | (store-frames surface-space) | |
| 55 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 56 | 56 | |
| 57 | (cog-close storage) | |
| 57 | (cog-set-value! storage (*-close-*)) | |
| 58 | 58 | |
| 59 | 59 | ; Clear out the spaces, start with a clean slate. |
| 60 | 60 | (cog-atomspace-clear surface-space) |
| … | … | @@ -75,13 +75,13 @@ |
| 75 | 75 | |
| 76 | 76 | ; Load everything. |
| 77 | 77 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-resave-test")) |
| 78 | (cog-open storage) | |
| 79 | (define top-space (car (load-frames))) | |
| 78 | (cog-set-value! storage (*-open-*)) | |
| 79 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 80 | 80 | (cog-set-atomspace! top-space) |
| 81 | (load-atomspace) | |
| 81 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 82 | 82 | ; (cog-rocks-stats storage) |
| 83 | 83 | ; (cog-rocks-print storage "") |
| 84 | (cog-close storage) | |
| 84 | (cog-set-value! storage (*-close-*)) | |
| 85 | 85 | |
| 86 | 86 | ; Grab references into the inheritance hierarchy |
| 87 | 87 | (define surface-space top-space) |
| … | … | @@ -22,7 +22,7 @@ |
| 22 | 22 | |
| 23 | 23 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-reval-test")) |
| 24 | 24 | (cog-open storage) |
| 25 | (store-frames (cog-atomspace)) | |
| 25 | (cog-set-value! storage (*-store-frames-*) (cog-atomspace)) | |
| 26 | 26 | |
| 27 | 27 | ; Splatter some atoms into the various spaces. |
| 28 | 28 | (set-cnt! (Concept "foo") (FloatValue 1 0 3)) |
| … | … | @@ -33,7 +33,7 @@ |
| 33 | 33 | |
| 34 | 34 | (cog-set-atomspace! mid1-space) |
| 35 | 35 | (set-cnt! (List (Concept "foo") (Concept "bar")) (FloatValue 1 0 5)) |
| 36 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 36 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 37 | 37 | |
| 38 | 38 | (define mid2-space (AtomSpace mid1-space)) |
| 39 | 39 | (cog-set-atomspace! mid2-space) |
| … | … | @@ -43,20 +43,20 @@ |
| 43 | 43 | ; But it has no values. Next, write an explicit value. |
| 44 | 44 | (cog-delete-recursive! (Concept "foo")) |
| 45 | 45 | (cog-extract-recursive! (Concept "foo")) |
| 46 | (store-atom (Concept "foo")) | |
| 46 | (cog-set-value! storage (*-store-atom-*) (Concept "foo")) | |
| 47 | 47 | (set-cnt! (Concept "foo") (FloatValue 1 0 6)) |
| 48 | (store-value (Concept "foo") (Predicate "kayfabe")) | |
| 48 | (cog-set-value! storage (*-store-value-*) (Concept "foo") (Predicate "kayfabe")) | |
| 49 | 49 | |
| 50 | 50 | (define mid3-space (AtomSpace mid2-space)) |
| 51 | 51 | (cog-set-atomspace! mid3-space) |
| 52 | 52 | (set-cnt! (List (Concept "foo") (Concept "bar")) (FloatValue 1 0 7)) |
| 53 | (store-atom (ListLink (Concept "foo") (Concept "bar"))) | |
| 53 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (Concept "bar"))) | |
| 54 | 54 | |
| 55 | 55 | (define surface-space (AtomSpace mid3-space)) |
| 56 | 56 | (cog-set-atomspace! surface-space) |
| 57 | (store-frames surface-space) | |
| 57 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 58 | 58 | |
| 59 | (cog-close storage) | |
| 59 | (cog-set-value! storage (*-close-*)) | |
| 60 | 60 | |
| 61 | 61 | ; Clear out the spaces, start with a clean slate. |
| 62 | 62 | (cog-atomspace-clear surface-space) |
| … | … | @@ -77,13 +77,13 @@ |
| 77 | 77 | |
| 78 | 78 | ; Load everything. |
| 79 | 79 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-reval-test")) |
| 80 | (cog-open storage) | |
| 81 | (define top-space (car (load-frames))) | |
| 80 | (cog-set-value! storage (*-open-*)) | |
| 81 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 82 | 82 | (cog-set-atomspace! top-space) |
| 83 | (load-atomspace) | |
| 83 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 84 | 84 | ; (cog-rocks-stats storage) |
| 85 | 85 | ; (cog-rocks-print storage "") |
| 86 | (cog-close storage) | |
| 86 | (cog-set-value! storage (*-close-*)) | |
| 87 | 87 | |
| 88 | 88 | ; Grab references into the inheritance hierarchy |
| 89 | 89 | (define surface-space top-space) |
| … | … | @@ -27,9 +27,9 @@ |
| 27 | 27 | |
| 28 | 28 | ; Store the content. Store only the top-most link. |
| 29 | 29 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-store-test")) |
| 30 | (cog-open storage) | |
| 31 | (store-atom (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 32 | (cog-close storage) | |
| 30 | (cog-set-value! storage (*-open-*)) | |
| 31 | (cog-set-value! storage (*-store-atom-*) (ListLink (Concept "foo") (List (Concept "bar")))) | |
| 32 | (cog-set-value! storage (*-close-*)) | |
| 33 | 33 | |
| 34 | 34 | ; Clear out the space, start with a clean slate. |
| 35 | 35 | (cog-atomspace-clear (cog-atomspace)) |
| … | … | @@ -46,11 +46,11 @@ |
| 46 | 46 | |
| 47 | 47 | ; Load everything. |
| 48 | 48 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-value-store-test")) |
| 49 | (cog-open storage) | |
| 49 | (cog-set-value! storage (*-open-*)) | |
| 50 | 50 | ; (cog-rocks-stats storage) |
| 51 | 51 | ; (cog-rocks-print storage "") |
| 52 | (load-atomspace) | |
| 53 | (cog-close storage) | |
| 52 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 53 | (cog-set-value! storage (*-close-*)) | |
| 54 | 54 | |
| 55 | 55 | ; Verify the ListLink is as expected. |
| 56 | 56 | (define lilly (ListLink (Concept "foo") (List (Concept "bar")))) |
| … | … | @@ -27,15 +27,15 @@ |
| 27 | 27 | (define surface-space (AtomSpace mid5-space)) |
| 28 | 28 | |
| 29 | 29 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-valueless-test")) |
| 30 | (cog-open storage) | |
| 31 | (store-frames surface-space) | |
| 30 | (cog-set-value! storage (*-open-*)) | |
| 31 | (cog-set-value! storage (*-store-frames-*) surface-space) | |
| 32 | 32 | |
| 33 | 33 | ; Splatter some atoms into the various spaces. |
| 34 | 34 | (cog-set-atomspace! base-space) |
| 35 | (store-atom (Concept "even")) | |
| 35 | (cog-set-value! storage (*-store-atom-*) (Concept "even")) | |
| 36 | 36 | |
| 37 | 37 | (cog-set-atomspace! mid1-space) |
| 38 | (store-atom (Concept "odd")) | |
| 38 | (cog-set-value! storage (*-store-atom-*) (Concept "odd")) | |
| 39 | 39 | |
| 40 | 40 | (cog-set-atomspace! mid2-space) |
| 41 | 41 | (cog-delete! (Concept "even")) |
| … | … | @@ -46,12 +46,12 @@ |
| 46 | 46 | (cog-extract! (Concept "odd")) |
| 47 | 47 | |
| 48 | 48 | (cog-set-atomspace! mid4-space) |
| 49 | (store-atom (Concept "even")) | |
| 49 | (cog-set-value! storage (*-store-atom-*) (Concept "even")) | |
| 50 | 50 | |
| 51 | 51 | (cog-set-atomspace! mid5-space) |
| 52 | (store-atom (Concept "odd")) | |
| 52 | (cog-set-value! storage (*-store-atom-*) (Concept "odd")) | |
| 53 | 53 | |
| 54 | (cog-close storage) | |
| 54 | (cog-set-value! storage (*-close-*)) | |
| 55 | 55 | |
| 56 | 56 | ; Clear out the spaces, start with a clean slate. |
| 57 | 57 | (cog-atomspace-clear surface-space) |
| … | … | @@ -79,11 +79,11 @@ |
| 79 | 79 | |
| 80 | 80 | ; Load everything. |
| 81 | 81 | (define storage (RocksStorageNode "rocks:///tmp/cog-rocks-valueless-test")) |
| 82 | (cog-open storage) | |
| 83 | (define top-space (car (load-frames))) | |
| 82 | (cog-set-value! storage (*-open-*)) | |
| 83 | (define top-space (car (cog-value->list (cog-value storage (*-load-frames-*))))) | |
| 84 | 84 | (cog-set-atomspace! top-space) |
| 85 | (load-atomspace) | |
| 86 | (cog-close storage) | |
| 85 | (cog-set-value! storage (*-load-atomspace-*) (cog-atomspace)) | |
| 86 | (cog-set-value! storage (*-close-*)) | |
| 87 | 87 | |
| 88 | 88 | ; Grab references into the inheritance hierarchy |
| 89 | 89 | (define surface-space top-space) |