use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class IndexedExecutionPlanGeneratorTest method testThrowsException2.
@Test
public void testThrowsException2() throws Exception {
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq1 = parser.parseQuery(q19, null);
ParsedQuery pq2 = parser.parseQuery(q20, null);
SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq2.getTupleExpr());
List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
list.add(extTup1);
IndexedExecutionPlanGenerator iep = new IndexedExecutionPlanGenerator(pq1.getTupleExpr(), list);
List<ExternalTupleSet> indexSet = iep.getNormalizedIndices();
Assert.assertEquals(3, indexSet.size());
Iterator<TupleExpr> processedTups = iep.getIndexedTuples();
processedTups.next();
processedTups.next();
processedTups.next();
boolean exceptionThrown = false;
try {
processedTups.next();
} catch (NoSuchElementException e) {
exceptionThrown = true;
}
Assert.assertTrue(exceptionThrown);
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class IndexedExecutionPlanGeneratorTest method testThreeIndexQueryFilter.
@Test
public void testThreeIndexQueryFilter() throws Exception {
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq1 = parser.parseQuery(q22, null);
ParsedQuery pq2 = parser.parseQuery(q7, null);
ParsedQuery pq3 = parser.parseQuery(q21, null);
ParsedQuery pq4 = parser.parseQuery(q23, null);
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(5, indexSet.size());
Iterator<TupleExpr> processedTups = iep.getIndexedTuples();
int size = 0;
while (processedTups.hasNext()) {
Assert.assertTrue(processedTups.hasNext());
TupleExpr te = processedTups.next();
System.out.println(te);
size++;
}
Assert.assertTrue(!processedTups.hasNext());
Assert.assertEquals(10, size);
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class IndexedExecutionPlanGeneratorTest method testTwoIndexLargeQuery.
@Test
public void testTwoIndexLargeQuery() throws Exception {
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq1 = parser.parseQuery(q15, null);
ParsedQuery pq2 = parser.parseQuery(q7, null);
ParsedQuery pq3 = parser.parseQuery(q12, null);
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(4, indexSet.size());
Iterator<TupleExpr> processedTups = iep.getIndexedTuples();
int size = 0;
while (processedTups.hasNext()) {
Assert.assertTrue(processedTups.hasNext());
processedTups.next();
size++;
}
Assert.assertTrue(!processedTups.hasNext());
Assert.assertEquals(5, size);
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class TupleExecutionPlanGeneratorTest method testThreeNodeOrderFilter.
@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()));
}
use of org.openrdf.query.parser.sparql.SPARQLParser in project incubator-rya by apache.
the class TupleExecutionPlanGeneratorTest method testThreeNodeOrder.
@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()));
}
Aggregations