| … | … | @@ -368,46 +368,43 @@ void MonoBasicSaveUTest::test_table() |
| 368 | 368 | { |
| 369 | 369 | logger().debug("BEGIN TEST: %s", __FUNCTION__); |
| 370 | 370 | |
| 371 | | size_t num_stored; |
| 372 | | |
| 373 | | // Use scope block to ensure as1 is destroyed before as2 opens |
| 371 | AtomSpacePtr as1 = createAtomSpace(); |
| 372 | Handle hsn = as1->add_node(MONO_STORAGE_NODE, std::string(uri)); |
| 373 | StorageNodePtr store = StorageNodeCast(hsn); |
| 374 | store->setValue(as1->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); |
| 375 | if (!store->connected()) |
| 374 | 376 | { |
| 375 | | AtomSpacePtr as1 = createAtomSpace(); |
| 376 | | Handle hsn = as1->add_node(MONO_STORAGE_NODE, std::string(uri)); |
| 377 | | StorageNodePtr store = StorageNodeCast(hsn); |
| 378 | | store->setValue(as1->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); |
| 379 | | if (!store->connected()) |
| 380 | | { |
| 381 | | logger().debug("test_table: cannot connect to db"); |
| 382 | | return; |
| 383 | | } |
| 377 | logger().debug("test_table: cannot connect to db"); |
| 378 | return; |
| 379 | } |
| 384 | 380 | |
| 385 | | int idx = 0; |
| 386 | | add_to_table(idx++, as1.get(), "AA-aa-wow "); |
| 387 | | add_to_table(idx++, as1.get(), "BB-bb-wow "); |
| 388 | | add_to_table(idx++, as1.get(), "CC-cc-wow "); |
| 389 | | add_to_table(idx++, as1.get(), "DD-dd-wow "); |
| 390 | | add_to_table(idx++, as1.get(), "EE-ee-wow "); |
| 381 | int idx = 0; |
| 382 | add_to_table(idx++, as1.get(), "AA-aa-wow "); |
| 383 | add_to_table(idx++, as1.get(), "BB-bb-wow "); |
| 384 | add_to_table(idx++, as1.get(), "CC-cc-wow "); |
| 385 | add_to_table(idx++, as1.get(), "DD-dd-wow "); |
| 386 | add_to_table(idx++, as1.get(), "EE-ee-wow "); |
| 391 | 387 | |
| 392 | | store->store_atomspace(); |
| 393 | | // Subtract 2 for the MonoStorageNode and *-open-* PredicateNode |
| 394 | | num_stored = as1->get_size() - 2; |
| 388 | store->store_atomspace(); |
| 389 | // Subtract 2 for the MonoStorageNode and *-open-* PredicateNode |
| 390 | size_t num_stored = as1->get_size() - 2; |
| 395 | 391 | #ifdef DOPRT |
| 396 | | HandleSeq hset; |
| 397 | | as1->get_handles_by_type(hset, ATOM, true, false); |
| 398 | | for (auto h: hset) { |
| 399 | | printf("Store table has %s\n", h->to_string().c_str()); |
| 400 | | } |
| 392 | HandleSeq hset; |
| 393 | as1->get_handles_by_type(hset, ATOM, true, false); |
| 394 | for (auto h: hset) { |
| 395 | printf("Store table has %s\n", h->to_string().c_str()); |
| 396 | } |
| 401 | 397 | #endif |
| 402 | 398 | |
| 403 | | printf("Done storing table; size=%lu\n", num_stored); |
| 404 | | } |
| 405 | | // as1 goes out of scope here, storage is closed automatically |
| 399 | printf("Done storing table; size=%lu\n", num_stored); |
| 400 | |
| 401 | // Clobber as1 to close storage. |
| 402 | as1 = nullptr; |
| 406 | 403 | |
| 407 | 404 | // Reopen connection, and load the atom table. |
| 408 | 405 | AtomSpacePtr as2 = createAtomSpace(); |
| 409 | | Handle hsn = as2->add_node(MONO_STORAGE_NODE, std::string(uri)); |
| 410 | | StorageNodePtr store = StorageNodeCast(hsn); |
| 406 | hsn = as2->add_node(MONO_STORAGE_NODE, std::string(uri)); |
| 407 | store = StorageNodeCast(hsn); |
| 411 | 408 | store->setValue(as2->add_node(PREDICATE_NODE, "*-open-*"), createVoidValue()); |
| 412 | 409 | TSM_ASSERT("Not connected to database", store->connected()); |
| 413 | 410 | |
| … | … | @@ -421,7 +418,7 @@ void MonoBasicSaveUTest::test_table() |
| 421 | 418 | // and (PredicateNode "*-IsKeyFlag-*") |
| 422 | 419 | TSM_ASSERT("Wrong number of atoms fetched", num_fetched == num_stored+2); |
| 423 | 420 | |
| 424 | | int idx = 0; |
| 421 | idx = 0; |
| 425 | 422 | check_table(idx++, as2.get(), "aaa "); |
| 426 | 423 | check_table(idx++, as2.get(), "bbb "); |
| 427 | 424 | check_table(idx++, as2.get(), "ccc "); |