-
Notifications
You must be signed in to change notification settings - Fork 1
FInish the process #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jiajunly
wants to merge
14
commits into
TuGraph-contrib:main
Choose a base branch
from
jiajunly:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
04ab593
Add GraphAr to proposal
jiajunly 0ffa6f7
Merge branch 'main' of github.com:jasinliu/data-migration
jiajunly 53fc237
get config json demo
jiajunly 038c19b
update demo to use relative path
jiajunly 8b60cdd
update the process
jiajunly 11253a8
update neo4j2graphar
jiajunly b238ca2
update submodule
5a2b391
update the doc
jiajunly 171fa96
update the image
jiajunly 0aefd38
update the doc
jiajunly 3b1b965
change the data and proposal
jiajunly 2cad3ec
update module
jiajunly 1828a38
show the bug
jiajunly 2cc6179
update the migration
jiajunly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # GraphAr链接 | ||
|
|
||
| 下载GraphAr源码,编译cpp文件之后,install会将libgar.so共享库和gar头文件安装到系统中,但是arrow的头文件和lib目录下的静态库没有安装到系统中,编写项目需要手动链接,或者手动安装,不然会报错 | ||
|
|
||
| 目前tugraph-compile的docker环境中, 完整使用GraphAr, cmake配置至少需要包含以下部分 | ||
|
|
||
| ```cmake | ||
| cmake_minimum_required(VERSION 3.15) | ||
|
|
||
| project(graph-archive-demo) | ||
|
|
||
| find_package(Threads REQUIRED) | ||
| add_definitions(-DGAR_NAMESPACE=GraphArchive) | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") | ||
|
|
||
| add_executable(show show.cpp) | ||
| target_link_libraries(show PRIVATE gar stdc++fs Threads::Threads | ||
| "/root/GraphAr/cpp/build/arrow_ep-prefix/lib/libarrow.a" | ||
| "/root/GraphAr/cpp/build/arrow_ep-prefix/lib/libarrow_dataset.a" | ||
| "/root/GraphAr/cpp/build/arrow_ep-prefix/lib/libarrow_bundled_dependencies.a" | ||
| "/root/GraphAr/cpp/build/arrow_ep-prefix/lib/libparquet.a" | ||
| ) | ||
| target_include_directories(show SYSTEM BEFORE PRIVATE /root/GraphAr/cpp/build/arrow_ep-prefix/include) | ||
| ``` | ||
|
|
||
| GraphAr编译后打包移动,build目录下cmake和make相关配置文件中的路径都是绝对路径,目前只有在相同系统和相同路径情况下可以复用 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,12 @@ | ||
| cmake_minimum_required(VERSION 3.15) | ||
|
|
||
| set(GAR_MAJOR_VERSION 0) | ||
| set(GAR_MINOR_VERSION 1) | ||
| set(GAR_PATCH_VERSION 0) | ||
| set(GAR_VERSION ${GAR_MAJOR_VERSION}.${GAR_MINOR_VERSION}.${GAR_PATCH_VERSION}) | ||
|
|
||
| project(graph-archive-demo LANGUAGES C CXX VERSION ${GAR_VERSION}) | ||
| project(graph-archive-demo) | ||
|
|
||
| find_package(Threads REQUIRED) | ||
| add_definitions(-DGAR_NAMESPACE=GraphArchive) | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -Wall") | ||
|
|
||
| add_executable(show show.cpp) | ||
| target_link_libraries(show PRIVATE gar stdc++fs) | ||
| set(TARGET "config") | ||
|
|
||
| add_executable(${TARGET} ${TARGET}.cpp) | ||
| target_link_libraries(${TARGET} PRIVATE gar stdc++fs Threads::Threads) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| #include <iostream> | ||
| #include "gar/graph.h" | ||
| #include "gar/graph_info.h" | ||
| #include "json.hpp" | ||
| #include <map> | ||
| #include <utility> | ||
|
|
||
| typedef std::map<std::string, std::string> Dict; | ||
|
|
||
| void ParseType(const GAR_NAMESPACE::DataType data_type, std::string &type_name) | ||
| { | ||
| switch (data_type.id()) | ||
| { | ||
| case GAR_NAMESPACE::Type::BOOL: | ||
| type_name = "BOOL"; | ||
| break; | ||
| case GAR_NAMESPACE::Type::INT32: | ||
| type_name = "INT32"; | ||
| break; | ||
| case GAR_NAMESPACE::Type::INT64: | ||
| type_name = "INT64"; | ||
| break; | ||
| case GAR_NAMESPACE::Type::FLOAT: | ||
| type_name = "FLOAT"; | ||
| break; | ||
| case GAR_NAMESPACE::Type::DOUBLE: | ||
| type_name = "DOUBLE"; | ||
| break; | ||
| case GAR_NAMESPACE::Type::STRING: | ||
| type_name = "STRING"; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| void CheckAdjListType(const GAR_NAMESPACE::EdgeInfo &edge_info, GAR_NAMESPACE::AdjListType &adj_list_type) | ||
| { | ||
| for (std::uint8_t i = 0; i <= static_cast<std::uint8_t>(GAR_NAMESPACE::AdjListType::ordered_by_dest); ++i) | ||
| { | ||
| GAR_NAMESPACE::AdjListType type = static_cast<GAR_NAMESPACE::AdjListType>(i); | ||
| if (edge_info.ContainAdjList(type)) | ||
| adj_list_type = type; | ||
| } | ||
| } | ||
|
|
||
| void WalkVertex(const GAR_NAMESPACE::VertexInfo &ver_info, std::string &primary, std::vector<Dict> &props, std::vector<std::string> &prop_names) | ||
| { | ||
| auto ver_groups = ver_info.GetPropertyGroups(); | ||
| for (auto ver_props : ver_groups) | ||
| { | ||
| for (auto prop : ver_props.GetProperties()) | ||
| { | ||
| if (prop.is_primary) | ||
| primary = prop.name; | ||
| prop_names.emplace_back(prop.name); | ||
| std::string type_name; | ||
| ParseType(prop.type, type_name); | ||
| props.emplace_back(std::map<std::string, std::string>{ | ||
| {"name", prop.name}, | ||
| {"type", type_name}}); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| void WalkEdge(const GAR_NAMESPACE::EdgeInfo &edge_info, std::vector<Dict> &props, std::vector<std::string> &prop_names) | ||
| { | ||
| GAR_NAMESPACE::AdjListType type; | ||
| CheckAdjListType(edge_info, type); | ||
| auto edge_groups = edge_info.GetPropertyGroups(type).value(); | ||
| for (auto edge_props : edge_groups) | ||
| { | ||
| for (auto prop : edge_props.GetProperties()) | ||
| { | ||
| prop_names.emplace_back(prop.name); | ||
| std::string type_name; | ||
| ParseType(prop.type, type_name); | ||
| props.emplace_back(std::map<std::string, std::string>{ | ||
| {"name", prop.name}, | ||
| {"type", type_name}}); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| std::string path = "/root/GraphAr/testing/ldbc_sample/parquet/ldbc_sample.graph.yml"; | ||
| auto graph_info = GAR_NAMESPACE::GraphInfo::Load(path).value(); | ||
|
|
||
| nlohmann::json json_conf; | ||
| json_conf["schema"] = {}; | ||
| json_conf["files"] = {}; | ||
| auto vertex_infos = graph_info.GetVertexInfos(); | ||
| for (const auto &[key, value] : vertex_infos) | ||
| { | ||
| nlohmann::json schema_node; | ||
| schema_node["label"] = value.GetLabel(); | ||
| schema_node["type"] = "VERTEX"; | ||
| std::string primary; | ||
| std::vector<Dict> properties; | ||
| std::vector<std::string> prop_names; | ||
| WalkVertex(value, primary, properties, prop_names); | ||
| schema_node["primary"] = primary; | ||
| schema_node["properties"] = properties; | ||
| json_conf["schema"].push_back(schema_node); | ||
|
|
||
| nlohmann::json file_node; | ||
| file_node["path"] = path; | ||
| file_node["format"] = "GraphAr"; | ||
| file_node["label"] = value.GetLabel(); | ||
| file_node["columns"] = prop_names; | ||
| json_conf["files"].push_back(file_node); | ||
| } | ||
|
|
||
| auto edge_infos = graph_info.GetEdgeInfos(); | ||
| for (const auto &[key, value] : edge_infos) | ||
| { | ||
| nlohmann::json schema_node; | ||
| schema_node["label"] = value.GetEdgeLabel(); | ||
| schema_node["type"] = "EDGE"; | ||
| std::vector<Dict> properties; | ||
| std::vector<std::string> prop_names = {"SRC_ID", "DST_ID"}; | ||
| WalkEdge(value, properties, prop_names); | ||
| schema_node["properties"] = properties; | ||
| json_conf["schema"].push_back(schema_node); | ||
|
|
||
| nlohmann::json file_node; | ||
| file_node["path"] = path; | ||
| file_node["format"] = "GraphAr"; | ||
| file_node["label"] = value.GetEdgeLabel(); | ||
| file_node["SRC_ID"] = value.GetSrcLabel(); | ||
| file_node["DST_ID"] = value.GetDstLabel(); | ||
| file_node["columns"] = prop_names; | ||
| json_conf["files"].push_back(file_node); | ||
| } | ||
|
|
||
| std::string json_str = json_conf.dump(); | ||
| std::cout << json_str << std::endl; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.