Posts Tagged ‘4store’

Compiling 4store on a Fedora 12 box

Monday, December 14th, 2009

I was attempting to install 4store on my fedora 12 box, and I found that I couldn’t run the tests which are shipped with 4store. I got the following output when attempting to run “make test” :


[root@blanket 4store]# make test
(cd tests && make -w test)
make[1]: Entering directory `/usr/local/src/4store/tests'
(cd query && pwd && ./setup.sh --autorun)
/usr/local/src/4store/tests/query
4store[9702]: backend-setup.c:176 erased files for KB query_test_mmt04r
4store[9702]: backend-setup.c:301 created RDF metadata for KB query_test_mmt04r
../../src/frontend/4s-import: error while loading shared libraries: librasqal.so.1: cannot open shared object file: No such file or directory
Preparing for tests...
../../src/frontend/4s-delete-model: error while loading shared libraries: librasqal.so.1: cannot open shared object file: No such file or directory
[FAIL] add-and-delete
[FAIL] distinct-predicate
[FAIL] foaf-all-limit
[FAIL] foaf-bnode-vs-variable
[FAIL] foaf-construct
[FAIL] foaf-disjunctive-filter
[FAIL] foaf-distinct
[FAIL] foaf-graph-all
[FAIL] foaf-graph-pred
[FAIL] foaf-knows-name
[FAIL] foaf-knows-name-sha1
[FAIL] foaf-knows-sha1
[FAIL] foaf-knows-sha1-xml
[FAIL] foaf-multi-disjunctive-filter
[FAIL] foaf-nested-optional
[FAIL] foaf-nothing
[FAIL] foaf-optional-order
[FAIL] foaf-optional-pair
[FAIL] foaf-optional-regex
[FAIL] foaf-repeat-var
[FAIL] graphs
[PASS] integrity
[FAIL] null-optional
[FAIL] null-optional-double
[FAIL] optimiser-disjunction
[FAIL] select-bnodes
[FAIL] select-order
[FAIL] select-unused
[FAIL] size
[FAIL] tiger-broadway
[FAIL] tiger-explosion
[FAIL] tiger-fail-optional
[FAIL] tiger-harold-ave
[FAIL] tiger-landmarks
[FAIL] tiger-mixed-optional
[FAIL] tiger-reverse
[FAIL] tiger-sugar-hill
[FAIL] tiger-sugar-hill-filter
[FAIL] tiger-typical
[FAIL] tiger-water-names
Tests completed: passed 1/40 (39 fails)
make[1]: Leaving directory `/usr/local/src/4store/tests'

This struck me as odd given that when I ran the “configure” script I got the following output :

[root@blanket 4store]# ./configure
[OK ] pkg-config installed
[OK ] raptor installed
[OK ] rasqal installed
[OK ] glib2 installed
[OK ] libxml2 installed
[OK ] pcre installed
[OK ] ncurses installed
[OK ] readline installed
[OK ] z installed
[OK ] avahi installed

So these are the setup step which I had to perform in order to get 4store working and running the tests:

1. After compiling the code, used ldd to see which libs were missing

ldd src/frontend/4s-query
[root@blanket 4store]# ldd !$2
ldd src/frontend/4s-query
linux-gate.so.1 => (0x00d9a000)
librasqal.so.1 => not found
libraptor.so.1 => /usr/lib/libraptor.so.1 (0x00678000)
libxml2.so.2 => /usr/lib/libxml2.so.2 (0x04f2f000)
libavahi-common.so.3 => /usr/lib/libavahi-common.so.3 (0x051d0000)
libavahi-client.so.3 => /usr/lib/libavahi-client.so.3 (0x051bd000)
libavahi-glib.so.1 => /usr/lib/libavahi-glib.so.1 (0x004b8000)
libglib-2.0.so.0 => /lib/libglib-2.0.so.0 (0x00da9000)
libpcre.so.0 => /lib/libpcre.so.0 (0x00110000)
....


2. Fix my ld.so configuration. The issue was that I had to add the following line, which points to my librasqal.so.1, to the following empty file
/etc/ld.so.conf.d/local.conf :


/usr/local/lib

A big yay to working 4store :

