aboutsummaryrefslogtreecommitdiff
path: root/test/uk/ac/ox/cs/jrdfox/Tester.java
blob: 00476d6bead3537e4c78a80c33c33d6bd82058f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package uk.ac.ox.cs.jrdfox;

import java.io.File;

import uk.ac.ox.cs.JRDFox.JRDFStoreException;
import uk.ac.ox.cs.JRDFox.Prefixes;
import uk.ac.ox.cs.JRDFox.store.DataStore;
import uk.ac.ox.cs.JRDFox.store.Parameters;
import uk.ac.ox.cs.JRDFox.store.TupleIterator;
import uk.ac.ox.cs.pagoda.util.Timer;

public class Tester {
	
	public static void main(String[] args) {
		try {
			(new Tester()).test();;
		} catch (JRDFStoreException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	DataStore store; 
	Prefixes prefixes = new Prefixes(); 
	Parameters parameters; 
	
	public Tester() {
		try {
			store = new DataStore(new File("lazy-upper-bound"));
		} catch (JRDFStoreException e) {
			e.printStackTrace();
		}
		parameters = new Parameters(); 
		parameters.m_allAnswersInRoot = true; 
		parameters.m_useBushy = true;
		
	}
	
	public void dispose() {
		store.dispose();
	}
	
	public void test() throws JRDFStoreException {
		evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " 
				+ "SELECT distinct ?x WHERE { "
				+ "?x a benchmark:Person . "
				+ "?x benchmark:like ?y . "
				+ "?z a benchmark:Chair . "
				+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
				+ "?z benchmark:like ?y . "
				+ "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
				+ "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
				+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }");
		
		evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " 
				+ "SELECT distinct ?x WHERE { "
				+ "?x a benchmark:Person . "
				+ "?x benchmark:like ?y . "
				+ "?z a benchmark:Chair . "
				+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
				+ "?z benchmark:like ?y . "
				+ "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
				+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> ."
				+ "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); 

		evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " 
				+ "SELECT distinct ?x WHERE { "
				+ "?x a benchmark:Person . "
				+ "?x benchmark:like ?y . "
				+ "?z a benchmark:Chair . "
				+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
				+ "?z benchmark:like ?y . "
				+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
				+ "?x a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> . "
				+ "?z a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); 
		
		evaluate("PREFIX benchmark: <http://semantics.crl.ibm.com/univ-bench-dl.owl#> " 
				+ "SELECT distinct ?x WHERE { "
				+ "?x a benchmark:Person . "
				+ "?x benchmark:like ?y . "
				+ "?z a benchmark:Chair . "
				+ "?z benchmark:isHeadOf <http://www.Department0.University0.edu> . "
				+ "?z benchmark:like ?y . "
				+ "?y a <http://www.cs.ox.ac.uk/PAGOdA/auxiliary#Original> }"); 
}
	
	public void evaluate(String query) throws JRDFStoreException {
		TupleIterator iter = store.compileQuery(query, prefixes, parameters);
		
		int number = 0; 
		Timer t = new Timer(); 
		try {
			for (long multi = iter.open(); multi != 0; multi = iter.getNext()) 
				++number; 
		} finally {
			iter.dispose();
		}
		System.out.println(number); 
		System.out.println(t.duration());
	}
	
}