OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace-rocks commits / 28b77d5

Remove special-casing for truth values
I will never be opening my old data sets again, and so support for the whack TV semantics is no longer needed.
28b77d5ed47d33c2e3e0468f21297b0324b18d18
by Linas Vepstas <linasvepstas@gmail.com> · 2026-01-20T18:11:51.000Z

Changed files (6) +2 -58

opencog/persist/monospace/MonoIO.cc +1 -17
……@@ -282,10 +282,6 @@ void MonoStorage::storeAtom(const Handle& h, bool synchronous)
282282 // Separator for keys
283283 std::string cid = "k@" + sid + ":";
284284
285 // Always clobber the TV, set it back to default.
286 // The below will revise as needed.
287 _rfile->Delete(rocksdb::WriteOptions(), cid + tv_pred_sid);
288
289285 // Store all the keys on the atom ...
290286 for (const Handle& key : h->getKeys())
291287 storeValue(cid + writeAtom(key), h->getValue(key));
……@@ -441,19 +437,7 @@ void MonoStorage::getKeys(AtomSpace* as,
441437 }
442438
443439 // read-only Atomspaces will refuse insertion of keys.
444 // However, we have to special-case the truth values.
445 // Mostly because (PredicateNode "*-TruthValueKey-*")
446 // is not in the AtomSpace. Argh! That's an old design flaw.
447 if (nullptr == key)
448 {
449 if (0 == tv_pred_sid.compare(it->key().ToString().substr(pos)))
450 {
451 size_t junk = 0;
452 ValuePtr vp = Sexpr::decode_value(it->value().ToString(), junk);
453 h->setValue(truth_key(), vp);
454 }
455 continue;
456 }
440 if (nullptr == key) continue;
457441
458442 size_t junk = 0;
459443 ValuePtr vp = Sexpr::decode_value(it->value().ToString(), junk);
opencog/persist/monospace/MonoStorage.cc +0 -7
……@@ -163,13 +163,6 @@ void MonoStorage::init(const char * uri, bool read_only)
163163printf("Mono: opened=%s%s\n", file.c_str(), read_only ? " (read-only)" : "");
164164printf("Mono: initial aid=%lu\n", _next_aid.load());
165165
166 if (read_only) return;
167
168 // Set up a SID for the TV predicate key.
169 // This must match what the AtomSpace is using.
170 // Tack on a leading colon, for convenience.
171 Handle h = createNode(PREDICATE_NODE, "*-TruthValueKey-*");
172 tv_pred_sid = writeAtom(h);
173166}
174167
175168void MonoStorage::open()
opencog/persist/monospace/MonoStorage.h +0 -3
……@@ -64,9 +64,6 @@ class MonoStorage : public StorageNode
6464 std::string aidtostr(uint64_t) const;
6565 void write_aid(void);
6666
67 // Special case (PredicateNode "*-TruthValueKey-*")
68 std::string tv_pred_sid;
69
7067 // Issue of sid needs to be atomic.
7168 std::mutex _mtx_sid;
7269
opencog/persist/rocks/RocksIO.cc +1 -21
……@@ -389,10 +389,6 @@ void RocksStorage::storeAtom(const Handle& h, bool synchronous)
389389 _rfile->Delete(rocksdb::WriteOptions(), marker);
390390 }
391391
392 // Always clobber the TV, set it back to default.
393 // The below will revise as needed.
394 _rfile->Delete(rocksdb::WriteOptions(), cid + tv_pred_sid);
395
396392 // Store all the keys on the atom ...
397393 for (const Handle& key : h->getKeys())
398394 storeValue(cid + writeAtom(key), h->getValue(key));
……@@ -405,10 +401,6 @@ void RocksStorage::storeMissingAtom(AtomSpace* as, const Handle& h)
405401 // Separator for keys
406402 std::string skid = "k@" + sid + ":" + writeFrame(as) + ":";
407403
408 // Always clobber the TV, set it back to default.
409 // The below will revise as needed.
410 _rfile->Delete(rocksdb::WriteOptions(), skid + tv_pred_sid);
411
412404 // If there is a previous marker, erase it!
413405 std::string marker = skid + "+1";
414406 _rfile->Delete(rocksdb::WriteOptions(), marker);
……@@ -589,19 +581,7 @@ void RocksStorage::getKeysMonospace(AtomSpace* as,
589581 }
590582
591583 // read-only Atomspaces will refuse insertion of keys.
592 // However, we have to special-case the truth values.
593 // Mostly because (PredicateNode "*-TruthValueKey-*")
594 // is not in the AtomSpace. Argh! That's an old design flaw.
595 if (nullptr == key)
596 {
597 if (0 == tv_pred_sid.compare(rks.substr(kidoff)))
598 {
599 size_t junk = 0;
600 ValuePtr vp = Sexpr::decode_value(it->value().ToString(), junk);
601 h->setValue(truth_key(), vp);
602 }
603 continue;
604 }
584 if (nullptr == key) continue;
605585
606586 size_t junk = 0;
607587 ValuePtr vp = Sexpr::decode_value(it->value().ToString(), junk);
opencog/persist/rocks/RocksStorage.cc +0 -7
……@@ -182,13 +182,6 @@ printf("Rocks: opened=%s%s\n", file.c_str(), read_only ? " (read-only)" : "");
182182printf("Rocks: DB-version=%s multi-space=%d initial aid=%lu\n",
183183get_version().c_str(), _multi_space, _next_aid.load());
184184
185 if (read_only) return;
186
187 // Set up a SID for the TV predicate key.
188 // This must match what the AtomSpace is using.
189 // Tack on a leading colon, for convenience.
190 Handle h = createNode(PREDICATE_NODE, "*-TruthValueKey-*");
191 tv_pred_sid = writeAtom(h);
192185}
193186
194187void RocksStorage::open()
opencog/persist/rocks/RocksStorage.h +0 -3
……@@ -96,9 +96,6 @@ class RocksStorage : public StorageNode
9696 void write_aid(void);
9797 std::string get_new_aid(void);
9898
99 // Special case (PredicateNode "*-TruthValueKey-*")
100 std::string tv_pred_sid;
101
10299 // Issue of sid needs to be atomic.
103100 std::mutex _mtx_sid;
104101