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/07 13:04:34 UTC
[04/51] [partial] incubator-rya git commit: Cannot delete temp branch,
doc'd it.
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/IndexWritingToolTest.java
----------------------------------------------------------------------
diff --git a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/IndexWritingToolTest.java b/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/IndexWritingToolTest.java
deleted file mode 100644
index 02a6f84..0000000
--- a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/IndexWritingToolTest.java
+++ /dev/null
@@ -1,326 +0,0 @@
-package mvm.rya.accumulo.pig;
-
-/*
- * 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.File;
-import java.io.IOException;
-import java.util.Map;
-import junit.framework.Assert;
-import org.apache.accumulo.core.client.AccumuloException;
-import org.apache.accumulo.core.client.AccumuloSecurityException;
-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.data.Key;
-import org.apache.accumulo.core.data.Range;
-import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
-import org.apache.commons.io.FileUtils;
-import org.apache.hadoop.util.ToolRunner;
-import org.junit.Test;
-
-public class IndexWritingToolTest {
-
-
-
- @Test
- public void testIndexWrite() {
-
-
-
- Connector accCon = null;
- Instance inst;
-
- String[] args = new String[7];
-
- args[0] = "src/test/resources/ResultsFile1.txt";
- args[1] = "src/test/resources/testQuery.txt";
- args[2] = "instance";
- args[3] = "mock";
- args[4] = "user";
- args[5] = "password";
- args[6] = "table";
-
- String query = null;
- try {
- query = FileUtils.readFileToString(new File(args[1]));
- } catch (IOException e1) {
-
- e1.printStackTrace();
- }
-
-
- try {
- inst = new MockInstance(args[2]);
- accCon = inst.getConnector(args[4], args[5].getBytes());
- if(accCon.tableOperations().exists(args[6])) {
- accCon.tableOperations().delete(args[6]);
- }
-
- accCon.tableOperations().create(args[6]);
-
- } catch (AccumuloException e) {
- e.printStackTrace();
- } catch (AccumuloSecurityException e) {
- e.printStackTrace();
- } catch (TableExistsException e) {
- e.printStackTrace();
- } catch (TableNotFoundException e) {
- e.printStackTrace();
- }
-
-
- int result = 5;
- try {
- result = ToolRunner.run(new IndexWritingTool(), args);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- Assert.assertEquals(0, result);
-
- Scanner scan = null;
-
- try {
- scan = accCon.createScanner("table", new Authorizations());
- } catch (TableNotFoundException e) {
-
- e.printStackTrace();
- }
- scan.setRange(new Range());
-
- int count = 0;
-
- for (Map.Entry<Key, Value> entry : scan) {
- String[] k = entry.getKey().getRow().toString().split("\u0000");
- String[] c = entry.getKey().getColumnFamily().toString().split("\u0000");
-
- if(count == 0) {
- Assert.assertEquals(k[0], "person10");
- Assert.assertEquals(k[1], "person8");
- Assert.assertEquals(k[2], "person9");
- Assert.assertEquals(c[0],"z");
- Assert.assertEquals(c[1],"x");
- Assert.assertEquals(c[2],"y");
- }
- else if(count == 2) {
- Assert.assertEquals(k[0], "person2");
- Assert.assertEquals(k[1], "person1");
- Assert.assertEquals(k[2], "person3");
- Assert.assertEquals(c[0],"y");
- Assert.assertEquals(c[1],"x");
- Assert.assertEquals(c[2],"z");
- }
- else if(count == 5) {
- Assert.assertEquals(k[0], "person3");
- Assert.assertEquals(k[1], "person2");
- Assert.assertEquals(k[2], "person4");
- Assert.assertEquals(c[0],"y");
- Assert.assertEquals(c[1],"x");
- Assert.assertEquals(c[2],"z");
- }
- else if(count == 9) {
- Assert.assertEquals(k[0], "person5");
- Assert.assertEquals(k[1], "person3");
- Assert.assertEquals(k[2], "person4");
- Assert.assertEquals(c[0],"z");
- Assert.assertEquals(c[1],"x");
- Assert.assertEquals(c[2],"y");
- }
- else if(count == 13) {
- Assert.assertEquals(k[0], "person6");
- Assert.assertEquals(k[1], "person5");
- Assert.assertEquals(k[2], "person4");
- Assert.assertEquals(c[0],"z");
- Assert.assertEquals(c[1],"y");
- Assert.assertEquals(c[2],"x");
- }
- else if(count == 17) {
- Assert.assertEquals(k[0], "person7");
- Assert.assertEquals(k[1], "person6");
- Assert.assertEquals(k[2], "person8");
- Assert.assertEquals(c[0],"y");
- Assert.assertEquals(c[1],"x");
- Assert.assertEquals(c[2],"z");
- }
- else if(count == 21) {
- Assert.assertEquals(k[0], "person9");
- Assert.assertEquals(k[1], "person7");
- Assert.assertEquals(k[2], "person8");
- Assert.assertEquals(c[0],"z");
- Assert.assertEquals(c[1],"x");
- Assert.assertEquals(c[2],"y");
- } else if(count == 24) {
- Assert.assertEquals(query, entry.getValue().toString());
- String[] varOrders = entry.getKey().getColumnQualifier().toString().split("\u0000");
- Assert.assertEquals(3,varOrders.length);
- Assert.assertEquals(varOrders[0],"z;y;x");
- Assert.assertEquals(varOrders[1],"y;x;z");
- Assert.assertEquals(varOrders[2],"z;x;y");
-
- } else {
- Assert.assertTrue(k[0].startsWith("person"));
- Assert.assertTrue(k[1].startsWith("person"));
- Assert.assertTrue(k[2].startsWith("person"));
-
- }
-
- count ++;
- }
-
- Assert.assertEquals(25, count);
-
-
-
-
- }
-
-
-
-
-
-
-
- @Test
- public void testIndexWrite2() {
-
-
-
- Connector accCon = null;
- Instance inst;
-
- String[] args = new String[7];
-
- args[0] = "src/test/resources/ResultsFile1.txt";
- args[1] = "src/test/resources/testQuery2.txt";
- args[2] = "instance";
- args[3] = "mock";
- args[4] = "user";
- args[5] = "password";
- args[6] = "table";
-
- String query = null;
- try {
- query = FileUtils.readFileToString(new File(args[1]));
- } catch (IOException e1) {
-
- e1.printStackTrace();
- }
-
-
- try {
- inst = new MockInstance(args[2]);
- accCon = inst.getConnector(args[4], args[5].getBytes());
- if(accCon.tableOperations().exists(args[6])) {
- accCon.tableOperations().delete(args[6]);
- }
-
- accCon.tableOperations().create(args[6]);
-
- } catch (AccumuloException e) {
-
- e.printStackTrace();
- } catch (AccumuloSecurityException e) {
-
- e.printStackTrace();
- } catch (TableExistsException e) {
-
- e.printStackTrace();
- } catch (TableNotFoundException e) {
-
- e.printStackTrace();
- }
-
-
- int result = 5;
- try {
- result = ToolRunner.run(new IndexWritingTool(), args);
- } catch (Exception e) {
-
- e.printStackTrace();
- }
-
- Assert.assertEquals(0, result);
-
- Scanner scan = null;
-
- try {
- scan = accCon.createScanner("table", new Authorizations());
- } catch (TableNotFoundException e) {
-
- e.printStackTrace();
- }
- scan.setRange(new Range());
-
- int count = 0;
-
- for (Map.Entry<Key, Value> entry : scan) {
- String[] k = entry.getKey().getRow().toString().split("\u0000");
- String[] c = entry.getKey().getColumnFamily().toString().split("\u0000");
-
- if(count == 0) {
- Assert.assertEquals(k[0], "person1");
- Assert.assertEquals(k[1], "person2");
- Assert.assertEquals(k[2], "person3");
- Assert.assertEquals(c[0],"x");
- Assert.assertEquals(c[1],"y");
- Assert.assertEquals(c[2],"z");
- }
- else if(count == 2) {
- Assert.assertEquals(k[0], "person3");
- Assert.assertEquals(k[1], "person4");
- Assert.assertEquals(k[2], "person5");
- Assert.assertEquals(c[0],"x");
- Assert.assertEquals(c[1],"y");
- Assert.assertEquals(c[2],"z");
- }
- else if(count == 5) {
- Assert.assertEquals(k[0], "person6");
- Assert.assertEquals(k[1], "person7");
- Assert.assertEquals(k[2], "person8");
- Assert.assertEquals(c[0],"x");
- Assert.assertEquals(c[1],"y");
- Assert.assertEquals(c[2],"z");
- }
-
-
- count ++;
- System.out.println(count);
- }
-
- Assert.assertEquals(9, count);
-
-
-
-
- }
-
-
-
-
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlQueryPigEngineTest.java
----------------------------------------------------------------------
diff --git a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlQueryPigEngineTest.java b/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlQueryPigEngineTest.java
deleted file mode 100644
index e4cf10e..0000000
--- a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlQueryPigEngineTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package mvm.rya.accumulo.pig;
-
-/*
- * 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 junit.framework.TestCase;
-import org.apache.pig.ExecType;
-
-/**
- * Created by IntelliJ IDEA.
- * Date: 4/23/12
- * Time: 10:14 AM
- * To change this template use File | Settings | File Templates.
- */
-public class SparqlQueryPigEngineTest extends TestCase {
-
- private SparqlQueryPigEngine engine;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix("l_");
- visitor.setInstance("stratus");
- visitor.setZk("stratus13:2181");
- visitor.setUser("root");
- visitor.setPassword("password");
-
- engine = new SparqlQueryPigEngine();
- engine.setSparqlToPigTransformVisitor(visitor);
- engine.setExecType(ExecType.LOCAL);
- engine.setInference(false);
- engine.setStats(false);
- engine.init();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- engine.destroy();
- }
-
- public void testStatementPattern() throws Exception {
- String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
- " PREFIX ub: <urn:lubm:rdfts#>\n" +
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
- " SELECT * WHERE\n" +
- " {\n" +
- "\t<http://www.Department0.University0.edu> ?p ?o\n" +
- " }\n" +
- "";
-
-// engine.runQuery(query, "/temp/testSP");
- assertTrue(engine.generatePigScript(query).contains("A = load 'accumulo://l_?instance=stratus&user=root&password=password&zookeepers=stratus13:2181&subject=<http://www.Department0.University0.edu>' using mvm.rya.accumulo.pig.StatementPatternStorage() AS (A_s:chararray, p:chararray, o:chararray);\n" +
- "PROJ = FOREACH A GENERATE p,o;"));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlToPigTransformVisitorTest.java
----------------------------------------------------------------------
diff --git a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlToPigTransformVisitorTest.java b/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlToPigTransformVisitorTest.java
deleted file mode 100644
index b011a24..0000000
--- a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/SparqlToPigTransformVisitorTest.java
+++ /dev/null
@@ -1,402 +0,0 @@
-package mvm.rya.accumulo.pig;
-
-/*
- * 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 junit.framework.TestCase;
-import mvm.rya.accumulo.pig.optimizer.SimilarVarJoinOptimizer;
-import org.openrdf.query.algebra.QueryRoot;
-import org.openrdf.query.algebra.TupleExpr;
-import org.openrdf.query.parser.ParsedQuery;
-import org.openrdf.query.parser.QueryParser;
-import org.openrdf.query.parser.sparql.SPARQLParser;
-
-/**
- * Created by IntelliJ IDEA.
- * Date: 4/12/12
- * Time: 10:18 AM
- * To change this template use File | Settings | File Templates.
- */
-public class SparqlToPigTransformVisitorTest extends TestCase {
-
- private String zk;
- private String instance;
- private String tablePrefix;
- private String user;
- private String password;
-
- protected void setUp() throws Exception {
- super.setUp();
- zk = "zoo";
- instance = "instance";
- tablePrefix = "l_";
- user = "root";
- password = "root";
- }
-
- public void testStatementPattern() throws Exception {
- String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
- " PREFIX ub: <urn:lubm:rdfts#>\n" +
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
- " SELECT * WHERE\n" +
- " {\n" +
- "\t?x rdf:type ub:UndergraduateStudent\n" +
- " }\n" +
- "";
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
-// System.out.println(parsedQuery);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
-// System.out.println(visitor.getPigScript());
- }
-
- public void testStatementPatternContext() throws Exception {
- String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
- " PREFIX ub: <urn:lubm:rdfts#>\n" +
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
- " SELECT * WHERE\n" +
- " {\n" +
- " GRAPH ub:g1 {\n" +
- "\t?x rdf:type ub:UndergraduateStudent\n" +
- " }\n" +
- " }\n" +
- "";
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
-// System.out.println(parsedQuery);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
-// System.out.println(visitor.getPigScript());
- }
-
- public void testStatementPatternContextVar() throws Exception {
- String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
- " PREFIX ub: <urn:lubm:rdfts#>\n" +
- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
- " SELECT * WHERE\n" +
- " {\n" +
- " GRAPH ?g {\n" +
- "\t?x rdf:type ub:UndergraduateStudent\n" +
- " }\n" +
- " ?x ub:pred ?g." +
- " }\n" +
- "";
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
-// System.out.println(parsedQuery);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
-// System.out.println(visitor.getPigScript());
- }
-
- public void testJoin() throws Exception {
- String query = "select * where {\n" +
- "?subj <urn:lubm:rdfts#name> 'Department0'.\n" +
- "?subj <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" +
- "}";
-// System.out.println(query);
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
-// System.out.println(parsedQuery);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
-// System.out.println(visitor.getPigScript());
- }
-
- public void testMutliReturnJoin() throws Exception {
- String query = "select * where {\n" +
- "?subj <urn:lubm:rdfts#name> 'Department0'.\n" +
- "?subj <urn:lubm:rdfts#subOrganizationOf> ?suborg.\n" +
- "}";
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
- System.out.println(query);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
- System.out.println(visitor.getPigScript());
- }
-
- public void testMutlipleJoins() throws Exception {
- String query = "select * where {\n" +
- "?subj <urn:lubm:rdfts#name> 'Department0'.\n" +
- "?subj <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" +
- "?subj <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <urn:lubm:rdfts#Department>.\n" +
- "}";
-// System.out.println(query);
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
-// System.out.println(parsedQuery);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
-// System.out.println(visitor.getPigScript());
- }
-
- public void testCross() throws Exception {
- String query = "select * where {\n" +
- "?subj0 <urn:lubm:rdfts#name> 'Department0'.\n" +
- "?subj1 <urn:lubm:rdfts#name> 'Department1'.\n" +
- "?subj0 <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" +
- "?subj1 <urn:lubm:rdfts#subOrganizationOf> <http://www.University0.edu>.\n" +
- "}";
-// System.out.println(query);
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
- QueryRoot tupleExpr = new QueryRoot(parsedQuery.getTupleExpr());
-
- SimilarVarJoinOptimizer similarVarJoinOptimizer = new SimilarVarJoinOptimizer();
- similarVarJoinOptimizer.optimize(tupleExpr, null, null);
-
-// System.out.println(tupleExpr);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(tupleExpr);
-// System.out.println(visitor.getPigScript());
- }
-
- public void testLimit() throws Exception {
- String query = "select * where {\n" +
- "?subj <urn:lubm:rdfts#name> 'Department0'.\n" +
- "?subj <urn:lubm:rdfts#subOrganizationOf> ?suborg.\n" +
- "} limit 100";
-// System.out.println(query);
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
-// System.out.println(parsedQuery);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
-// System.out.println(visitor.getPigScript());
- }
-
- public void testHardQuery() throws Exception {
- String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
- " PREFIX ub: <urn:lubm:rdfts#>\n" +
- " SELECT * WHERE\n" +
- " {\n" +
- " ?y rdf:type ub:University .\n" +
- " ?z ub:subOrganizationOf ?y .\n" +
- " ?z rdf:type ub:Department .\n" +
- " ?x ub:memberOf ?z .\n" +
- " ?x ub:undergraduateDegreeFrom ?y .\n" +
- " ?x rdf:type ub:GraduateStudent .\n" +
- " }\n" +
- "limit 100";
-// String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
-// " PREFIX ub: <urn:lubm:rdfts#>\n" +
-// " SELECT * WHERE\n" +
-// " {\n" +
-// "\t?x ub:advisor ?y.\n" +
-// "\t?y ub:teacherOf ?z.\n" +
-// "\t?x ub:takesCourse ?z.\n" +
-// "\t?x rdf:type ub:Student.\n" +
-// "\t?y rdf:type ub:Faculty.\n" +
-// "\t?z rdf:type ub:Course.\n" +
-// " }\n" +
-// "limit 100";
-// System.out.println(query);
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
- TupleExpr tupleExpr = parsedQuery.getTupleExpr();
-
-// CloudbaseRdfEvalStatsDAO rdfEvalStatsDAO = new CloudbaseRdfEvalStatsDAO();
-// rdfEvalStatsDAO.setConnector(new ZooKeeperInstance("stratus", "stratus13:2181").getConnector("root", "password".getBytes()));
-// rdfEvalStatsDAO.setEvalTable("l_eval");
-// RdfCloudTripleStoreEvaluationStatistics stats = new RdfCloudTripleStoreEvaluationStatistics(new Configuration(), rdfEvalStatsDAO);
-// (new SimilarVarJoinOptimizer(stats)).optimize(tupleExpr, null, null);
-
-// System.out.println(tupleExpr);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(tupleExpr));
- //System.out.println(visitor.getPigScript());
- }
-
- public void testFixedStatementPatternInferenceQuery() throws Exception {
- String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
- " PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n" +
- " PREFIX ub: <urn:lubm:rdfts#>\n" +
- " SELECT * WHERE\n" +
- " {\n" +
- " ?y ub:memberOf <http://www.Department3.University10.edu>.\n" +
- " {?y rdf:type ub:Professor.}\n" +
- " UNION \n" +
- " {?y rdf:type ub:GraduateStudent.}\n" +
- " }";
-// System.out.println(query);
- QueryParser parser = new SPARQLParser();
- ParsedQuery parsedQuery = parser.parseQuery(query, null);
-
- TupleExpr tupleExpr = parsedQuery.getTupleExpr();
-
-// Configuration conf = new Configuration();
-// Connector connector = new ZooKeeperInstance("stratus", "stratus13:2181").getConnector("root", "password".getBytes());
-//
-// InferenceEngine inferenceEngine = new InferenceEngine();
-// CloudbaseRdfDAO rdfDAO = new CloudbaseRdfDAO();
-// rdfDAO.setConf(conf);
-// rdfDAO.setConnector(connector);
-// rdfDAO.setNamespaceTable("l_ns");
-// rdfDAO.setSpoTable("l_spo");
-// rdfDAO.setPoTable("l_po");
-// rdfDAO.setOspTable("l_osp");
-// rdfDAO.init();
-//
-// inferenceEngine.setRdfDao(rdfDAO);
-// inferenceEngine.setConf(conf);
-// inferenceEngine.init();
-//
-// tupleExpr.visit(new TransitivePropertyVisitor(conf, inferenceEngine));
-// tupleExpr.visit(new SymmetricPropertyVisitor(conf, inferenceEngine));
-// tupleExpr.visit(new InverseOfVisitor(conf, inferenceEngine));
-// tupleExpr.visit(new SubPropertyOfVisitor(conf, inferenceEngine));
-// tupleExpr.visit(new SubClassOfVisitor(conf, inferenceEngine));
-//
-// CloudbaseRdfEvalStatsDAO rdfEvalStatsDAO = new CloudbaseRdfEvalStatsDAO();
-// rdfEvalStatsDAO.setConnector(connector);
-// rdfEvalStatsDAO.setEvalTable("l_eval");
-// RdfCloudTripleStoreEvaluationStatistics stats = new RdfCloudTripleStoreEvaluationStatistics(conf, rdfEvalStatsDAO);
-// (new QueryJoinOptimizer(stats)).optimize(tupleExpr, null, null);
-
-// System.out.println(tupleExpr);
-
- SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
- visitor.setTablePrefix(tablePrefix);
- visitor.setInstance(instance);
- visitor.setZk(zk);
- visitor.setUser(user);
- visitor.setPassword(password);
- visitor.meet(new QueryRoot(tupleExpr));
-// System.out.println(visitor.getPigScript());
- }
-
-// public void testInverseOf() throws Exception {
-// String query = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" +
-// " PREFIX ub: <urn:lubm:rdfts#>\n" +
-// " SELECT * WHERE\n" +
-// " {\n" +
-// " ?x rdf:type ub:Person .\n" +
-// " <http://www.University0.edu> ub:hasAlumnus ?x .\n" +
-// " } ";
-// System.out.println(query);
-// QueryParser parser = new SPARQLParser();
-// ParsedQuery parsedQuery = parser.parseQuery(query, null);
-// TupleExpr tupleExpr = parsedQuery.getTupleExpr();
-//
-// Configuration conf = new Configuration();
-// Connector connector = new ZooKeeperInstance("stratus", "stratus13:2181").getConnector("root", "password".getBytes());
-//
-// InferenceEngine inferenceEngine = new InferenceEngine();
-// CloudbaseRdfDAO rdfDAO = new CloudbaseRdfDAO();
-// rdfDAO.setConf(conf);
-// rdfDAO.setConnector(connector);
-// rdfDAO.setNamespaceTable("l_ns");
-// rdfDAO.setSpoTable("l_spo");
-// rdfDAO.setPoTable("l_po");
-// rdfDAO.setOspTable("l_osp");
-// rdfDAO.init();
-//
-// inferenceEngine.setRdfDao(rdfDAO);
-// inferenceEngine.setConf(conf);
-// inferenceEngine.init();
-//
-// tupleExpr.visit(new TransitivePropertyVisitor(conf, inferenceEngine));
-// tupleExpr.visit(new SymmetricPropertyVisitor(conf, inferenceEngine));
-// tupleExpr.visit(new InverseOfVisitor(conf, inferenceEngine));
-//
-// CloudbaseRdfEvalStatsDAO rdfEvalStatsDAO = new CloudbaseRdfEvalStatsDAO();
-// rdfEvalStatsDAO.setConnector(connector);
-// rdfEvalStatsDAO.setEvalTable("l_eval");
-// RdfCloudTripleStoreEvaluationStatistics stats = new RdfCloudTripleStoreEvaluationStatistics(conf, rdfEvalStatsDAO);
-// (new QueryJoinOptimizer(stats)).optimize(tupleExpr, null, null);
-//
-//
-// System.out.println(tupleExpr);
-//
-// SparqlToPigTransformVisitor visitor = new SparqlToPigTransformVisitor();
-// visitor.setTablePrefix("l_");
-// visitor.setInstance("stratus");
-// visitor.setZk("stratus13:2181");
-// visitor.setUser("root");
-// visitor.setPassword("password");
-// visitor.meet(new QueryRoot(parsedQuery.getTupleExpr()));
-// System.out.println(visitor.getPigScript());
-// }
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/StatementPatternStorageTest.java
----------------------------------------------------------------------
diff --git a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/StatementPatternStorageTest.java b/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/StatementPatternStorageTest.java
deleted file mode 100644
index 5bc4a34..0000000
--- a/pig/accumulo.pig/src/test/java/mvm/rya/accumulo/pig/StatementPatternStorageTest.java
+++ /dev/null
@@ -1,185 +0,0 @@
-package mvm.rya.accumulo.pig;
-
-/*
- * 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.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-import mvm.rya.accumulo.AccumuloRdfConfiguration;
-import mvm.rya.accumulo.AccumuloRyaDAO;
-import mvm.rya.api.RdfCloudTripleStoreConstants;
-import mvm.rya.api.domain.RyaStatement;
-import mvm.rya.api.domain.RyaType;
-import mvm.rya.api.domain.RyaURI;
-
-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.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.mapreduce.InputFormat;
-import org.apache.hadoop.mapreduce.InputSplit;
-import org.apache.hadoop.mapreduce.Job;
-import org.apache.hadoop.mapreduce.RecordReader;
-import org.apache.hadoop.mapreduce.TaskAttemptContext;
-import org.apache.hadoop.mapreduce.TaskAttemptID;
-import org.apache.hadoop.mapreduce.task.TaskAttemptContextImpl;
-import org.apache.pig.data.Tuple;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.ValueFactoryImpl;
-
-/**
- * Created by IntelliJ IDEA.
- * Date: 4/20/12
- * Time: 5:14 PM
- * To change this template use File | Settings | File Templates.
- */
-public class StatementPatternStorageTest 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);
- }
-
- public void testSimplePredicateRange() throws Exception {
- ryaDAO.add(new RyaStatement(new RyaURI(namespace, "a"),new RyaURI(namespace,"p"), new RyaType("l")));
- ryaDAO.add(new RyaStatement(new RyaURI(namespace, "b"), new RyaURI(namespace, "p"), new RyaType("l")));
- ryaDAO.add(new RyaStatement(new RyaURI(namespace, "c"), new RyaURI(namespace, "n"), new RyaType("l")));
-
-
- int count = 0;
- List<StatementPatternStorage> storages = createStorages("accumulo://" + tablePrefix + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&predicate=<" + namespace + "p>&mock=true");
- for (StatementPatternStorage storage : storages) {
- while (true) {
- Tuple next = storage.getNext();
- if (next == null) {
- break;
- }
- count++;
- }
- }
- assertEquals(2, count);
- ryaDAO.destroy();
- }
-
- public void testContext() throws Exception {
- ryaDAO.add(new RyaStatement(new RyaURI(namespace, "a"), new RyaURI(namespace, "p"), new RyaType("l1")));
- ryaDAO.add(new RyaStatement(new RyaURI(namespace, "a"), new RyaURI(namespace, "p"), new RyaType("l2"), new RyaURI(namespace, "g1")));
-
-
- int count = 0;
- List<StatementPatternStorage> storages = createStorages("accumulo://" + tablePrefix + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&predicate=<" + namespace + "p>&mock=true");
- for (StatementPatternStorage storage : storages) {
- while (true) {
- Tuple next = storage.getNext();
- if (next == null) {
- break;
- }
- count++;
- }
- }
- assertEquals(2, count);
-
- count = 0;
- storages = createStorages("accumulo://" + tablePrefix + "?instance=" + instance + "&user=" + user + "&password=" + pwd + "&predicate=<" + namespace + "p>&context=<"+namespace+"g1>&mock=true");
- for (StatementPatternStorage storage : storages) {
- while (true) {
- Tuple next = storage.getNext();
- if (next == null) {
- break;
- }
- count++;
- }
- }
- assertEquals(1, count);
-
- ryaDAO.destroy();
- }
-
- protected List<StatementPatternStorage> createStorages(String location) throws IOException, InterruptedException {
- List<StatementPatternStorage> storages = new ArrayList<StatementPatternStorage>();
- StatementPatternStorage storage = new StatementPatternStorage();
- InputFormat inputFormat = storage.getInputFormat();
- Job job = new Job(new Configuration());
- storage.setLocation(location, job);
- List<InputSplit> splits = inputFormat.getSplits(job);
- assertNotNull(splits);
-
- for (InputSplit inputSplit : splits) {
- storage = new StatementPatternStorage();
- job = new Job(new Configuration());
- storage.setLocation(location, job);
- TaskAttemptContext taskAttemptContext = new TaskAttemptContextImpl(job.getConfiguration(),
- new TaskAttemptID("jtid", 0, false, 0, 0));
- RecordReader recordReader = inputFormat.createRecordReader(inputSplit,
- taskAttemptContext);
- recordReader.initialize(inputSplit, taskAttemptContext);
-
- storage.prepareToRead(recordReader, null);
- storages.add(storage);
- }
- return storages;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/accumulo.pig/src/test/resources/ResultsFile1.txt
----------------------------------------------------------------------
diff --git a/pig/accumulo.pig/src/test/resources/ResultsFile1.txt b/pig/accumulo.pig/src/test/resources/ResultsFile1.txt
deleted file mode 100644
index e1dcc92..0000000
--- a/pig/accumulo.pig/src/test/resources/ResultsFile1.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-person1 person2 person3
-person2 person3 person4
-person3 person4 person5
-person4 person5 person6
-person5 person6 person7
-person6 person7 person8
-person7 person8 person9
-person8 person9 person10
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/accumulo.pig/src/test/resources/testQuery.txt
----------------------------------------------------------------------
diff --git a/pig/accumulo.pig/src/test/resources/testQuery.txt b/pig/accumulo.pig/src/test/resources/testQuery.txt
deleted file mode 100644
index 8f5d022..0000000
--- a/pig/accumulo.pig/src/test/resources/testQuery.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-#prefix z, y, x
-#prefix y, x, z
-#prefix z, x, y
-SELECT ?x ?y ?z WHERE {
-?x <uri:talksTo> ?y.
-?y <uri:hangsOutWith> ?z.
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/accumulo.pig/src/test/resources/testQuery2.txt
----------------------------------------------------------------------
diff --git a/pig/accumulo.pig/src/test/resources/testQuery2.txt b/pig/accumulo.pig/src/test/resources/testQuery2.txt
deleted file mode 100644
index 476b39c..0000000
--- a/pig/accumulo.pig/src/test/resources/testQuery2.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-SELECT ?x ?y ?z WHERE {
-?x <uri:talksTo> ?y.
-?y <uri:hangsOutWith> ?z.
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/pig/pom.xml
----------------------------------------------------------------------
diff --git a/pig/pom.xml b/pig/pom.xml
deleted file mode 100644
index 2df2d1c..0000000
--- a/pig/pom.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<!--
-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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya-project</artifactId>
- <version>3.2.10-SNAPSHOT</version>
- </parent>
-
- <artifactId>rya.pig</artifactId>
- <name>Apache Rya Pig Projects</name>
-
- <packaging>pom</packaging>
-
- <modules>
- <module>accumulo.pig</module>
- </modules>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/sail/pom.xml
----------------------------------------------------------------------
diff --git a/sail/pom.xml b/sail/pom.xml
deleted file mode 100644
index dfd2811..0000000
--- a/sail/pom.xml
+++ /dev/null
@@ -1,98 +0,0 @@
-<?xml version='1.0'?>
-<!--
-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.
--->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya-project</artifactId>
- <version>3.2.10-SNAPSHOT</version>
- </parent>
-
- <artifactId>rya.sail</artifactId>
- <name>Apache Rya SAIL</name>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.provenance</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>rya.prospector</artifactId>
- </dependency>
-
- <dependency>
- <groupId>net.sf.ehcache</groupId>
- <artifactId>ehcache-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.apache.hadoop</groupId>
- <artifactId>hadoop-common</artifactId>
- </dependency>
-
- <dependency>
- <groupId>com.tinkerpop.blueprints</groupId>
- <artifactId>blueprints-core</artifactId>
- </dependency>
-
- <dependency>
- <groupId>org.openrdf.sesame</groupId>
- <artifactId>sesame-runtime</artifactId>
- </dependency>
-
- <!-- Test -->
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.rya</groupId>
- <artifactId>accumulo.rya</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes combine.children="append">
- <exclude>**/resources/META-INF/org.openrdf.store.schemas</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/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
deleted file mode 100644
index 4fcc726..0000000
--- a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStore.java
+++ /dev/null
@@ -1,179 +0,0 @@
-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/5a03ef61/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
deleted file mode 100644
index 24ec109..0000000
--- a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreConnection.java
+++ /dev/null
@@ -1,623 +0,0 @@
-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/5a03ef61/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
deleted file mode 100644
index 42f1aa4..0000000
--- a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-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/5a03ef61/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
deleted file mode 100644
index 6542b55..0000000
--- a/sail/src/main/java/mvm/rya/rdftriplestore/RdfCloudTripleStoreSailConfig.java
+++ /dev/null
@@ -1,133 +0,0 @@
-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);
- }
- }
-}