-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into zsy/vy-0182
- Loading branch information
Showing
128 changed files
with
13,657 additions
and
2,707 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,97 @@ | ||
/** Copyright 2020 Alibaba Group Holding Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <filesystem> | ||
#include <iostream> | ||
|
||
#include <glog/logging.h> | ||
|
||
#include <boost/program_options.hpp> | ||
|
||
#include "flex/engines/graph_db/database/graph_db.h" | ||
#include "flex/engines/http_server/options.h" | ||
|
||
namespace bpo = boost::program_options; | ||
|
||
int main(int argc, char** argv) { | ||
bpo::options_description desc("Usage:"); | ||
desc.add_options()("help", "Display help message")( | ||
"version,v", "Display version")("parallelism,p", | ||
bpo::value<uint32_t>()->default_value(1), | ||
"parallelism of bulk loader")( | ||
"data-path,d", bpo::value<std::string>(), "data directory path")( | ||
"graph-config,g", bpo::value<std::string>(), "graph schema config file")( | ||
"bulk-load,l", bpo::value<std::string>(), "bulk-load config file"); | ||
google::InitGoogleLogging(argv[0]); | ||
FLAGS_logtostderr = true; | ||
|
||
bpo::variables_map vm; | ||
bpo::store(bpo::command_line_parser(argc, argv).options(desc).run(), vm); | ||
bpo::notify(vm); | ||
|
||
if (vm.count("help")) { | ||
std::cout << desc << std::endl; | ||
return 0; | ||
} | ||
|
||
if (vm.count("version")) { | ||
std::cout << "GraphScope/Flex version " << FLEX_VERSION << std::endl; | ||
return 0; | ||
} | ||
|
||
uint32_t parallelism = vm["parallelism"].as<uint32_t>(); | ||
std::string data_path = ""; | ||
std::string bulk_load_config_path = ""; | ||
std::string graph_schema_path = ""; | ||
|
||
if (!vm.count("graph-config")) { | ||
LOG(ERROR) << "graph-config is required"; | ||
return -1; | ||
} | ||
graph_schema_path = vm["graph-config"].as<std::string>(); | ||
if (!vm.count("data-path")) { | ||
LOG(ERROR) << "data-path is required"; | ||
return -1; | ||
} | ||
data_path = vm["data-path"].as<std::string>(); | ||
if (!vm.count("bulk-load")) { | ||
LOG(ERROR) << "bulk-load-config is required"; | ||
return -1; | ||
} | ||
bulk_load_config_path = vm["bulk-load"].as<std::string>(); | ||
|
||
setenv("TZ", "Asia/Shanghai", 1); | ||
tzset(); | ||
|
||
auto schema = gs::Schema::LoadFromYaml(graph_schema_path); | ||
auto loading_config = | ||
gs::LoadingConfig::ParseFromYamlFile(schema, bulk_load_config_path); | ||
|
||
std::filesystem::path data_dir_path(data_path); | ||
if (!std::filesystem::exists(data_dir_path)) { | ||
std::filesystem::create_directory(data_dir_path); | ||
} | ||
std::filesystem::path serial_path = data_dir_path / "schema"; | ||
if (std::filesystem::exists(serial_path)) { | ||
LOG(WARNING) << "data directory is not empty"; | ||
return 0; | ||
} | ||
|
||
auto loader = gs::LoaderFactory::CreateFragmentLoader( | ||
data_dir_path.string(), schema, loading_config, parallelism); | ||
loader->LoadFragment(); | ||
|
||
return 0; | ||
} |
Oops, something went wrong.