9#include "absl/status/status.h"
10#include "absl/strings/str_cat.h"
17 if (mkdir(
path.c_str(), 0755) != 0 && errno != EEXIST) {
18 return absl::ErrnoToStatus(errno, absl::StrCat(
"can't make ",
path));
20 std::ofstream
nodes(
path +
"/nodes.jsonl");
21 std::ofstream relationships(
path +
"/relationships.csv");
22 if (!
nodes || !relationships) {
23 return absl::UnavailableError(absl::StrCat(
"can't write in ",
path));
28 nodes <<
"{\"id\": " << node
34 relationships <<
"from,to,type\n";
37 relationships << record.
from <<
',' << record.
to <<
',' << graph.
type(
id)
40 return absl::OkStatus();
A graph kept in three files of records, one for nodes, one for relationships and one for their proper...
size_t relationship_count() const
size_t node_count() const
std::string label(NodeId node) const
std::vector< Property > Properties(NodeId node) const
Returns the properties of a node or a relationship, in the order they were first set.
RelationshipRecord relationship(RelationshipId id) const
std::string type(RelationshipId relationship) const
std::string name(NodeId node) const
std::string PropertiesJson(const std::vector< Property > &properties)
Returns properties as a JSON object, with a field for each key.
std::string JsonString(std::string_view text)
What sg serve answers with, as JSON.
absl::Status Export(const Graph &graph, const std::string &path)
Writes the graph into the folder at path, for programs outside the database to read,...
std::vector< NodeId > nodes
A relationship on disk: its type's token, the nodes it joins, the next relationship that starts at fr...