knowrob
2.1.0
A Knowledge Base System for Cognition-enabled Robots
|
#include <MongoKnowledgeGraph.h>
Classes | |
class | ConnectionRAII |
Public Member Functions | |
MongoKnowledgeGraph () | |
~MongoKnowledgeGraph () override=default | |
bool | initializeBackend (std::string_view db_uri, std::string_view db_name="knowrob", std::string_view collectionName="triples") |
bool | initializeBackend (const PropertyTree &config) override |
const std::string & | dbName () const |
const std::string & | dbURI () const |
bool | isReadOnly () const |
auto | tripleCollection () |
void | drop () |
mongo::BindingsCursorPtr | lookup (const TriplePattern &query) |
mongo::BindingsCursorPtr | lookup (const GraphTerm &query) |
bool | insertOne (const Triple &triple) override |
bool | insertAll (const TripleContainerPtr &triples) override |
bool | removeOne (const Triple &triple) override |
bool | removeAll (const TripleContainerPtr &triples) override |
bool | removeAllWithOrigin (std::string_view origin) override |
bool | isPersistent () const override |
void | foreach (const TripleVisitor &callback) const override |
void | batch (const TripleHandler &callback) const override |
void | batchOrigin (std::string_view origin, const TripleHandler &callback) override |
void | match (const TriplePattern &query, const TripleVisitor &visitor) override |
void | query (const GraphQueryPtr &query, const BindingsHandler &callback) override |
void | count (const ResourceCounter &callback) const override |
MongoKnowledgeGraph () | |
~MongoKnowledgeGraph () override=default | |
bool | initializeBackend (std::string_view db_uri, std::string_view db_name="knowrob", std::string_view collectionName="triples") |
bool | initializeBackend (const PropertyTree &config) override |
const std::string & | dbName () const |
const std::string & | dbURI () const |
bool | isReadOnly () const |
auto | tripleCollection () |
void | drop () |
mongo::BindingsCursorPtr | lookup (const TriplePattern &query) |
mongo::BindingsCursorPtr | lookup (const GraphTerm &query) |
bool | insertOne (const Triple &triple) override |
bool | insertAll (const TripleContainerPtr &triples) override |
bool | removeOne (const Triple &triple) override |
bool | removeAll (const TripleContainerPtr &triples) override |
bool | removeAllWithOrigin (std::string_view origin) override |
bool | isPersistent () const override |
void | foreach (const TripleVisitor &callback) const override |
void | batch (const TripleHandler &callback) const override |
void | batchOrigin (std::string_view origin, const TripleHandler &callback) override |
void | match (const TriplePattern &query, const TripleVisitor &visitor) override |
void | query (const GraphQueryPtr &query, const BindingsHandler &callback) override |
void | count (const ResourceCounter &callback) const override |
Public Member Functions inherited from knowrob::QueryableStorage | |
QueryableStorage (StorageFeatures features=StorageFeature::NothingSpecial) | |
~QueryableStorage () override=default | |
virtual bool | contains (const Triple &triple) |
std::vector< VersionedOriginPtr > | getOrigins () |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) |
void | setVersionOfOrigin (std::string_view origin, std::string_view version) |
void | dropSessionOrigins () |
GraphQueryExpansionPtr | expand (const GraphQueryPtr &q) |
QueryableStorage (StorageFeatures features=StorageFeature::NothingSpecial) | |
~QueryableStorage () override=default | |
virtual bool | contains (const Triple &triple) |
std::vector< VersionedOriginPtr > | getOrigins () |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) |
void | setVersionOfOrigin (std::string_view origin, std::string_view version) |
void | dropSessionOrigins () |
GraphQueryExpansionPtr | expand (const GraphQueryPtr &q) |
Public Member Functions inherited from knowrob::Storage | |
Storage (StorageFeatures features=StorageFeature::NothingSpecial) | |
virtual | ~Storage ()=default |
PluginLanguage | storageLanguage () const |
const auto & | vocabulary () const |
void | setVocabulary (std::shared_ptr< Vocabulary > vocabulary) |
bool | supports (StorageFeature feature) const |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) const |
void | setVersionOfOrigin (std::string_view origin, std::optional< std::string_view > version) |
Storage (StorageFeatures features=StorageFeature::NothingSpecial) | |
virtual | ~Storage ()=default |
PluginLanguage | storageLanguage () const |
const auto & | vocabulary () const |
void | setVocabulary (std::shared_ptr< Vocabulary > vocabulary) |
bool | supports (StorageFeature feature) const |
std::optional< std::string > | getVersionOfOrigin (std::string_view origin) const |
void | setVersionOfOrigin (std::string_view origin, std::optional< std::string_view > version) |
Public Member Functions inherited from knowrob::DataSourceHandler | |
DataSourceHandler ()=default | |
virtual | ~DataSourceHandler ()=default |
void | addDataHandler (const std::string &format, const DataSourceLoader &fn) |
bool | loadDataSource (const DataSourcePtr &dataSource) |
bool | hasDataHandler (const DataSourcePtr &dataSource) const |
DataSourceHandler ()=default | |
virtual | ~DataSourceHandler ()=default |
void | addDataHandler (const std::string &format, const DataSourceLoader &fn) |
bool | loadDataSource (const DataSourcePtr &dataSource) |
bool | hasDataHandler (const DataSourcePtr &dataSource) const |
Static Public Attributes | |
static const std::string | DB_URI_DEFAULT = "mongodb://localhost:27017" |
static const std::string | DB_NAME_KNOWROB = "knowrob" |
static const std::string | DB_NAME_TESTS = "knowrob_test" |
static const std::string | COLL_NAME_TRIPLES = "triples" |
static const std::string | COLL_NAME_TESTS = "triples_test" |
Static Public Attributes inherited from knowrob::QueryableStorage | |
static AtomPtr | versionProperty = IRIAtom::Tabled("http://knowrob.org/kb/knowrob.owl#hasVersionOfOrigin") |
Protected Member Functions | |
void | initializeMongo (const std::shared_ptr< mongo::Collection > &tripleCollection) |
bool | dropOrigin (std::string_view origin) |
mongo::TripleStore | acquireStore () const |
void | releaseStore (mongo::TripleStore &store) const |
void | initializeMongo (const std::shared_ptr< mongo::Collection > &tripleCollection) |
bool | dropOrigin (std::string_view origin) |
mongo::TripleStore | acquireStore () const |
void | releaseStore (mongo::TripleStore &store) const |
Protected Member Functions inherited from knowrob::Storage | |
void | enableFeature (StorageFeature feature) |
void | setStorageLanguage (PluginLanguage storageLanguage) |
void | enableFeature (StorageFeature feature) |
void | setStorageLanguage (PluginLanguage storageLanguage) |
Protected Member Functions inherited from knowrob::DataSourceHandler | |
virtual bool | loadDataSourceWithUnknownFormat (const DataSourcePtr &) |
virtual bool | loadDataSourceWithUnknownFormat (const DataSourcePtr &) |
Static Protected Member Functions | |
static void | iterate (mongo::TripleCursor &cursor, const TripleVisitor &visitor) |
static std::shared_ptr< mongo::Collection > | connect (const boost::property_tree::ptree &config) |
static std::shared_ptr< mongo::Collection > | connect (std::string_view uri, std::string_view db, std::string_view collection) |
static std::string | getDBName (const boost::property_tree::ptree &config) |
static std::string | getCollectionName (const boost::property_tree::ptree &config) |
static std::string | getURI (const boost::property_tree::ptree &config) |
static void | iterate (mongo::TripleCursor &cursor, const TripleVisitor &visitor) |
static std::shared_ptr< mongo::Collection > | connect (const boost::property_tree::ptree &config) |
static std::shared_ptr< mongo::Collection > | connect (std::string_view uri, std::string_view db, std::string_view collection) |
static std::string | getDBName (const boost::property_tree::ptree &config) |
static std::string | getCollectionName (const boost::property_tree::ptree &config) |
static std::string | getURI (const boost::property_tree::ptree &config) |
Protected Attributes | |
std::shared_ptr< mongo::Collection > | tripleCollection_ |
std::shared_ptr< mongo::Collection > | oneCollection_ |
std::shared_ptr< mongo::MongoTaxonomy > | taxonomy_ |
bool | isReadOnly_ |
std::mutex | storeMutex_ |
std::list< mongo::TripleStore > | connections_ |
Protected Attributes inherited from knowrob::Storage | |
std::map< std::string, std::string > | originVersions_ |
std::shared_ptr< Vocabulary > | vocabulary_ |
StorageFeatures | features_ |
PluginLanguage | storageLanguage_ |
Protected Attributes inherited from knowrob::DataSourceHandler | |
std::map< std::string, DataSourceLoader > | dataSourceHandler_ |
Friends | |
class | ConnectionRAII |
Additional Inherited Members | |
Static Public Member Functions inherited from knowrob::QueryableStorage | |
static std::shared_ptr< AnswerYes > | yes (const GraphPathQueryPtr &original, const GraphQueryExpansionPtr &expansion, const BindingsPtr &bindings) |
static std::shared_ptr< AnswerNo > | no (const GraphPathQueryPtr &q) |
static std::shared_ptr< AnswerYes > | yes (const GraphPathQueryPtr &original, const GraphQueryExpansionPtr &expansion, const BindingsPtr &bindings) |
static std::shared_ptr< AnswerNo > | no (const GraphPathQueryPtr &q) |
A knowledge graph implemented with MongoDB.
Definition at line 26 of file MongoKnowledgeGraph.h.
MongoKnowledgeGraph::MongoKnowledgeGraph | ( | ) |
Definition at line 58 of file MongoKnowledgeGraph.cpp.
|
overridedefault |
knowrob::MongoKnowledgeGraph::MongoKnowledgeGraph | ( | ) |
|
overridedefault |
|
protected |
Definition at line 70 of file MongoKnowledgeGraph.cpp.
|
protected |
|
overridevirtual |
Iterate over all triples in the model.
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
Definition at line 409 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Iterate over all triples in the model.
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
|
overridevirtual |
Iterate over all triples in the model that have a given origin.
origin | the origin of the triples. |
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
Definition at line 414 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Iterate over all triples in the model that have a given origin.
origin | the origin of the triples. |
callback | the callback to handle the triples. |
Implements knowrob::QueryableStorage.
|
staticprotected |
Definition at line 191 of file MongoKnowledgeGraph.cpp.
|
staticprotected |
|
staticprotected |
Definition at line 178 of file MongoKnowledgeGraph.cpp.
|
staticprotected |
|
overridevirtual |
callback | a function that is called for each resource and its count. |
Implements knowrob::QueryableStorage.
Definition at line 332 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
callback | a function that is called for each resource and its count. |
Implements knowrob::QueryableStorage.
|
inline |
|
inline |
|
inline |
Definition at line 60 of file MongoKnowledgeGraph.h.
|
inline |
Definition at line 60 of file MongoKnowledgeGraph.h.
void MongoKnowledgeGraph::drop | ( | ) |
Delete all statements in the database. Note: ths will also delete all indices which need to be re-created afterwards.
Definition at line 227 of file MongoKnowledgeGraph.cpp.
void knowrob::MongoKnowledgeGraph::drop | ( | ) |
Delete all statements in the database. Note: ths will also delete all indices which need to be re-created afterwards.
|
protected |
Definition at line 320 of file MongoKnowledgeGraph.cpp.
|
protected |
|
overridevirtual |
Iterate over all triples in the model.
visitor | the callback to handle the triples. |
Reimplemented from knowrob::QueryableStorage.
Definition at line 369 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Iterate over all triples in the model.
visitor | the callback to handle the triples. |
Reimplemented from knowrob::QueryableStorage.
|
staticprotected |
Definition at line 201 of file MongoKnowledgeGraph.cpp.
|
staticprotected |
|
staticprotected |
Definition at line 195 of file MongoKnowledgeGraph.cpp.
|
staticprotected |
|
staticprotected |
Definition at line 207 of file MongoKnowledgeGraph.cpp.
|
staticprotected |
|
overridevirtual |
Initialize this backend from a property tree.
config | a property tree. |
Implements knowrob::Storage.
Definition at line 108 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Initialize this backend from a property tree.
config | a property tree. |
Implements knowrob::Storage.
bool MongoKnowledgeGraph::initializeBackend | ( | std::string_view | db_uri, |
std::string_view | db_name = "knowrob" , |
||
std::string_view | collectionName = "triples" |
||
) |
Initialize the knowledge graph with a MongoDB URI.
db_uri | the URI string used to connect to the database. |
db_name | the name of the database. |
collectionName | the name of the collection for triples. |
Definition at line 96 of file MongoKnowledgeGraph.cpp.
bool knowrob::MongoKnowledgeGraph::initializeBackend | ( | std::string_view | db_uri, |
std::string_view | db_name = "knowrob" , |
||
std::string_view | collectionName = "triples" |
||
) |
|
protected |
|
protected |
Definition at line 147 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Add assertions to this backend.
triples | a set of triples. |
Implements knowrob::Storage.
Definition at line 249 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Add assertions to this backend.
triples | a set of triples. |
Implements knowrob::Storage.
|
overridevirtual |
Add an assertion to this backend.
triple | a triple. |
Implements knowrob::Storage.
Definition at line 233 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Add an assertion to this backend.
triple | a triple. |
Implements knowrob::Storage.
|
inlineoverridevirtual |
Implements knowrob::QueryableStorage.
Definition at line 110 of file MongoKnowledgeGraph.h.
|
inlineoverridevirtual |
Implements knowrob::QueryableStorage.
Definition at line 110 of file MongoKnowledgeGraph.h.
|
inline |
Definition at line 65 of file MongoKnowledgeGraph.h.
|
inline |
Definition at line 65 of file MongoKnowledgeGraph.h.
|
staticprotected |
Definition at line 354 of file MongoKnowledgeGraph.cpp.
|
staticprotected |
BindingsCursorPtr MongoKnowledgeGraph::lookup | ( | const GraphTerm & | query | ) |
Lookup up a path of matching triples. The lookup pipeline includes a step for each expression in the vector in the same order as the expressions are ordered in the vector.
query | a path query |
Definition at line 456 of file MongoKnowledgeGraph.cpp.
mongo::BindingsCursorPtr knowrob::MongoKnowledgeGraph::lookup | ( | const GraphTerm & | query | ) |
Lookup up a path of matching triples. The lookup pipeline includes a step for each expression in the vector in the same order as the expressions are ordered in the vector.
query | a path query |
BindingsCursorPtr MongoKnowledgeGraph::lookup | ( | const TriplePattern & | query | ) |
Lookup up all matching triples.
query | a triple pattern |
Definition at line 451 of file MongoKnowledgeGraph.cpp.
mongo::BindingsCursorPtr knowrob::MongoKnowledgeGraph::lookup | ( | const TriplePattern & | query | ) |
Lookup up all matching triples.
query | a triple pattern |
|
overridevirtual |
query | a framed triple pattern. |
visitor | a function that is called for each matching framed triple. |
Reimplemented from knowrob::QueryableStorage.
Definition at line 421 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
query | a framed triple pattern. |
visitor | a function that is called for each matching framed triple. |
Reimplemented from knowrob::QueryableStorage.
|
overridevirtual |
Submits a graph query to this storage.
query | a graph query |
callback | a function that is called for each answer to the query. |
Implements knowrob::QueryableStorage.
Definition at line 461 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Submits a graph query to this storage.
query | a graph query |
callback | a function that is called for each answer to the query. |
Implements knowrob::QueryableStorage.
|
protected |
Definition at line 89 of file MongoKnowledgeGraph.cpp.
|
protected |
|
overridevirtual |
Delete all matching statements from this backend.
triples | a set of triples. |
Implements knowrob::Storage.
Definition at line 293 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Delete all matching statements from this backend.
triples | a set of triples. |
Implements knowrob::Storage.
|
overridevirtual |
Delete all statements with a given origin from this backend.
origin | the origin of the statements to be deleted. |
Implements knowrob::Storage.
Definition at line 328 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Delete all statements with a given origin from this backend.
origin | the origin of the statements to be deleted. |
Implements knowrob::Storage.
|
overridevirtual |
Delete the first matching statement from this backend.
triple | a triple. |
Implements knowrob::Storage.
Definition at line 276 of file MongoKnowledgeGraph.cpp.
|
overridevirtual |
Delete the first matching statement from this backend.
triple | a triple. |
Implements knowrob::Storage.
|
inline |
|
inline |
|
friend |
Definition at line 170 of file MongoKnowledgeGraph.h.
|
static |
Definition at line 32 of file MongoKnowledgeGraph.h.
|
static |
Definition at line 31 of file MongoKnowledgeGraph.h.
|
mutableprotected |
Definition at line 137 of file MongoKnowledgeGraph.h.
|
static |
Definition at line 29 of file MongoKnowledgeGraph.h.
|
static |
Definition at line 30 of file MongoKnowledgeGraph.h.
|
static |
Register the backend with the BackendManager
Definition at line 28 of file MongoKnowledgeGraph.h.
|
protected |
Definition at line 134 of file MongoKnowledgeGraph.h.
|
protected |
Definition at line 132 of file MongoKnowledgeGraph.h.
|
mutableprotected |
Definition at line 136 of file MongoKnowledgeGraph.h.
|
protected |
Definition at line 133 of file MongoKnowledgeGraph.h.
|
protected |
Definition at line 131 of file MongoKnowledgeGraph.h.