[
https://issues.apache.org/jira/browse/RYA-417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16320372#comment-16320372
]
ASF GitHub Bot commented on RYA-417:
------------------------------------
Github user meiercaleb commented on a diff in the pull request:
https://github.com/apache/incubator-rya/pull/255#discussion_r160699176
--- Diff:
dao/mongodb.rya/src/test/java/org/apache/rya/mongodb/aggregation/SparqlToPipelineTransformVisitorTest.java
---
@@ -0,0 +1,221 @@
+/*
+ * 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.
+ */
+package org.apache.rya.mongodb.aggregation;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.bson.Document;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openrdf.model.URI;
+import org.openrdf.model.ValueFactory;
+import org.openrdf.model.impl.ValueFactoryImpl;
+import org.openrdf.model.vocabulary.OWL;
+import org.openrdf.model.vocabulary.RDF;
+import org.openrdf.query.algebra.Extension;
+import org.openrdf.query.algebra.ExtensionElem;
+import org.openrdf.query.algebra.Join;
+import org.openrdf.query.algebra.MultiProjection;
+import org.openrdf.query.algebra.Not;
+import org.openrdf.query.algebra.Projection;
+import org.openrdf.query.algebra.ProjectionElem;
+import org.openrdf.query.algebra.ProjectionElemList;
+import org.openrdf.query.algebra.QueryRoot;
+import org.openrdf.query.algebra.StatementPattern;
+import org.openrdf.query.algebra.TupleExpr;
+import org.openrdf.query.algebra.ValueConstant;
+import org.openrdf.query.algebra.Var;
+
+import com.google.common.collect.Sets;
+import com.mongodb.MongoNamespace;
+import com.mongodb.client.MongoCollection;
+
+public class SparqlToPipelineTransformVisitorTest {
+
+ private static final ValueFactory VF = ValueFactoryImpl.getInstance();
+
+ private static final String LUBM = "urn:lubm";
+ private static final URI UNDERGRAD = VF.createURI(LUBM,
"UndergraduateStudent");
+ private static final URI PROFESSOR = VF.createURI(LUBM, "Professor");
+ private static final URI COURSE = VF.createURI(LUBM, "Course");
+ private static final URI TAKES = VF.createURI(LUBM, "takesCourse");
+ private static final URI TEACHES = VF.createURI(LUBM, "teachesCourse");
+
+ private static Var constant(URI value) {
+ return new Var(value.stringValue(), value);
+ }
+
+ MongoCollection<Document> collection;
+
+ @Before
+ @SuppressWarnings("unchecked")
+ public void setUp() {
+ collection = Mockito.mock(MongoCollection.class);
+ Mockito.when(collection.getNamespace()).thenReturn(new
MongoNamespace("db", "collection"));
+ }
+
+ @Test
+ public void testStatementPattern() throws Exception {
+ QueryRoot query = new QueryRoot(new StatementPattern(
+ new Var("x"), constant(RDF.TYPE), constant(UNDERGRAD)));
+ SparqlToPipelineTransformVisitor visitor = new
SparqlToPipelineTransformVisitor(collection);
+ query.visit(visitor);
+ Assert.assertTrue(query.getArg() instanceof
AggregationPipelineQueryNode);
+ AggregationPipelineQueryNode pipelineNode =
(AggregationPipelineQueryNode) query.getArg();
+ Assert.assertEquals(Sets.newHashSet("x"),
pipelineNode.getAssuredBindingNames());
+ }
+
+ @Test
+ public void testJoin() throws Exception {
+ QueryRoot query = new QueryRoot(new Join(
+ new StatementPattern(new Var("x"), constant(RDF.TYPE),
constant(UNDERGRAD)),
+ new StatementPattern(new Var("x"), constant(TAKES), new
Var("course"))));
+ SparqlToPipelineTransformVisitor visitor = new
SparqlToPipelineTransformVisitor(collection);
+ query.visit(visitor);
+ Assert.assertTrue(query.getArg() instanceof
AggregationPipelineQueryNode);
+ AggregationPipelineQueryNode pipelineNode =
(AggregationPipelineQueryNode) query.getArg();
+ Assert.assertEquals(Sets.newHashSet("x", "course"),
pipelineNode.getAssuredBindingNames());
+ }
+
+ @Test
+ public void testNestedJoins() throws Exception {
+ StatementPattern isUndergrad = new StatementPattern(new Var("x"),
constant(RDF.TYPE), constant(UNDERGRAD));
--- End diff --
Yep. I see the distinction. Very thorough of you sir.
> Implement a forward-chaining rules engine (SPIN)
> ------------------------------------------------
>
> Key: RYA-417
> URL: https://issues.apache.org/jira/browse/RYA-417
> Project: Rya
> Issue Type: New Feature
> Reporter: Jesse Hatfield
> Assignee: Jesse Hatfield
>
> Implement a forward-chaining reasoner that:
> * Runs as a batch process
> * Operates on user-defined [SPIN|http://spinrdf.org] rules
> * Inserts derived information back into Rya
> * Iterates until no new information can be derived
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)