Changes between Initial Version and Version 1 of 4storeQuickPrimer

Show
Ignore:
Timestamp:
2010/02/10 01:14:56 (9 years ago)
Author:
admin
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • 4storeQuickPrimer

    v1 v1  
     1http://4store.org/trac/wiki/Documentation  
     2 
     3= Installation = 
     4 
     5For Mac OS X with MacPorts user. 
     6{{{ 
     7git clone git@github.com:nakao/4store.git 
     8cd 4store 
     9./configure 
     10}}} 
     11 
     12{{{ 
     13port install pkg-config 
     14port install raptor   
     15port install rasqal   
     16port install glib2  
     17port install libxml2  
     18port install pcre  
     19port install ncurses   
     20port instal readline   
     21port install zlib  
     22}}} 
     23+universal variant configuration may be useful. 
     24Install 
     25{{{ 
     26./configure 
     27make 
     28make test 
     29}}} 
     30 
     31Install as a Mac .dmg package 
     32{{{ 
     33make macdmg 
     34}}} 
     35 
     36or  
     37 
     38{{{ 
     39sudo make install 
     40}}} 
     41 
     42 
     43= Usage = 
     444store Commands  
     45{{{ 
     46$ ls /Applications/4store.app/Contents/MacOS/bin/ 
     474s-backend*          4s-cluster-create*               4s-httpd* 
     484s-backend-copy*     4s-cluster-destroy*              4s-import* 
     494s-backend-destroy*  4s-cluster-file-backup*          4s-info* 
     504s-backend-info*     4s-cluster-info*                 4s-query* 
     514s-backend-passwd*   4s-cluster-replication-disable*  4s-resolve* 
     524s-backend-setup*    4s-cluster-start*                4s-restore* 
     534s-bind*             4s-cluster-stop*                 4s-reverse-bind* 
     544s-cluster-cache*    4s-delete-model*                 4s-size* 
     554s-cluster-copy*     4s-dump*                         4s-update* 
     56}}} 
     57 
     58 
     59To setup a knowledge base (named demo) by 4s-backend-setup  
     60http://4store.org/trac/wiki/CreateDatabase 
     61 
     62 
     63{{{ 
     64$ 4s-backend-setup demo 
     654store[39388]: backend-setup.c:176 erased files for KB demo 
     664store[39388]: backend-setup.c:301 created RDF metadata for KB demo 
     67}}} 
     68 
     69You can find the database files at /var/lib/4store/demo . 
     70 
     71 
     72 
     73To boot a backend process by 4s-backend 
     74{{{ 
     754s-backend demo 
     76}}} 
     77 
     78 
     79 
     80To import triples by 4s-import 
     81http://4store.org/trac/wiki/ImportData 
     82 
     83{{{ 
     84curl -O  
     85$ 4s-import -v demo data/tiger/tiger_features.rdf 
     86removing old data 
     87Reading <file:///Users/nakao/Applications/4store/4store/data/tiger/tiger_features.rdf>; 
     88Pass 1, processed 748 triples (748) 
     89Pass 2, processed 748 triples, 90250 triples/s 
     90Updating index 
     91Index update took 1.469478 seconds 
     92Imported 748 triples, average 505 triples/s 
     93}}} 
     94 
     95 
     964s-query is a interactive query shell 
     97http://4store.org/trac/wiki/Query 
     98 
     99{{{ 
     100$ 4s-query demo4store> SELECT * WHERE {?s ?p ?o} 
     101#EOQ 
     102?s     ?p     ?o 
     103<http://www.census.gov/tiger/2002/CFCC/D85>;     <http://www.w3.org/2000/01/rdf-schema#subClassOf>;     <http://www.census.gov/tiger/2002/CFCC/D8>; 
     104<http://www.census.gov/tiger/2002/CFCC/F40>;     <http://www.w3.org/2000/01/rdf-schema#subClassOf>;     <http://www.census.gov/tiger/2002/CFCC/F4>; 
     105<http://www.census.gov/tiger/2002/CFCC/E0>;     <http://www.w3.org/2000/01/rdf-schema#subClassOf>;     <http://www.census.gov/tiger/2002/CFCC/E>; 
     106}}} 
     107Ctrl+D 
     108 
     109To query in one-liner 
     110{{{ 
     111$ 4s-query demo 'SELECT * WHERE { ?s ?p ?o } LIMIT 1' 
     112<?xml version="1.0"?> 
     113<sparql xmlns="http://www.w3.org/2005/sparql-results#">; 
     114  <head> 
     115    <variable name="s"/> 
     116    <variable name="p"/> 
     117    <variable name="o"/> 
     118  </head> 
     119  <results> 
     120    <result> 
     121      <binding name="s"><uri>http://www.census.gov/tiger/2002/CFCC/D85</uri></binding>; 
     122      <binding name="p"><uri>http://www.w3.org/2000/01/rdf-schema#subClassOf</uri></binding>; 
     123      <binding name="o"><uri>http://www.census.gov/tiger/2002/CFCC/D8</uri></binding>; 
     124    </result> 
     125  </results> 
     126</sparql> 
     127}}} 
     128 
     129in JSON format 
     130{{{ 
     131$ 4s-query -f json demo 'SELECT * WHERE { ?s ?p ?o } LIMIT 1' 
     132{"head":{"vars":["s","p","o"]}, 
     133 "results": { 
     134  "bindings":[ 
     135   {"s":{"type":"uri","value":"http://www.census.gov/tiger/2002/CFCC/D85";}, 
     136    "p":{"type":"uri","value":"http://www.w3.org/2000/01/rdf-schema#subClassOf";}, 
     137    "o":{"type":"uri","value":"http://www.census.gov/tiger/2002/CFCC/D8";}} 
     138  ] 
     139 }} 
     140}}} 
     141[http://www.w3.org/TR/rdf-sparql-json-res/ Serializing SPARQL Query Results in JSON] 
     142 
     143in SPARQL-RESULTS format 
     144 
     145{{{ 
     146$ 4s-query -f sparql demo 'SELECT * WHERE { ?s ?p ?o } LIMIT 1' 
     147<?xml version="1.0"?> 
     148<sparql xmlns="http://www.w3.org/2005/sparql-results#">; 
     149  <head> 
     150    <variable name="s"/> 
     151    <variable name="p"/> 
     152    <variable name="o"/> 
     153  </head> 
     154  <results> 
     155    <result> 
     156      <binding name="s"><uri>http://www.census.gov/tiger/2002/CFCC/D85</uri></binding>; 
     157      <binding name="p"><uri>http://www.w3.org/2000/01/rdf-schema#subClassOf</uri></binding>; 
     158      <binding name="o"><uri>http://www.census.gov/tiger/2002/CFCC/D8</uri></binding>; 
     159    </result> 
     160  </results> 
     161</sparql> 
     162}}} 
     163[http://www.w3.org/TR/rdf-sparql-XMLres/ SPARQL Query Results XML Format] 
     164 
     165 
     166in a text format 
     167 
     168{{{ 
     169$ 4s-query -f text demo 'SELECT * WHERE { ?s ?p ?o } LIMIT 1' 
     170?s     ?p     ?o 
     171<http://www.census.gov/tiger/2002/CFCC/D85>;     <http://www.w3.org/2000/01/rdf-schema#subClassOf>;     <http://www.census.gov/tiger/2002/CFCC/D8>; 
     172}}} 
     173 
     174in RDF test case format (Turtle) 
     175 
     176{{{ 
     177$ 4s-query -f testcase demo 'SELECT * WHERE { ?s ?p ?o } LIMIT 1' 
     178@prefix rs: <http://www.w3.org/2001/sw/DataAccess/tests/result-set#>; . 
     179@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>; . 
     180@prefix xsd: <http://www.w3.org/2001/XMLSchema#>; . 
     181 
     182[] rdf:type rs:ResultSet ; 
     183   rs:resultVariable "s", "p", "o" ; 
     184   rs:solution [ 
     185      rs:binding [ rs:variable "s" ; 
     186                   rs:value <http://www.census.gov/tiger/2002/CFCC/D85> ] ; 
     187      rs:binding [ rs:variable "p" ; 
     188                   rs:value <http://www.w3.org/2000/01/rdf-schema#subClassOf> ] ; 
     189      rs:binding [ rs:variable "o" ; 
     190                   rs:value <http://www.census.gov/tiger/2002/CFCC/D8> ] 
     191   ] . 
     192}}} 
     193[http://www.w3.org/TeamSubmission/turtle/ Turtle] 
     194 
     195 
     1964s-httpd for a SPARQL endpoint 
     197{{{ 
     198$ 4s-httpd -p 8000 demo 
     199}}} 
     200 
     201 
     202[[Image(http://img.skitch.com/20100106-ey6gcjsu42qsege2gimq316ia6.jpg)]] 
     203 
     204[[Image(http://img.skitch.com/20100106-nsq5ir2j1c6ynbkmif43t5a9p8.jpg)]] 
     205 
     206[[Image(http://img.skitch.com/20100106-cb9dq16jare8b33q82exaq12c.jpg)]] 
     207 
     208[[Image(http://img.skitch.com/20100106-x8hfwfdjt3xkexyn9nwcg346nh.jpg)]] 
     209 
     210[[Image(http://img.skitch.com/20100106-8g2w2r4tsycy8sdwrnxa6966hp.jpg)]] 
     211 
     212 
     213 
     214RESTful interface 
     215 
     216PUT 
     217{{{ 
     218$ curl -T file.rdf http://localhost:8000/sparql/file.rdf 
     219}}} 
     220 
     221DELETE 
     222{{{ 
     223$ curl -X DELETE http://localhost:8000/sparql/file.rdf 
     224}}} 
     225Note: http://4store.org/trac/wiki/TODO 
     226 
     227 
     228Connecting from script language 
     229 
     230http://4store.org/trac/wiki/ClientLibraries 
     231available php, python, ruby and Java (no Perl) 
     232 
     233To install the ruby client 
     234{{{ 
     235$ gem build 4store-ruby.gemspec 
     236WARNING:  no rubyforge_project specified 
     237  Successfully built RubyGem 
     238  Name: 4store-ruby 
     239  Version: 0.0.3 
     240  File: 4store-ruby-0.0.3.gem 
     241$ sudo gem install 4store-ruby-0.0.3.gem 
     242}}} 
     243 
     244Usage 
     245{{{ 
     246>> require 'four_store/store' 
     247=> true 
     248>> FourStore 
     249=> FourStore 
     250>> FourStore::Store 
     251=> FourStore::Store 
     252>> ep = FourStore::Store.new("http://localhost:8000/sparql/";) 
     253=> #<FourStore::Store:0x101763890 @endpoint=#<URI::HTTP:0x101763548 URL:http://localhost:8000/sparql/>>; 
     254>> res = ep.select("SELECT * WHERE { ?s ?p ?o } LIMIT 10"); 
     255?> " 
     256" 
     257=> "\n" 
     258>> require 'pp' 
     259=> true 
     260>> pp res 
     261[{"o"=>"http://www.census.gov/tiger/2002/CFCC/D8";, 
     262  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     263  "s"=>"http://www.census.gov/tiger/2002/CFCC/D85";}, 
     264 {"o"=>"http://www.census.gov/tiger/2002/CFCC/F4";, 
     265  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     266  "s"=>"http://www.census.gov/tiger/2002/CFCC/F40";}, 
     267 {"o"=>"http://www.census.gov/tiger/2002/CFCC/E";, 
     268  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     269  "s"=>"http://www.census.gov/tiger/2002/CFCC/E0";}, 
     270 {"o"=>"http://www.census.gov/tiger/2002/CFCC/B";, 
     271  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     272  "s"=>"http://www.census.gov/tiger/2002/CFCC/B4";}, 
     273 {"o"=>"http://www.census.gov/tiger/2002/CFCC/D2";, 
     274  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     275  "s"=>"http://www.census.gov/tiger/2002/CFCC/D27";}, 
     276 {"o"=>"http://www.census.gov/tiger/2002/CFCC/A";, 
     277  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     278  "s"=>"http://www.census.gov/tiger/2002/CFCC/A5";}, 
     279 {"o"=>"http://www.census.gov/tiger/2002/CFCC/A2";, 
     280  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     281  "s"=>"http://www.census.gov/tiger/2002/CFCC/A21";}, 
     282 {"o"=>"http://www.census.gov/tiger/2002/CFCC/H7";, 
     283  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     284  "s"=>"http://www.census.gov/tiger/2002/CFCC/H70";}, 
     285 {"o"=>"http://www.census.gov/tiger/2002/CFCC/B5";, 
     286  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     287  "s"=>"http://www.census.gov/tiger/2002/CFCC/B52";}, 
     288 {"o"=>"http://www.census.gov/tiger/2002/CFCC/D4";, 
     289  "p"=>"http://www.w3.org/2000/01/rdf-schema#subClassOf";, 
     290  "s"=>"http://www.census.gov/tiger/2002/CFCC/D43";}] 
     291=> nil 
     292}}} 
     293 
     294Methods in FourStore::Store class. 
     295{{{ 
     296>> FourStore::Store.instance_methods - Object.methods 
     297=> ["delete", "add", "set", "select", "load"] 
     298}}}