[root@blanket 4store]# make test
(cd tests && make -w test)
make[1]: Entering directory `/usr/local/src/4store/tests'
(cd query && pwd && ./setup.sh --autorun)
/usr/local/src/4store/tests/query
4store[10887]: backend-setup.c:176 erased files for KB query_test_mmt04r
4store[10887]: backend-setup.c:301 created RDF metadata for KB query_test_mmt04r
removing old data
Reading
into
Pass 1, processed 63 triples (63)
Reading
into
Pass 1, processed 764610 triples (764547)
Reading
into
Pass 1, processed 764658 triples (48)
Pass 2, processed 764658 triples, 26769 triples/s
Updating index
Index update took 17.133335 seconds
Imported 764658 triples, average 19375 triples/s
Preparing for tests...
[PASS] add-and-delete
[PASS] count
[PASS] distinct-predicate
[PASS] foaf-all-limit
[PASS] foaf-bnode-vs-variable
[PASS] foaf-construct
[PASS] foaf-disjunctive-filter
[PASS] foaf-distinct
[PASS] foaf-graph-all
[PASS] foaf-graph-pred
[PASS] foaf-knows-name
[PASS] foaf-knows-name-sha1
[PASS] foaf-knows-sha1
[PASS] foaf-knows-sha1-xml
[PASS] foaf-multi-disjunctive-filter
[PASS] foaf-nested-optional
[PASS] foaf-nothing
[PASS] foaf-optional-order
[PASS] foaf-optional-pair
[PASS] foaf-optional-regex
[PASS] foaf-repeat-var
[PASS] graphs
[PASS] integrity
[PASS] null-optional
[PASS] null-optional-double
[PASS] optimiser-disjunction
[PASS] select-bnodes
[PASS] select-order
[PASS] select-unused
[PASS] size
[PASS] tiger-broadway
[PASS] tiger-explosion
[PASS] tiger-fail-optional
[PASS] tiger-harold-ave
[PASS] tiger-landmarks
[PASS] tiger-mixed-optional
[PASS] tiger-reverse
[PASS] tiger-sugar-hill
[PASS] tiger-sugar-hill-filter
[PASS] tiger-typical
[PASS] tiger-water-names
[PASS] union-nobind
Tests completed: passed 42/42 (0 fails)
make[1]: Leaving directory `/usr/local/src/4store/tests'

4store and Dan Hanley’s client libgs

Sunday, December 13th, 2009

Find below step by step instructions on how to talk to a 4store KB via the SPARQL-Procotol in Java, using Dan Hanley’s 4store client libs.

First of all you need to have the following installed :
4store
A java compiler (i have Sun’s Java SDK 1.6.x installed on my laptop)
Maven (to compile Dan Hanley’s 4store client libs).

I have all of the code needed for this example placed on my site here : http://mmt.me.uk/examples/4store-java-query-example/ feel free to grab and use it as you wish.

First of all, I should say that I have had to patch the 4store-client-library, as it seems to chomp all of the carriage returns at the end of the lines (“\n”). This is fine you are using the SPARQL-XML-RESULT format, by I am a tad lazy and much prefer working with the tsv format: tsv requires line breaks.

The git diff of my patch looks like so (and again yes it is a tad dirty) :

diff --git a/src/main/java/uk/co/magus/fourstore/client/Store.java b/src/main/java/uk/co/magus/fourstore/clie
index 6652874..097be43 100644
--- a/src/main/java/uk/co/magus/fourstore/client/Store.java
+++ b/src/main/java/uk/co/magus/fourstore/client/Store.java
@@ -349,7 +349,7 @@ public class Store {
String response = "";
String str;
while (null != ((str = in.readLine()))) {
- response += str;
+ response += str+"\n";
}
in.close();
return response;
~
~

This above patch allows me to make use of the TSV output as needed. The patch can be grabbed from here : http://mmt.me.uk/examples/4store-java-query-example/patch.txt.

Ok, now that I have built the 4store-client.jar file with my patch using the instructions in the git repo. I create an example RDF file, and some example java code which will query the 4store KB. All the files can be found on my site http://mmt.me.uk/examples/4store-java-query-example/.

These are the steps which I have taken to get this little demo up and running :
1. Create 4store KB called lame

4s-backend-setup --node 0 --cluster 1 --segments 2 lame

2. Start lame‘s backend (i.e. start the KB)

4s-backend lame

3. Import the example.rdf file into lame‘s backend (i.e. start the KB)

4s-import lame example.rdf

4. Start HTTPD for the KB named lame

4s-httpd -s -1 lame

And then I need to compile the exampleQuery code I knocked together

javac -cp 4store-client-1.0.jar exampleQuery.java

Finally, I run the code like so :

java -cp 4store-client-1.0.jar:. exampleQuery

Resulting in the following output:

Am about to query a sparql endpoint
A user name is:"Bob"
A user name is:"Alice"

I hope this helps!