2016-09-25 22:14:36 +08:00
|
|
|
/*=============================================================================
|
2017-01-16 14:12:57 +08:00
|
|
|
# Filename: gbuild.cpp
|
2016-09-25 22:14:36 +08:00
|
|
|
# Author: Bookug Lobert
|
|
|
|
# Mail: 1181955272@qq.com
|
|
|
|
# Last Modified: 2015-10-24 19:27
|
|
|
|
# Description: firstly written by liyouhuan, modified by zengli
|
|
|
|
TODO: add -h/--help for help message
|
|
|
|
=============================================================================*/
|
|
|
|
|
|
|
|
#include "../Util/Util.h"
|
|
|
|
#include "../Database/Database.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2017-01-16 14:12:57 +08:00
|
|
|
//[0]./gbuild [1]data_folder_path [2]rdf_file_path
|
2016-09-25 22:14:36 +08:00
|
|
|
int
|
|
|
|
main(int argc, char * argv[])
|
|
|
|
{
|
|
|
|
//chdir(dirname(argv[0]));
|
2017-03-25 20:08:23 +08:00
|
|
|
//#ifdef DEBUG
|
2016-09-25 22:14:36 +08:00
|
|
|
Util util;
|
2017-03-25 20:08:23 +08:00
|
|
|
//#endif
|
2017-02-26 17:18:21 +08:00
|
|
|
if(argc < 3) //./gbuild
|
2017-02-17 17:09:47 +08:00
|
|
|
{
|
|
|
|
//output help info here
|
|
|
|
cout << "the usage of gbuild: " << endl;
|
|
|
|
cout << "bin/gbuild your_database_name.db your_dataset_path" << endl;
|
|
|
|
return 0;
|
|
|
|
}
|
2016-09-25 22:14:36 +08:00
|
|
|
//system("clock");
|
2017-01-16 14:12:57 +08:00
|
|
|
cout << "gbuild..." << endl;
|
2016-09-25 22:14:36 +08:00
|
|
|
{
|
|
|
|
cout << "argc: " << argc << "\t";
|
|
|
|
cout << "DB_store:" << argv[1] << "\t";
|
|
|
|
cout << "RDF_data: " << argv[2] << "\t";
|
|
|
|
cout << endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
string _db_path = string(argv[1]);
|
2017-03-23 21:32:41 +08:00
|
|
|
int len = _db_path.length();
|
|
|
|
if(_db_path.substr(len-3, 3) == ".db")
|
|
|
|
{
|
|
|
|
cout<<"your database can not end with .db"<<endl;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-09-25 22:14:36 +08:00
|
|
|
//if(_db_path[0] != '/' && _db_path[0] != '~') //using relative path
|
|
|
|
//{
|
|
|
|
//_db_path = string("../") + _db_path;
|
|
|
|
//}
|
|
|
|
string _rdf = string(argv[2]);
|
|
|
|
//if(_rdf[0] != '/' && _rdf[0] != '~') //using relative path
|
|
|
|
//{
|
|
|
|
//_rdf = string("../") + _rdf;
|
|
|
|
//}
|
|
|
|
Database _db(_db_path);
|
|
|
|
bool flag = _db.build(_rdf);
|
|
|
|
if (flag)
|
|
|
|
{
|
|
|
|
cout << "import RDF file to database done." << endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cout << "import RDF file to database failed." << endl;
|
|
|
|
}
|
|
|
|
//system("clock");
|
|
|
|
return 0;
|
|
|
|
}
|