memgraph/storage/vertex.hpp

44 lines
1.0 KiB
C++
Raw Normal View History

#pragma once
2015-07-07 22:18:26 +08:00
#include <vector>
2015-10-14 02:32:54 +08:00
#include "model/properties/jsonwriter.hpp"
#include "model/record.hpp"
2015-07-07 22:18:26 +08:00
#include "edge.hpp"
2015-07-31 18:31:08 +08:00
struct Vertex : public Record<Vertex>
2015-07-07 22:18:26 +08:00
{
std::vector<Edge*> in;
2015-07-31 18:31:08 +08:00
std::vector<Edge*> out;
2015-07-07 22:18:26 +08:00
};
inline std::ostream& operator<<(std::ostream& stream, Vertex& record)
{
2015-10-14 02:32:54 +08:00
StringBuffer buffer;
JsonWriter<StringBuffer> writer(buffer);
// dump properties in this buffer
record.properties.accept(writer);
2015-10-14 02:44:14 +08:00
writer.finish();
return stream << "Vertex"
<< "(xmin = " << record.tx.min()
<< ", xmax = " << record.tx.max()
2015-10-14 02:32:54 +08:00
<< "): " << buffer.str();
}
// TODO: find more appropriate place for this
inline std::string properties_to_string(Vertex* vertex)
{
// make a string buffer
StringBuffer buffer;
JsonWriter<StringBuffer> writer(buffer);
// dump properties in this buffer
vertex->properties.accept(writer);
writer.finish();
// respond to the use with the buffer
return std::move(buffer.str());
}