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:51 UTC
[21/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/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleExecutionPlanGeneratorTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleExecutionPlanGeneratorTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleExecutionPlanGeneratorTest.java
deleted file mode 100644
index ffb7b2d..0000000
--- a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleExecutionPlanGeneratorTest.java
+++ /dev/null
@@ -1,364 +0,0 @@
-package mvm.rya.indexing.IndexPlanValidator;
-
-/*
- * 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 org.junit.Assert.*;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.Assert;
-
-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;
-
-import com.beust.jcommander.internal.Lists;
-import com.beust.jcommander.internal.Sets;
-
-public class TupleExecutionPlanGeneratorTest {
-
-
-
- private String q1 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
- private String q2 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?s a ?t ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
- private String q3 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?u <uri:talksTo> ?s . "//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?s a ?t ."//
- + "}";//
-
-
- private String q4 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + "}";//
-
-
- private String q5 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?s a ?t ."//
- + "}";//
-
-
- private String q6 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?u <uri:talksTo> ?s . "//
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + "}";//
-
-
-
-
- private String q7 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + "}";//
-
-
- private String q8 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?s a ?t ."//
- + "}";//
-
-
-
-
-
-
- private String q9 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?t > 2). "//
- + " Filter(?s > 1). "//
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
- private String q10 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?t > 2). "//
- + " Filter(?s > 1). "//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?s a ?t ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
- private String q11 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?t > 2). "//
- + " Filter(?s > 1). "//
- + " ?u <uri:talksTo> ?s . "//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?s a ?t ."//
- + "}";//
-
-
- private String q12 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?t > 2). "//
- + " Filter(?s > 1). "//
- + " ?s a ?t ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + "}";//
-
-
- private String q13 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?t > 2). "//
- + " Filter(?s > 1). "//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?s a ?t ."//
- + "}";//
-
-
- private String q14 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?t > 2). "//
- + " Filter(?s > 1). "//
- + " ?u <uri:talksTo> ?s . "//
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + "}";//
-
-
- private String q15 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?s > 1). "//
- + " Filter(?t > 2). "//
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
-
-
- @Test
- public void testTwoNodeOrder() {
-
- SPARQLParser parser = new SPARQLParser();
-
- ParsedQuery pq1 = null;
- ParsedQuery pq2 = null;
-
- try {
- pq1 = parser.parseQuery(q7, null);
- pq2 = parser.parseQuery(q8, null);
- } catch (MalformedQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- Set<TupleExpr> tupSet = Sets.newHashSet();
- tupSet.add(pq1.getTupleExpr());
-
- TupleExecutionPlanGenerator tep = new TupleExecutionPlanGenerator();
- Iterator<TupleExpr> processedTups = tep.getPlans(tupSet.iterator());
-
- List<TupleExpr> processedTupList = Lists.newArrayList();
-
- int size = 0;
-
- while(processedTups.hasNext()) {
- Assert.assertTrue(processedTups.hasNext());
- processedTupList.add(processedTups.next());
- size++;
- }
-
- Assert.assertEquals(2, size);
-
- Assert.assertTrue(processedTupList.get(0).equals(pq2.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(1).equals(pq1.getTupleExpr()));
-
- }
-
-
-
-
-
- @Test
- public void testThreeNodeOrder() {
-
- SPARQLParser parser = new SPARQLParser();
-
- ParsedQuery pq1 = null;
- ParsedQuery pq2 = null;
- ParsedQuery pq3 = null;
- ParsedQuery pq4 = null;
- ParsedQuery pq5 = null;
- ParsedQuery pq6 = null;
-
- try {
- pq1 = parser.parseQuery(q1, null);
- pq2 = parser.parseQuery(q2, null);
- pq3 = parser.parseQuery(q3, null);
- pq4 = parser.parseQuery(q4, null);
- pq5 = parser.parseQuery(q5, null);
- pq6 = parser.parseQuery(q6, null);
- } catch (MalformedQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- Set<TupleExpr> tupSet = Sets.newHashSet();
- tupSet.add(pq1.getTupleExpr());
-
- TupleExecutionPlanGenerator tep = new TupleExecutionPlanGenerator();
- Iterator<TupleExpr> processedTups= tep.getPlans(tupSet.iterator());
-
- List<TupleExpr> processedTupList = Lists.newArrayList();
-
- int size = 0;
-
- while(processedTups.hasNext()) {
- Assert.assertTrue(processedTups.hasNext());
- processedTupList.add(processedTups.next());
- size++;
- }
-
- Assert.assertTrue(!processedTups.hasNext());
- Assert.assertEquals(6, size);
-
- Assert.assertTrue(processedTupList.get(5).equals(pq1.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(0).equals(pq2.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(2).equals(pq3.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(4).equals(pq4.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(1).equals(pq5.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(3).equals(pq6.getTupleExpr()));
-
- }
-
-
-
- @Test
- public void testThreeNodeOrderFilter() {
-
- SPARQLParser parser = new SPARQLParser();
-
- ParsedQuery pq1 = null;
- ParsedQuery pq2 = null;
- ParsedQuery pq3 = null;
- ParsedQuery pq4 = null;
- ParsedQuery pq5 = null;
- ParsedQuery pq6 = null;
- ParsedQuery pq7 = null;
-
- try {
- pq1 = parser.parseQuery(q9, null);
- pq2 = parser.parseQuery(q10, null);
- pq3 = parser.parseQuery(q11, null);
- pq4 = parser.parseQuery(q12, null);
- pq5 = parser.parseQuery(q13, null);
- pq6 = parser.parseQuery(q14, null);
- pq7 = parser.parseQuery(q15, null);
- } catch (MalformedQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- System.out.println(pq1.getTupleExpr());
-
- Set<TupleExpr> tupSet = Sets.newHashSet();
- tupSet.add(pq7.getTupleExpr());
-
- TupleExecutionPlanGenerator tep = new TupleExecutionPlanGenerator();
- Iterator<TupleExpr> processedTups= tep.getPlans(tupSet.iterator());
-
- List<TupleExpr> processedTupList = Lists.newArrayList();
-
- int size = 0;
-
- while(processedTups.hasNext()) {
-
- Assert.assertTrue(processedTups.hasNext());
- TupleExpr te = processedTups.next();
- processedTupList.add(te);
- System.out.println("Processed tups are " + te);
- size++;
- }
-
- Assert.assertTrue(!processedTups.hasNext());
- Assert.assertEquals(6, size);
-
- Assert.assertTrue(processedTupList.get(5).equals(pq1.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(0).equals(pq2.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(2).equals(pq3.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(4).equals(pq4.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(1).equals(pq5.getTupleExpr()));
- Assert.assertTrue(processedTupList.get(3).equals(pq6.getTupleExpr()));
-
- }
-
-
-
-
-
-
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleReArrangerTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleReArrangerTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleReArrangerTest.java
deleted file mode 100644
index 96466cb..0000000
--- a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/TupleReArrangerTest.java
+++ /dev/null
@@ -1,141 +0,0 @@
-package mvm.rya.indexing.IndexPlanValidator;
-
-/*
- * 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.util.List;
-
-import junit.framework.Assert;
-
-import org.junit.Test;
-import org.openrdf.query.MalformedQueryException;
-import org.openrdf.query.algebra.TupleExpr;
-import org.openrdf.query.algebra.evaluation.impl.FilterOptimizer;
-import org.openrdf.query.parser.ParsedQuery;
-import org.openrdf.query.parser.sparql.SPARQLParser;
-
-public class TupleReArrangerTest {
-
- @Test
- public void tupleReArrangeTest1() throws MalformedQueryException {
-
- String queryString = ""//
- + "SELECT ?a ?b ?c ?d ?e" //
- + "{" //
- + "{ ?a a ?b . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?c }"//
- + " UNION { ?a <uri:talksTo> ?d . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?e }"//
- + "}";//
-
- SPARQLParser sp = new SPARQLParser();
- ParsedQuery pq = sp.parseQuery(queryString, null);
- List<TupleExpr> tuples = TupleReArranger.getTupleReOrderings(pq.getTupleExpr());
-
- Assert.assertEquals(4, tuples.size());
-
- }
-
-
-
- @Test
- public void tupleReArrangeTest2() throws MalformedQueryException {
-
- String queryString = ""//
- + "SELECT ?a ?b ?c ?d ?e ?x ?y" //
- + "{" //
- + " ?e <uri:laughsAt> ?x ." //
- + " ?e <uri:livesIn> ?y . "//
- + "{ ?a a ?b . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?c }"//
- + " UNION { ?a <uri:talksTo> ?d . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?e }"//
- + "}";//
-
- SPARQLParser sp = new SPARQLParser();
- ParsedQuery pq = sp.parseQuery(queryString, null);
- List<TupleExpr> tuples = TupleReArranger.getTupleReOrderings(pq.getTupleExpr());
-
-
- Assert.assertEquals(24, tuples.size());
-
- }
-
-
-
-
-
- @Test
- public void tupleReArrangeTest3() throws MalformedQueryException {
-
- String queryString = ""//
- + "SELECT ?a ?b ?c ?d ?e ?x ?y" //
- + "{" //
- + " Filter(?c = <uri:label2>)" //
- + " Filter(?x = <uri:somethingFunny>) "//
- + " ?e <uri:laughsAt> ?x ." //
- + " ?e <uri:livesIn> ?y . "//
- + "{ ?a a ?b . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?c }"//
- + " UNION { ?a <uri:talksTo> ?d . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?e }"//
- + "}";//
-
- SPARQLParser sp = new SPARQLParser();
- ParsedQuery pq = sp.parseQuery(queryString, null);
- List<TupleExpr> tuples = TupleReArranger.getTupleReOrderings(pq.getTupleExpr());
-
- Assert.assertEquals(24, tuples.size());
-
- }
-
-
-
-
-
-
-
- @Test
- public void tupleReArrangeTest4() throws MalformedQueryException {
-
- String queryString = ""//
- + "SELECT ?a ?b ?c ?d ?e ?x ?y" //
- + "{" //
- + " Filter(?c = <uri:label2>)" //
- + " Filter(?x = <uri:somethingFunny>) "//
- + " Filter(?d = <uri:Fred> ) " //
- + " ?e <uri:laughsAt> ?x ." //
- + " ?e <uri:livesIn> ?y . "//
- + "{ ?a a ?b . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?c }"//
- + " UNION { ?a <uri:talksTo> ?d . ?a <http://www.w3.org/2000/01/rdf-schema#label> ?e }"//
- + "}";//
-
- SPARQLParser sp = new SPARQLParser();
- ParsedQuery pq = sp.parseQuery(queryString, null);
- TupleExpr te = pq.getTupleExpr();
- (new FilterOptimizer()).optimize(te, null, null);
- System.out.println(te);
- List<TupleExpr> tuples = TupleReArranger.getTupleReOrderings(te);
- System.out.println(tuples);
-
- Assert.assertEquals(24, tuples.size());
-
- }
-
-
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/ValidIndexCombinationGeneratorTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/ValidIndexCombinationGeneratorTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/ValidIndexCombinationGeneratorTest.java
deleted file mode 100644
index 38f7813..0000000
--- a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/ValidIndexCombinationGeneratorTest.java
+++ /dev/null
@@ -1,620 +0,0 @@
-package mvm.rya.indexing.IndexPlanValidator;
-
-/*
- * 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.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import junit.framework.Assert;
-import mvm.rya.indexing.external.tupleSet.ExternalTupleSet;
-import mvm.rya.indexing.external.tupleSet.SimpleExternalTupleSet;
-import org.junit.Test;
-import org.openrdf.query.MalformedQueryException;
-import org.openrdf.query.algebra.Projection;
-import org.openrdf.query.parser.ParsedQuery;
-import org.openrdf.query.parser.sparql.SPARQLParser;
-import com.google.common.collect.Lists;
-
-
-public class ValidIndexCombinationGeneratorTest {
-
-
-
-
-
-
- @Test
- public void singleIndex() {
- String q1 = ""//
- + "SELECT ?f ?m ?d " //
- + "{" //
- + " ?f a ?m ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?f <uri:hangOutWith> ?m ." //
- + " ?m <uri:hangOutWith> ?d ." //
- + " ?f <uri:associatesWith> ?m ." //
- + " ?m <uri:associatesWith> ?d ." //
- + "}";//
-
-
-
-
-
-
- SPARQLParser parser = new SPARQLParser();
- ParsedQuery pq1 = null;
-
-
- SimpleExternalTupleSet extTup1 = null;
-
-
-
-
-
-
- try {
- pq1 = parser.parseQuery(q1, null);
-
-
-
- extTup1 = new SimpleExternalTupleSet((Projection) pq1.getTupleExpr());
-
-
- } catch (MalformedQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- List<ExternalTupleSet> indexList = Lists.newArrayList();
- indexList.add(extTup1);
-
-
- ValidIndexCombinationGenerator vic = new ValidIndexCombinationGenerator(pq1.getTupleExpr());
- Iterator<List<ExternalTupleSet>> combos = vic.getValidIndexCombos(indexList);
- int size = 0;
- while(combos.hasNext()) {
- combos.hasNext();
- size++;
- combos.next();
- combos.hasNext();
- }
-
- Assert.assertTrue(!combos.hasNext());
- Assert.assertEquals(1,size);
-
-
- }
-
-
-
-
-
-
- @Test
- public void medQueryEightOverlapIndex() {
- String q1 = ""//
- + "SELECT ?f ?m ?d " //
- + "{" //
- + " ?f a ?m ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?f <uri:hangOutWith> ?m ." //
- + " ?m <uri:hangOutWith> ?d ." //
- + " ?f <uri:associatesWith> ?m ." //
- + " ?m <uri:associatesWith> ?d ." //
- + "}";//
-
-
- String q2 = ""//
- + "SELECT ?t ?s ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
- String q3 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s <uri:hangOutWith> ?t ." //
- + " ?t <uri:hangOutWith> ?u ." //
- + "}";//
-
- String q4 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s <uri:associatesWith> ?t ." //
- + " ?t <uri:associatesWith> ?u ." //
- + "}";//
-
-
- String q5 = ""//
- + "SELECT ?t ?s ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?s <uri:hangOutWith> ?t ." //
- + " ?t <uri:hangOutWith> ?u ." //
- + "}";//
-
- String q6 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s <uri:associatesWith> ?t ." //
- + " ?t <uri:associatesWith> ?u ." //
- + " ?s <uri:hangOutWith> ?t ." //
- + " ?t <uri:hangOutWith> ?u ." //
- + "}";//
-
-
- String q7 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s <uri:associatesWith> ?t ." //
- + " ?t <uri:associatesWith> ?u ." //
- + " ?t <uri:hangOutWith> ?u ." //
- + "}";//
-
-
-
- String q8 = ""//
- + "SELECT ?t ?s ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?s <uri:associatesWith> ?t ." //
- + "}";//
-
-
- String q9 = ""//
- + "SELECT ?t ?s ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + "}";//
-
-
-
-
-
-
-
-
-
- SPARQLParser parser = new SPARQLParser();
- ParsedQuery pq1 = null;
- ParsedQuery pq2 = null;
- ParsedQuery pq3 = null;
- ParsedQuery pq4 = null;
- ParsedQuery pq5 = null;
- ParsedQuery pq6 = null;
- ParsedQuery pq7 = null;
- ParsedQuery pq8 = null;
- ParsedQuery pq9 = null;
-
- SimpleExternalTupleSet extTup1 = null;
- SimpleExternalTupleSet extTup2 = null;
- SimpleExternalTupleSet extTup3 = null;
- SimpleExternalTupleSet extTup4 = null;
- SimpleExternalTupleSet extTup5 = null;
- SimpleExternalTupleSet extTup6 = null;
- SimpleExternalTupleSet extTup7 = null;
- SimpleExternalTupleSet extTup8 = null;
-
-
-
-
-
- try {
- pq1 = parser.parseQuery(q1, null);
- pq2 = parser.parseQuery(q2, null);
- pq3 = parser.parseQuery(q3, null);
- pq4 = parser.parseQuery(q4, null);
- pq5 = parser.parseQuery(q5, null);
- pq6 = parser.parseQuery(q6, null);
- pq7 = parser.parseQuery(q7, null);
- pq8 = parser.parseQuery(q8, null);
- pq9 = parser.parseQuery(q9, null);
-
-
- extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
- extTup2 = new SimpleExternalTupleSet((Projection) pq3.getTupleExpr());
- extTup3 = new SimpleExternalTupleSet((Projection) pq4.getTupleExpr());
- extTup4 = new SimpleExternalTupleSet((Projection) pq5.getTupleExpr());
- extTup5 = new SimpleExternalTupleSet((Projection) pq6.getTupleExpr());
- extTup6 = new SimpleExternalTupleSet((Projection) pq7.getTupleExpr());
- extTup7 = new SimpleExternalTupleSet((Projection) pq8.getTupleExpr());
- extTup8 = new SimpleExternalTupleSet((Projection) pq9.getTupleExpr());
-
-
- } catch (MalformedQueryException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- List<ExternalTupleSet> indexList = Lists.newArrayList();
- indexList.add(extTup1);
- indexList.add(extTup2);
- indexList.add(extTup3);
- indexList.add(extTup4);
- indexList.add(extTup5);
- indexList.add(extTup6);
- indexList.add(extTup7);
- indexList.add(extTup8);
-
-
- ValidIndexCombinationGenerator vic = new ValidIndexCombinationGenerator(pq1.getTupleExpr());
- Iterator<List<ExternalTupleSet>> combos = vic.getValidIndexCombos(indexList);
- int size = 0;
- while(combos.hasNext()) {
- combos.hasNext();
- size++;
- combos.next();
- combos.hasNext();
- }
-
- Assert.assertTrue(!combos.hasNext());
- Assert.assertEquals(21,size);
-
-
- }
-
-
-
-
-
- @Test
- public void largeQuerySixteenIndexTest() {
-
-
- String q1 = ""//
- + "SELECT ?f ?m ?d ?e ?l ?c ?n ?o ?p ?a ?h ?r " //
- + "{" //
- + " ?f a ?m ."//
- + " ?e a ?l ."//
- + " ?n a ?o ."//
- + " ?a a ?h ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ."//
- + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?p ."//
- + " ?h <http://www.w3.org/2000/01/rdf-schema#label> ?r ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?c <uri:talksTo> ?e . "//
- + " ?p <uri:talksTo> ?n . "//
- + " ?r <uri:talksTo> ?a . "//
- + "}";//
-
-
- String q2 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
-
- String q3 = ""//
- + "SELECT ?s ?t ?u ?d ?f ?g " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?d a ?f ."//
- + " ?f <http://www.w3.org/2000/01/rdf-schema#label> ?g ."//
- + " ?g <uri:talksTo> ?d . "//
- + "}";//
-
-
-
-
- SPARQLParser parser = new SPARQLParser();
-
- ParsedQuery pq1 = null;
- ParsedQuery pq2 = null;
- ParsedQuery pq3 = null;
-
-
- try {
- pq1 = parser.parseQuery(q1, null);
- pq2 = parser.parseQuery(q2, null);
- pq3 = parser.parseQuery(q3, null);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
- SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet((Projection) pq3.getTupleExpr());
-
-
- List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
-
- list.add(extTup2);
- list.add(extTup1);
-
-
- IndexedExecutionPlanGenerator iep = new IndexedExecutionPlanGenerator(pq1.getTupleExpr(), list);
- List<ExternalTupleSet> indexSet = iep.getNormalizedIndices();
-
-
- Assert.assertEquals(16, indexSet.size());
-
- ValidIndexCombinationGenerator vic = new ValidIndexCombinationGenerator(pq1.getTupleExpr());
- Iterator<List<ExternalTupleSet>> eSet = vic.getValidIndexCombos(Lists.newArrayList(indexSet));
-
- int size = 0;
- while(eSet.hasNext()) {
- size++;
- Assert.assertTrue(eSet.hasNext());
- eSet.next();
- }
-
-
- Assert.assertTrue(!eSet.hasNext());
- Assert.assertEquals(75, size);
-
- }
-
-
-
-
-
-
- @Test
- public void largeQueryFourtyIndexTest() {
-
-
- String q1 = ""//
- + "SELECT ?f ?m ?d ?e ?l ?c ?n ?o ?p ?a ?h ?r " //
- + "{" //
- + " ?f a ?m ."//
- + " ?e a ?l ."//
- + " ?n a ?o ."//
- + " ?a a ?h ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ."//
- + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?p ."//
- + " ?h <http://www.w3.org/2000/01/rdf-schema#label> ?r ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?c <uri:talksTo> ?e . "//
- + " ?p <uri:talksTo> ?n . "//
- + " ?r <uri:talksTo> ?a . "//
- + "}";//
-
-
- String q2 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
-
- String q3 = ""//
- + "SELECT ?s ?t ?u ?d ?f ?g " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?d a ?f ."//
- + " ?f <http://www.w3.org/2000/01/rdf-schema#label> ?g ."//
- + " ?g <uri:talksTo> ?d . "//
- + "}";//
-
-
-
- String q4 = ""//
- + "SELECT ?s ?t ?u ?d ?f ?g ?a ?b ?c" //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + " ?d a ?f ."//
- + " ?f <http://www.w3.org/2000/01/rdf-schema#label> ?g ."//
- + " ?g <uri:talksTo> ?d . "//
- + " ?a a ?b ."//
- + " ?b <http://www.w3.org/2000/01/rdf-schema#label> ?c ."//
- + " ?c <uri:talksTo> ?a . "//
- + "}";//
-
-
- SPARQLParser parser = new SPARQLParser();
-
- ParsedQuery pq1 = null;
- ParsedQuery pq2 = null;
- ParsedQuery pq3 = null;
- ParsedQuery pq4 = null;
-
-
- try {
- pq1 = parser.parseQuery(q1, null);
- pq2 = parser.parseQuery(q2, null);
- pq3 = parser.parseQuery(q3, null);
- pq4 = parser.parseQuery(q4, null);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
- SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet((Projection) pq3.getTupleExpr());
- SimpleExternalTupleSet extTup3 = new SimpleExternalTupleSet((Projection) pq4.getTupleExpr());
-
- List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
-
- list.add(extTup2);
- list.add(extTup1);
- list.add(extTup3);
-
- IndexedExecutionPlanGenerator iep = new IndexedExecutionPlanGenerator(pq1.getTupleExpr(), list);
- List<ExternalTupleSet> indexSet = iep.getNormalizedIndices();
- Assert.assertEquals(40, indexSet.size());
-
- ValidIndexCombinationGenerator vic = new ValidIndexCombinationGenerator(pq1.getTupleExpr());
- Iterator<List<ExternalTupleSet>> eSet = vic.getValidIndexCombos(Lists.newArrayList(indexSet));
-
- int size = 0;
- while(eSet.hasNext()) {
- size++;
- Assert.assertTrue(eSet.hasNext());
- eSet.next();
- }
-
- Assert.assertTrue(!eSet.hasNext());
- Assert.assertEquals(123, size);
- }
-
-
-
-
-
- @Test
- public void overlappingFilterIndex() {
-
-
- String q5 = ""//
- + "SELECT ?s ?t " //
- + "{" //
- + " ?s a \"Person\" ." //
- + " ?t a \"Student\" ."//
- + "}";//
-
-
- String q4 = ""//
- + "SELECT ?s ?t " //
- + "{" //
- + " ?s a ?t ."//
- + " ?s <uri:talksTo> ?t . "//
- + "}";//
-
-
- String q3 = ""//
- + "SELECT ?s ?t " //
- + "{" //
- + " Filter(?s > 5). "//
- + " ?s a ?t ."//
- + " ?s <uri:talksTo> ?t . "//
- + "}";//
-
-
- String q2 = ""//
- + "SELECT ?s ?t " //
- + "{" //
- + " Filter(?s > 5). "//
- + " ?s a \"Person\" ." //
- + " ?t a \"Student\" ."//
- + "}";//
-
-
-
- String q1 = ""//
- + "SELECT ?s ?t " //
- + "{" //
- + " Filter(?s > 5). "//
- + " ?s a ?t ."//
- + " ?s <uri:talksTo> ?t . "//
- + " ?s a \"Person\" ." //
- + " ?t a \"Student\" ."//
- + "}";//
-
-
-
-
- SPARQLParser parser = new SPARQLParser();
-
- ParsedQuery pq1 = null;
- ParsedQuery pq2 = null;
- ParsedQuery pq3 = null;
- ParsedQuery pq4 = null;
- ParsedQuery pq5 = null;
-
-
- try {
- pq1 = parser.parseQuery(q1, null);
- pq2 = parser.parseQuery(q2, null);
- pq3 = parser.parseQuery(q3, null);
- pq4 = parser.parseQuery(q4, null);
- pq5 = parser.parseQuery(q5, null);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
- SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet((Projection) pq3.getTupleExpr());
- SimpleExternalTupleSet extTup3 = new SimpleExternalTupleSet((Projection) pq4.getTupleExpr());
- SimpleExternalTupleSet extTup4 = new SimpleExternalTupleSet((Projection) pq5.getTupleExpr());
-
-
- List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
-
- list.add(extTup2);
- list.add(extTup1);
- list.add(extTup3);
- list.add(extTup4);
-
-
- IndexedExecutionPlanGenerator iep = new IndexedExecutionPlanGenerator(pq1.getTupleExpr(), list);
- List<ExternalTupleSet> indexSet = iep.getNormalizedIndices();
-
-
-
- Assert.assertEquals(4, indexSet.size());
-
- ValidIndexCombinationGenerator vic = new ValidIndexCombinationGenerator(pq1.getTupleExpr());
- Iterator<List<ExternalTupleSet>> eSet = vic.getValidIndexCombos(Lists.newArrayList(indexSet));
-
- int size = 0;
- while(eSet.hasNext()) {
- size++;
- Assert.assertTrue(eSet.hasNext());
- List<ExternalTupleSet> eList = eSet.next();
-
- }
-
-
- Assert.assertTrue(!eSet.hasNext());
- Assert.assertEquals(7, size);
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/VarConstantIndexListPrunerTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/VarConstantIndexListPrunerTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/VarConstantIndexListPrunerTest.java
deleted file mode 100644
index 181d4fb..0000000
--- a/extras/indexing/src/test/java/mvm/rya/indexing/IndexPlanValidator/VarConstantIndexListPrunerTest.java
+++ /dev/null
@@ -1,329 +0,0 @@
-package mvm.rya.indexing.IndexPlanValidator;
-
-/*
- * 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 org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import mvm.rya.indexing.external.ExternalProcessor;
-import mvm.rya.indexing.external.tupleSet.ExternalTupleSet;
-import mvm.rya.indexing.external.tupleSet.SimpleExternalTupleSet;
-import mvm.rya.indexing.external.tupleSet.ExternalProcessorTest.ExternalTupleVstor;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openrdf.query.algebra.Projection;
-import org.openrdf.query.algebra.QueryModelNode;
-import org.openrdf.query.algebra.StatementPattern;
-import org.openrdf.query.algebra.TupleExpr;
-import org.openrdf.query.algebra.helpers.StatementPatternCollector;
-import org.openrdf.query.parser.ParsedQuery;
-import org.openrdf.query.parser.sparql.SPARQLParser;
-
-import com.google.common.collect.Sets;
-
-public class VarConstantIndexListPrunerTest {
-
-
-
- private String q7 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
- private String q8 = ""//
- + "SELECT ?f ?m ?d ?e ?l ?c ?n ?o ?p ?a ?h ?r " //
- + "{" //
- + " ?h <http://www.w3.org/2000/01/rdf-schema#label> ?r ."//
- + " ?f a ?m ."//
- + " ?p <uri:talksTo> ?n . "//
- + " ?e a ?l ."//
- + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?p ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?c <uri:talksTo> ?e . "//
- + " ?n a ?o ."//
- + " ?a a ?h ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ."//
- + " ?r <uri:talksTo> ?a . "//
- + "}";//
-
-
-
-
- private String q11 = ""//
- + "SELECT ?f ?m ?d ?e ?l ?c ?n ?o ?p ?a ?h ?r ?x ?y ?w ?t ?duck ?chicken ?pig ?rabbit " //
- + "{" //
- + " ?w a ?t ."//
- + " ?x a ?y ."//
- + " ?duck a ?chicken ."//
- + " ?pig a ?rabbit ."//
- + " ?h <http://www.w3.org/2000/01/rdf-schema#label> ?r ."//
- + " ?f a ?m ."//
- + " ?p <uri:talksTo> ?n . "//
- + " ?e a ?l ."//
- + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?p ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?c <uri:talksTo> ?e . "//
- + " ?n a ?o ."//
- + " ?a a ?h ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ."//
- + " ?r <uri:talksTo> ?a . "//
- + "}";//
-
-
- private String q12 = ""//
- + "SELECT ?b ?p ?dog ?cat " //
- + "{" //
- + " ?b a ?p ."//
- + " ?dog a ?cat. "//
- + "}";//
-
-
-
- private String q13 = ""//
- + "SELECT ?f ?m ?d ?e ?l ?c ?n ?o ?p ?a ?h ?r ?x ?y ?w ?t ?duck ?chicken ?pig ?rabbit ?dick ?jane ?betty " //
- + "{" //
- + " ?w a ?t ."//
- + " ?x a ?y ."//
- + " ?duck a ?chicken ."//
- + " ?pig a ?rabbit ."//
- + " ?h <http://www.w3.org/2000/01/rdf-schema#label> ?r ."//
- + " ?f a ?m ."//
- + " ?p <uri:talksTo> ?n . "//
- + " ?e a ?l ."//
- + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?p ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?c <uri:talksTo> ?e . "//
- + " ?n a ?o ."//
- + " ?a a ?h ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ."//
- + " ?r <uri:talksTo> ?a . "//
- + " ?dick <uri:talksTo> ?jane . "//
- + " ?jane <uri:talksTo> ?betty . "//
- + "}";//
-
- private String q14 = ""//
- + "SELECT ?f ?m ?d ?e ?l ?c ?n ?o ?p ?a ?h ?r ?x ?y ?w ?t ?duck ?chicken ?pig ?rabbit " //
- + "{" //
- + " ?w a ?t ."//
- + " ?x a ?y ."//
- + " ?duck a ?chicken ."//
- + " ?pig a ?rabbit ."//
- + " ?h <http://www.w3.org/2000/01/rdf-schema#label> ?r ."//
- + " ?f a ?m ."//
- + " ?p <uri:talksTo> ?n . "//
- + " ?e a ?l ."//
- + " ?o <http://www.w3.org/2000/01/rdf-schema#label> ?p ."//
- + " ?d <uri:talksTo> ?f . "//
- + " ?c <uri:talksTo> ?e . "//
- + " ?n a ?o ."//
- + " ?a a ?h ."//
- + " ?m <http://www.w3.org/2000/01/rdf-schema#label> ?d ."//
- + " ?l <http://www.w3.org/2000/01/rdf-schema#label> ?c ."//
- + " ?r <uri:talksTo> ?a . "//
- + " ?d <uri:talksTo> ?a . "//
- + "}";//
-
-
-
- private String q15 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?s > 1)."//
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
- private String q16 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?s > 2)."//
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
- private String q17 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?t > 1)."//
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
-
- @Test
- public void testTwoIndexLargeQuery() throws Exception {
-
- SPARQLParser parser = new SPARQLParser();
-
-
- ParsedQuery pq1 = parser.parseQuery(q11, null);
- ParsedQuery pq2 = parser.parseQuery(q7, null);
- ParsedQuery pq3 = parser.parseQuery(q12, null);
- ParsedQuery pq4 = parser.parseQuery(q13, null);
- ParsedQuery pq5 = parser.parseQuery(q8, null);
- ParsedQuery pq6 = parser.parseQuery(q14, null);
-
- System.out.println("Query is " + pq1.getTupleExpr());
-
- SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
- SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet((Projection)pq3.getTupleExpr());
- SimpleExternalTupleSet extTup3 = new SimpleExternalTupleSet((Projection)pq4.getTupleExpr());
- SimpleExternalTupleSet extTup4 = new SimpleExternalTupleSet((Projection)pq5.getTupleExpr());
- SimpleExternalTupleSet extTup5 = new SimpleExternalTupleSet((Projection)pq6.getTupleExpr());
-
- List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
- list.add(extTup1);
- list.add(extTup2);
- list.add(extTup3);
- list.add(extTup4);
- list.add(extTup5);
-
- VarConstantIndexListPruner vci = new VarConstantIndexListPruner(pq1.getTupleExpr());
- Set<ExternalTupleSet> processedIndexSet = vci.getRelevantIndices(list);
-
- System.out.println("Relevant indexes are: ");
- for(ExternalTupleSet e: processedIndexSet) {
- System.out.println(e);
- }
-
- Set<ExternalTupleSet> indexSet = Sets.newHashSet();
- indexSet.add(extTup1);
- indexSet.add(extTup2);
- indexSet.add(extTup4);
-
- Assert.assertTrue(Sets.intersection(indexSet, processedIndexSet).equals(processedIndexSet));
-
-
-
- }
-
-
-
-
-
- @Test
- public void testTwoIndexFilter1() throws Exception {
-
- SPARQLParser parser = new SPARQLParser();
-
-
- ParsedQuery pq1 = parser.parseQuery(q15, null);
- ParsedQuery pq2 = parser.parseQuery(q16, null);
- ParsedQuery pq3 = parser.parseQuery(q17, null);
-
- System.out.println("Query is " + pq1.getTupleExpr());
-
- SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
- SimpleExternalTupleSet extTup2 = new SimpleExternalTupleSet((Projection)pq3.getTupleExpr());
-
- List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
- list.add(extTup1);
- list.add(extTup2);
-
- VarConstantIndexListPruner vci = new VarConstantIndexListPruner(pq1.getTupleExpr());
- Set<ExternalTupleSet> processedIndexSet = vci.getRelevantIndices(list);
-
- System.out.println("Relevant indexes are: ");
- for(ExternalTupleSet e: processedIndexSet) {
- System.out.println(e);
- }
-
- Set<ExternalTupleSet> indexSet = Sets.newHashSet();
- indexSet.add(extTup2);
-
-
- Assert.assertTrue(Sets.intersection(indexSet, processedIndexSet).equals(processedIndexSet));
-
-
-
- }
-
-
-
- @Test
- public void testTwoIndexFilter2() throws Exception {
-
-
- String q18 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?s > 1 && ?t > 8)." //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
- String q19 = ""//
- + "SELECT ?s ?t ?u " //
- + "{" //
- + " Filter(?s > 1)." //
- + " Filter(?t > 8)." //
- + " ?s a ?t ."//
- + " ?t <http://www.w3.org/2000/01/rdf-schema#label> ?u ."//
- + " ?u <uri:talksTo> ?s . "//
- + "}";//
-
-
-
- SPARQLParser parser = new SPARQLParser();
-
-
- ParsedQuery pq1 = parser.parseQuery(q18, null);
- ParsedQuery pq2 = parser.parseQuery(q19, null);
-
- System.out.println("Query is " + pq1.getTupleExpr());
-
- SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
-
- List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
- list.add(extTup1);
-
- VarConstantIndexListPruner vci = new VarConstantIndexListPruner(pq1.getTupleExpr());
- Set<ExternalTupleSet> processedIndexSet = vci.getRelevantIndices(list);
-
- Assert.assertTrue(processedIndexSet.isEmpty());
-
-
-
- }
-
-
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-rya/blob/5a03ef61/extras/indexing/src/test/java/mvm/rya/indexing/accumulo/StatementSerializerTest.java
----------------------------------------------------------------------
diff --git a/extras/indexing/src/test/java/mvm/rya/indexing/accumulo/StatementSerializerTest.java b/extras/indexing/src/test/java/mvm/rya/indexing/accumulo/StatementSerializerTest.java
deleted file mode 100644
index 88e2841..0000000
--- a/extras/indexing/src/test/java/mvm/rya/indexing/accumulo/StatementSerializerTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package mvm.rya.indexing.accumulo;
-
-/*
- * 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.Assert;
-import mvm.rya.indexing.accumulo.StatementSerializer;
-
-import org.junit.Test;
-import org.openrdf.model.Statement;
-import org.openrdf.model.ValueFactory;
-import org.openrdf.model.impl.ContextStatementImpl;
-import org.openrdf.model.impl.StatementImpl;
-import org.openrdf.model.impl.ValueFactoryImpl;
-
-public class StatementSerializerTest {
-
- @Test
- public void testSimpleStatementObjectUri() throws Exception {
- ValueFactory vf = new ValueFactoryImpl();
- Statement s;
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createURI("foo:object"));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- s = new ContextStatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createURI("foo:object"),
- vf.createURI("foo:context"));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
- }
-
- @Test
- public void testSimpleObjectLiteral() throws Exception {
- ValueFactory vf = new ValueFactoryImpl();
- Statement s;
- String str;
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createURI("foo:object"));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- str = "Alice Palace";
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, "en"));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, vf.createURI("xsd:string")));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
- }
-
- @Test
- public void testObjectLiteralWithDataTypeGarbage() throws Exception {
- // test with some garbage in the literal that may throw off the parser
- ValueFactory vf = new ValueFactoryImpl();
- Statement s;
- String str;
-
- str = "Alice ^^<Palace>\"";
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, "en"));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, vf.createURI("xsd:string")));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- }
-
- @Test
- public void testObjectLiteralWithAtSignGarbage() throws Exception {
- // test with some garbage in the literal that may throw off the parser
- ValueFactory vf = new ValueFactoryImpl();
- Statement s;
- String str;
-
- str = "Alice @en";
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, "en"));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
-
- s = new StatementImpl(vf.createURI("foo:subject"), vf.createURI("foo:predicate"), vf.createLiteral(str, vf.createURI("xsd:string")));
- Assert.assertEquals(s, StatementSerializer.readStatement(StatementSerializer.writeStatement(s)));
- }
-
-}