You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rya.apache.org by mi...@apache.org on 2015/12/22 17:49:33 UTC
[09/56] [abbrv] incubator-rya git commit: RYA-7 POM and License
Clean-up for Apache Move
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/rya.sail.impl/src/test/java/mvm/rya/rdftriplestore/evaluation/RdfCloudTripleStoreSelectivityEvaluationStatisticsTest.java
----------------------------------------------------------------------
diff --git a/sail/rya.sail.impl/src/test/java/mvm/rya/rdftriplestore/evaluation/RdfCloudTripleStoreSelectivityEvaluationStatisticsTest.java b/sail/rya.sail.impl/src/test/java/mvm/rya/rdftriplestore/evaluation/RdfCloudTripleStoreSelectivityEvaluationStatisticsTest.java
deleted file mode 100644
index 14d532e..0000000
--- a/sail/rya.sail.impl/src/test/java/mvm/rya/rdftriplestore/evaluation/RdfCloudTripleStoreSelectivityEvaluationStatisticsTest.java
+++ /dev/null
@@ -1,303 +0,0 @@
-package mvm.rya.rdftriplestore.evaluation;
-
-/*
- * #%L
- * mvm.rya.rya.sail.impl
- * %%
- * Copyright (C) 2014 - 2015 Rya
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-
-import mvm.rya.accumulo.AccumuloRdfConfiguration;
-import mvm.rya.api.RdfCloudTripleStoreConfiguration;
-import mvm.rya.api.layout.TablePrefixLayoutStrategy;
-import mvm.rya.api.persist.RdfEvalStatsDAO;
-import mvm.rya.joinselect.AccumuloSelectivityEvalDAO;
-import mvm.rya.prospector.service.ProspectorServiceEvalStatsDAO;
-
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.Instance;
-import org.apache.accumulo.core.client.Scanner;
-import org.apache.accumulo.core.client.TableExistsException;
-import org.apache.accumulo.core.client.TableNotFoundException;
-import org.apache.accumulo.core.client.mock.MockInstance;
-import org.apache.accumulo.core.client.security.tokens.PasswordToken;
-import org.apache.accumulo.core.data.Key;
-import org.apache.accumulo.core.data.Mutation;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.hadoop.io.Text;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.openrdf.query.MalformedQueryException;
-import org.openrdf.query.algebra.TupleExpr;
-import org.openrdf.query.parser.ParsedQuery;
-import org.openrdf.query.parser.sparql.SPARQLParser;
-
-public class RdfCloudTripleStoreSelectivityEvaluationStatisticsTest {
-
- // TODO fix table names!!!
-
- private static final String DELIM = "\u0000";
- private final byte[] EMPTY_BYTE = new byte[0];
- private final Value EMPTY_VAL = new Value(EMPTY_BYTE);
-
- private String q1 = ""//
- + "SELECT ?h " //
- + "{" //
- + " ?h <http://www.w3.org/2000/01/rdf-schema#label> <uri:dog> ."//
- + " ?h <uri:barksAt> <uri:cat> ."//
- + " ?h <uri:peesOn> <uri:hydrant> . "//
- + "}";//
-
- private Connector conn;
- AccumuloRdfConfiguration arc;
- BatchWriterConfig config;
- Instance mock;
-
- @Before
- public void init() throws AccumuloException, AccumuloSecurityException, TableNotFoundException, TableExistsException {
-
- mock = new MockInstance("accumulo");
- PasswordToken pToken = new PasswordToken("pass".getBytes());
- conn = mock.getConnector("user", pToken);
-
- config = new BatchWriterConfig();
- config.setMaxMemory(1000);
- config.setMaxLatency(1000, TimeUnit.SECONDS);
- config.setMaxWriteThreads(10);
-
- if (conn.tableOperations().exists("rya_prospects")) {
- conn.tableOperations().delete("rya_prospects");
- }
- if (conn.tableOperations().exists("rya_selectivity")) {
- conn.tableOperations().delete("rya_selectivity");
- }
-
- arc = new AccumuloRdfConfiguration();
- arc.setTableLayoutStrategy(new TablePrefixLayoutStrategy());
- arc.setMaxRangesForScanner(300);
-
- }
-
- @Test
- public void testOptimizeQ1() throws Exception {
-
- RdfEvalStatsDAO<RdfCloudTripleStoreConfiguration> res = new ProspectorServiceEvalStatsDAO(conn, arc);
- AccumuloSelectivityEvalDAO accc = new AccumuloSelectivityEvalDAO();
- accc.setConf(arc);
- accc.setRdfEvalDAO(res);
- accc.setConnector(conn);
- accc.init();
-
- BatchWriter bw1 = conn.createBatchWriter("rya_prospects", config);
- BatchWriter bw2 = conn.createBatchWriter("rya_selectivity", config);
-
- String s1 = "predicateobject" + DELIM + "http://www.w3.org/2000/01/rdf-schema#label" + DELIM + "uri:dog";
- String s2 = "predicateobject" + DELIM + "uri:barksAt" + DELIM + "uri:cat";
- String s3 = "predicateobject" + DELIM + "uri:peesOn" + DELIM + "uri:hydrant";
- List<Mutation> mList = new ArrayList<Mutation>();
- List<Mutation> mList2 = new ArrayList<Mutation>();
- List<String> sList = Arrays.asList("subjectobject", "subjectpredicate", "subjectsubject", "predicateobject", "predicatepredicate",
- "predicatesubject");
- Mutation m1, m2, m3, m4;
-
- m1 = new Mutation(s1 + DELIM + "1");
- m1.put(new Text("count"), new Text(""), new Value("1".getBytes()));
- m2 = new Mutation(s2 + DELIM + "2");
- m2.put(new Text("count"), new Text(""), new Value("2".getBytes()));
- m3 = new Mutation(s3 + DELIM + "3");
- m3.put(new Text("count"), new Text(""), new Value("3".getBytes()));
- mList.add(m1);
- mList.add(m2);
- mList.add(m3);
-
- bw1.addMutations(mList);
- bw1.close();
-
-// Scanner scan = conn.createScanner("rya_prospects", new Authorizations());
-// scan.setRange(new Range());
-
-// for (Map.Entry<Key, Value> entry : scan) {
-// System.out.println("Key row string is " + entry.getKey().getRow().toString());
-// System.out.println("Key is " + entry.getKey());
-// System.out.println("Value is " + (new String(entry.getValue().get())));
-// }
-
- m1 = new Mutation(s1);
- m2 = new Mutation(s2);
- m3 = new Mutation(s3);
- m4 = new Mutation(new Text("subjectpredicateobject" + DELIM + "FullTableCardinality"));
- m4.put(new Text("FullTableCardinality"), new Text("100"), EMPTY_VAL);
- int i = 2;
- int j = 3;
- int k = 4;
- Long count1;
- Long count2;
- Long count3;
-
- for (String s : sList) {
- count1 = (long) i;
- count2 = (long) j;
- count3 = (long) k;
- m1.put(new Text(s), new Text(count1.toString()), EMPTY_VAL);
- m2.put(new Text(s), new Text(count2.toString()), EMPTY_VAL);
- m3.put(new Text(s), new Text(count3.toString()), EMPTY_VAL);
- i = 2 * i;
- j = 2 * j;
- k = 2 * k;
- }
- mList2.add(m1);
- mList2.add(m2);
- mList2.add(m3);
- mList2.add(m4);
- bw2.addMutations(mList2);
- bw2.close();
-
-// scan = conn.createScanner("rya_selectivity", new Authorizations());
-// scan.setRange(new Range());
-
-// for (Map.Entry<Key, Value> entry : scan) {
-// System.out.println("Key row string is " + entry.getKey().getRow().toString());
-// System.out.println("Key is " + entry.getKey());
-// System.out.println("Value is " + (new String(entry.getKey().getColumnQualifier().toString())));
-//
-// }
-
- TupleExpr te = getTupleExpr(q1);
- System.out.println(te);
-
- RdfCloudTripleStoreSelectivityEvaluationStatistics ars = new RdfCloudTripleStoreSelectivityEvaluationStatistics(arc, res, accc);
- double card = ars.getCardinality(te);
-
- Assert.assertEquals(6.3136, card, .0001);
-
- }
-
- @Test
- public void testOptimizeQ1ZeroCard() throws Exception {
-
- RdfEvalStatsDAO<RdfCloudTripleStoreConfiguration> res = new ProspectorServiceEvalStatsDAO(conn, arc);
- AccumuloSelectivityEvalDAO accc = new AccumuloSelectivityEvalDAO();
- accc.setConf(arc);
- accc.setConnector(conn);
- accc.setRdfEvalDAO(res);
- accc.init();
-
- BatchWriter bw1 = conn.createBatchWriter("rya_prospects", config);
- BatchWriter bw2 = conn.createBatchWriter("rya_selectivity", config);
-
- String s1 = "predicateobject" + DELIM + "http://www.w3.org/2000/01/rdf-schema#label" + DELIM + "uri:dog";
- String s2 = "predicateobject" + DELIM + "uri:barksAt" + DELIM + "uri:cat";
- String s3 = "predicateobject" + DELIM + "uri:peesOn" + DELIM + "uri:hydrant";
- List<Mutation> mList = new ArrayList<Mutation>();
- List<Mutation> mList2 = new ArrayList<Mutation>();
- List<String> sList = Arrays.asList("subjectobject", "subjectpredicate", "subjectsubject", "predicateobject", "predicatepredicate",
- "predicatesubject");
- Mutation m1, m2, m3, m4;
-
- m1 = new Mutation(s1 + DELIM + "1");
- m1.put(new Text("count"), new Text(""), new Value("1".getBytes()));
- m2 = new Mutation(s2 + DELIM + "2");
- m2.put(new Text("count"), new Text(""), new Value("2".getBytes()));
- // m3 = new Mutation(s3 + DELIM + "3");
- // m3.put(new Text("count"), new Text(""), new Value("3".getBytes()));
- mList.add(m1);
- mList.add(m2);
- // mList.add(m3);
-
- bw1.addMutations(mList);
- bw1.close();
-
-// Scanner scan = conn.createScanner("rya_prospects", new Authorizations());
-// scan.setRange(new Range());
-
-// for (Map.Entry<Key, Value> entry : scan) {
-// System.out.println("Key row string is " + entry.getKey().getRow().toString());
-// System.out.println("Key is " + entry.getKey());
-// System.out.println("Value is " + (new String(entry.getValue().get())));
-// }
-
- m1 = new Mutation(s1);
- m2 = new Mutation(s2);
- m3 = new Mutation(s3);
- m4 = new Mutation(new Text("subjectpredicateobject" + DELIM + "FullTableCardinality"));
- m4.put(new Text("FullTableCardinality"), new Text("100"), EMPTY_VAL);
- int i = 2;
- int j = 3;
- int k = 4;
- Long count1;
- Long count2;
- Long count3;
-
- for (String s : sList) {
- count1 = (long) i;
- count2 = (long) j;
- count3 = (long) k;
- m1.put(new Text(s), new Text(count1.toString()), EMPTY_VAL);
- m2.put(new Text(s), new Text(count2.toString()), EMPTY_VAL);
- m3.put(new Text(s), new Text(count3.toString()), EMPTY_VAL);
- i = 2 * i;
- j = 2 * j;
- k = 2 * k;
- }
- mList2.add(m1);
- mList2.add(m2);
- mList2.add(m3);
- mList2.add(m4);
- bw2.addMutations(mList2);
- bw2.close();
-
-// scan = conn.createScanner("rya_selectivity", new Authorizations());
-// scan.setRange(new Range());
-
-// for (Map.Entry<Key, Value> entry : scan) {
-// System.out.println("Key row string is " + entry.getKey().getRow().toString());
-// System.out.println("Key is " + entry.getKey());
-// System.out.println("Value is " + (new String(entry.getKey().getColumnQualifier().toString())));
-//
-// }
-
- TupleExpr te = getTupleExpr(q1);
- System.out.println(te);
-
- RdfCloudTripleStoreSelectivityEvaluationStatistics ars = new RdfCloudTripleStoreSelectivityEvaluationStatistics(arc, res, accc);
- double card = ars.getCardinality(te);
-
- Assert.assertEquals(4.04, card, .0001);
-
- }
-
- private TupleExpr getTupleExpr(String query) throws MalformedQueryException {
-
- SPARQLParser sp = new SPARQLParser();
- ParsedQuery pq = sp.parseQuery(query, null);
-
- return pq.getTupleExpr();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/rya.sail.impl/src/test/java/mvm/rya/triplestore/inference/SameAsTest.java
----------------------------------------------------------------------
diff --git a/sail/rya.sail.impl/src/test/java/mvm/rya/triplestore/inference/SameAsTest.java b/sail/rya.sail.impl/src/test/java/mvm/rya/triplestore/inference/SameAsTest.java
deleted file mode 100644
index 66ba33a..0000000
--- a/sail/rya.sail.impl/src/test/java/mvm/rya/triplestore/inference/SameAsTest.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package mvm.rya.triplestore.inference;
-
-/*
- * #%L
- * mvm.rya.rya.sail.impl
- * %%
- * Copyright (C) 2014 Rya
- * %%
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * #L%
- */
-
-import info.aduna.iteration.Iterations;
-import junit.framework.TestCase;
-import mvm.rya.accumulo.AccumuloRdfConfiguration;
-import mvm.rya.accumulo.AccumuloRyaDAO;
-import mvm.rya.api.RdfCloudTripleStoreConstants;
-import mvm.rya.api.resolver.RdfToRyaConversions;
-import mvm.rya.rdftriplestore.RdfCloudTripleStore;
-import mvm.rya.rdftriplestore.inference.InferenceEngine;
-
-import org.apache.accumulo.core.Constants;
-import org.apache.accumulo.core.client.Connector;
-import org.apache.accumulo.core.client.admin.SecurityOperations;
-import org.apache.accumulo.core.client.mock.MockInstance;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.accumulo.core.security.TablePermission;
-import org.junit.Test;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.StatementImpl;
-import org.openrdf.model.impl.ValueFactoryImpl;
-
-public class SameAsTest extends TestCase {
- private String user = "user";
- private String pwd = "pwd";
- private String instance = "myinstance";
- private String tablePrefix = "t_";
- private Authorizations auths = Constants.NO_AUTHS;
- private Connector connector;
- private AccumuloRyaDAO ryaDAO;
- private ValueFactory vf = new ValueFactoryImpl();
- private String namespace = "urn:test#";
- private AccumuloRdfConfiguration conf;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- connector = new MockInstance(instance).getConnector(user, pwd.getBytes());
- connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
- connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
- connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
- connector.tableOperations().create(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
- SecurityOperations secOps = connector.securityOperations();
- secOps.createUser(user, pwd.getBytes(), auths);
- secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX, TablePermission.READ);
- secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX, TablePermission.READ);
- secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX, TablePermission.READ);
- secOps.grantTablePermission(user, tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX, TablePermission.READ);
-
- conf = new AccumuloRdfConfiguration();
- ryaDAO = new AccumuloRyaDAO();
- ryaDAO.setConnector(connector);
- conf.setTablePrefix(tablePrefix);
- ryaDAO.setConf(conf);
- ryaDAO.init();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_SPO_SUFFIX);
- connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_PO_SUFFIX);
- connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_OSP_SUFFIX);
- connector.tableOperations().delete(tablePrefix + RdfCloudTripleStoreConstants.TBL_NS_SUFFIX);
- }
-
- @Test
- //This isn't a good test. It's simply a cut-and-paste from a test that was failing in a different package in the SameAsVisitor.
- public void testGraphConfiguration() throws Exception {
- URI a = vf.createURI(namespace, "a");
- Statement statement = new StatementImpl(a, vf.createURI(namespace, "p"), vf.createLiteral("l"));
- Statement statement2 = new StatementImpl(a, vf.createURI(namespace, "p2"), vf.createLiteral("l"));
- ryaDAO.add(RdfToRyaConversions.convertStatement(statement));
- ryaDAO.add(RdfToRyaConversions.convertStatement(statement2));
- ryaDAO.add(RdfToRyaConversions.convertStatement(new StatementImpl(vf.createURI(namespace, "b"), vf.createURI(namespace, "p"), vf.createLiteral("l"))));
- ryaDAO.add(RdfToRyaConversions.convertStatement(new StatementImpl(vf.createURI(namespace, "c"), vf.createURI(namespace, "n"), vf.createLiteral("l"))));
-
- // build a connection
- RdfCloudTripleStore store = new RdfCloudTripleStore();
- store.setConf(conf);
- store.setRyaDAO(ryaDAO);
-
- InferenceEngine inferenceEngine = new InferenceEngine();
- inferenceEngine.setRyaDAO(ryaDAO);
- store.setInferenceEngine(inferenceEngine);
-
- store.initialize();
-
- System.out.println(Iterations.asList(store.getConnection().getStatements(a, vf.createURI(namespace, "p"), vf.createLiteral("l"), false, new Resource[0])).size());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/rya.sail.impl/src/test/resources/cdrdf.xml
----------------------------------------------------------------------
diff --git a/sail/rya.sail.impl/src/test/resources/cdrdf.xml b/sail/rya.sail.impl/src/test/resources/cdrdf.xml
deleted file mode 100644
index 506b017..0000000
--- a/sail/rya.sail.impl/src/test/resources/cdrdf.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0"?>
-<!--
- #%L
- mvm.rya.rya.sail.impl
- %%
- Copyright (C) 2014 Rya
- %%
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- #L%
- -->
-
-<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:cd="http://www.recshop.fake/cd#">
-
- <rdf:Description rdf:about="http://www.recshop.fake/cd/Empire_Burlesque">
- <cd:artist>Bob Dylan</cd:artist>
- <cd:country>USA</cd:country>
- <cd:company>Columbia</cd:company>
- <cd:price>10.90</cd:price>
- <cd:year>1985</cd:year>
- </rdf:Description>
-
- <rdf:Description rdf:about="http://www.recshop.fake/cd/Hide_your_fingers">
- <cd:artist>Bonnie Tyler</cd:artist>
- <cd:country>UK</cd:country>
- <cd:company>CBS Records</cd:company>
- <cd:price>9.90</cd:price>
- <cd:year>1993</cd:year>
- </rdf:Description>
-</rdf:RDF>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/rya.sail.impl/src/test/resources/namedgraphs.trig
----------------------------------------------------------------------
diff --git a/sail/rya.sail.impl/src/test/resources/namedgraphs.trig b/sail/rya.sail.impl/src/test/resources/namedgraphs.trig
deleted file mode 100644
index 748d276..0000000
--- a/sail/rya.sail.impl/src/test/resources/namedgraphs.trig
+++ /dev/null
@@ -1,37 +0,0 @@
-@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
-@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
-@prefix swp: <http://www.w3.org/2004/03/trix/swp-1/> .
-@prefix dc: <http://purl.org/dc/elements/1.1/> .
-@prefix ex: <http://www.example.org/vocabulary#> .
-@prefix : <http://www.example.org/exampleDocument#> .
-:G1 { :Monica ex:name "Monica Murphy" .
- :Monica ex:homepage <http://www.monicamurphy.org> .
- :Monica ex:email <ma...@monicamurphy.org> .
- :Monica ex:one <ma...@monicamurphy.org> .
- :Monica ex:two <ma...@monicamurphy.org> .
- :Monica ex:three <ma...@monicamurphy.org> .
- :Monica ex:four <ma...@monicamurphy.org> .
- :Monica ex:five <ma...@monicamurphy.org> .
- :Monica ex:six <ma...@monicamurphy.org> .
- :Monica ex:seven <ma...@monicamurphy.org> .
- :Monica ex:eight <ma...@monicamurphy.org> .
- :Monica ex:nine <ma...@monicamurphy.org> .
- :Monica ex:ten <ma...@monicamurphy.org> .
- :Monica ex:hasSkill ex:Management }
-
-:G2 { :Monica rdf:type ex:Person .
- :Monica ex:hasSkill ex:Programming }
-
-:G4 { :Phobe ex:name "Phobe Buffet" }
-
-:G3 { :G1 swp:assertedBy _:w1 .
- _:w1 swp:authority :Chris .
- _:w1 dc:date "2003-10-02"^^xsd:date .
- :G2 swp:quotedBy _:w2 .
- :G4 swp:assertedBy _:w2 .
- _:w2 dc:date "2003-09-03"^^xsd:date .
- _:w2 swp:authority :Tom .
- :Chris rdf:type ex:Person .
- :Chris ex:email <ma...@bizer.de>.
- :Tom rdf:type ex:Person .
- :Tom ex:email <ma...@bizer.de>}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/rya.sail.impl/src/test/resources/ntriples
----------------------------------------------------------------------
diff --git a/sail/rya.sail.impl/src/test/resources/ntriples b/sail/rya.sail.impl/src/test/resources/ntriples
deleted file mode 100644
index edf1190..0000000
--- a/sail/rya.sail.impl/src/test/resources/ntriples
+++ /dev/null
@@ -1 +0,0 @@
-<urn:lubm:rdfts#GraduateStudent> <http://www.w3.org/2000/01/rdf-schema#subPropertyOf> <urn:lubm:rdfts#Student> .
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/rya.sail.impl/src/test/resources/reification.xml
----------------------------------------------------------------------
diff --git a/sail/rya.sail.impl/src/test/resources/reification.xml b/sail/rya.sail.impl/src/test/resources/reification.xml
deleted file mode 100644
index 414800f..0000000
--- a/sail/rya.sail.impl/src/test/resources/reification.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0"?>
-<!--
- #%L
- mvm.rya.rya.sail.impl
- %%
- Copyright (C) 2014 Rya
- %%
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- #L%
- -->
-
-<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:cd="http://www.recshop.fake/cd#"
- xmlns:mm="http://mvm.com/owl/2010/10/mm.owl#">
-
- <rdf:Description rdf:nodeID="A4">
- <rdf:subject
- rdf:resource="http://mvm.com/owl/2010/10/mm.owl#urn:mm:mvm:root/cimv2:Linux_Processor:0:CIM_ComputerSystem:nimbus02.bullpen.net"/>
- <rdf:predicate rdf:resource="http://mvm.com/owl/2010/10/mm.owl#loadPercentage"/>
- <rdf:object rdf:datatype="http://www.w3.org/2001/XMLSchema#int">1</rdf:object>
- <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement"/>
- <mm:reportedAt rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">2011-01-07T21:29:45.545Z</mm:reportedAt>
- </rdf:Description>
-
-</rdf:RDF>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/rya.sail.impl/src/test/resources/univ-bench.owl
----------------------------------------------------------------------
diff --git a/sail/rya.sail.impl/src/test/resources/univ-bench.owl b/sail/rya.sail.impl/src/test/resources/univ-bench.owl
deleted file mode 100644
index 691a330..0000000
--- a/sail/rya.sail.impl/src/test/resources/univ-bench.owl
+++ /dev/null
@@ -1,466 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<rdf:RDF
- xmlns="urn:lubm:rdfts#"
- xml:base="urn:lubm:rdfts#"
- xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
- xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
- xmlns:owl="http://www.w3.org/2002/07/owl#"
->
-
-<owl:Class rdf:ID="AdministrativeStaff">
- <rdfs:label>administrative staff worker</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Employee" />
-</owl:Class>
-
-<owl:Class rdf:ID="Article">
- <rdfs:label>article</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Publication" />
-</owl:Class>
-
-<owl:Class rdf:ID="AssistantProfessor">
- <rdfs:label>assistant professor</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Professor" />
-</owl:Class>
-
-<owl:Class rdf:ID="AssociateProfessor">
- <rdfs:label>associate professor</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Professor" />
-</owl:Class>
-
-<owl:Class rdf:ID="Book">
- <rdfs:label>book</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Publication" />
-</owl:Class>
-
-<owl:Class rdf:ID="Chair">
- <rdfs:label>chair</rdfs:label>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Class rdf:about="#Person" />
- <owl:Restriction>
- <owl:onProperty rdf:resource="#headOf" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#Department" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </owl:intersectionOf>
- <rdfs:subPropertyOf rdf:resource="#Professor" />
-</owl:Class>
-
-<owl:Class rdf:ID="ClericalStaff">
- <rdfs:label>clerical staff worker</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#AdministrativeStaff" />
-</owl:Class>
-
-<owl:Class rdf:ID="College">
- <rdfs:label>school</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Organization" />
-</owl:Class>
-
-<owl:Class rdf:ID="ConferencePaper">
- <rdfs:label>conference paper</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Article" />
-</owl:Class>
-
-<owl:Class rdf:ID="Course">
- <rdfs:label>teaching course</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Work" />
-</owl:Class>
-
-<owl:Class rdf:ID="Dean">
- <rdfs:label>dean</rdfs:label>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Class rdf:about="#Person" />
- <owl:Restriction>
- <owl:onProperty rdf:resource="#headOf" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#College" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </owl:intersectionOf>
- <rdfs:subPropertyOf rdf:resource="#Professor" />
-</owl:Class>
-
-<owl:Class rdf:ID="Department">
- <rdfs:label>university department</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Organization" />
-</owl:Class>
-
-<owl:Class rdf:ID="Director">
- <rdfs:label>director</rdfs:label>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Class rdf:about="#Person" />
- <owl:Restriction>
- <owl:onProperty rdf:resource="#headOf" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#Program" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </owl:intersectionOf>
-</owl:Class>
-
-<owl:Class rdf:ID="Employee">
- <rdfs:label>Employee</rdfs:label>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Class rdf:about="#Person" />
- <owl:Restriction>
- <owl:onProperty rdf:resource="#worksFor" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#Organization" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </owl:intersectionOf>
-</owl:Class>
-
-<owl:Class rdf:ID="Faculty">
- <rdfs:label>faculty member</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Employee" />
-</owl:Class>
-
-<owl:Class rdf:ID="FullProfessor">
- <rdfs:label>full professor</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Professor" />
-</owl:Class>
-
-<owl:Class rdf:ID="GraduateCourse">
- <rdfs:label>Graduate Level Courses</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Course" />
-</owl:Class>
-
-<owl:Class rdf:ID="GraduateStudent">
- <rdfs:label>graduate student</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Person" />
- <rdfs:subPropertyOf>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#takesCourse" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#GraduateCourse" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </rdfs:subPropertyOf>
-</owl:Class>
-
-<owl:Class rdf:ID="Institute">
- <rdfs:label>institute</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Organization" />
-</owl:Class>
-
-<owl:Class rdf:ID="JournalArticle">
- <rdfs:label>journal article</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Article" />
-</owl:Class>
-
-<owl:Class rdf:ID="Lecturer">
- <rdfs:label>lecturer</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Faculty" />
-</owl:Class>
-
-<owl:Class rdf:ID="Manual">
- <rdfs:label>manual</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Publication" />
-</owl:Class>
-
-<owl:Class rdf:ID="Organization">
- <rdfs:label>organization</rdfs:label>
-</owl:Class>
-
-<owl:Class rdf:ID="Person">
- <rdfs:label>person</rdfs:label>
-</owl:Class>
-
-<owl:Class rdf:ID="PostDoc">
- <rdfs:label>post doctorate</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Faculty" />
-</owl:Class>
-
-<owl:Class rdf:ID="Professor">
- <rdfs:label>professor</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Faculty" />
-</owl:Class>
-
-<owl:Class rdf:ID="Program">
- <rdfs:label>program</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Organization" />
-</owl:Class>
-
-<owl:Class rdf:ID="Publication">
- <rdfs:label>publication</rdfs:label>
-</owl:Class>
-
-<owl:Class rdf:ID="Research">
- <rdfs:label>research work</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Work" />
-</owl:Class>
-
-<owl:Class rdf:ID="ResearchAssistant">
- <rdfs:label>university research assistant</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Student" />
- <rdfs:subPropertyOf>
- <owl:Restriction>
- <owl:onProperty rdf:resource="#worksFor" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#ResearchGroup" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </rdfs:subPropertyOf>
-</owl:Class>
-
-<owl:Class rdf:ID="ResearchGroup">
- <rdfs:label>research group</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Organization" />
-</owl:Class>
-
-<owl:Class rdf:ID="Schedule">
- <rdfs:label>schedule</rdfs:label>
-</owl:Class>
-
-<owl:Class rdf:ID="Software">
- <rdfs:label>software program</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Publication" />
-</owl:Class>
-
-<owl:Class rdf:ID="Specification">
- <rdfs:label>published specification</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Publication" />
-</owl:Class>
-
-<owl:Class rdf:ID="Student">
- <rdfs:label>student</rdfs:label>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Class rdf:about="#Person" />
- <owl:Restriction>
- <owl:onProperty rdf:resource="#takesCourse" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#Course" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </owl:intersectionOf>
-</owl:Class>
-
-<owl:Class rdf:ID="SystemsStaff">
- <rdfs:label>systems staff worker</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#AdministrativeStaff" />
-</owl:Class>
-
-<owl:Class rdf:ID="TeachingAssistant">
- <rdfs:label>university teaching assistant</rdfs:label>
- <owl:intersectionOf rdf:parseType="Collection">
- <owl:Class rdf:about="#Person" />
- <owl:Restriction>
- <owl:onProperty rdf:resource="#teachingAssistantOf" />
- <owl:someValuesFrom>
- <owl:Class rdf:about="#Course" />
- </owl:someValuesFrom>
- </owl:Restriction>
- </owl:intersectionOf>
-</owl:Class>
-
-<owl:Class rdf:ID="TechnicalReport">
- <rdfs:label>technical report</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Article" />
-</owl:Class>
-
-<owl:Class rdf:ID="UndergraduateStudent">
- <rdfs:label>undergraduate student</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Student" />
-</owl:Class>
-
-<owl:Class rdf:ID="University">
- <rdfs:label>university</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Organization" />
-</owl:Class>
-
-<owl:Class rdf:ID="UnofficialPublication">
- <rdfs:label>unnoficial publication</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Publication" />
-</owl:Class>
-
-<owl:Class rdf:ID="VisitingProfessor">
- <rdfs:label>visiting professor</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#Professor" />
-</owl:Class>
-
-<owl:Class rdf:ID="Work">
- <rdfs:label>Work</rdfs:label>
-</owl:Class>
-
-<owl:ObjectProperty rdf:ID="advisor">
- <rdfs:label>is being advised by</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
- <rdfs:range rdf:resource="#Professor" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="affiliatedOrganizationOf">
- <rdfs:label>is affiliated with</rdfs:label>
- <rdfs:domain rdf:resource="#Organization" />
- <rdfs:range rdf:resource="#Organization" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="affiliateOf">
- <rdfs:label>is affiliated with</rdfs:label>
- <rdfs:domain rdf:resource="#Organization" />
- <rdfs:range rdf:resource="#Person" />
-</owl:ObjectProperty>
-
-<owl:DatatypeProperty rdf:ID="age">
- <rdfs:label>is age</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
-</owl:DatatypeProperty>
-
-<owl:ObjectProperty rdf:ID="degreeFrom">
- <rdfs:label>has a degree from</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
- <rdfs:range rdf:resource="#University" />
- <owl:inverseOf rdf:resource="#hasAlumnus"/>
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="doctoralDegreeFrom">
- <rdfs:label>has a doctoral degree from</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
- <rdfs:range rdf:resource="#University" />
- <rdfs:subPropertyOf rdf:resource="#degreeFrom" />
-</owl:ObjectProperty>
-
-<owl:DatatypeProperty rdf:ID="emailAddress">
- <rdfs:label>can be reached at</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
-</owl:DatatypeProperty>
-
-<owl:ObjectProperty rdf:ID="hasAlumnus">
- <rdfs:label>has as an alumnus</rdfs:label>
- <rdfs:domain rdf:resource="#University" />
- <rdfs:range rdf:resource="#Person" />
- <owl:inverseOf rdf:resource="#degreeFrom"/>
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="headOf">
- <rdfs:label>is the head of</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#worksFor"/>
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="listedCourse">
- <rdfs:label>lists as a course</rdfs:label>
- <rdfs:domain rdf:resource="#Schedule" />
- <rdfs:range rdf:resource="#Course" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="mastersDegreeFrom">
- <rdfs:label>has a masters degree from</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
- <rdfs:range rdf:resource="#University" />
- <rdfs:subPropertyOf rdf:resource="#degreeFrom"/>
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="member">
- <rdfs:label>has as a member</rdfs:label>
- <rdfs:domain rdf:resource="#Organization" />
- <rdfs:range rdf:resource="#Person" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="memberOf">
-<rdfs:label>member of</rdfs:label>
-<owl:inverseOf rdf:resource="#member" />
-</owl:ObjectProperty>
-
-<owl:DatatypeProperty rdf:ID="name">
-<rdfs:label>name</rdfs:label>
-</owl:DatatypeProperty>
-
-<owl:DatatypeProperty rdf:ID="officeNumber">
- <rdfs:label>office room No.</rdfs:label>
-</owl:DatatypeProperty>
-
-<owl:ObjectProperty rdf:ID="orgPublication">
- <rdfs:label>publishes</rdfs:label>
- <rdfs:domain rdf:resource="#Organization" />
- <rdfs:range rdf:resource="#Publication" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="publicationAuthor">
- <rdfs:label>was written by</rdfs:label>
- <rdfs:domain rdf:resource="#Publication" />
- <rdfs:range rdf:resource="#Person" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="publicationDate">
- <rdfs:label>was written on</rdfs:label>
- <rdfs:domain rdf:resource="#Publication" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="publicationResearch">
- <rdfs:label>is about</rdfs:label>
- <rdfs:domain rdf:resource="#Publication" />
- <rdfs:range rdf:resource="#Research" />
-</owl:ObjectProperty>
-
-<owl:DatatypeProperty rdf:ID="researchInterest">
- <rdfs:label>is researching</rdfs:label>
-</owl:DatatypeProperty>
-
-<owl:ObjectProperty rdf:ID="researchProject">
- <rdfs:label>has as a research project</rdfs:label>
- <rdfs:domain rdf:resource="#ResearchGroup" />
- <rdfs:range rdf:resource="#Research" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="softwareDocumentation">
- <rdfs:label>is documented in</rdfs:label>
- <rdfs:domain rdf:resource="#Software" />
- <rdfs:range rdf:resource="#Publication" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="softwareVersion">
- <rdfs:label>is version</rdfs:label>
- <rdfs:domain rdf:resource="#Software" />
-</owl:ObjectProperty>
-
-<owl:TransitiveProperty rdf:ID="subOrganizationOf">
- <rdfs:label>is part of</rdfs:label>
- <rdfs:domain rdf:resource="#Organization" />
- <rdfs:range rdf:resource="#Organization" />
-</owl:TransitiveProperty>
-
-<owl:ObjectProperty rdf:ID="takesCourse">
- <rdfs:label>is taking</rdfs:label>
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="teacherOf">
- <rdfs:label>teaches</rdfs:label>
- <rdfs:domain rdf:resource="#Faculty" />
- <rdfs:range rdf:resource="#Course" />
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="teachingAssistantOf">
- <rdfs:label>is a teaching assistant for</rdfs:label>
- <rdfs:domain rdf:resource="#TeachingAssistant" />
- <rdfs:range rdf:resource="#Course" />
-</owl:ObjectProperty>
-
-<owl:DatatypeProperty rdf:ID="telephone">
- <rdfs:label>telephone number</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
-</owl:DatatypeProperty>
-
-<owl:ObjectProperty rdf:ID="tenured">
- <rdfs:label>is tenured:</rdfs:label>
- <rdfs:domain rdf:resource="#Professor" />
-</owl:ObjectProperty>
-
-<owl:DatatypeProperty rdf:ID="title">
- <rdfs:label>title</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
-</owl:DatatypeProperty>
-
-<owl:ObjectProperty rdf:ID="undergraduateDegreeFrom">
- <rdfs:label>has an undergraduate degree from</rdfs:label>
- <rdfs:domain rdf:resource="#Person" />
- <rdfs:range rdf:resource="#University" />
- <rdfs:subPropertyOf rdf:resource="#degreeFrom"/>
-</owl:ObjectProperty>
-
-<owl:ObjectProperty rdf:ID="worksFor">
- <rdfs:label>Works For</rdfs:label>
- <rdfs:subPropertyOf rdf:resource="#memberOf" />
-</owl:ObjectProperty>
-
-</rdf:RDF>
-
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStore.java
----------------------------------------------------------------------
diff --git a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStore.java b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStore.java
new file mode 100644
index 0000000..4fcc726
--- /dev/null
+++ b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStore.java
@@ -0,0 +1,179 @@
+package mvm.rya.rdftriplestore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.api.persist.RdfEvalStatsDAO;
+import mvm.rya.api.persist.RyaDAO;
+import mvm.rya.api.persist.RyaDAOException;
+import mvm.rya.api.persist.joinselect.SelectivityEvalDAO;
+import mvm.rya.rdftriplestore.inference.InferenceEngine;
+import mvm.rya.rdftriplestore.namespace.NamespaceManager;
+import mvm.rya.rdftriplestore.provenance.ProvenanceCollector;
+
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.sail.SailConnection;
+import org.openrdf.sail.SailException;
+import org.openrdf.sail.helpers.SailBase;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+public class RdfCloudTripleStore extends SailBase {
+
+ private RdfCloudTripleStoreConfiguration conf;
+
+ protected RyaDAO ryaDAO;
+ protected InferenceEngine inferenceEngine;
+ protected RdfEvalStatsDAO rdfEvalStatsDAO;
+ protected SelectivityEvalDAO selectEvalDAO;
+ private NamespaceManager namespaceManager;
+ protected ProvenanceCollector provenanceCollector;
+
+ private ValueFactory vf = new ValueFactoryImpl();
+
+ @Override
+ protected SailConnection getConnectionInternal() throws SailException {
+ return new RdfCloudTripleStoreConnection(this, conf, vf);
+ }
+
+ @Override
+ protected void initializeInternal() throws SailException {
+ checkNotNull(ryaDAO);
+
+ if (this.conf == null) {
+ this.conf = ryaDAO.getConf();
+ }
+
+ checkNotNull(this.conf);
+
+ try {
+ if (!ryaDAO.isInitialized()) {
+ ryaDAO.setConf(this.conf);
+ ryaDAO.init();
+ }
+ } catch (RyaDAOException e) {
+ throw new SailException(e);
+ }
+
+ if (rdfEvalStatsDAO != null && !rdfEvalStatsDAO.isInitialized()) {
+ rdfEvalStatsDAO.setConf(this.conf);
+ rdfEvalStatsDAO.init();
+ }
+
+ //TODO: Support inferencing with ryadao
+// if (inferenceEngine != null && !inferenceEngine.isInitialized()) {
+// inferenceEngine.setConf(this.conf);
+// inferenceEngine.setRyaDAO(ryaDAO);
+// inferenceEngine.init();
+// }
+
+ if (namespaceManager == null) {
+ this.namespaceManager = new NamespaceManager(ryaDAO, this.conf);
+ }
+ }
+
+ @Override
+ protected void shutDownInternal() throws SailException {
+ try {
+ if (namespaceManager != null) {
+ namespaceManager.shutdown();
+ }
+ if (inferenceEngine != null) {
+ inferenceEngine.destroy();
+ }
+ if (rdfEvalStatsDAO != null) {
+ rdfEvalStatsDAO.destroy();
+ }
+ ryaDAO.destroy();
+ } catch (Exception e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ public ValueFactory getValueFactory() {
+ return vf;
+ }
+
+ @Override
+ public boolean isWritable() throws SailException {
+ return true;
+ }
+
+ public RdfCloudTripleStoreConfiguration getConf() {
+ return conf;
+ }
+
+ public void setConf(RdfCloudTripleStoreConfiguration conf) {
+ this.conf = conf;
+ }
+
+ public RdfEvalStatsDAO getRdfEvalStatsDAO() {
+ return rdfEvalStatsDAO;
+ }
+
+ public void setRdfEvalStatsDAO(RdfEvalStatsDAO rdfEvalStatsDAO) {
+ this.rdfEvalStatsDAO = rdfEvalStatsDAO;
+ }
+
+ public SelectivityEvalDAO getSelectEvalDAO() {
+ return selectEvalDAO;
+ }
+
+ public void setSelectEvalDAO(SelectivityEvalDAO selectEvalDAO) {
+ this.selectEvalDAO = selectEvalDAO;
+ }
+
+ public RyaDAO getRyaDAO() {
+ return ryaDAO;
+ }
+
+ public void setRyaDAO(RyaDAO ryaDAO) {
+ this.ryaDAO = ryaDAO;
+ }
+
+ public InferenceEngine getInferenceEngine() {
+ return inferenceEngine;
+ }
+
+ public void setInferenceEngine(InferenceEngine inferenceEngine) {
+ this.inferenceEngine = inferenceEngine;
+ }
+
+ public NamespaceManager getNamespaceManager() {
+ return namespaceManager;
+ }
+
+ public void setNamespaceManager(NamespaceManager namespaceManager) {
+ this.namespaceManager = namespaceManager;
+ }
+
+ public ProvenanceCollector getProvenanceCollector() {
+ return provenanceCollector;
+ }
+
+ public void setProvenanceCollector(ProvenanceCollector provenanceCollector) {
+ this.provenanceCollector = provenanceCollector;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreConnection.java
----------------------------------------------------------------------
diff --git a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreConnection.java b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreConnection.java
new file mode 100644
index 0000000..24ec109
--- /dev/null
+++ b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreConnection.java
@@ -0,0 +1,623 @@
+package mvm.rya.rdftriplestore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import info.aduna.iteration.CloseableIteration;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.NoSuchElementException;
+
+import mvm.rya.api.RdfCloudTripleStoreConfiguration;
+import mvm.rya.api.RdfCloudTripleStoreConstants;
+import mvm.rya.api.domain.RyaStatement;
+import mvm.rya.api.domain.RyaURI;
+import mvm.rya.api.persist.RdfEvalStatsDAO;
+import mvm.rya.api.persist.RyaDAO;
+import mvm.rya.api.persist.RyaDAOException;
+import mvm.rya.api.persist.joinselect.SelectivityEvalDAO;
+import mvm.rya.api.persist.utils.RyaDAOHelper;
+import mvm.rya.api.resolver.RdfToRyaConversions;
+import mvm.rya.rdftriplestore.evaluation.FilterRangeVisitor;
+import mvm.rya.rdftriplestore.evaluation.ParallelEvaluationStrategyImpl;
+import mvm.rya.rdftriplestore.evaluation.QueryJoinSelectOptimizer;
+import mvm.rya.rdftriplestore.evaluation.RdfCloudTripleStoreEvaluationStatistics;
+import mvm.rya.rdftriplestore.evaluation.RdfCloudTripleStoreSelectivityEvaluationStatistics;
+import mvm.rya.rdftriplestore.evaluation.SeparateFilterJoinsVisitor;
+import mvm.rya.rdftriplestore.inference.InferenceEngine;
+import mvm.rya.rdftriplestore.inference.InverseOfVisitor;
+import mvm.rya.rdftriplestore.inference.SameAsVisitor;
+import mvm.rya.rdftriplestore.inference.SubClassOfVisitor;
+import mvm.rya.rdftriplestore.inference.SubPropertyOfVisitor;
+import mvm.rya.rdftriplestore.inference.SymmetricPropertyVisitor;
+import mvm.rya.rdftriplestore.inference.TransitivePropertyVisitor;
+import mvm.rya.rdftriplestore.namespace.NamespaceManager;
+import mvm.rya.rdftriplestore.provenance.ProvenanceCollectionException;
+import mvm.rya.rdftriplestore.provenance.ProvenanceCollector;
+import mvm.rya.rdftriplestore.utils.DefaultStatistics;
+
+import org.apache.hadoop.conf.Configurable;
+import org.openrdf.model.Namespace;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ContextStatementImpl;
+import org.openrdf.model.impl.StatementImpl;
+import org.openrdf.query.Binding;
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.Dataset;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.algebra.QueryRoot;
+import org.openrdf.query.algebra.StatementPattern;
+import org.openrdf.query.algebra.TupleExpr;
+import org.openrdf.query.algebra.Var;
+import org.openrdf.query.algebra.evaluation.EvaluationStrategy;
+import org.openrdf.query.algebra.evaluation.QueryBindingSet;
+import org.openrdf.query.algebra.evaluation.QueryOptimizer;
+import org.openrdf.query.algebra.evaluation.TripleSource;
+import org.openrdf.query.algebra.evaluation.impl.BindingAssigner;
+import org.openrdf.query.algebra.evaluation.impl.CompareOptimizer;
+import org.openrdf.query.algebra.evaluation.impl.ConjunctiveConstraintSplitter;
+import org.openrdf.query.algebra.evaluation.impl.ConstantOptimizer;
+import org.openrdf.query.algebra.evaluation.impl.DisjunctiveConstraintOptimizer;
+import org.openrdf.query.algebra.evaluation.impl.EvaluationStatistics;
+import org.openrdf.query.algebra.evaluation.impl.FilterOptimizer;
+import org.openrdf.query.algebra.evaluation.impl.IterativeEvaluationOptimizer;
+import org.openrdf.query.algebra.evaluation.impl.OrderLimitOptimizer;
+import org.openrdf.query.algebra.evaluation.impl.QueryModelNormalizer;
+import org.openrdf.query.algebra.evaluation.impl.SameTermFilterOptimizer;
+import org.openrdf.query.impl.EmptyBindingSet;
+import org.openrdf.sail.SailException;
+import org.openrdf.sail.helpers.SailConnectionBase;
+
+public class RdfCloudTripleStoreConnection extends SailConnectionBase {
+
+ private RdfCloudTripleStore store;
+
+ private RdfEvalStatsDAO rdfEvalStatsDAO;
+ private SelectivityEvalDAO selectEvalDAO;
+ private RyaDAO ryaDAO;
+ private InferenceEngine inferenceEngine;
+ private NamespaceManager namespaceManager;
+ private RdfCloudTripleStoreConfiguration conf;
+
+
+ private ProvenanceCollector provenanceCollector;
+
+ public RdfCloudTripleStoreConnection(RdfCloudTripleStore sailBase, RdfCloudTripleStoreConfiguration conf, ValueFactory vf)
+ throws SailException {
+ super(sailBase);
+ this.store = sailBase;
+ this.conf = conf;
+ initialize();
+ }
+
+ protected void initialize() throws SailException {
+ refreshConnection();
+ }
+
+ protected void refreshConnection() throws SailException {
+ try {
+ checkNotNull(store.getRyaDAO());
+ checkArgument(store.getRyaDAO().isInitialized());
+ checkNotNull(store.getNamespaceManager());
+
+ this.ryaDAO = store.getRyaDAO();
+ this.rdfEvalStatsDAO = store.getRdfEvalStatsDAO();
+ this.selectEvalDAO = store.getSelectEvalDAO();
+ this.inferenceEngine = store.getInferenceEngine();
+ this.namespaceManager = store.getNamespaceManager();
+ this.provenanceCollector = store.getProvenanceCollector();
+
+ } catch (Exception e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ protected void addStatementInternal(Resource subject, URI predicate,
+ Value object, Resource... contexts) throws SailException {
+ try {
+ String cv_s = conf.getCv();
+ byte[] cv = cv_s == null ? null : cv_s.getBytes();
+ if (contexts != null && contexts.length > 0) {
+ for (Resource context : contexts) {
+ RyaStatement statement = new RyaStatement(
+ RdfToRyaConversions.convertResource(subject),
+ RdfToRyaConversions.convertURI(predicate),
+ RdfToRyaConversions.convertValue(object),
+ RdfToRyaConversions.convertResource(context),
+ null, cv);
+
+ ryaDAO.add(statement);
+ }
+ } else {
+ RyaStatement statement = new RyaStatement(
+ RdfToRyaConversions.convertResource(subject),
+ RdfToRyaConversions.convertURI(predicate),
+ RdfToRyaConversions.convertValue(object),
+ null, null, cv);
+
+ ryaDAO.add(statement);
+ }
+ } catch (RyaDAOException e) {
+ throw new SailException(e);
+ }
+ }
+
+
+
+
+ @Override
+ protected void clearInternal(Resource... aresource) throws SailException {
+ try {
+ RyaURI[] graphs = new RyaURI[aresource.length];
+ for (int i = 0 ; i < graphs.length ; i++){
+ graphs[i] = RdfToRyaConversions.convertResource(aresource[i]);
+ }
+ ryaDAO.dropGraph(conf, graphs);
+ } catch (RyaDAOException e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ protected void clearNamespacesInternal() throws SailException {
+ logger.error("Clear Namespace Repository method not implemented");
+ }
+
+ @Override
+ protected void closeInternal() throws SailException {
+ verifyIsOpen();
+ }
+
+ @Override
+ protected void commitInternal() throws SailException {
+ verifyIsOpen();
+ //There is no transactional layer
+ }
+
+ @Override
+ protected CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluateInternal(
+ TupleExpr tupleExpr, Dataset dataset, BindingSet bindings,
+ boolean flag) throws SailException {
+ verifyIsOpen();
+ logger.trace("Incoming query model:\n{}", tupleExpr.toString());
+ if (provenanceCollector != null){
+ try {
+ provenanceCollector.recordQuery(tupleExpr.toString());
+ } catch (ProvenanceCollectionException e) {
+ // TODO silent fail
+ e.printStackTrace();
+ }
+ }
+ tupleExpr = tupleExpr.clone();
+
+ RdfCloudTripleStoreConfiguration queryConf = store.getConf().clone();
+ if (bindings != null) {
+ Binding dispPlan = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_QUERYPLAN_FLAG);
+ if (dispPlan != null) {
+ queryConf.setDisplayQueryPlan(Boolean.parseBoolean(dispPlan.getValue().stringValue()));
+ }
+
+ Binding authBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_QUERY_AUTH);
+ if (authBinding != null) {
+ queryConf.setAuths(authBinding.getValue().stringValue().split(","));
+ }
+
+ Binding ttlBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_TTL);
+ if (ttlBinding != null) {
+ queryConf.setTtl(Long.valueOf(ttlBinding.getValue().stringValue()));
+ }
+
+ Binding startTimeBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_STARTTIME);
+ if (startTimeBinding != null) {
+ queryConf.setStartTime(Long.valueOf(startTimeBinding.getValue().stringValue()));
+ }
+
+ Binding performantBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_PERFORMANT);
+ if (performantBinding != null) {
+ queryConf.setBoolean(RdfCloudTripleStoreConfiguration.CONF_PERFORMANT, Boolean.parseBoolean(performantBinding.getValue().stringValue()));
+ }
+
+ Binding inferBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_INFER);
+ if (inferBinding != null) {
+ queryConf.setInfer(Boolean.parseBoolean(inferBinding.getValue().stringValue()));
+ }
+
+ Binding useStatsBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_USE_STATS);
+ if (useStatsBinding != null) {
+ queryConf.setUseStats(Boolean.parseBoolean(useStatsBinding.getValue().stringValue()));
+ }
+
+ Binding offsetBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_OFFSET);
+ if (offsetBinding != null) {
+ queryConf.setOffset(Long.parseLong(offsetBinding.getValue().stringValue()));
+ }
+
+ Binding limitBinding = bindings.getBinding(RdfCloudTripleStoreConfiguration.CONF_LIMIT);
+ if (limitBinding != null) {
+ queryConf.setLimit(Long.parseLong(limitBinding.getValue().stringValue()));
+ }
+ } else {
+ bindings = new QueryBindingSet();
+ }
+
+ if (!(tupleExpr instanceof QueryRoot)) {
+ tupleExpr = new QueryRoot(tupleExpr);
+ }
+
+ try {
+ List<Class<QueryOptimizer>> optimizers = queryConf.getOptimizers();
+ Class<QueryOptimizer> pcjOptimizer = queryConf.getPcjOptimizer();
+
+ if(pcjOptimizer != null) {
+ QueryOptimizer opt = null;
+ try {
+ Constructor<QueryOptimizer> construct = pcjOptimizer.getDeclaredConstructor(new Class[] {});
+ opt = construct.newInstance();
+ } catch (Exception e) {
+ }
+ if (opt == null) {
+ throw new NoSuchMethodException("Could not find valid constructor for " + pcjOptimizer.getName());
+ }
+ if (opt instanceof Configurable) {
+ ((Configurable) opt).setConf(conf);
+ }
+ opt.optimize(tupleExpr, dataset, bindings);
+ }
+
+ final ParallelEvaluationStrategyImpl strategy = new ParallelEvaluationStrategyImpl(
+ new StoreTripleSource(queryConf), inferenceEngine, dataset, queryConf);
+
+ (new BindingAssigner()).optimize(tupleExpr, dataset, bindings);
+ (new ConstantOptimizer(strategy)).optimize(tupleExpr, dataset,
+ bindings);
+ (new CompareOptimizer()).optimize(tupleExpr, dataset, bindings);
+ (new ConjunctiveConstraintSplitter()).optimize(tupleExpr, dataset,
+ bindings);
+ (new DisjunctiveConstraintOptimizer()).optimize(tupleExpr, dataset,
+ bindings);
+ (new SameTermFilterOptimizer()).optimize(tupleExpr, dataset,
+ bindings);
+ (new QueryModelNormalizer()).optimize(tupleExpr, dataset, bindings);
+
+ (new IterativeEvaluationOptimizer()).optimize(tupleExpr, dataset,
+ bindings);
+
+ if (!optimizers.isEmpty()) {
+ for (Class<QueryOptimizer> optclz : optimizers) {
+ QueryOptimizer result = null;
+ try {
+ Constructor<QueryOptimizer> meth = optclz.getDeclaredConstructor(new Class[] {});
+ result = meth.newInstance();
+ } catch (Exception e) {
+ }
+ try {
+ Constructor<QueryOptimizer> meth = optclz.getDeclaredConstructor(EvaluationStrategy.class);
+ result = meth.newInstance(strategy);
+ } catch (Exception e) {
+ }
+ if (result == null) {
+ throw new NoSuchMethodException("Could not find valid constructor for " + optclz.getName());
+ }
+ if (result instanceof Configurable) {
+ ((Configurable) result).setConf(conf);
+ }
+ result.optimize(tupleExpr, dataset, bindings);
+ }
+ }
+
+ (new FilterOptimizer()).optimize(tupleExpr, dataset, bindings);
+ (new OrderLimitOptimizer()).optimize(tupleExpr, dataset, bindings);
+
+ logger.trace("Optimized query model:\n{}", tupleExpr.toString());
+
+ if (queryConf.isInfer()
+ && this.inferenceEngine != null
+ ) {
+ try {
+ tupleExpr.visit(new TransitivePropertyVisitor(queryConf, inferenceEngine));
+ tupleExpr.visit(new SymmetricPropertyVisitor(queryConf, inferenceEngine));
+ tupleExpr.visit(new InverseOfVisitor(queryConf, inferenceEngine));
+ tupleExpr.visit(new SubPropertyOfVisitor(queryConf, inferenceEngine));
+ tupleExpr.visit(new SubClassOfVisitor(queryConf, inferenceEngine));
+ tupleExpr.visit(new SameAsVisitor(queryConf, inferenceEngine));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ if (queryConf.isPerformant()) {
+ tupleExpr.visit(new SeparateFilterJoinsVisitor());
+// tupleExpr.visit(new FilterTimeIndexVisitor(queryConf));
+// tupleExpr.visit(new PartitionFilterTimeIndexVisitor(queryConf));
+ }
+ FilterRangeVisitor rangeVisitor = new FilterRangeVisitor(queryConf);
+ tupleExpr.visit(rangeVisitor);
+ tupleExpr.visit(rangeVisitor); //this has to be done twice to get replace the statementpatterns with the right ranges
+ EvaluationStatistics stats = null;
+ if (!queryConf.isUseStats() && queryConf.isPerformant() || rdfEvalStatsDAO == null) {
+ stats = new DefaultStatistics();
+ } else if (queryConf.isUseStats()) {
+
+ if (queryConf.isUseSelectivity()) {
+ stats = new RdfCloudTripleStoreSelectivityEvaluationStatistics(queryConf, rdfEvalStatsDAO,
+ selectEvalDAO);
+ } else {
+ stats = new RdfCloudTripleStoreEvaluationStatistics(queryConf, rdfEvalStatsDAO);
+ }
+ }
+ if (stats != null) {
+
+ if (stats instanceof RdfCloudTripleStoreSelectivityEvaluationStatistics) {
+
+ (new QueryJoinSelectOptimizer((RdfCloudTripleStoreSelectivityEvaluationStatistics) stats,
+ selectEvalDAO)).optimize(tupleExpr, dataset, bindings);
+ } else {
+
+ (new mvm.rya.rdftriplestore.evaluation.QueryJoinOptimizer(stats)).optimize(tupleExpr, dataset,
+ bindings); // TODO: Make pluggable
+ }
+ }
+
+ final CloseableIteration<BindingSet, QueryEvaluationException> iter = strategy
+ .evaluate(tupleExpr, EmptyBindingSet.getInstance());
+ CloseableIteration<BindingSet, QueryEvaluationException> iterWrap = new CloseableIteration<BindingSet, QueryEvaluationException>() {
+
+ @Override
+ public void remove() throws QueryEvaluationException {
+ iter.remove();
+ }
+
+ @Override
+ public BindingSet next() throws QueryEvaluationException {
+ return iter.next();
+ }
+
+ @Override
+ public boolean hasNext() throws QueryEvaluationException {
+ return iter.hasNext();
+ }
+
+ @Override
+ public void close() throws QueryEvaluationException {
+ iter.close();
+ strategy.shutdown();
+ }
+ };
+ return iterWrap;
+ } catch (QueryEvaluationException e) {
+ throw new SailException(e);
+ } catch (Exception e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ protected CloseableIteration<? extends Resource, SailException> getContextIDsInternal()
+ throws SailException {
+ verifyIsOpen();
+
+ // iterate through all contextids
+ return null;
+ }
+
+ @Override
+ protected String getNamespaceInternal(String s) throws SailException {
+ return namespaceManager.getNamespace(s);
+ }
+
+ @Override
+ protected CloseableIteration<? extends Namespace, SailException> getNamespacesInternal()
+ throws SailException {
+ return namespaceManager.iterateNamespace();
+ }
+
+ @Override
+ protected CloseableIteration<? extends Statement, SailException> getStatementsInternal(
+ Resource subject, URI predicate, Value object, boolean flag,
+ Resource... contexts) throws SailException {
+// try {
+ //have to do this to get the inferred values
+ //TODO: Will this method reduce performance?
+ final Var subjVar = decorateValue(subject, "s");
+ final Var predVar = decorateValue(predicate, "p");
+ final Var objVar = decorateValue(object, "o");
+ StatementPattern sp = null;
+ final boolean hasContext = contexts != null && contexts.length > 0;
+ final Resource context = (hasContext) ? contexts[0] : null;
+ final Var cntxtVar = decorateValue(context, "c");
+ //TODO: Only using one context here
+ sp = new StatementPattern(subjVar, predVar, objVar, cntxtVar);
+ //return new StoreTripleSource(store.getConf()).getStatements(resource, uri, value, contexts);
+ final CloseableIteration<? extends BindingSet, QueryEvaluationException> evaluate = evaluate(sp, null, null, false);
+ return new CloseableIteration<Statement, SailException>() { //TODO: Use a util class to do this
+ private boolean isClosed = false;
+
+ @Override
+ public void close() throws SailException {
+ isClosed = true;
+ try {
+ evaluate.close();
+ } catch (QueryEvaluationException e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ public boolean hasNext() throws SailException {
+ try {
+ return evaluate.hasNext();
+ } catch (QueryEvaluationException e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ public Statement next() throws SailException {
+ if (!hasNext() || isClosed) {
+ throw new NoSuchElementException();
+ }
+
+ try {
+ BindingSet next = evaluate.next();
+ Resource bs_subj = (Resource) ((subjVar.hasValue()) ? subjVar.getValue() : next.getBinding(subjVar.getName()).getValue());
+ URI bs_pred = (URI) ((predVar.hasValue()) ? predVar.getValue() : next.getBinding(predVar.getName()).getValue());
+ Value bs_obj = (objVar.hasValue()) ? objVar.getValue() : (Value) next.getBinding(objVar.getName()).getValue();
+ Binding b_cntxt = next.getBinding(cntxtVar.getName());
+
+ //convert BindingSet to Statement
+ if (b_cntxt != null) {
+ return new ContextStatementImpl(bs_subj, bs_pred, bs_obj, (Resource) b_cntxt.getValue());
+ } else {
+ return new StatementImpl(bs_subj, bs_pred, bs_obj);
+ }
+ } catch (QueryEvaluationException e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ public void remove() throws SailException {
+ try {
+ evaluate.remove();
+ } catch (QueryEvaluationException e) {
+ throw new SailException(e);
+ }
+ }
+ };
+// } catch (QueryEvaluationException e) {
+// throw new SailException(e);
+// }
+ }
+
+ protected Var decorateValue(Value val, String name) {
+ if (val == null) {
+ return new Var(name);
+ } else {
+ return new Var(name, val);
+ }
+ }
+
+ @Override
+ protected void removeNamespaceInternal(String s) throws SailException {
+ namespaceManager.removeNamespace(s);
+ }
+
+ @Override
+ protected void removeStatementsInternal(Resource subject, URI predicate,
+ Value object, Resource... contexts) throws SailException {
+ if (!(subject instanceof URI)) {
+ throw new SailException("Subject[" + subject + "] must be URI");
+ }
+
+ try {
+ if (contexts != null && contexts.length > 0) {
+ for (Resource context : contexts) {
+ if (!(context instanceof URI)) {
+ throw new SailException("Context[" + context + "] must be URI");
+ }
+ RyaStatement statement = new RyaStatement(
+ RdfToRyaConversions.convertResource(subject),
+ RdfToRyaConversions.convertURI(predicate),
+ RdfToRyaConversions.convertValue(object),
+ RdfToRyaConversions.convertResource(context));
+
+ ryaDAO.delete(statement, conf);
+ }
+ } else {
+ RyaStatement statement = new RyaStatement(
+ RdfToRyaConversions.convertResource(subject),
+ RdfToRyaConversions.convertURI(predicate),
+ RdfToRyaConversions.convertValue(object),
+ null);
+
+ ryaDAO.delete(statement, conf);
+ }
+ } catch (RyaDAOException e) {
+ throw new SailException(e);
+ }
+ }
+
+ @Override
+ protected void rollbackInternal() throws SailException {
+ //TODO: No transactional layer as of yet
+ }
+
+ @Override
+ protected void setNamespaceInternal(String s, String s1)
+ throws SailException {
+ namespaceManager.addNamespace(s, s1);
+ }
+
+ @Override
+ protected long sizeInternal(Resource... contexts) throws SailException {
+ logger.error("Cannot determine size as of yet");
+
+ return 0;
+ }
+
+ @Override
+ protected void startTransactionInternal() throws SailException {
+ //TODO: ?
+ }
+
+ public class StoreTripleSource implements TripleSource {
+
+ private RdfCloudTripleStoreConfiguration conf;
+
+ public StoreTripleSource(RdfCloudTripleStoreConfiguration conf) {
+ this.conf = conf;
+ }
+
+ public CloseableIteration<Statement, QueryEvaluationException> getStatements(
+ Resource subject, URI predicate, Value object,
+ Resource... contexts) throws QueryEvaluationException {
+ return RyaDAOHelper.query(ryaDAO, subject, predicate, object, conf, contexts);
+ }
+
+ public CloseableIteration<? extends Entry<Statement, BindingSet>, QueryEvaluationException> getStatements(
+ Collection<Map.Entry<Statement, BindingSet>> statements,
+ Resource... contexts) throws QueryEvaluationException {
+
+ return RyaDAOHelper.query(ryaDAO, statements, conf);
+ }
+
+ public ValueFactory getValueFactory() {
+ return RdfCloudTripleStoreConstants.VALUE_FACTORY;
+ }
+ }
+
+ public InferenceEngine getInferenceEngine() {
+ return inferenceEngine;
+ }
+ public RdfCloudTripleStoreConfiguration getConf() {
+ return conf;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreFactory.java
----------------------------------------------------------------------
diff --git a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreFactory.java b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreFactory.java
new file mode 100644
index 0000000..42f1aa4
--- /dev/null
+++ b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreFactory.java
@@ -0,0 +1,56 @@
+package mvm.rya.rdftriplestore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import org.openrdf.sail.Sail;
+import org.openrdf.sail.config.SailConfigException;
+import org.openrdf.sail.config.SailFactory;
+import org.openrdf.sail.config.SailImplConfig;
+
+public class RdfCloudTripleStoreFactory implements SailFactory {
+
+ public static final String SAIL_TYPE = "openrdf:RdfCloudTripleStore";
+
+ @Override
+ public SailImplConfig getConfig() {
+ return new RdfCloudTripleStoreSailConfig();
+ }
+
+ @Override
+ public Sail getSail(SailImplConfig config) throws SailConfigException {
+// RdfCloudTripleStore cbStore = new RdfCloudTripleStore();
+// RdfCloudTripleStoreSailConfig cbconfig = (RdfCloudTripleStoreSailConfig) config;
+// cbStore.setServer(cbconfig.getServer());
+// cbStore.setPort(cbconfig.getPort());
+// cbStore.setInstance(cbconfig.getInstance());
+// cbStore.setPassword(cbconfig.getPassword());
+// cbStore.setUser(cbconfig.getUser());
+// return cbStore;
+ return null; //TODO: How?
+ }
+
+ @Override
+ public String getSailType() {
+ return SAIL_TYPE;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreSailConfig.java
----------------------------------------------------------------------
diff --git a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreSailConfig.java b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreSailConfig.java
new file mode 100644
index 0000000..6542b55
--- /dev/null
+++ b/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreSailConfig.java
@@ -0,0 +1,133 @@
+package mvm.rya.rdftriplestore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import org.openrdf.model.*;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.model.util.GraphUtil;
+import org.openrdf.model.util.GraphUtilException;
+import org.openrdf.sail.config.SailConfigException;
+import org.openrdf.sail.config.SailImplConfigBase;
+
+public class RdfCloudTripleStoreSailConfig extends SailImplConfigBase {
+
+ public static final String NAMESPACE = "http://www.openrdf.org/config/sail/cloudbasestore#";
+
+ public static final URI SERVER;
+ public static final URI PORT;
+ public static final URI INSTANCE;
+ public static final URI USER;
+ public static final URI PASSWORD;
+
+ static {
+ ValueFactory factory = ValueFactoryImpl.getInstance();
+ SERVER = factory.createURI(NAMESPACE, "server");
+ PORT = factory.createURI(NAMESPACE, "port");
+ INSTANCE = factory.createURI(NAMESPACE, "instance");
+ USER = factory.createURI(NAMESPACE, "user");
+ PASSWORD = factory.createURI(NAMESPACE, "password");
+ }
+
+ private String server = "stratus13";
+
+ private int port = 2181;
+
+ private String user = "root";
+
+ private String password = "password";
+
+ private String instance = "stratus";
+
+ public String getServer() {
+ return server;
+ }
+
+ public void setServer(String server) {
+ this.server = server;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getInstance() {
+ return instance;
+ }
+
+ public void setInstance(String instance) {
+ this.instance = instance;
+ }
+
+ @Override
+ public void parse(Graph graph, Resource implNode)
+ throws SailConfigException
+ {
+ super.parse(graph, implNode);
+ System.out.println("parsing");
+
+ try {
+ Literal serverLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, SERVER);
+ if (serverLit != null) {
+ setServer(serverLit.getLabel());
+ }
+ Literal portLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, PORT);
+ if (portLit != null) {
+ setPort(Integer.parseInt(portLit.getLabel()));
+ }
+ Literal instList = GraphUtil.getOptionalObjectLiteral(graph, implNode, INSTANCE);
+ if (instList != null) {
+ setInstance(instList.getLabel());
+ }
+ Literal userLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, USER);
+ if (userLit != null) {
+ setUser(userLit.getLabel());
+ }
+ Literal pwdLit = GraphUtil.getOptionalObjectLiteral(graph, implNode, PASSWORD);
+ if (pwdLit != null) {
+ setPassword(pwdLit.getLabel());
+ }
+ }
+ catch (GraphUtilException e) {
+ throw new SailConfigException(e.getMessage(), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepository.java
----------------------------------------------------------------------
diff --git a/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepository.java b/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepository.java
new file mode 100644
index 0000000..7003398
--- /dev/null
+++ b/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepository.java
@@ -0,0 +1,53 @@
+package mvm.rya.rdftriplestore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.repository.sail.SailRepositoryConnection;
+import org.openrdf.sail.Sail;
+import org.openrdf.sail.SailException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: RoshanP
+ * Date: 3/23/12
+ * Time: 10:05 AM
+ * To change this template use File | Settings | File Templates.
+ */
+public class RyaSailRepository extends SailRepository{
+ public RyaSailRepository(Sail sail) {
+ super(sail);
+ }
+
+ @Override
+ public SailRepositoryConnection getConnection() throws RepositoryException {
+ try
+ {
+ return new RyaSailRepositoryConnection(this, this.getSail().getConnection());
+ }
+ catch(SailException e)
+ {
+ throw new RepositoryException(e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepositoryConnection.java
----------------------------------------------------------------------
diff --git a/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepositoryConnection.java b/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepositoryConnection.java
new file mode 100644
index 0000000..6261b8c
--- /dev/null
+++ b/sail/src/main/java/mvm/rya/rdftriplestore/RyaSailRepositoryConnection.java
@@ -0,0 +1,109 @@
+package mvm.rya.rdftriplestore;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import mvm.rya.rdftriplestore.utils.CombineContextsRdfInserter;
+
+import org.openrdf.OpenRDFUtil;
+import org.openrdf.model.Resource;
+import org.openrdf.repository.RepositoryException;
+import org.openrdf.repository.sail.SailRepository;
+import org.openrdf.repository.sail.SailRepositoryConnection;
+import org.openrdf.repository.util.RDFLoader;
+import org.openrdf.rio.RDFFormat;
+import org.openrdf.rio.RDFHandlerException;
+import org.openrdf.rio.RDFParseException;
+import org.openrdf.sail.SailConnection;
+
+/**
+ * The real reason for this is so that we can combine contexts from an input stream/reader and the given contexts in the add function
+ */
+public class RyaSailRepositoryConnection extends SailRepositoryConnection {
+
+ protected RyaSailRepositoryConnection(SailRepository repository, SailConnection sailConnection) {
+ super(repository, sailConnection);
+ }
+
+ @Override
+ public void add(InputStream in, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException,
+ RepositoryException {
+ OpenRDFUtil.verifyContextNotNull(contexts);
+
+ CombineContextsRdfInserter rdfInserter = new CombineContextsRdfInserter(this);
+ rdfInserter.enforceContext(contexts);
+
+ boolean localTransaction = startLocalTransaction();
+ try {
+ RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory());
+ loader.load(in, baseURI, dataFormat, rdfInserter);
+
+ conditionalCommit(localTransaction);
+ } catch (RDFHandlerException e) {
+ conditionalRollback(localTransaction);
+
+ throw ((RepositoryException) e.getCause());
+ } catch (RDFParseException e) {
+ conditionalRollback(localTransaction);
+ throw e;
+ } catch (IOException e) {
+ conditionalRollback(localTransaction);
+ throw e;
+ } catch (RuntimeException e) {
+ conditionalRollback(localTransaction);
+ throw e;
+ }
+ }
+
+ @Override
+ public void add(Reader reader, String baseURI, RDFFormat dataFormat, Resource... contexts) throws IOException, RDFParseException,
+ RepositoryException {
+ OpenRDFUtil.verifyContextNotNull(contexts);
+
+ CombineContextsRdfInserter rdfInserter = new CombineContextsRdfInserter(this);
+ rdfInserter.enforceContext(contexts);
+
+ boolean localTransaction = startLocalTransaction();
+ try {
+ RDFLoader loader = new RDFLoader(getParserConfig(), getValueFactory());
+ loader.load(reader, baseURI, dataFormat, rdfInserter);
+
+ conditionalCommit(localTransaction);
+ } catch (RDFHandlerException e) {
+ conditionalRollback(localTransaction);
+
+ throw ((RepositoryException) e.getCause());
+ } catch (RDFParseException e) {
+ conditionalRollback(localTransaction);
+ throw e;
+ } catch (IOException e) {
+ conditionalRollback(localTransaction);
+ throw e;
+ } catch (RuntimeException e) {
+ conditionalRollback(localTransaction);
+ throw e;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/80faf06d/sail/src/main/java/mvm/rya/rdftriplestore/evaluation/ExternalBatchingIterator.java
----------------------------------------------------------------------
diff --git a/sail/src/main/java/mvm/rya/rdftriplestore/evaluation/ExternalBatchingIterator.java b/sail/src/main/java/mvm/rya/rdftriplestore/evaluation/ExternalBatchingIterator.java
new file mode 100644
index 0000000..b84104a
--- /dev/null
+++ b/sail/src/main/java/mvm/rya/rdftriplestore/evaluation/ExternalBatchingIterator.java
@@ -0,0 +1,33 @@
+package mvm.rya.rdftriplestore.evaluation;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+
+import info.aduna.iteration.CloseableIteration;
+
+import java.util.Collection;
+
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.QueryEvaluationException;
+
+public interface ExternalBatchingIterator {
+ public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Collection<BindingSet> bindingset) throws QueryEvaluationException;
+}