GraphScope icon indicating copy to clipboard operation
GraphScope copied to clipboard

Proposal of Graph File Format `Reader` and `Writer` APIs

Open acezen opened this issue 3 years ago • 0 comments

Reader

# create a reader with graph meta yaml
void Init(FILE meta_file);

# The graph meta API
int VerticesNum(vertex_label_name);
int EdgeNum(edge_label_name);
int TotalVerticeNum();
int TotalEdgeNum();
int VertexLabelNum();
int EdgeLabelNum();

# Get the chunk number of certain vertex or edge
int GetVertexChunkNumber(vertex_label);
int GetEdgeChunkNumber(src_label, edge_label, dst_label);

# Get the certain chunk of vertice as stream to read
Stream GetVertice(int label, int chunk_offset);
Stream GetVerticeProperty(label, property, chunk_offset);
Stream GetVertexProperty(global_vertex_id);
# Get the certain chunk of edges as stream to read
# 三元组 (src_label, e_label, dst_label) 定义一种边
Stream GetEdges((src_label, e_label, dst_label), int chunk_offset);
Stream GetEdgesProperty((src_label,e_label, dst_label), int chunk_offset);

# 存在offset表的情况, 通过CSR结构读取点相关的边
Stream GetOffsets((src_label,e_label, dst_label), int chunk_offset);
# Get the edges of certain vertex
Stream GetEdges(global_vertex_id, (src_label,e_label, dst_label));
Stream GetEdgeProperties(global_vertex_id, (src_label,e_label, dst_label));

# TODO: 考虑外部点,跨分区边

Writer

void Init(path_prefix, comm_spec);

# set some graph meta message
void Set(vertex_label_num, edge_label_num, list<vertex_label>, list<edge_label>,
         total_vertex_num, total_edge_num, vertex_chunk_size, edge_chunk_size);

# maping global vertex id in writer, dumps the vertices to chunks, and gather a global vertex mapping
Status DumpVertices(List<VertexTable>);

# dumps the properties to chunks base on the global vertex mapping
Status DumpVertexProperties(PropertyTable, vertex_label);

# dumps the edges to chunks base on the global vertex mapping
Status DumpEdges(EdgesTable, (src_label, edge_label, dst_label));

# dumps the edges property to chunks base on the global vertex mapping
Status DumpEdgeProperty(EdgesPropertyTable, (src_label, edge_label, dst_label));

# TODO: 考虑shuffle

acezen avatar Jul 28 '22 08:07 acezen