6 #include <boost/algorithm/string.hpp>
7 #include "knowrob/Logger.h"
8 #include "knowrob/storage/mongo/TripleCursor.h"
9 #include "knowrob/terms/RDFNode.h"
10 #include "knowrob/storage/mongo/bson-helper.h"
16 tripleDocument_(nullptr),
22 const bson_oid_t *tripleOID =
nullptr;
36 }
else if (key ==
"s") {
38 }
else if (key ==
"p") {
40 }
else if (key ==
"graph") {
42 }
else if (key ==
"agent") {
44 }
else if (key ==
"uncertain") {
46 }
else if (key ==
"occasional") {
48 }
else if (key ==
"since") {
50 }
else if (key ==
"until") {
52 }
else if (key ==
"confidence") {
55 }
else if (key ==
"o") {
57 case BSON_TYPE_UTF8: {
74 case BSON_TYPE_DOUBLE:
87 KB_WARN(
"skipping triple with unexpected type '{}' of \"o\" field.",
91 }
else if (key ==
"scope") {
92 bson_iter_t scopeIter, timeIter;
94 bson_iter_find(&scopeIter,
"time");
95 bson_iter_recurse(&scopeIter, &timeIter);
97 while (bson_iter_next(&timeIter)) {
98 std::string_view scopeKey = bson_iter_key(&timeIter);
99 if (scopeKey ==
"since") {
101 if (v && v.value() != 0) tripleData.
setBegin(v.value());
102 }
else if (scopeKey ==
"until") {
104 if (v && v.value() != 0) tripleData.
setEnd(v.value());
virtual void setDoubleValue(double v)=0
virtual void setSubject(std::string_view subject)=0
virtual void setGraph(std::string_view graph)=0
virtual void setIntValue(int v)=0
virtual void setStringValue(std::string_view v)=0
void setConfidence(double confidence)
virtual void setPerspective(std::string_view perspective)=0
void setIsUncertain(bool isUncertain)
virtual void setLongValue(long v)=0
void setIsOccasional(bool isOccasional)
void setBegin(double begin)
virtual void setObjectIRI(std::string_view object)=0
virtual void setObjectBlank(std::string_view str)=0
virtual void setPredicate(std::string_view predicate)=0
bool next(const bson_t **doc, bool ignore_empty=false)
bool nextTriple(Triple &tripleData, const bson_oid_t **tripleOID)
TripleCursor(const std::shared_ptr< Collection > &collection)
const bson_t * tripleDocument_
std::optional< double > bson_iterOptionalDouble(const bson_iter_t *iter)
RDFNodeType rdfNodeTypeGuess(std::string_view str)