use of org.apache.rya.indexing.external.tupleSet.ExternalTupleSet in project incubator-rya by apache.
the class PCJOptionalTestIT method testSimpleOptionalTest1.
@Test
public void testSimpleOptionalTest1() throws Exception {
final String query = //
"" + //
"SELECT ?u ?s ?t " + //
"{" + //
" ?s a ?t ." + //
" OPTIONAL{?t <http://www.w3.org/2000/01/rdf-schema#label> ?u } ." + //
" ?u <uri:talksTo> ?s . " + //
"}";
final SPARQLParser parser = new SPARQLParser();
final ParsedQuery pq1 = parser.parseQuery(query, null);
final SimpleExternalTupleSet extTup1 = new SimpleExternalTupleSet((Projection) pq1.getTupleExpr().clone());
final List<ExternalTupleSet> list = new ArrayList<ExternalTupleSet>();
list.add(extTup1);
final List<QueryModelNode> optTupNodes = Lists.newArrayList();
optTupNodes.add(extTup1);
final PCJOptimizer pcj = new PCJOptimizer(list, true, new AccumuloIndexSetProvider(new Configuration(), list));
final TupleExpr te = pq1.getTupleExpr();
pcj.optimize(te, null, null);
final NodeCollector nc = new NodeCollector();
te.visit(nc);
final List<QueryModelNode> qNodes = nc.getNodes();
Assert.assertEquals(qNodes.size(), optTupNodes.size());
for (final QueryModelNode node : qNodes) {
Assert.assertTrue(optTupNodes.contains(node));
}
}
use of org.apache.rya.indexing.external.tupleSet.ExternalTupleSet in project incubator-rya by apache.
the class IndexedExecutionPlanGeneratorTest method testThreeSingleNodeIndex.
@Test
public void testThreeSingleNodeIndex() 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();
int size = 0;
while (processedTups.hasNext()) {
Assert.assertTrue(processedTups.hasNext());
processedTups.next();
size++;
}
Assert.assertTrue(!processedTups.hasNext());
Assert.assertEquals(3, size);
}
use of org.apache.rya.indexing.external.tupleSet.ExternalTupleSet in project incubator-rya by apache.
the class IndexedExecutionPlanGeneratorTest method testThreeIndexQuery.
@Test
public void testThreeIndexQuery() throws Exception {
SPARQLParser parser = new SPARQLParser();
ParsedQuery pq1 = parser.parseQuery(q16, null);
ParsedQuery pq2 = parser.parseQuery(q17, null);
ParsedQuery pq3 = parser.parseQuery(q18, 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(6, 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(9, size);
}
use of org.apache.rya.indexing.external.tupleSet.ExternalTupleSet 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.apache.rya.indexing.external.tupleSet.ExternalTupleSet 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);
}
Aggregations