| … | … | @@ -30,6 +30,7 @@ |
| 30 | 30 | #include <opencog/atoms/base/Link.h> |
| 31 | 31 | #include <opencog/atoms/base/Node.h> |
| 32 | 32 | #include <opencog/atoms/value/FloatValue.h> |
| 33 | #include <opencog/atoms/value/VoidValue.h> | |
| 33 | 34 | #include <opencog/atomspace/AtomSpace.h> |
| 34 | 35 | #include <opencog/persist/rocks-types/atom_types.h> |
| 35 | 36 | #include <opencog/persist/monospace/MonoStorage.h> |
| … | … | @@ -41,7 +42,7 @@ using namespace opencog; |
| 41 | 42 | class LargeFlatUTest : public CxxTest::TestSuite |
| 42 | 43 | { |
| 43 | 44 | private: |
| 44 | AtomSpace *_as; | |
| 45 | AtomSpacePtr _as; | |
| 45 | 46 | |
| 46 | 47 | // 75000 * 7 == half-a-million atoms |
| 47 | 48 | // 19000 * 7 == 133K atoms |
| … | … | @@ -104,12 +105,12 @@ LargeFlatUTest::~LargeFlatUTest() |
| 104 | 105 | */ |
| 105 | 106 | void LargeFlatUTest::setUp(void) |
| 106 | 107 | { |
| 107 | _as = new AtomSpace(); | |
| 108 | _as = createAtomSpace(); | |
| 108 | 109 | } |
| 109 | 110 | |
| 110 | 111 | void LargeFlatUTest::tearDown(void) |
| 111 | 112 | { |
| 112 | delete _as; | |
| 113 | _as = nullptr; | |
| 113 | 114 | kill_data(); |
| 114 | 115 | } |
| 115 | 116 | |
| … | … | @@ -342,16 +343,16 @@ int LargeFlatUTest::filler_up(AtomSpace *space) |
| 342 | 343 | while (idx < (NCOPIES-20)) |
| 343 | 344 | { |
| 344 | 345 | std::string lbl = std::to_string(idx); |
| 345 | add_to_space(idx++, _as, "AA-aa-wow " + lbl); | |
| 346 | add_to_space(idx++, _as, "BB-bb-wow " + lbl); | |
| 347 | add_to_space(idx++, _as, "CC-cc-wow " + lbl); | |
| 348 | add_to_space(idx++, _as, "DD-dd-wow " + lbl); | |
| 349 | add_to_space(idx++, _as, "EE-ee-wow " + lbl); | |
| 346 | add_to_space(idx++, _as.get(), "AA-aa-wow " + lbl); | |
| 347 | add_to_space(idx++, _as.get(), "BB-bb-wow " + lbl); | |
| 348 | add_to_space(idx++, _as.get(), "CC-cc-wow " + lbl); | |
| 349 | add_to_space(idx++, _as.get(), "DD-dd-wow " + lbl); | |
| 350 | add_to_space(idx++, _as.get(), "EE-ee-wow " + lbl); | |
| 350 | 351 | |
| 351 | 352 | /* Make sure UTF-8 works fine. */ |
| 352 | add_to_space(idx++, _as, "Попытка выбраться вызвала слабый стон " + lbl); | |
| 353 | add_to_space(idx++, _as, "はにがうりだそうであってるのかはち " + lbl); | |
| 354 | add_to_space(idx++, _as, "係拉丁字母" + lbl); | |
| 353 | add_to_space(idx++, _as.get(), "Попытка выбраться вызвала слабый стон " + lbl); | |
| 354 | add_to_space(idx++, _as.get(), "はにがうりだそうであってるのかはち " + lbl); | |
| 355 | add_to_space(idx++, _as.get(), "係拉丁字母" + lbl); | |
| 355 | 356 | } |
| 356 | 357 | return idx; |
| 357 | 358 | } |
| … | … | @@ -364,16 +365,16 @@ void LargeFlatUTest::test_atomspace(void) |
| 364 | 365 | |
| 365 | 366 | Handle hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-large-flat-utest"); |
| 366 | 367 | StorageNodePtr store = StorageNodeCast(hsn); |
| 367 | store->open(); | |
| 368 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 368 | 369 | TS_ASSERT(store->connected()) |
| 369 | 370 | |
| 370 | 371 | /* Create a large number of atoms */ |
| 371 | int idx = filler_up(_as); | |
| 372 | int idx = filler_up(_as.get()); | |
| 372 | 373 | |
| 373 | 374 | /* Verify that the atoms were added */ |
| 374 | 375 | int i; |
| 375 | 376 | for (i=0; i<idx; i++) |
| 376 | check_space(i, _as, "verify-add"); | |
| 377 | check_space(i, _as.get(), "verify-add"); | |
| 377 | 378 | |
| 378 | 379 | /* Push all atoms out to the SQL DB */ |
| 379 | 380 | store->store_atomspace(); |
| … | … | @@ -389,14 +390,14 @@ void LargeFlatUTest::test_atomspace(void) |
| 389 | 390 | /* The clear above nuked the storage, so restart */ |
| 390 | 391 | hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-large-flat-utest"); |
| 391 | 392 | store = StorageNodeCast(hsn); |
| 392 | store->open(); | |
| 393 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 393 | 394 | TS_ASSERT(store->connected()) |
| 394 | 395 | |
| 395 | 396 | /* Verify that the atoms can still be fetched from storage. */ |
| 396 | 397 | for (i=0; i<idx; i++) { |
| 397 | 398 | fetch_space(i, store); |
| 398 | 399 | store->barrier(); |
| 399 | check_space(i, _as, "verify-fetch"); | |
| 400 | check_space(i, _as.get(), "verify-fetch"); | |
| 400 | 401 | } |
| 401 | 402 | |
| 402 | 403 | /* Do it again, for good luck. */ |
| … | … | @@ -406,14 +407,14 @@ void LargeFlatUTest::test_atomspace(void) |
| 406 | 407 | /* The clear above nuked the storage, so restart */ |
| 407 | 408 | hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-large-flat-utest"); |
| 408 | 409 | store = StorageNodeCast(hsn); |
| 409 | store->open(); | |
| 410 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 410 | 411 | TS_ASSERT(store->connected()) |
| 411 | 412 | |
| 412 | 413 | /* Verify that the atoms can still be fetched from storage. */ |
| 413 | 414 | for (i=0; i<idx; i++) { |
| 414 | 415 | fetch_space(i, store); |
| 415 | 416 | store->barrier(); |
| 416 | check_space(i, _as, "ver-again"); | |
| 417 | check_space(i, _as.get(), "ver-again"); | |
| 417 | 418 | } |
| 418 | 419 | |
| 419 | 420 | /* Kill data for good */ |
| … | … | @@ -422,7 +423,7 @@ void LargeFlatUTest::test_atomspace(void) |
| 422 | 423 | |
| 423 | 424 | /* Verify that the atoms are no longer being found. */ |
| 424 | 425 | for (i=0; i<idx; i++) |
| 425 | check_empty(i, _as); | |
| 426 | check_empty(i, _as.get()); | |
| 426 | 427 | |
| 427 | 428 | logger().debug("END TEST: %s", __FUNCTION__); |
| 428 | 429 | } |
| … | … | @@ -34,6 +34,7 @@ |
| 34 | 34 | #include <opencog/atomspace/AtomSpace.h> |
| 35 | 35 | #include <opencog/persist/rocks-types/atom_types.h> |
| 36 | 36 | #include <opencog/atoms/value/FloatValue.h> |
| 37 | #include <opencog/atoms/value/VoidValue.h> | |
| 37 | 38 | #include <opencog/persist/monospace/MonoStorage.h> |
| 38 | 39 | |
| 39 | 40 | #include <opencog/util/Logger.h> |
| … | … | @@ -43,7 +44,7 @@ using namespace opencog; |
| 43 | 44 | class LargeZipfUTest : public CxxTest::TestSuite |
| 44 | 45 | { |
| 45 | 46 | private: |
| 46 | AtomSpace *_as; | |
| 47 | AtomSpacePtr _as; | |
| 47 | 48 | |
| 48 | 49 | #define NWORDS 35000 |
| 49 | 50 | Handle hword[NWORDS]; |
| … | … | @@ -92,12 +93,12 @@ LargeZipfUTest::~LargeZipfUTest() |
| 92 | 93 | */ |
| 93 | 94 | void LargeZipfUTest::setUp(void) |
| 94 | 95 | { |
| 95 | _as = new AtomSpace(); | |
| 96 | _as = createAtomSpace(); | |
| 96 | 97 | } |
| 97 | 98 | |
| 98 | 99 | void LargeZipfUTest::tearDown(void) |
| 99 | 100 | { |
| 100 | delete _as; | |
| 101 | _as = nullptr; | |
| 101 | 102 | kill_data(); |
| 102 | 103 | } |
| 103 | 104 | |
| … | … | @@ -289,14 +290,14 @@ void LargeZipfUTest::test_atomspace(void) |
| 289 | 290 | |
| 290 | 291 | Handle hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-large-zipf-utest"); |
| 291 | 292 | StorageNodePtr store = StorageNodeCast(hsn); |
| 292 | store->open(); | |
| 293 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 293 | 294 | TS_ASSERT(store->connected()) |
| 294 | 295 | |
| 295 | 296 | /* Create a large number of atoms */ |
| 296 | filler_up(_as); | |
| 297 | filler_up(_as.get()); | |
| 297 | 298 | |
| 298 | 299 | /* Verify that the atoms were added */ |
| 299 | check_space(_as, "verify-add"); | |
| 300 | check_space(_as.get(), "verify-add"); | |
| 300 | 301 | |
| 301 | 302 | /* Push all atoms out to the SQL DB */ |
| 302 | 303 | store->store_atomspace(); |
| … | … | @@ -312,13 +313,13 @@ void LargeZipfUTest::test_atomspace(void) |
| 312 | 313 | /* The clear above nuked the storage, so restart */ |
| 313 | 314 | hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-large-zipf-utest"); |
| 314 | 315 | store = StorageNodeCast(hsn); |
| 315 | store->open(); | |
| 316 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 316 | 317 | TS_ASSERT(store->connected()) |
| 317 | 318 | |
| 318 | 319 | /* Verify that the atoms can still be fetched from storage. */ |
| 319 | fetch_space(_as, store); | |
| 320 | fetch_space(_as.get(), store); | |
| 320 | 321 | store->barrier(); |
| 321 | check_space(_as, "verify-fetch"); | |
| 322 | check_space(_as.get(), "verify-fetch"); | |
| 322 | 323 | |
| 323 | 324 | /* Do it again, for good luck. */ |
| 324 | 325 | _as->clear(); |
| … | … | @@ -327,20 +328,20 @@ void LargeZipfUTest::test_atomspace(void) |
| 327 | 328 | /* The clear above nuked the storage, so restart */ |
| 328 | 329 | hsn = _as->add_node(MONO_STORAGE_NODE, "monospace:///tmp/cog-mono-large-zipf-utest"); |
| 329 | 330 | store = StorageNodeCast(hsn); |
| 330 | store->open(); | |
| 331 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 331 | 332 | TS_ASSERT(store->connected()) |
| 332 | 333 | |
| 333 | 334 | /* Verify that the atoms can still be fetched from storage. */ |
| 334 | fetch_space(_as, store); | |
| 335 | fetch_space(_as.get(), store); | |
| 335 | 336 | store->barrier(); |
| 336 | check_space(_as, "ver-again"); | |
| 337 | check_space(_as.get(), "ver-again"); | |
| 337 | 338 | |
| 338 | 339 | /* Kill data for good */ |
| 339 | 340 | _as->clear(); |
| 340 | 341 | TSM_ASSERT("Non-empty atomspace", 0 == _as->get_size()); |
| 341 | 342 | |
| 342 | 343 | /* Verify that the atoms are no longer being found. */ |
| 343 | check_empty(_as); | |
| 344 | check_empty(_as.get()); | |
| 344 | 345 | |
| 345 | 346 | logger().debug("END TEST: %s", __FUNCTION__); |
| 346 | 347 | } |
| … | … | @@ -34,6 +34,7 @@ |
| 34 | 34 | #include <opencog/persist/rocks-types/atom_types.h> |
| 35 | 35 | #include <opencog/atoms/value/FloatValue.h> |
| 36 | 36 | #include <opencog/atoms/value/LinkValue.h> |
| 37 | #include <opencog/atoms/value/VoidValue.h> | |
| 37 | 38 | #include <opencog/persist/monospace/MonoStorage.h> |
| 38 | 39 | |
| 39 | 40 | #include <opencog/util/Logger.h> |
| … | … | @@ -126,7 +127,7 @@ void QueryPersistUTest::setup_data(void) |
| 126 | 127 | |
| 127 | 128 | Handle hsn = _as->add_node(MONO_STORAGE_NODE, std::string(uri)); |
| 128 | 129 | StorageNodePtr store = StorageNodeCast(hsn); |
| 129 | store->open(); | |
| 130 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 130 | 131 | TS_ASSERT(store->connected()) |
| 131 | 132 | |
| 132 | 133 | /* Populate the Storage with stuff that we will later query. */ |
| … | … | @@ -173,7 +174,7 @@ void QueryPersistUTest::test_meet(void) |
| 173 | 174 | _as = createAtomSpace(); |
| 174 | 175 | Handle hsn = _as->add_node(MONO_STORAGE_NODE, std::string(uri)); |
| 175 | 176 | StorageNodePtr store = StorageNodeCast(hsn); |
| 176 | store->open(); | |
| 177 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 177 | 178 | TS_ASSERT(store->connected()) |
| 178 | 179 | |
| 179 | 180 | // Create a query to find all things that have wheels. |
| … | … | @@ -234,7 +235,7 @@ void QueryPersistUTest::test_join(void) |
| 234 | 235 | _as = createAtomSpace(); |
| 235 | 236 | Handle hsn = _as->add_node(MONO_STORAGE_NODE, std::string(uri)); |
| 236 | 237 | StorageNodePtr store = StorageNodeCast(hsn); |
| 237 | store->open(); | |
| 238 | store->setValue(_as->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); | |
| 238 | 239 | TS_ASSERT(store->connected()) |
| 239 | 240 | |
| 240 | 241 | // Create a join to find all vehicles. |