Update md files under docs folder

This commit is contained in:
suxunbin 2018-10-07 16:23:02 +08:00
parent 2aca137b05
commit f2b6ede9c9
4 changed files with 102 additions and 9 deletions

View File

@ -0,0 +1,11 @@
const GStoreClient = require("./index.js");
const client = new GStoreClient(
"root",
"123456",
"http://127.0.0.1:9001"
);
(async function() {
const result = await client.query("small","select * where {?s ?p ?o}");
console.log(JSON.stringify(result,","));
})();

View File

@ -77,6 +77,18 @@ The HTTP API of gStore is placed in api/http directory in the root directory of
- GstoreConnector.py
- nodejs/ (the Nodejs API)
- index.js (source code of Nodejs API)
- LICENSE
- package.json
- README.md
- example.js (small example to show the basic idea of using the Nodejs API)
- php/ (the Php API)
- example/
@ -239,6 +251,47 @@ def fquery(self, username, password, db_name, sparql, filename):
- - -
## Nodejs API
#### Interface
Before using Nodejs API, type `npm install request` and `npm install request-promise` under the nodejs folder to add the required module.
To use Nodejs API, please see gStore/api/http/nodejs/index.js. Functions should be called like following:
```
# start a gc with given IP and Port
gc = new GStoreClient(username, password, "http://127.0.0.1:9000")
# build database with a RDF graph
ret = gc.build("test", "data/lubm/lubm.nt")
# load the database
ret = gc.load("test")
# query
print (gc.query("test", sparql))
# unload the database
ret = gc.unload("test")
```
The original declaration of these functions are as below:
```
class GStoreClient
async build(db = '', dataPath = '')
async load(db = '')
async unload(db = '')
async query(db = '', sparql = '')
```
- - -
## Php API
#### Interface

View File

@ -16,6 +16,7 @@ readline-devel | need to be installed
openjdk | needed if using Java api
openjdk-devel | needed if using Java api
requests | needed if using Python http api
node | needed if using Nodejs http api and version >= 10.9.0
pthreads | needed if using php http api
curl-devel | needed if using php http api
realpath | needed if using gconsole
@ -78,19 +79,27 @@ We will run make clear just to be sure that no other crashed build will mess our
# make
# make install
8- Copy configuration file of PHP and add local lib to include path
8- install node
# wget https://npm.taobao.org/mirrors/node/v10.9.0/node-v10.9.0.tar.gz
# tar -xvf node-v10.9.0.tar.gz
# cd node-v10.9.0
# ./configure
# make
# sudo make install
9- Copy configuration file of PHP and add local lib to include path
# cp php.ini-development /etc/php.ini
Edit php.ini and set Include_path to be like this:
Include_path = "/usr/local/lib/php"
9- Check Modules
10- Check Modules
# php -m (check pthread loaded)
You have to see pthreads listed
10- If pthread is not listed, update php.ini
11- If pthread is not listed, update php.ini
# echo "extension=pthreads.so" >> /etc/php.ini
```

View File

@ -95,18 +95,26 @@ type:
`bin/ghttp db_name serverPort` or `bin/ghttp serverPort db_name` to start server with serverPort and load database named db_name initially.
Attention: the argument serverPort can be left out
Attention: the argument serverPort or db_name can be left out
if you leave out the argument serverPort in the commond, then the corresponding value will be set to default as 9000.
if you leave out the argument db_name in the commond, then the server will start with no database loaded.
operation: build, load, unload, query, monitor, show, checkpoint, user
operation: build, load, unload, query, monitor, show, checkpoint, checkall, user, drop
```
// build a new database by a RDF file.
gc.build("test", "data/lubm/LUBM_10.n3", "root", "123456");
// load databse
// drop a database already built but leave a backup.
gc.drop("test", "root", "123456");
// drop a database already built completely.
gc.drop_r("test", "root", "123456");
// load database
gc.load("test", "root", "123456");
// then you can execute SPARQL query on this database.
@ -115,10 +123,16 @@ answer = gc.query("root", "123456", "test", sparql);
// output information of a database
cout << answer << std::endl;
// unload this databse
// unload this database
gc.unload("lubm", "root", "123456");
//add a user(with username: Jack, passwor: 2)
// show all databases already built and if they are loaded
gc.show();
// show statistical information of a loaded database
gc.monitor("lubm");
//add a user(with username: Jack, password: 2)
answer = gc.user("add_user", "root", "123456", "Jack", "2");
//add privilege to user Jack(add_query, add_load, add_unload)
@ -292,10 +306,16 @@ After starting ghttp, type `bin/gshow ip port` to check loaded database.
null--->[HTTP/1.1 200 OK]
Content-Length--->[4]
database: lubm
- - -
#### 11. shutdown
After starting ghttp, type `bin/shutdown port` to stop the server.
---
#### 11. test utilities
#### 12. test utilities
A series of test program are placed in the scripts/ folder, and we will introduce the two useful ones: gtest.cpp and full_test.sh