in cpp/src/graphar/graph_info.cc [933:986]
Result<std::string> EdgeInfo::Dump() const noexcept {
if (!IsValidated()) {
return Status::Invalid("The edge info is not validated.");
}
std::string dump_string;
::Yaml::Node node;
try {
node["src_type"] = impl_->src_type_;
node["edge_type"] = impl_->edge_type_;
node["dst_type"] = impl_->dst_type_;
node["chunk_size"] = std::to_string(impl_->chunk_size_);
node["src_chunk_size"] = std::to_string(impl_->src_chunk_size_);
node["dst_chunk_size"] = std::to_string(impl_->dst_chunk_size_);
node["prefix"] = impl_->prefix_;
node["directed"] = impl_->directed_ ? "true" : "false";
for (const auto& adjacent_list : impl_->adjacent_lists_) {
::Yaml::Node adj_list_node;
auto adj_list_type = adjacent_list->GetType();
auto pair = AdjListTypeToOrderedAligned(adj_list_type);
adj_list_node["ordered"] = pair.first ? "true" : "false";
adj_list_node["aligned_by"] = pair.second;
adj_list_node["prefix"] = adjacent_list->GetPrefix();
adj_list_node["file_type"] =
FileTypeToString(adjacent_list->GetFileType());
node["adj_lists"].PushBack();
node["adj_lists"][node["adj_lists"].Size() - 1] = adj_list_node;
}
for (const auto& pg : impl_->property_groups_) {
::Yaml::Node pg_node;
if (!pg->GetPrefix().empty()) {
pg_node["prefix"] = pg->GetPrefix();
}
pg_node["file_type"] = FileTypeToString(pg->GetFileType());
for (const auto& p : pg->GetProperties()) {
::Yaml::Node p_node;
p_node["name"] = p.name;
p_node["data_type"] = p.type->ToTypeName();
p_node["is_primary"] = p.is_primary ? "true" : "false";
p_node["is_nullable"] = p.is_nullable ? "true" : "false";
pg_node["properties"].PushBack();
pg_node["properties"][pg_node["properties"].Size() - 1] = p_node;
}
node["property_groups"].PushBack();
node["property_groups"][node["property_groups"].Size() - 1] = pg_node;
}
if (impl_->version_ != nullptr) {
node["version"] = impl_->version_->ToString();
}
::Yaml::Serialize(node, dump_string);
} catch (const std::exception& e) {
return Status::Invalid("Failed to dump edge info: ", e.what());
}
return dump_string;
}