Search in sources :

Example 1 with ProcessorEntry

use of org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry in project incubator-rya by apache.

the class TopologyFactoryTest method projectionStatementPattern.

@Test
public void projectionStatementPattern() throws Exception {
    final String query = "SELECT * WHERE { " + "?person <urn:talksTo> ?otherPerson . " + "}";
    FACTORY.build(query, "source", "sink", new RandomUUIDFactory());
    final List<ProcessorEntry> entries = FACTORY.getProcessorEntry();
    assertTrue(entries.get(0).getNode() instanceof Projection);
    assertTrue(entries.get(1).getNode() instanceof StatementPattern);
    final StatementPattern expected = new StatementPattern(new Var("person"), TALKS_TO, new Var("otherPerson"));
    assertEquals(expected, entries.get(1).getNode());
}
Also used : StatementPattern(org.openrdf.query.algebra.StatementPattern) Var(org.openrdf.query.algebra.Var) RandomUUIDFactory(org.apache.rya.api.function.projection.RandomUUIDFactory) Projection(org.openrdf.query.algebra.Projection) ProcessorEntry(org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry) Test(org.junit.Test)

Example 2 with ProcessorEntry

use of org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry in project incubator-rya by apache.

the class TopologyFactoryTest method projectionJoinJoinStatementPattern.

@Test
public void projectionJoinJoinStatementPattern() throws Exception {
    final String query = "SELECT * WHERE { " + "?person <urn:talksTo> ?otherPerson . " + "?otherPerson <urn:talksTo> ?dog . " + "?dog <urn:chews> ?toy . " + "}";
    FACTORY.build(query, "source", "sink", new RandomUUIDFactory());
    final List<ProcessorEntry> entries = FACTORY.getProcessorEntry();
    assertTrue(entries.get(0).getNode() instanceof Projection);
    assertTrue(entries.get(1).getNode() instanceof Join);
    assertTrue(entries.get(2).getNode() instanceof Join);
    StatementPattern expected = new StatementPattern(new Var("person"), TALKS_TO, new Var("otherPerson"));
    assertEquals(expected, entries.get(3).getNode());
    expected = new StatementPattern(new Var("otherPerson"), TALKS_TO, new Var("dog"));
    assertEquals(expected, entries.get(4).getNode());
    expected = new StatementPattern(new Var("dog"), CHEWS, new Var("toy"));
    assertEquals(expected, entries.get(5).getNode());
}
Also used : StatementPattern(org.openrdf.query.algebra.StatementPattern) Var(org.openrdf.query.algebra.Var) RandomUUIDFactory(org.apache.rya.api.function.projection.RandomUUIDFactory) Projection(org.openrdf.query.algebra.Projection) Join(org.openrdf.query.algebra.Join) ProcessorEntry(org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry) Test(org.junit.Test)

Example 3 with ProcessorEntry

use of org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry in project incubator-rya by apache.

the class TopologyFactoryTest method projectionStatementPattern_rebind.

@Test
public void projectionStatementPattern_rebind() throws Exception {
    final String query = "CONSTRUCT { ?person <urn:mightKnow> ?otherPerson } WHERE { " + "?person <urn:talksTo> ?otherPerson . " + "}";
    FACTORY.build(query, "source", "sink", new RandomUUIDFactory());
    final List<ProcessorEntry> entries = FACTORY.getProcessorEntry();
    assertTrue(entries.get(0).getNode() instanceof Projection);
    final StatementPattern expected = new StatementPattern(new Var("person"), TALKS_TO, new Var("otherPerson"));
    assertEquals(expected, entries.get(1).getNode());
}
Also used : StatementPattern(org.openrdf.query.algebra.StatementPattern) Var(org.openrdf.query.algebra.Var) RandomUUIDFactory(org.apache.rya.api.function.projection.RandomUUIDFactory) Projection(org.openrdf.query.algebra.Projection) ProcessorEntry(org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry) Test(org.junit.Test)

Example 4 with ProcessorEntry

use of org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry in project incubator-rya by apache.

the class TopologyFactoryTest method projectionJoinStatementPattern.

@Test
public void projectionJoinStatementPattern() throws Exception {
    final String query = "SELECT * WHERE { " + "?person <urn:talksTo> ?otherPerson . " + "?otherPerson <urn:talksTo> ?dog . " + "}";
    FACTORY.build(query, "source", "sink", new RandomUUIDFactory());
    final List<ProcessorEntry> entries = FACTORY.getProcessorEntry();
    assertTrue(entries.get(0).getNode() instanceof Projection);
    assertTrue(entries.get(1).getNode() instanceof Join);
    StatementPattern expected = new StatementPattern(new Var("person"), TALKS_TO, new Var("otherPerson"));
    assertEquals(expected, entries.get(2).getNode());
    expected = new StatementPattern(new Var("otherPerson"), TALKS_TO, new Var("dog"));
    assertEquals(expected, entries.get(3).getNode());
}
Also used : StatementPattern(org.openrdf.query.algebra.StatementPattern) Var(org.openrdf.query.algebra.Var) RandomUUIDFactory(org.apache.rya.api.function.projection.RandomUUIDFactory) Projection(org.openrdf.query.algebra.Projection) Join(org.openrdf.query.algebra.Join) ProcessorEntry(org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry) Test(org.junit.Test)

Aggregations

RandomUUIDFactory (org.apache.rya.api.function.projection.RandomUUIDFactory)4 ProcessorEntry (org.apache.rya.streams.kafka.topology.TopologyFactory.ProcessorEntry)4 Test (org.junit.Test)4 Projection (org.openrdf.query.algebra.Projection)4 StatementPattern (org.openrdf.query.algebra.StatementPattern)4 Var (org.openrdf.query.algebra.Var)4 Join (org.openrdf.query.algebra.Join)2