From: <tho...@us...> - 2014-02-22 22:38:49
|
Revision: 7872 http://sourceforge.net/p/bigdata/code/7872 Author: thompsonbry Date: 2014-02-22 22:38:43 +0000 (Sat, 22 Feb 2014) Log Message: ----------- added GASService. Works. Sort of. The next steps are to interpret maxIterations and maxVertices as GASState constraints, not GASProgram options. The same for the link type URI and the access to the link weights. This will all make it much easier to paramterize the algorithms through the SPARQL SERVICE invocation. Modified Paths: -------------- branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/ServiceRegistry.java Modified: branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java =================================================================== --- branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-02-22 22:37:27 UTC (rev 7871) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-02-22 22:38:43 UTC (rev 7872) @@ -57,10 +57,12 @@ import com.bigdata.rdf.graph.impl.GASState; import com.bigdata.rdf.graph.impl.bd.BigdataGASEngine.BigdataGraphAccessor; import com.bigdata.rdf.graph.impl.scheduler.CHMScheduler; +import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.sail.BigdataSail.BigdataSailConnection; import com.bigdata.rdf.sparql.ast.GraphPatternGroup; import com.bigdata.rdf.sparql.ast.IGroupMemberNode; import com.bigdata.rdf.sparql.ast.StatementPatternNode; +import com.bigdata.rdf.sparql.ast.VarNode; import com.bigdata.rdf.sparql.ast.service.BigdataNativeServiceOptions; import com.bigdata.rdf.sparql.ast.service.BigdataServiceCall; import com.bigdata.rdf.sparql.ast.service.CustomServiceFactory; @@ -79,9 +81,9 @@ * For example, the following would run a depth-limited BFS traversal: * * <pre> - * PREFIX gas <http://www.bigdata.com/rdf/gas#> + * PREFIX gas: <http://www.bigdata.com/rdf/gas#> * #... - * SERVICE <GAS> { + * SERVICE <gas#service> { * gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.BFS" . * gas:program gas:in <IRI> . # one or more times, specifies the initial frontier. * gas:program gas:out ?out . # exactly once - will be bound to the visited vertices. @@ -94,9 +96,9 @@ * Or the following would run the FuzzySSSP algorithm. * * <pre> - * PREFIX gas <http://www.bigdata.com/rdf/gas#> + * PREFIX gas: <http://www.bigdata.com/rdf/gas#> * #... - * SERVICE <GAS> { + * SERVICE <gas:service> { * gas:program gas:gasClass "com.bigdata.rdf.graph.analytics.FuzzySSSP" . * gas:program gas:in <IRI> . # one or more times, specifies the initial frontier. * gas:program gas:target <IRI> . # one or more times, identifies the target vertices and hence the paths of interest. @@ -150,6 +152,11 @@ * The namespace used for bigdata GAS API. */ String NAMESPACE = "http://www.bigdata.com/rdf/gas#"; + + /** + * The URL at which the {@link GASService} will respond. + */ + URI SERVICE_KEY = new URIImpl(NAMESPACE + "service"); /** * Used as the subject in the GAS SERVICE invocation pattern. @@ -479,7 +486,7 @@ tmp = new LinkedList<Value>(); // found an o. - return (IVariable<?>) sp.o(); + return ((VarNode)sp.o()).getValueExpression(); } @@ -614,10 +621,9 @@ } /** + * Execute the GAS program. + * <p> * {@inheritDoc} - * - * TODO Join with the source solutions? Or is that handled by the - * caller? */ @Override public ICloseableIterator<IBindingSet> call( @@ -657,10 +663,19 @@ // Setup the initial frontier. for (Value startingVertex : initialFrontier) { - gasState.setFrontier(gasContext, startingVertex); + /* + * FIXME Why can't we pass in the Value (with a defined + * IV) and not the IV? This should work. Passing in the + * IV is against the grain of the API and the + * generalized abstraction as Values. Of course, having + * the IV is necessary since this is an internal, high + * performance, and close to the indices operation. + */ + gasState.setFrontier(gasContext, + ((BigdataValue) startingVertex).getIV()); } - + } // Run the analytic. @@ -702,7 +717,7 @@ int i = 0; for (Value v : visitedSet) { - out[i] = new ListBindingSet(vars, + out[i++] = new ListBindingSet(vars, new IConstant[] { new Constant(v) }); } Modified: branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/ServiceRegistry.java =================================================================== --- branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/ServiceRegistry.java 2014-02-22 22:37:27 UTC (rev 7871) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/service/ServiceRegistry.java 2014-02-22 22:38:43 UTC (rev 7872) @@ -10,6 +10,7 @@ import org.openrdf.model.URI; import org.openrdf.model.impl.URIImpl; +import com.bigdata.rdf.graph.impl.bd.GASService; import com.bigdata.rdf.sparql.ast.QueryHints; import com.bigdata.rdf.sparql.ast.cache.DescribeServiceFactory; import com.bigdata.rdf.sparql.ast.eval.SampleServiceFactory; @@ -112,6 +113,9 @@ } + // The Gather-Apply-Scatter RDF Graph Mining service. + add(GASService.Options.SERVICE_KEY, new GASService()); + } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |