Skip to content

Commit

Permalink
feat!(format):change the naming of vertex/edge unique identify type f…
Browse files Browse the repository at this point in the history
…rom `label` to `type` (#605)



---------

Signed-off-by: Elssky <1914127671@qq.com>
Co-authored-by: acezen <qiaozi.zwb@alibaba-inc.com>
  • Loading branch information
Elssky and acezen authored Aug 27, 2024
1 parent 5ce3a0b commit bbd562e
Show file tree
Hide file tree
Showing 55 changed files with 707 additions and 712 deletions.
16 changes: 8 additions & 8 deletions cpp/examples/bfs_father_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// get the "person_knows_person" edges of graph
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto maybe_edges = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::unordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_edges =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::unordered_by_source);
ASSERT(!maybe_edges.has_error());
auto& edges = maybe_edges.value();

Expand Down Expand Up @@ -130,16 +130,16 @@ int main(int argc, char* argv[]) {
ASSERT(writer.WriteTable(table, group, 0).ok());

// construct a new graph
src_label = "person";
edge_label = "bfs";
dst_label = "person";
src_type = "person";
edge_type = "bfs";
dst_type = "person";
int edge_chunk_size = 1024, src_chunk_size = 100, dst_chunk_size = 100;
bool directed = true;
auto version = graphar::InfoVersion::Parse("gar/v1").value();
auto al = graphar::CreateAdjacentList(graphar::AdjListType::ordered_by_source,
graphar::FileType::CSV);
auto new_edge_info = graphar::CreateEdgeInfo(
src_label, edge_label, dst_label, edge_chunk_size, src_chunk_size,
src_type, edge_type, dst_type, edge_chunk_size, src_chunk_size,
dst_chunk_size, directed, {al}, {}, "", version);
ASSERT(new_edge_info->IsValidated());
// save & dump
Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/bfs_pull_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto maybe_edges = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_dest);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_edges =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_dest);
ASSERT(!maybe_edges.has_error());
auto& edges = maybe_edges.value();

Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/bfs_push_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto maybe_edges = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_edges =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(!maybe_edges.has_error());
auto& edges = maybe_edges.value();

Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/bfs_stream_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto maybe_edges = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::unordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_edges =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::unordered_by_source);
ASSERT(!maybe_edges.has_error());
auto& edges = maybe_edges.value();

Expand Down
12 changes: 6 additions & 6 deletions cpp/examples/bgl_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto maybe_edges = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_edges =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(!maybe_edges.has_error());
auto& edges = maybe_edges.value();

Expand Down Expand Up @@ -108,10 +108,10 @@ int main(int argc, char* argv[]) {
auto group =
graphar::CreatePropertyGroup(property_vector, graphar::FileType::PARQUET);
// construct new vertex info
std::string vertex_label = "cc_result", vertex_prefix = "result/";
std::string type = "cc_result", vertex_prefix = "result/";
int chunk_size = 100;
auto version = graphar::InfoVersion::Parse("gar/v1").value();
auto new_info = graphar::CreateVertexInfo(vertex_label, chunk_size, {group},
auto new_info = graphar::CreateVertexInfo(type, chunk_size, {group},
vertex_prefix, version);
// dump new vertex info
ASSERT(new_info->IsValidated());
Expand Down
14 changes: 7 additions & 7 deletions cpp/examples/cc_push_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto expect1 = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto expect1 =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(!expect1.has_error());
auto& edges1 = expect1.value();
auto expect2 = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_dest);
auto expect2 =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_dest);
ASSERT(!expect2.has_error());
auto& edges2 = expect2.value();

Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/cc_stream_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto maybe_edges = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_edges =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(!maybe_edges.has_error());
auto& edges = maybe_edges.value();

Expand Down
24 changes: 12 additions & 12 deletions cpp/examples/construct_info_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int main(int argc, char* argv[]) {
auto version = graphar::InfoVersion::Parse("gar/v1").value();

// meta info
std::string vertex_label = "person", vertex_prefix = "vertex/person/";
std::string type = "person", vertex_prefix = "vertex/person/";
int chunk_size = 100;

// construct properties and property groups
Expand All @@ -43,11 +43,11 @@ int main(int argc, char* argv[]) {
graphar::CreatePropertyGroup(property_vector_2, graphar::FileType::ORC);

// create vertex info
auto vertex_info = graphar::CreateVertexInfo(
vertex_label, chunk_size, {group1}, vertex_prefix, version);
auto vertex_info = graphar::CreateVertexInfo(type, chunk_size, {group1},
vertex_prefix, version);

ASSERT(vertex_info != nullptr);
ASSERT(vertex_info->GetLabel() == vertex_label);
ASSERT(vertex_info->GetType() == type);
ASSERT(vertex_info->GetChunkSize() == chunk_size);
ASSERT(vertex_info->GetPropertyGroups().size() == 1);
ASSERT(vertex_info->HasProperty("id"));
Expand Down Expand Up @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) {

/*------------------construct edge info------------------*/
// meta info
std::string src_label = "person", edge_label = "knows", dst_label = "person",
std::string src_type = "person", edge_type = "knows", dst_type = "person",
edge_prefix = "edge/person_knows_person/";
int edge_chunk_size = 1024, src_chunk_size = 100, dst_chunk_size = 100;
bool directed = false;
Expand All @@ -94,13 +94,13 @@ int main(int argc, char* argv[]) {

// create edge info
auto edge_info = graphar::CreateEdgeInfo(
src_label, edge_label, dst_label, edge_chunk_size, src_chunk_size,
src_type, edge_type, dst_type, edge_chunk_size, src_chunk_size,
dst_chunk_size, directed, adjacent_lists, {group3}, edge_prefix, version);

ASSERT(edge_info != nullptr);
ASSERT(edge_info->GetSrcLabel() == src_label);
ASSERT(edge_info->GetEdgeLabel() == edge_label);
ASSERT(edge_info->GetDstLabel() == dst_label);
ASSERT(edge_info->GetSrcType() == src_type);
ASSERT(edge_info->GetEdgeType() == edge_type);
ASSERT(edge_info->GetDstType() == dst_type);
ASSERT(edge_info->GetChunkSize() == edge_chunk_size);
ASSERT(edge_info->GetSrcChunkSize() == src_chunk_size);
ASSERT(edge_info->GetDstChunkSize() == dst_chunk_size);
Expand Down Expand Up @@ -154,14 +154,14 @@ int main(int argc, char* argv[]) {
ASSERT(graph_info->GetName() == name);
ASSERT(graph_info->GetPrefix() == prefix);
ASSERT(graph_info->GetVertexInfos().size() == 1);
ASSERT(graph_info->GetVertexInfo(vertex_label) != nullptr);
auto vertex_info_from_graph = graph_info->GetVertexInfo(vertex_label);
ASSERT(graph_info->GetVertexInfo(type) != nullptr);
auto vertex_info_from_graph = graph_info->GetVertexInfo(type);
ASSERT(vertex_info_from_graph != nullptr);
ASSERT(vertex_info_from_graph->HasPropertyGroup(group1));
ASSERT(vertex_info_from_graph->HasPropertyGroup(group2));
ASSERT(graph_info->GetEdgeInfos().size() == 1);
auto edge_info_from_graph =
graph_info->GetEdgeInfo(src_label, edge_label, dst_label);
graph_info->GetEdgeInfo(src_type, edge_type, dst_type);
ASSERT(edge_info_from_graph != nullptr);
ASSERT(edge_info_from_graph->PropertyGroupNum() == 1);
ASSERT(edge_info_from_graph->HasPropertyGroup(group3));
Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/high_level_reader_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ void vertices_collection(

void edges_collection(const std::shared_ptr<graphar::GraphInfo>& graph_info) {
// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto expect = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto expect =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(!expect.has_error());
auto edges = expect.value();

Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/low_level_reader_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ void vertex_property_chunk_info_reader(
void adj_list_chunk_info_reader(
const std::shared_ptr<graphar::GraphInfo>& graph_info) {
// construct reader
std::string src_label = "person", edge_label = "knows", dst_label = "person";
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_reader = graphar::AdjListChunkInfoReader::Make(
graph_info, src_label, edge_label, dst_label,
graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(maybe_reader.status().ok());
auto reader = maybe_reader.value();
Expand Down Expand Up @@ -92,11 +92,11 @@ void adj_list_chunk_info_reader(
void adj_list_property_chunk_info_reader(
const std::shared_ptr<graphar::GraphInfo>& graph_info) {
// construct reader
std::string src_label = "person", edge_label = "knows", dst_label = "person",
std::string src_type = "person", edge_type = "knows", dst_type = "person",
property_name = "creationDate";

auto maybe_property_reader = graphar::AdjListPropertyChunkInfoReader::Make(
graph_info, src_label, edge_label, dst_label, property_name,
graph_info, src_type, edge_type, dst_type, property_name,
graphar::AdjListType::ordered_by_source);
ASSERT(maybe_property_reader.status().ok());
auto reader = maybe_property_reader.value();
Expand Down
14 changes: 7 additions & 7 deletions cpp/examples/mid_level_reader_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ void vertex_property_chunk_reader(
void adj_list_chunk_reader(
const std::shared_ptr<graphar::GraphInfo>& graph_info) {
// create reader
std::string src_label = "person", edge_label = "knows", dst_label = "person";
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_reader = graphar::AdjListArrowChunkReader::Make(
graph_info, src_label, edge_label, dst_label,
graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(maybe_reader.status().ok());

Expand Down Expand Up @@ -124,10 +124,10 @@ void adj_list_chunk_reader(
void adj_list_property_chunk_reader(
const std::shared_ptr<graphar::GraphInfo>& graph_info) {
// create reader
std::string src_label = "person", edge_label = "knows", dst_label = "person",
std::string src_type = "person", edge_type = "knows", dst_type = "person",
property_name = "creationDate";
auto maybe_reader = graphar::AdjListPropertyArrowChunkReader::Make(
graph_info, src_label, edge_label, dst_label, property_name,
graph_info, src_type, edge_type, dst_type, property_name,
graphar::AdjListType::ordered_by_source);
ASSERT(maybe_reader.status().ok());
auto reader = maybe_reader.value();
Expand Down Expand Up @@ -165,7 +165,7 @@ void adj_list_property_chunk_reader(
auto filter = graphar::_And(expr1, expr2);
std::vector<std::string> expected_cols{"creationDate"};
auto maybe_filter_reader = graphar::AdjListPropertyArrowChunkReader::Make(
graph_info, src_label, edge_label, dst_label, property_name,
graph_info, src_type, edge_type, dst_type, property_name,
graphar::AdjListType::ordered_by_source);
ASSERT(maybe_filter_reader.status().ok());
auto filter_reader = maybe_filter_reader.value();
Expand All @@ -181,9 +181,9 @@ void adj_list_property_chunk_reader(
void adj_list_offset_chunk_reader(
const std::shared_ptr<graphar::GraphInfo>& graph_info) {
// create reader
std::string src_label = "person", edge_label = "knows", dst_label = "person";
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_reader = graphar::AdjListOffsetArrowChunkReader::Make(
graph_info, src_label, edge_label, dst_label,
graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(maybe_reader.status().ok());
auto reader = maybe_reader.value();
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/mid_level_writer_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void vertex_property_writer(
GetTestingResourceRoot() + "/ldbc_sample/parquet/" + "person.vertex.yml";
auto vertex_meta = graphar::Yaml::LoadFile(vertex_meta_file).value();
auto vertex_info = graphar::VertexInfo::Load(vertex_meta).value();
ASSERT(vertex_info->GetLabel() == "person");
ASSERT(vertex_info->GetType() == "person");

auto maybe_writer = graphar::VertexPropertyWriter::Make(vertex_info, "/tmp/");
ASSERT(maybe_writer.status().ok());
Expand Down
8 changes: 4 additions & 4 deletions cpp/examples/pagerank_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ int main(int argc, char* argv[]) {
std::cout << "num_vertices: " << num_vertices << std::endl;

// construct edges collection
std::string src_label = "person", edge_label = "knows", dst_label = "person";
auto maybe_edges = graphar::EdgesCollection::Make(
graph_info, src_label, edge_label, dst_label,
graphar::AdjListType::ordered_by_source);
std::string src_type = "person", edge_type = "knows", dst_type = "person";
auto maybe_edges =
graphar::EdgesCollection::Make(graph_info, src_type, edge_type, dst_type,
graphar::AdjListType::ordered_by_source);
ASSERT(!maybe_edges.has_error());
auto& edges = maybe_edges.value();

Expand Down
10 changes: 5 additions & 5 deletions cpp/examples/snap_dataset_to_graphar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ int main(int argc, char* argv[]) {
auto version = graphar::InfoVersion::Parse("gar/v1").value();

// meta info
std::string vertex_label = "node", vertex_prefix = "vertex/node/";
std::string type = "node", vertex_prefix = "vertex/node/";

// create vertex info
auto vertex_info = graphar::CreateVertexInfo(vertex_label, VERTEX_CHUNK_SIZE,
{}, vertex_prefix, version);
auto vertex_info = graphar::CreateVertexInfo(type, VERTEX_CHUNK_SIZE, {},
vertex_prefix, version);

// save & dump
ASSERT(!vertex_info->Dump().has_error());
ASSERT(vertex_info->Save(save_path + "node.vertex.yml").ok());

/*------------------construct edge info------------------*/
std::string src_label = "node", edge_label = "links", dst_label = "node",
std::string src_type = "node", edge_type = "links", dst_type = "node",
edge_prefix = "edge/node_links_node/";
bool directed = IS_DIRECTED;

Expand All @@ -66,7 +66,7 @@ int main(int argc, char* argv[]) {
graphar::CreateAdjacentList(ADJLIST_TYPE, PAYLOAD_TYPE)};
// create edge info
auto edge_info = graphar::CreateEdgeInfo(
src_label, edge_label, dst_label, EDGE_CHUNK_SIZE, VERTEX_CHUNK_SIZE,
src_type, edge_type, dst_type, EDGE_CHUNK_SIZE, VERTEX_CHUNK_SIZE,
VERTEX_CHUNK_SIZE, directed, adjacent_lists, {}, edge_prefix, version);

// save & dump
Expand Down
Loading

0 comments on commit bbd562e

Please sign in to comment.