This list is closed, nobody may subscribe to it.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(139) |
Aug
(94) |
Sep
(232) |
Oct
(143) |
Nov
(138) |
Dec
(55) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(127) |
Feb
(90) |
Mar
(101) |
Apr
(74) |
May
(148) |
Jun
(241) |
Jul
(169) |
Aug
(121) |
Sep
(157) |
Oct
(199) |
Nov
(281) |
Dec
(75) |
2012 |
Jan
(107) |
Feb
(122) |
Mar
(184) |
Apr
(73) |
May
(14) |
Jun
(49) |
Jul
(26) |
Aug
(103) |
Sep
(133) |
Oct
(61) |
Nov
(51) |
Dec
(55) |
2013 |
Jan
(59) |
Feb
(72) |
Mar
(99) |
Apr
(62) |
May
(92) |
Jun
(19) |
Jul
(31) |
Aug
(138) |
Sep
(47) |
Oct
(83) |
Nov
(95) |
Dec
(111) |
2014 |
Jan
(125) |
Feb
(60) |
Mar
(119) |
Apr
(136) |
May
(270) |
Jun
(83) |
Jul
(88) |
Aug
(30) |
Sep
(47) |
Oct
(27) |
Nov
(23) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(4) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <tho...@us...> - 2014-03-15 14:00:41
|
Revision: 7982 http://sourceforge.net/p/bigdata/code/7982 Author: thompsonbry Date: 2014-03-15 14:00:37 +0000 (Sat, 15 Mar 2014) Log Message: ----------- Replaced the concept of directedTraversal:boolean with the more general concept of TraversalDirection. The TraversalDirection is a type safe enum with three possible values Forward, Reverse, and Undirected. This generalizes the concept of directed versus undirected traversal and adds support for reverse traversal. Added a unit test for this. Updated the wiki page to reflect the changed API. Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java Added Paths: ----------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/TraversalDirectionEnum.java Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java 2014-03-15 13:31:34 UTC (rev 7981) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java 2014-03-15 14:00:37 UTC (rev 7982) @@ -67,20 +67,22 @@ IGraphAccessor getGraphAccessor(); /** - * Specify whether the visited edges of the graph are to be interpreted as - * directed or undirected (default <code>directed</code>). + * Specify the traversal direction for the {@link IGASProgram}. * <p> * The value specified here is used to determine how the {@link EdgesEnum} - * will be interpreted for the GATHER and SCATTER phases. See - * {@link EdgesEnum#asUndirectedTraversal()}. + * will be interpreted for the GATHER and SCATTER phases. The default is + * {@link TraversalDirectionEnum#Forward}. + * + * @see TraversalDirectionEnum#asTraversed(EdgesEnum) + * @see EdgesEnum#asUndirectedTraversal() */ - void setDirectedTraversal(boolean newVal); + void setTraversalDirection(TraversalDirectionEnum newVal); /** - * Return <code>true</code> if the graph should be interpreted as a directed - * graph. + * Return a type safe value indicating the traversal direction for the + * {@link IGASProgram}. */ - boolean isDirectedTraversal(); + TraversalDirectionEnum getTraversalDirection(); /** * Specify the maximum number of iterations for the algorithm. A value of Added: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/TraversalDirectionEnum.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/TraversalDirectionEnum.java (rev 0) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/TraversalDirectionEnum.java 2014-03-15 14:00:37 UTC (rev 7982) @@ -0,0 +1,76 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed 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 com.bigdata.rdf.graph; + +/** + * Typesafe enumeration of manner in which an RDF graph will be traversed by an + * {@link IGASProgram} based on its {@link EdgesEnum}. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +public enum TraversalDirectionEnum { + + /** + * Directed traversal along the natural direction of the RDF statements + * (from Subject to Object). + */ + Forward, + /** + * Directed traversal along the reverse direction of the RDF statements + * (from Object to Subject). + */ + Reverse, + /** + * Undirected traversal - edges are explored in both the {@link #Forward} + * and the {@link #Reverse} direction. + */ + Undirected; + + /** + * Interpret the given {@link EdgesEnum}, returning the effective value + * required to impose the semantics of this {@link TraversalDirectionEnum}. + * + * @param edges + * The {@link EdgesEnum}. + * + * @return The effective {@link EdgesEnum} value that will impose the + * traversal semantics of this {@link TraversalDirectionEnum}. + * + * @see EdgesEnum#asUndirectedTraversal() + */ + public EdgesEnum asTraversed(final EdgesEnum edges) { + + switch (this) { + case Forward: + return edges; + case Reverse: + switch (edges) { + case InEdges: + return EdgesEnum.OutEdges; + case OutEdges: + return EdgesEnum.InEdges; + default: + return edges; + } + case Undirected: + return edges.asUndirectedTraversal(); + default: + throw new AssertionError(); + } + + } + +} Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java 2014-03-15 13:31:34 UTC (rev 7981) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java 2014-03-15 14:00:37 UTC (rev 7982) @@ -19,7 +19,6 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -37,6 +36,7 @@ import com.bigdata.rdf.graph.IGraphAccessor; import com.bigdata.rdf.graph.IReducer; import com.bigdata.rdf.graph.IStaticFrontier; +import com.bigdata.rdf.graph.TraversalDirectionEnum; import com.bigdata.rdf.graph.util.GASUtil; import cutthecrap.utils.striterators.Filter; @@ -65,9 +65,10 @@ /** * Whether or not the edges of the graph will be traversed with directed - * graph semantics (default is TRUE). + * graph semantics (default is {@link TraversalDirectionEnum#Forward}). */ - private final AtomicBoolean directedGraph = new AtomicBoolean(true); + private final AtomicReference<TraversalDirectionEnum> traversalDirection = new AtomicReference<TraversalDirectionEnum>( + TraversalDirectionEnum.Forward); /** * The maximum number of iterations (defaults to {@link Integer#MAX_VALUE}). @@ -258,12 +259,10 @@ * APPLY is done before the SCATTER - this would not work if we pushed * down the APPLY into the SCATTER). */ - final EdgesEnum gatherEdges = isDirectedTraversal() ? program - .getGatherEdges() : program.getGatherEdges() - .asUndirectedTraversal(); - final EdgesEnum scatterEdges = isDirectedTraversal() ? program - .getScatterEdges() : program.getScatterEdges() - .asUndirectedTraversal(); + final EdgesEnum gatherEdges = getTraversalDirection().asTraversed( + program.getGatherEdges()); + final EdgesEnum scatterEdges = getTraversalDirection().asTraversed( + program.getScatterEdges()); final boolean pushDownApplyInGather; final boolean pushDownApplyInScatter; final boolean runApplyStage; @@ -816,17 +815,20 @@ } @Override - public boolean isDirectedTraversal() { - - return directedGraph.get(); - + public TraversalDirectionEnum getTraversalDirection() { + + return traversalDirection.get(); + } - + @Override - public void setDirectedTraversal(final boolean newVal) { + public void setTraversalDirection(final TraversalDirectionEnum newVal) { - directedGraph.set(newVal); - + if (newVal == null) + throw new IllegalArgumentException(); + + traversalDirection.set(newVal); + } @Override Modified: branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java =================================================================== --- branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java 2014-03-15 13:31:34 UTC (rev 7981) +++ branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java 2014-03-15 14:00:37 UTC (rev 7982) @@ -21,6 +21,7 @@ import com.bigdata.rdf.graph.IGASEngine; import com.bigdata.rdf.graph.IGASState; import com.bigdata.rdf.graph.IGraphAccessor; +import com.bigdata.rdf.graph.TraversalDirectionEnum; import com.bigdata.rdf.graph.impl.sail.AbstractSailGraphTestCase; /** @@ -104,11 +105,11 @@ /** * Variant test in which we choose a vertex (<code>foaf:person</code>) in - * the middle of the graph and insist on directed edges. Since the edges - * point from the person to the <code>foaf:person</code> vertex, this BSF - * traversal does not discover any connected vertices. + * the middle of the graph and insist on forward directed edges. Since the + * edges point from the person to the <code>foaf:person</code> vertex, this + * BSF traversal does not discover any connected vertices. */ - public void testBFS_directed() throws Exception { + public void testBFS_directed_forward() throws Exception { final SmallGraphProblem p = setupSmallGraphProblem(); @@ -135,7 +136,8 @@ gasState.setFrontier(gasContext, p.getFoafPerson()); // directed traversal. - gasContext.setDirectedTraversal(true); + gasContext + .setTraversalDirection(TraversalDirectionEnum.Forward); // Converge. gasContext.call(); @@ -177,6 +179,83 @@ /** * Variant test in which we choose a vertex (<code>foaf:person</code>) in + * the middle of the graph and insist on reverse directed edges. Since the + * edges point from the person to the <code>foaf:person</code> vertex, + * forward BSF traversal does not discover any connected vertices. However, + * since the traversal direction is reversed, the vertices are all one hop + * away. + */ + public void testBFS_directed_reverse() throws Exception { + + final SmallGraphProblem p = setupSmallGraphProblem(); + + final IGASEngine gasEngine = getGraphFixture() + .newGASEngine(1/* nthreads */); + + try { + + final SailConnection cxn = getGraphFixture().getSail() + .getConnection(); + + try { + + final IGraphAccessor graphAccessor = getGraphFixture() + .newGraphAccessor(cxn); + + final IGASContext<BFS.VS, BFS.ES, Void> gasContext = gasEngine + .newGASContext(graphAccessor, new BFS()); + + final IGASState<BFS.VS, BFS.ES, Void> gasState = gasContext + .getGASState(); + + // Initialize the froniter. + gasState.setFrontier(gasContext, p.getFoafPerson()); + + // directed traversal. + gasContext + .setTraversalDirection(TraversalDirectionEnum.Reverse); + + // Converge. + gasContext.call(); + + // starting vertex at (0,null). + assertEquals(0, gasState.getState(p.getFoafPerson()).depth()); + assertEquals(null, gasState.getState(p.getFoafPerson()) + .predecessor()); + + // All other vertices are 1-hop. + assertEquals(1, gasState.getState(p.getMike()).depth()); + assertEquals(p.getFoafPerson(), gasState.getState(p.getMike()) + .predecessor()); + + assertEquals(1, gasState.getState(p.getBryan()).depth()); + assertEquals(p.getFoafPerson(), gasState.getState(p.getBryan()) + .predecessor()); + + assertEquals(1, gasState.getState(p.getMartyn()).depth()); + assertEquals(p.getFoafPerson(), gasState + .getState(p.getMartyn()).predecessor()); + + } finally { + + try { + cxn.rollback(); + } finally { + cxn.close(); + } + + } + + } finally { + + gasEngine.shutdownNow(); + + } + + } + + /** + * Variant test in which we choose a vertex (<code>foaf:person</code>) in * the middle of the graph and insist on directed edges. Since the edges * point from the person to the <code>foaf:person</code> vertex, this BSF * traversal does not discover any connected vertices. @@ -208,8 +287,9 @@ gasState.setFrontier(gasContext, p.getFoafPerson()); // undirected traversal. - gasContext.setDirectedTraversal(false); - + gasContext + .setTraversalDirection(TraversalDirectionEnum.Undirected); + // Converge. gasContext.call(); 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-03-15 13:31:34 UTC (rev 7981) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-03-15 14:00:37 UTC (rev 7982) @@ -55,6 +55,7 @@ import com.bigdata.rdf.graph.IGraphAccessor; import com.bigdata.rdf.graph.IPredecessor; import com.bigdata.rdf.graph.IReducer; +import com.bigdata.rdf.graph.TraversalDirectionEnum; import com.bigdata.rdf.graph.analytics.CC; import com.bigdata.rdf.graph.analytics.PR; import com.bigdata.rdf.graph.impl.GASEngine; @@ -167,14 +168,19 @@ int DEFAULT_NTHREADS = 4; /** - * This option determines whether the traversal of the graph will - * interpret the edges as directed or undirected. + * This option determines the traversal direction semantics for the + * {@link IGASProgram} against the graph, including whether the the + * edges of the graph will be interpreted as directed ( + * {@link TraversalDirectionEnum#Forward} (which is the default), + * {@link TraversalDirectionEnum#Reverse}), or + * {@link TraversalDirectionEnum#Undirected}. * - * @see IGASContext#setDirectedTraversal(boolean) + * @see TraversalDirectionEnum + * @see IGASContext#setTraversalDirection(TraversalDirectionEnum) */ - URI DIRECTED_TRAVERSAL = new URIImpl(NAMESPACE + "directedTraversal"); + URI TRAVERSAL_DIRECTION = new URIImpl(NAMESPACE + "traversalDirection"); - boolean DEFAULT_DIRECTED_TRAVERSAL = true; + TraversalDirectionEnum DEFAULT_DIRECTED_TRAVERSAL = TraversalDirectionEnum.Forward; /** * The maximum #of iterations for the GAS program (optional, default @@ -398,7 +404,7 @@ // options extracted from the SERVICE's graph pattern. private final int nthreads; - private final boolean directedTraversal; + private final TraversalDirectionEnum traversalDirection; private final int maxIterations; private final int maxVisited; private final URI linkType, linkAttrType; @@ -433,10 +439,13 @@ store.getValueFactory().createLiteral( Options.DEFAULT_NTHREADS))).intValue(); - this.directedTraversal = ((Literal) getOnlyArg(Options.PROGRAM, - Options.DIRECTED_TRAVERSAL, store.getValueFactory() - .createLiteral(Options.DEFAULT_DIRECTED_TRAVERSAL))) - .booleanValue(); + this.traversalDirection = TraversalDirectionEnum + .valueOf(((Literal) getOnlyArg( + Options.PROGRAM, + Options.TRAVERSAL_DIRECTION, + store.getValueFactory().createLiteral( + Options.DEFAULT_DIRECTED_TRAVERSAL.name()))) + .stringValue()); this.maxIterations = ((Literal) getOnlyArg(Options.PROGRAM, Options.MAX_ITERATIONS, store.getValueFactory() @@ -761,7 +770,7 @@ final IGASContext<VS, ES, ST> gasContext = gasEngine.newGASContext( graphAccessor, gasProgram); - gasContext.setDirectedTraversal(directedTraversal); + gasContext.setTraversalDirection(traversalDirection); gasContext.setMaxIterations(maxIterations); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-15 13:31:38
|
Revision: 7981 http://sourceforge.net/p/bigdata/code/7981 Author: thompsonbry Date: 2014-03-15 13:31:34 +0000 (Sat, 15 Mar 2014) Log Message: ----------- Added the IPredecessor interface. This interface can be used to remove vertices from the visited vertex set if they do not lie along a path to a specified target vertex. This interface is only supported by BFS right now since SSSP does not yet support the concept of a predecessor (we need to reimplement SSSP as a push-style scatter). See #810 (GAS Service) Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASState.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASState.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java Added Paths: ----------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IPredecessor.java Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASState.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASState.java 2014-03-15 10:58:29 UTC (rev 7980) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASState.java 2014-03-15 13:31:34 UTC (rev 7981) @@ -15,6 +15,8 @@ */ package com.bigdata.rdf.graph; +import java.util.Set; + import org.openrdf.model.Statement; import org.openrdf.model.URI; import org.openrdf.model.Value; @@ -260,4 +262,12 @@ */ int compareTo(Value u, Value v); + /** + * Retain only those vertices in the visited set that are found in the + * specified collection. + * + * @param retainSet The set of vertices to be retained. + */ + void retainAll(Set<Value> retainSet); + } Added: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IPredecessor.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IPredecessor.java (rev 0) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IPredecessor.java 2014-03-15 13:31:34 UTC (rev 7981) @@ -0,0 +1,45 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed 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 com.bigdata.rdf.graph; + +import org.openrdf.model.Value; + +/** + * A interface for {@link IGASProgram}s that compute paths and track a + * predecessor relationship among the visited vertices. This interface can be + * used to eliminate vertices from the visited set that are not on a path to a + * set of specified target vertices. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +public interface IPredecessor<VS, ES, ST> { + + /** + * Remove any vertices from the visited set that do not line on path that + * leads to at least one of the target vertices. + * + * @param ctx + * The {@link IGASContext}. + * @param targetVertices + * An array of zero or more target vertices. + * + * @throws IllegalArgumentException + * if either argument is <code>null</code>. + */ + public void prunePaths(final IGASContext<VS, ES, ST> ctx, + final Value[] targetVertices); + +} Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-15 10:58:29 UTC (rev 7980) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-15 13:31:34 UTC (rev 7981) @@ -15,12 +15,10 @@ */ package com.bigdata.rdf.graph.analytics; -import java.util.Collections; +import java.util.HashSet; import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import org.openrdf.model.Statement; @@ -35,7 +33,7 @@ import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; -import com.bigdata.rdf.graph.IReducer; +import com.bigdata.rdf.graph.IPredecessor; import com.bigdata.rdf.graph.impl.BaseGASProgram; /** @@ -46,7 +44,8 @@ * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> */ -public class BFS extends BaseGASProgram<BFS.VS, BFS.ES, Void> { +public class BFS extends BaseGASProgram<BFS.VS, BFS.ES, Void> implements + IPredecessor<BFS.VS, BFS.ES, Void> { // private static final Logger log = Logger.getLogger(BFS.class); @@ -339,68 +338,112 @@ } - /** - * Reduce the active vertex state, returning a histogram reporting the #of - * vertices at each distance from the starting vertex. There will always be - * one vertex at depth zero - this is the starting vertex. For each - * successive depth, the #of vertices that were labeled at that depth is - * reported. This is essentially the same as reporting the size of the - * frontier in each round of the traversal, but the histograph is reported - * based on the vertex state. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * - * TODO Do another reducer that reports the actual BFS tree rather - * than a histogram. We need to store the predecessor for this. That - * will allow us to trivially report the BFS route between any two - * vertices. +// /** +// * Reduce the active vertex state, returning a histogram reporting the #of +// * vertices at each distance from the starting vertex. There will always be +// * one vertex at depth zero - this is the starting vertex. For each +// * successive depth, the #of vertices that were labeled at that depth is +// * reported. This is essentially the same as reporting the size of the +// * frontier in each round of the traversal, but the histograph is reported +// * based on the vertex state. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// */ +// protected static class HistogramReducer implements +// IReducer<VS, ES, Void, Map<Integer, AtomicLong>> { +// +// private final ConcurrentHashMap<Integer, AtomicLong> values = new ConcurrentHashMap<Integer, AtomicLong>(); +// +// @Override +// public void visit(final IGASState<VS, ES, Void> state, final Value u) { +// +// final VS us = state.getState(u); +// +// if (us != null) { +// +// final Integer depth = Integer.valueOf(us.depth()); +// +// AtomicLong newval = values.get(depth); +// +// if (newval == null) { +// +// final AtomicLong oldval = values.putIfAbsent(depth, +// newval = new AtomicLong()); +// +// if (oldval != null) { +// +// // lost data race. +// newval = oldval; +// +// } +// +// } +// +// newval.incrementAndGet(); +// +// } +// +// } +// +// @Override +// public Map<Integer, AtomicLong> get() { +// +// return Collections.unmodifiableMap(values); +// +// } +// +// } + + /* + * TODO Do this in parallel for each specified target vertex. */ - protected static class HistogramReducer implements - IReducer<VS, ES, Void, Map<Integer, AtomicLong>> { + @Override + public void prunePaths(final IGASContext<VS, ES, Void> ctx, + final Value[] targetVertices) { - private final ConcurrentHashMap<Integer, AtomicLong> values = new ConcurrentHashMap<Integer, AtomicLong>(); + if (ctx == null) + throw new IllegalArgumentException(); - @Override - public void visit(final IGASState<VS, ES, Void> state, final Value u) { + if (targetVertices == null) + throw new IllegalArgumentException(); + + final IGASState<BFS.VS, BFS.ES, Void> gasState = ctx.getGASState(); - final VS us = state.getState(u); + final Set<Value> retainSet = new HashSet<Value>(); - if (us != null) { + for (Value v : targetVertices) { - final Integer depth = Integer.valueOf(us.depth()); + if (!gasState.isVisited(v)) { - AtomicLong newval = values.get(depth); + // This target was not reachable. + continue; - if (newval == null) { + } - final AtomicLong oldval = values.putIfAbsent(depth, - newval = new AtomicLong()); + /* + * Walk the precessors back to a starting vertex. + */ + Value current = v; - if (oldval != null) { + while (current != null) { - // lost data race. - newval = oldval; + retainSet.add(current); - } + final BFS.VS currentState = gasState.getState(current); - } + final Value predecessor = currentState.predecessor(); - newval.incrementAndGet(); + current = predecessor; } - - } - - @Override - public Map<Integer, AtomicLong> get() { - - return Collections.unmodifiableMap(values); - } + } // next target vertex. + gasState.retainAll(retainSet); + } - + // @Override // public <T> IReducer<VS, ES, Void, T> getDefaultAfterOp() { // Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASState.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASState.java 2014-03-15 10:58:29 UTC (rev 7980) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASState.java 2014-03-15 13:31:34 UTC (rev 7981) @@ -241,7 +241,25 @@ } + /* + * TODO batch parallel in java 8. + */ @Override + public void retainAll(final Set<Value> retainSet) { + + for (Value v : vertexState.keySet()) { + + if (!retainSet.contains(v)) { + + vertexState.remove(v); + + } + + } + + } + + @Override public int round() { return round.get(); 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-03-15 10:58:29 UTC (rev 7980) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-03-15 13:31:34 UTC (rev 7981) @@ -53,7 +53,10 @@ import com.bigdata.rdf.graph.IGASState; import com.bigdata.rdf.graph.IGASStats; import com.bigdata.rdf.graph.IGraphAccessor; +import com.bigdata.rdf.graph.IPredecessor; import com.bigdata.rdf.graph.IReducer; +import com.bigdata.rdf.graph.analytics.CC; +import com.bigdata.rdf.graph.analytics.PR; import com.bigdata.rdf.graph.impl.GASEngine; import com.bigdata.rdf.graph.impl.GASState; import com.bigdata.rdf.graph.impl.bd.BigdataGASEngine.BigdataGraphAccessor; @@ -112,41 +115,20 @@ * } * </pre> * - * FIXME Also allow the execution of gas workflows, such as FuzzySSSP. A workflow - * would be more along the lines of a Callable, but one where the initial source - * and/or target vertices could be identified. Or have an interface that wraps - * the analytics (including things like FuzzySSSP) so they can declare their own - * arguments for invocation as a SERVICE. + * FIXME Also allow the execution of gas workflows, such as FuzzySSSP. A + * workflow would be more along the lines of a Callable, but one where the + * initial source and/or target vertices could be identified. Or have an + * interface that wraps the analytics (including things like FuzzySSSP) so they + * can declare their own arguments for invocation as a SERVICE. * * TODO The input frontier could be a variable, in which case we would pull out * the column for that variable rather than running the algorithm once per * source binding set, right? Or maybe not. * - * TODO Allow {@link IReducer} that binds the visited vertex and also the - * dynamic state associated with that vertex. For BFS and SSSP, this could be - * depth/distance and the predecessor (for path information). For BFS and SSSP, - * we could also have a specific target vertex (or vertices) and then report out - * the path for that vertex/vertices. This would significantly reduce the data - * reported back. (Could we run SSSP in both directions to accelerate the - * convergence?) + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * - * TODO Also support export. This could be easily done using a SPARQL SELECT - * - * <pre> - * SELECT ?src ?tgt ?edgeWeight { - * <<?src linkType ?tgt> propertyType ?edgeWeight> - * } - * </pre> - * - * or (if you have a simple topology without edge weights) - * - * <pre> - * SELECT ?src ?tgt bind(?edgeWeight,1) { - * ?src linkType ?tgt - * } - * </pre> - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @see <a href="http://wiki.bigdata.com/wiki/index.php/RDF_GAS_API">RDF GAS + * API</a> */ public class GASService implements CustomServiceFactory { @@ -248,11 +230,42 @@ Class<? extends IGASSchedulerImpl> DEFAULT_SCHEDULER = CHMScheduler.class; /** - * Magic predicate used to specify a vertex in the initial frontier. + * Magic predicate used to specify one (or more) vertices in the initial + * frontier. + * <p> + * Note: Algorithms such as {@link CC} and {@link PR} automatically + * place all vertices into the initial frontier. For such algorithms, + * you do not need to specify {@link #IN}. */ URI IN = new URIImpl(NAMESPACE + "in"); /** + * Magic predicate used to specify one (or more) target vertices. This + * may be used in combination with algorithms that compute paths in a + * graph to filter the visited vertices after the traversal in order to + * remove any vertex that is not part of a path to one or more of the + * specified target vertices. + * <p> + * In order to support this, the algorithm has to have a concept of a + * <code>predecessor</code>. For each <code>target</code>, the set of + * visited vertices is checked to see if the target was reachable. If it + * was reachable, then the predecessors are walked backwards until a + * starting vertex is reached (predecessor:=null). Each such predecessor + * is added to a list of vertices to be retained. This is repeated for + * each target. Once we have identified the combined list of vertices to + * be reained, all vertices NOT in that list are removed from the + * visited vertex state. This causes the algorithm to only report on + * those paths that lead to at least one of the specified target + * vertices. + * <p> + * Note: If you do not care about the distance between two vertices, but + * only whether they are reachable from one another, you can put both + * vertices into the initial frontier. The algorithm will then work from + * both points which can accelerate convergence. + */ + URI TARGET = new URIImpl(NAMESPACE + "target"); + + /** * Magic predicate used to specify a variable that will become bound to * each vertex in the visited set for the analytic. {@link #OUT} is * always bound to the visited vertices. The other "out" variables are @@ -392,6 +405,7 @@ private final Class<IGASProgram<VS, ES, ST>> gasClass; private final Class<IGASSchedulerImpl> schedulerClass; private final Value[] initialFrontier; + private final Value[] targetVertices; private final IVariable<?>[] outVars; public GASServiceCall(final AbstractTripleStore store, @@ -506,6 +520,9 @@ // Initial frontier. this.initialFrontier = getArg(Options.PROGRAM, Options.IN); + // Target vertices + this.targetVertices = getArg(Options.PROGRAM, Options.TARGET); + /* * The output variable (bound to the visited set). * @@ -760,10 +777,6 @@ final IGASState<VS, ES, ST> gasState = gasContext.getGASState(); - // TODO We should look at this when extracting the parameters from the SERVICE's graph pattern. -// final FrontierEnum frontierEnum = gasProgram -// .getInitialFrontierEnum(); - if (initialFrontier != null) { /* @@ -774,16 +787,9 @@ * necessary since this is an internal, high performance, * and close to the indices operation. */ - final IV[] tmp = new IV[initialFrontier.length]; - - // Setup the initial frontier. - int i = 0; - for (Value startingVertex : initialFrontier) { - - tmp[i++] = ((BigdataValue) startingVertex).getIV(); - - } - + @SuppressWarnings("rawtypes") + final IV[] tmp = toIV(initialFrontier); + // set the frontier. gasState.setFrontier(gasContext, tmp); @@ -792,6 +798,32 @@ // Run the analytic. final IGASStats stats = (IGASStats) gasContext.call(); + if (targetVertices != null + && gasProgram instanceof IPredecessor) { + + /* + * Remove vertices from the visited set that are not on a + * path leading to at least one of the specified target + * vertices. + * + * 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. + */ + + @SuppressWarnings("rawtypes") + final IV[] tmp = toIV(targetVertices); + + @SuppressWarnings("unchecked") + final IPredecessor<VS, ES, ST> t = (IPredecessor<VS, ES, ST>) gasProgram; + + t.prunePaths(gasContext, tmp); + + } + if (log.isInfoEnabled()) { final StringBuilder sb = new StringBuilder(); sb.append("GAS"); @@ -828,6 +860,27 @@ } /** + * Convert a {@link Value}[] of {@link BigdataValue} instances into an + * {@link IV}[]. + */ + private static IV[] toIV(final Value[] values) { + + @SuppressWarnings("rawtypes") + final IV[] tmp = new IV[values.length]; + + // Setup the initial frontier. + int i = 0; + for (Value v : values) { + + tmp[i++] = ((BigdataValue) v).getIV(); + + } + + return tmp; + + } + + /** * Class used to report {@link IBindingSet}s to the {@link GASService}. * {@link IGASProgram}s can customize the way in which they interpret * the declared variables by subclassing this class. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-15 10:58:32
|
Revision: 7980 http://sourceforge.net/p/bigdata/code/7980 Author: thompsonbry Date: 2014-03-15 10:58:29 +0000 (Sat, 15 Mar 2014) Log Message: ----------- Pulled the IBinder interface out of the IBindingExtractor interface. Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java Added Paths: ----------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBinder.java Added: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBinder.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBinder.java (rev 0) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBinder.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -0,0 +1,51 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed 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 com.bigdata.rdf.graph; + +import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; + +/** + * An interface that may be used to extract variable bindings for the + * vertices visited by the algorithm. + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + */ +public interface IBinder<VS, ES, ST> { + + /** + * The ordinal index of the variable that is bound by this + * {@link IBinder}. By convention, index ZERO is the vertex. Indices + * greater than ZERO are typically aspects of the state of the vertex. + */ + int getIndex(); + + /** + * @param vf + * The {@link ValueFactory} used to create the return + * {@link Value}. + * @param u + * The vertex. + * + * @return The {@link Value} for that ordinal variable or + * <code>null</code> if there is no binding for that ordinal + * variable. + */ + Value bind(ValueFactory vf, final IGASState<VS, ES, ST> state, Value u); + +} + Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java 2014-03-15 10:53:47 UTC (rev 7979) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -17,9 +17,6 @@ import java.util.List; -import org.openrdf.model.Value; -import org.openrdf.model.ValueFactory; - /** * This interface makes it possible to extract bindings for variables from an * {@link IGASProgram}. @@ -41,37 +38,6 @@ public interface IBindingExtractor<VS, ES, ST> { /** - * An interface that may be used to extract variable bindings for the - * vertices visited by the algorithm. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - */ - public interface IBinder<VS, ES, ST> { - - /** - * The ordinal index of the variable that is bound by this - * {@link IBinder}. By convention, index ZERO is the vertex. Indices - * greater than ZERO are typically aspects of the state of the vertex. - */ - int getIndex(); - - /** - * @param vf - * The {@link ValueFactory} used to create the return - * {@link Value}. - * @param u - * The vertex. - * - * @return The {@link Value} for that ordinal variable or - * <code>null</code> if there is no binding for that ordinal - * variable. - */ - Value bind(ValueFactory vf, final IGASState<VS, ES, ST> state, Value u); - - } - - /** * Return a list of interfaces that may be used to extract variable bindings * for the vertices visited by the algorithm. */ Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-15 10:53:47 UTC (rev 7979) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -30,6 +30,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBinder; import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASScheduler; @@ -278,11 +279,11 @@ * </dl> */ @Override - public List<IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>> getBinderList() { + public List<IBinder<BFS.VS, BFS.ES, Void>> getBinderList() { - final List<IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>> tmp = super.getBinderList(); + final List<IBinder<BFS.VS, BFS.ES, Void>> tmp = super.getBinderList(); - tmp.add(new IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>() { + tmp.add(new IBinder<BFS.VS, BFS.ES, Void>() { @Override public int getIndex() { @@ -298,7 +299,7 @@ } }); - tmp.add(new IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>() { + tmp.add(new IBinder<BFS.VS, BFS.ES, Void>() { @Override public int getIndex() { Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-15 10:53:47 UTC (rev 7979) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -30,6 +30,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBinder; import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; @@ -314,11 +315,11 @@ * </dl> */ @Override - public List<IBindingExtractor.IBinder<CC.VS, CC.ES, Value>> getBinderList() { + public List<IBinder<CC.VS, CC.ES, Value>> getBinderList() { - final List<IBindingExtractor.IBinder<CC.VS, CC.ES, Value>> tmp = super.getBinderList(); + final List<IBinder<CC.VS, CC.ES, Value>> tmp = super.getBinderList(); - tmp.add(new IBindingExtractor.IBinder<CC.VS, CC.ES, Value>() { + tmp.add(new IBinder<CC.VS, CC.ES, Value>() { @Override public int getIndex() { Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-15 10:53:47 UTC (rev 7979) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -28,13 +28,12 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBinder; import com.bigdata.rdf.graph.IBindingExtractor; -import com.bigdata.rdf.graph.IBindingExtractor.IBinder; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; import com.bigdata.rdf.graph.IReducer; -import com.bigdata.rdf.graph.analytics.CC.Bindings; import com.bigdata.rdf.graph.impl.BaseGASProgram; /** @@ -349,11 +348,11 @@ * </dl> */ @Override - public List<IBindingExtractor.IBinder<PR.VS, PR.ES, Double>> getBinderList() { + public List<IBinder<PR.VS, PR.ES, Double>> getBinderList() { - final List<IBindingExtractor.IBinder<PR.VS, PR.ES, Double>> tmp = super.getBinderList(); + final List<IBinder<PR.VS, PR.ES, Double>> tmp = super.getBinderList(); - tmp.add(new IBindingExtractor.IBinder<PR.VS, PR.ES, Double>() { + tmp.add(new IBinder<PR.VS, PR.ES, Double>() { @Override public int getIndex() { Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-15 10:53:47 UTC (rev 7979) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -25,6 +25,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBinder; import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASScheduler; @@ -446,12 +447,12 @@ * </dl> */ @Override - public List<IBindingExtractor.IBinder<SSSP.VS, SSSP.ES, Integer>> getBinderList() { + public List<IBinder<SSSP.VS, SSSP.ES, Integer>> getBinderList() { - final List<IBindingExtractor.IBinder<SSSP.VS, SSSP.ES, Integer>> tmp = super + final List<IBinder<SSSP.VS, SSSP.ES, Integer>> tmp = super .getBinderList(); - tmp.add(new IBindingExtractor.IBinder<SSSP.VS, SSSP.ES, Integer>() { + tmp.add(new IBinder<SSSP.VS, SSSP.ES, Integer>() { @Override public int getIndex() { Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-15 10:53:47 UTC (rev 7979) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -29,6 +29,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBinder; import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASProgram; @@ -232,11 +233,11 @@ * </dl> */ @Override - public List<IBindingExtractor.IBinder<VS, ES, ST>> getBinderList() { + public List<IBinder<VS, ES, ST>> getBinderList() { - final List<IBindingExtractor.IBinder<VS, ES, ST>> tmp = new LinkedList<IBindingExtractor.IBinder<VS, ES, ST>>(); + final List<IBinder<VS, ES, ST>> tmp = new LinkedList<IBinder<VS, ES, ST>>(); - tmp.add(new IBindingExtractor.IBinder<VS, ES, ST>() { + tmp.add(new IBinder<VS, ES, ST>() { @Override public int getIndex() { 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-03-15 10:53:47 UTC (rev 7979) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-03-15 10:58:29 UTC (rev 7980) @@ -44,8 +44,7 @@ import com.bigdata.bop.IVariable; import com.bigdata.bop.bindingSet.ListBindingSet; import com.bigdata.journal.IIndexManager; -import com.bigdata.rdf.graph.IBindingExtractor; -import com.bigdata.rdf.graph.IBindingExtractor.IBinder; +import com.bigdata.rdf.graph.IBinder; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASEngine; import com.bigdata.rdf.graph.IGASProgram; @@ -871,7 +870,7 @@ /** * The list of objects used to extract the variable bindings. */ - private final List<IBindingExtractor.IBinder<VS, ES, ST>> binderList; + private final List<IBinder<VS, ES, ST>> binderList; /** * The collected solutions. @@ -908,7 +907,7 @@ final IBindingSet bs = new ListBindingSet(); - for (IBindingExtractor.IBinder<VS, ES, ST> b : binderList) { + for (IBinder<VS, ES, ST> b : binderList) { // The variable for this binder. final IVariable<?> var = outVars[b.getIndex()]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-15 10:53:50
|
Revision: 7979 http://sourceforge.net/p/bigdata/code/7979 Author: thompsonbry Date: 2014-03-15 10:53:47 +0000 (Sat, 15 Mar 2014) Log Message: ----------- Extracted an IBindingExtractor interface from the IGASProgram interface. Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java Added Paths: ----------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java Added: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java (rev 0) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IBindingExtractor.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -0,0 +1,80 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed 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 com.bigdata.rdf.graph; + +import java.util.List; + +import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; + +/** + * This interface makes it possible to extract bindings for variables from an + * {@link IGASProgram}. + * + * @param <VS> + * The generic type for the per-vertex state. This is scoped to the + * computation of the {@link IGASProgram}. + * @param <ES> + * The generic type for the per-edge state. This is scoped to the + * computation of the {@link IGASProgram}. + * @param <ST> + * The generic type for the SUM. This is often directly related to + * the generic type for the per-edge state, but that is not always + * true. The SUM type is scoped to the GATHER + SUM operation (NOT + * the computation). + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ +public interface IBindingExtractor<VS, ES, ST> { + + /** + * An interface that may be used to extract variable bindings for the + * vertices visited by the algorithm. + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + */ + public interface IBinder<VS, ES, ST> { + + /** + * The ordinal index of the variable that is bound by this + * {@link IBinder}. By convention, index ZERO is the vertex. Indices + * greater than ZERO are typically aspects of the state of the vertex. + */ + int getIndex(); + + /** + * @param vf + * The {@link ValueFactory} used to create the return + * {@link Value}. + * @param u + * The vertex. + * + * @return The {@link Value} for that ordinal variable or + * <code>null</code> if there is no binding for that ordinal + * variable. + */ + Value bind(ValueFactory vf, final IGASState<VS, ES, ST> state, Value u); + + } + + /** + * Return a list of interfaces that may be used to extract variable bindings + * for the vertices visited by the algorithm. + */ + List<IBinder<VS, ES, ST>> getBinderList(); + +} Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java 2014-03-15 01:32:44 UTC (rev 7978) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -15,11 +15,8 @@ */ package com.bigdata.rdf.graph; -import java.util.List; - import org.openrdf.model.Statement; import org.openrdf.model.Value; -import org.openrdf.model.ValueFactory; /** * Abstract interface for GAS programs. @@ -43,7 +40,8 @@ * an API that is aimed at vectored (for GPU) execution with 2D * partitioning (for out-of-core, multi-node). */ -public interface IGASProgram<VS, ES, ST> extends IGASOptions<VS, ES, ST> { +public interface IGASProgram<VS, ES, ST> extends IGASOptions<VS, ES, ST>, + IBindingExtractor<VS, ES, ST> { /** * One time initialization before the {@link IGASProgram} is executed. @@ -205,41 +203,4 @@ */ boolean nextRound(IGASContext<VS, ES, ST> ctx); - /** - * Return a list of interfaces that may be used to extract variable bindings - * for the vertices visited by the algorithm. - */ - List<IBinder<VS, ES, ST>> getBinderList(); - - /** - * An interface that may be used to extract variable bindings for the - * vertices visited by the algorithm. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - */ - public interface IBinder<VS, ES, ST> { - - /** - * The ordinal index of the variable that is bound by this - * {@link IBinder}. By convention, index ZERO is the vertex. Indices - * greater than ZERO are typically aspects of the state of the vertex. - */ - int getIndex(); - - /** - * @param vf - * The {@link ValueFactory} used to create the return - * {@link Value}. - * @param u - * The vertex. - * - * @return The {@link Value} for that ordinal variable or - * <code>null</code> if there is no binding for that ordinal - * variable. - */ - Value bind(ValueFactory vf, final IGASState<VS, ES, ST> state, Value u); - - } - } \ No newline at end of file Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-15 01:32:44 UTC (rev 7978) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -30,6 +30,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; @@ -277,11 +278,11 @@ * </dl> */ @Override - public List<IBinder<BFS.VS, BFS.ES, Void>> getBinderList() { + public List<IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>> getBinderList() { - final List<IBinder<BFS.VS, BFS.ES, Void>> tmp = super.getBinderList(); + final List<IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>> tmp = super.getBinderList(); - tmp.add(new IBinder<BFS.VS, BFS.ES, Void>() { + tmp.add(new IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>() { @Override public int getIndex() { @@ -297,7 +298,7 @@ } }); - tmp.add(new IBinder<BFS.VS, BFS.ES, Void>() { + tmp.add(new IBindingExtractor.IBinder<BFS.VS, BFS.ES, Void>() { @Override public int getIndex() { @@ -318,7 +319,7 @@ } /** - * Additional {@link IBinder}s exposed by {@link BFS}. + * Additional {@link IBindingExtractor.IBinder}s exposed by {@link BFS}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> */ Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-15 01:32:44 UTC (rev 7978) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -30,6 +30,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; import com.bigdata.rdf.graph.IReducer; @@ -313,11 +314,11 @@ * </dl> */ @Override - public List<IBinder<CC.VS, CC.ES, Value>> getBinderList() { + public List<IBindingExtractor.IBinder<CC.VS, CC.ES, Value>> getBinderList() { - final List<IBinder<CC.VS, CC.ES, Value>> tmp = super.getBinderList(); + final List<IBindingExtractor.IBinder<CC.VS, CC.ES, Value>> tmp = super.getBinderList(); - tmp.add(new IBinder<CC.VS, CC.ES, Value>() { + tmp.add(new IBindingExtractor.IBinder<CC.VS, CC.ES, Value>() { @Override public int getIndex() { @@ -338,7 +339,7 @@ } /** - * Additional {@link IBinder}s exposed by {@link CC}. + * Additional {@link IBindingExtractor.IBinder}s exposed by {@link CC}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> */ Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-15 01:32:44 UTC (rev 7978) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -28,11 +28,12 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBindingExtractor; +import com.bigdata.rdf.graph.IBindingExtractor.IBinder; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; import com.bigdata.rdf.graph.IReducer; -import com.bigdata.rdf.graph.IGASProgram.IBinder; import com.bigdata.rdf.graph.analytics.CC.Bindings; import com.bigdata.rdf.graph.impl.BaseGASProgram; @@ -348,11 +349,11 @@ * </dl> */ @Override - public List<IBinder<PR.VS, PR.ES, Double>> getBinderList() { + public List<IBindingExtractor.IBinder<PR.VS, PR.ES, Double>> getBinderList() { - final List<IBinder<PR.VS, PR.ES, Double>> tmp = super.getBinderList(); + final List<IBindingExtractor.IBinder<PR.VS, PR.ES, Double>> tmp = super.getBinderList(); - tmp.add(new IBinder<PR.VS, PR.ES, Double>() { + tmp.add(new IBindingExtractor.IBinder<PR.VS, PR.ES, Double>() { @Override public int getIndex() { @@ -373,7 +374,7 @@ } /** - * Additional {@link IBinder}s exposed by {@link PR}. + * Additional {@link IBindingExtractor.IBinder}s exposed by {@link PR}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> */ Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-15 01:32:44 UTC (rev 7978) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -25,6 +25,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; @@ -445,12 +446,12 @@ * </dl> */ @Override - public List<IBinder<SSSP.VS, SSSP.ES, Integer>> getBinderList() { + public List<IBindingExtractor.IBinder<SSSP.VS, SSSP.ES, Integer>> getBinderList() { - final List<IBinder<SSSP.VS, SSSP.ES, Integer>> tmp = super + final List<IBindingExtractor.IBinder<SSSP.VS, SSSP.ES, Integer>> tmp = super .getBinderList(); - tmp.add(new IBinder<SSSP.VS, SSSP.ES, Integer>() { + tmp.add(new IBindingExtractor.IBinder<SSSP.VS, SSSP.ES, Integer>() { @Override public int getIndex() { @@ -472,7 +473,7 @@ } /** - * Additional {@link IBinder}s exposed by {@link SSSP}. + * Additional {@link IBindingExtractor.IBinder}s exposed by {@link SSSP}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> */ Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-15 01:32:44 UTC (rev 7978) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -29,6 +29,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; import com.bigdata.rdf.graph.FrontierEnum; +import com.bigdata.rdf.graph.IBindingExtractor; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASProgram; import com.bigdata.rdf.graph.IGASState; @@ -231,11 +232,11 @@ * </dl> */ @Override - public List<IBinder<VS, ES, ST>> getBinderList() { + public List<IBindingExtractor.IBinder<VS, ES, ST>> getBinderList() { - final List<IBinder<VS, ES, ST>> tmp = new LinkedList<IBinder<VS, ES, ST>>(); + final List<IBindingExtractor.IBinder<VS, ES, ST>> tmp = new LinkedList<IBindingExtractor.IBinder<VS, ES, ST>>(); - tmp.add(new IBinder<VS, ES, ST>() { + tmp.add(new IBindingExtractor.IBinder<VS, ES, ST>() { @Override public int getIndex() { @@ -259,7 +260,7 @@ } /** - * Interface declares symbolic constants for the {@link IBinder}s reported + * Interface declares symbolic constants for the {@link IBindingExtractor.IBinder}s reported * by {@link BaseGASProgram#getBinderList()}. * * @author <a href="mailto:tho...@us...">Bryan 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-03-15 01:32:44 UTC (rev 7978) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-03-15 10:53:47 UTC (rev 7979) @@ -44,10 +44,11 @@ import com.bigdata.bop.IVariable; import com.bigdata.bop.bindingSet.ListBindingSet; import com.bigdata.journal.IIndexManager; +import com.bigdata.rdf.graph.IBindingExtractor; +import com.bigdata.rdf.graph.IBindingExtractor.IBinder; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASEngine; import com.bigdata.rdf.graph.IGASProgram; -import com.bigdata.rdf.graph.IGASProgram.IBinder; import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASSchedulerImpl; import com.bigdata.rdf.graph.IGASState; @@ -870,7 +871,7 @@ /** * The list of objects used to extract the variable bindings. */ - private final List<IBinder<VS, ES, ST>> binderList; + private final List<IBindingExtractor.IBinder<VS, ES, ST>> binderList; /** * The collected solutions. @@ -907,7 +908,7 @@ final IBindingSet bs = new ListBindingSet(); - for (IBinder<VS, ES, ST> b : binderList) { + for (IBindingExtractor.IBinder<VS, ES, ST> b : binderList) { // The variable for this binder. final IVariable<?> var = outVars[b.getIndex()]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-15 01:32:51
|
Revision: 7978 http://sourceforge.net/p/bigdata/code/7978 Author: tobycraig Date: 2014-03-15 01:32:44 +0000 (Sat, 15 Mar 2014) Log Message: ----------- #827 - Change No Results Found to No Incoming/Outgoing Links/Attributes Modified Paths: -------------- branches/RDR/bigdata-war/src/html/css/style.css branches/RDR/bigdata-war/src/html/js/workbench.js branches/RDR/bigdata-war/src/html/new.html Modified: branches/RDR/bigdata-war/src/html/css/style.css =================================================================== --- branches/RDR/bigdata-war/src/html/css/style.css 2014-03-15 01:21:15 UTC (rev 7977) +++ branches/RDR/bigdata-war/src/html/css/style.css 2014-03-15 01:32:44 UTC (rev 7978) @@ -179,7 +179,7 @@ border: none; } -#advanced-features, #query-explanation, #explore-results, #namespace-properties { +#advanced-features, #query-explanation, #namespace-properties { display: none; } Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 01:21:15 UTC (rev 7977) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 01:32:44 UTC (rev 7978) @@ -636,13 +636,13 @@ var re = /<< <([^<>]*)> <([^<>]*)> <([^<>]*)> >>/; var match = uri.match(re); if(match) { - $('#explore-header h1').html('<< <<a href="#">' + match[1] + '</a> > <<a href="#">' + match[2] + '</a> > <<a href="#">' + match[3] + '</a> > >>'); + $('#explore-header').html('<h1><< <<a href="#">' + match[1] + '</a> > <<a href="#">' + match[2] + '</a> > <<a href="#">' + match[3] + '</a> > >></h1>'); $('#explore-header h1 a').click(function(e) { e.preventDefault(); explore(this.text); }); } else { - $('#explore-header h1').text(uri); + $('#explore-header').html('<h1>' + uri + '</h1>'); } } }); @@ -718,15 +718,7 @@ console.log('Explore results'); console.log(data); var results = data.results.bindings.length > 0; - $('#explore-results').toggle(results); - $('#explore-no-results').toggle(!results); - // see if we got any results - if(!results) { - $('#explore-no-results').html('<h1>No results found!</h1>'); - return; - } - // clear tables $('#explore-incoming, #explore-outgoing, #explore-attributes').html('<table>'); @@ -790,9 +782,8 @@ } function updateExploreError(jqXHR, textStatus, errorThrown) { - $('#explore-results').hide(); - $('#explore-no-results').show(); - $('#explore-no-results').html('Error! ' + textStatus + ' ' + errorThrown); + $('#explore-results .box').html(''); + $('#explore-header').html('Error! ' + textStatus + ' ' + errorThrown); } /* Status */ Modified: branches/RDR/bigdata-war/src/html/new.html =================================================================== --- branches/RDR/bigdata-war/src/html/new.html 2014-03-15 01:21:15 UTC (rev 7977) +++ branches/RDR/bigdata-war/src/html/new.html 2014-03-15 01:32:44 UTC (rev 7978) @@ -144,14 +144,12 @@ </div> <div id="explore-results"> - <div class="box" id="explore-header"><h1></h1></div> + <div class="box" id="explore-header"></div> <div class="box" id="explore-incoming"></div> <div class="box" id="explore-outgoing"></div> <div class="box" id="explore-attributes"></div> </div> - <div class="box" id="explore-no-results"></div> - </div> <div class="tab" id="status-tab"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-15 01:21:23
|
Revision: 7977 http://sourceforge.net/p/bigdata/code/7977 Author: tobycraig Date: 2014-03-15 01:21:15 +0000 (Sat, 15 Mar 2014) Log Message: ----------- #827 - Changed header when no incoming/outgoing links/attributes Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js branches/RDR/bigdata-war/src/html/new.html Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 00:54:42 UTC (rev 7976) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 01:21:15 UTC (rev 7977) @@ -728,7 +728,7 @@ } // clear tables - $('#explore-incoming table, #explore-outgoing table, #explore-attributes table').html(''); + $('#explore-incoming, #explore-outgoing, #explore-attributes').html('<table>'); // go through each binding, adding it to the appropriate table $.each(data.results.bindings, function(i, binding) { @@ -770,6 +770,13 @@ } }); + var sections = {incoming: 'Incoming Links', outgoing: 'Outgoing Links', attributes: 'Attributes'}; + for(var k in sections) { + if($('#explore-' + k + ' table tr').length == 0) { + $('#explore-' + k).html('No ' + sections[k]); + } + } + $('#explore-results a').click(function(e) { e.preventDefault(); explore($(this).data('sid') ? $(this).data('sid') : this.text); Modified: branches/RDR/bigdata-war/src/html/new.html =================================================================== --- branches/RDR/bigdata-war/src/html/new.html 2014-03-15 00:54:42 UTC (rev 7976) +++ branches/RDR/bigdata-war/src/html/new.html 2014-03-15 01:21:15 UTC (rev 7977) @@ -145,18 +145,9 @@ <div id="explore-results"> <div class="box" id="explore-header"><h1></h1></div> - <div class="box" id="explore-incoming"> - <h2>Incoming links</h2> - <table></table> - </div> - <div class="box" id="explore-outgoing"> - <h2>Outgoing links</h2> - <table></table> - </div> - <div class="box" id="explore-attributes"> - <h2>Attributes</h2> - <table></table> - </div> + <div class="box" id="explore-incoming"></div> + <div class="box" id="explore-outgoing"></div> + <div class="box" id="explore-attributes"></div> </div> <div class="box" id="explore-no-results"></div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-15 00:54:46
|
Revision: 7976 http://sourceforge.net/p/bigdata/code/7976 Author: tobycraig Date: 2014-03-15 00:54:42 +0000 (Sat, 15 Mar 2014) Log Message: ----------- #827 - Put * (n) inside << >> Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 00:52:32 UTC (rev 7975) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 00:54:42 UTC (rev 7976) @@ -751,7 +751,7 @@ } else { var sid = '<< <' + $('#explore-form input[type=text]').val() + '> <' + binding.col1.value + '> <' + binding.col2.value + '> >>'; } - star = '<a href="#" data-sid="' + sid + '">*</a> (' + star + ')'; + star = '<a href="#" data-sid="' + sid + '"><< * (' + star + ') >></a>'; } else { star = ''; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-15 00:52:38
|
Revision: 7975 http://sourceforge.net/p/bigdata/code/7975 Author: tobycraig Date: 2014-03-15 00:52:32 +0000 (Sat, 15 Mar 2014) Log Message: ----------- #827 - Added angle brackets around SIDs Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 00:29:12 UTC (rev 7974) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-15 00:52:32 UTC (rev 7975) @@ -633,10 +633,10 @@ loadURI(uri); // if this is a SID, make the components clickable - var re = /< <([^<>]*)> <([^<>]*)> <([^<>]*)> >/; + var re = /<< <([^<>]*)> <([^<>]*)> <([^<>]*)> >>/; var match = uri.match(re); if(match) { - $('#explore-header h1').html('< <<a href="#">' + match[1] + '</a> > <<a href="#">' + match[2] + '</a> > <<a href="#">' + match[3] + '</a> > >'); + $('#explore-header h1').html('<< <<a href="#">' + match[1] + '</a> > <<a href="#">' + match[2] + '</a> > <<a href="#">' + match[3] + '</a> > >>'); $('#explore-header h1 a').click(function(e) { e.preventDefault(); explore(this.text); @@ -649,7 +649,7 @@ function loadURI(target) { // identify if this is a vertex or a SID - var re = /< (?:<[^<>]*> ){3}>/; + var re = /<< (?:<[^<>]*> ){3}>>/; var vertex = !target.match(re); var vertexQuery = '\ @@ -675,7 +675,7 @@ select ?col1 ?col2 ?incoming (count(?star) as ?star)\n\ with {\n\ select ?explore where {\n\ - bind (<SID> as ?explore) .\n\ + bind (SID as ?explore) .\n\ }\n\ } as %_explore\n\ where {\n\ @@ -747,9 +747,9 @@ var star = parseInt(binding.star.value); if(star > 0) { if(binding.incoming.value == 'true') { - var sid = '< <' + binding.col1.value + '> <' + binding.col2.value + '> <' + $('#explore-form input[type=text]').val() + '> >'; + var sid = '<< <' + binding.col1.value + '> <' + binding.col2.value + '> <' + $('#explore-form input[type=text]').val() + '> >>'; } else { - var sid = '< <' + $('#explore-form input[type=text]').val() + '> <' + binding.col1.value + '> <' + binding.col2.value + '> >'; + var sid = '<< <' + $('#explore-form input[type=text]').val() + '> <' + binding.col1.value + '> <' + binding.col2.value + '> >>'; } star = '<a href="#" data-sid="' + sid + '">*</a> (' + star + ')'; } else { @@ -807,7 +807,7 @@ /* Utility functions */ function getSID(binding) { - return '< <' + binding.value['sid-s'].value + '> <' + binding.value['sid-p'].value + '> <' + binding.value['sid-o'].value + '> >'; + return '<< <' + binding.value['sid-s'].value + '> <' + binding.value['sid-p'].value + '> <' + binding.value['sid-o'].value + '> >>'; } function parseSID(sid) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-15 00:29:17
|
Revision: 7974 http://sourceforge.net/p/bigdata/code/7974 Author: tobycraig Date: 2014-03-15 00:29:12 +0000 (Sat, 15 Mar 2014) Log Message: ----------- #827 - Don't draw border on last column of explore results Modified Paths: -------------- branches/RDR/bigdata-war/src/html/css/style.css Modified: branches/RDR/bigdata-war/src/html/css/style.css =================================================================== --- branches/RDR/bigdata-war/src/html/css/style.css 2014-03-14 23:49:43 UTC (rev 7973) +++ branches/RDR/bigdata-war/src/html/css/style.css 2014-03-15 00:29:12 UTC (rev 7974) @@ -175,6 +175,10 @@ width: 50%; } +#explore-tab td:last-of-type { + border: none; +} + #advanced-features, #query-explanation, #explore-results, #namespace-properties { display: none; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-14 23:49:46
|
Revision: 7973 http://sourceforge.net/p/bigdata/code/7973 Author: tobycraig Date: 2014-03-14 23:49:43 +0000 (Fri, 14 Mar 2014) Log Message: ----------- #827 - Made SID components in header clickable, and removed old code Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 23:44:38 UTC (rev 7972) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 23:49:43 UTC (rev 7973) @@ -631,7 +631,19 @@ var uri = $(this).find('input').val(); if(uri) { loadURI(uri); - $('#explore-header h1').text(uri); + + // if this is a SID, make the components clickable + var re = /< <([^<>]*)> <([^<>]*)> <([^<>]*)> >/; + var match = uri.match(re); + if(match) { + $('#explore-header h1').html('< <<a href="#">' + match[1] + '</a> > <<a href="#">' + match[2] + '</a> > <<a href="#">' + match[3] + '</a> > >'); + $('#explore-header h1 a').click(function(e) { + e.preventDefault(); + explore(this.text); + }); + } else { + $('#explore-header h1').text(uri); + } } }); @@ -762,68 +774,6 @@ e.preventDefault(); explore($(this).data('sid') ? $(this).data('sid') : this.text); }); - - return; - - var outbound={}, inbound={}, attributes={}; - for(var i=0; i<data.results.bindings.length; i++) { - var binding = data.results.bindings[i]; - var star = typeof(binding.sidP) != 'undefined'; - if('o' in binding) { - var key = [binding.p.value, binding.o.value]; - if(binding.o.type == 'uri') { - // leave star true if it was before, or set it to current value - outbound[key] = !!outbound[key] || star; - } else { - // do not show star for attributes - attributes[key] = false; - } - } else { - var key = [binding.s.value, binding.p.value] - inbound[key] == !!inbound[key] || star; - } - } - - var outgoingContainer = $('#explore-outgoing'); - outgoingContainer.html(''); - if(outbound.length) { - outgoingContainer.append('<h2>Outgoing links</h2>'); - var table = $('<table>').appendTo(outgoingContainer); - for(key in outbound) { - table.append('<tr><td>' + key[0] + '</td><td><a href="#">' + key[1] + '</a></td><td>' + (outbound[key] ? '*' : '') + '</td></tr>'); - } - } else { - outgoingContainer.append('<h2>No outgoing links</h2>'); - } - - var incomingContainer = $('#explore-incoming'); - incomingContainer.html(''); - if(inbound.length) { - incomingContainer.append('<h2>Inbound links</h2>'); - var table = $('<table>').appendTo(incomingContainer); - for(key in inbound) { - table.append('<tr><td>' + key[0] + '</td><td><a href="#">' + key[1] + '</a></td><td>' + (inbound[key] ? '*' : '') + '</td></tr>'); - } - } else { - incomingContainer.append('<h2>No incoming links</h2>'); - } - - var attributesContainer = $('#explore-attributes'); - attributesContainer.html(''); - if(attributes.length) { - attributesContainer.append('<h4>Attributes</h4>'); - var table = $('<table>').appendTo(attributesContainer); - for(var i=0; i<attributes.length; i++) { - table.append('<tr><td>' + attributes[i].p.value + '</td><td>' + attributes[i].o.value + '</td></tr>'); - } - } else { - attributesContainer.append('<h2>No attributes</h2>'); - } - - $('#explore-results a').click(function(e) { - e.preventDefault(); - explore(this.text); - }); } function explore(uri) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-14 23:44:41
|
Revision: 7972 http://sourceforge.net/p/bigdata/code/7972 Author: thompsonbry Date: 2014-03-14 23:44:38 +0000 (Fri, 14 Mar 2014) Log Message: ----------- Added support for the control over directed versus undirected edge traversal semantics. There is a new isDirectedTraversal() option and setDirectedTraversal() option on IGASContext and a gas:directedTraversal option for the GASService. I have written a test of this functionality for BFS. I found and fixed some assumptions in BFS and SSP where they used e.getSubject() or e.getObject() rather than u and gasState.getOtherVertex(u,e). The former do not correctly handle the case where the traversal assumptions change from either in-edges or out-edges to all-edges. The latter (u and getOtherVertex(u,e)) does. See #810 (GAS Service) Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/EdgesEnum.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASOptions.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/EdgesEnum.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/EdgesEnum.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/EdgesEnum.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -83,4 +83,27 @@ } } + /** + * Promote an {@link EdgesEnum} value that was specified with the assumption + * that the graph is directed into an {@link EdgesEnum} value that should be + * used when the graph is undirected. There is no change for + * {@link #NoEdges} and {@link #AllEdges}. If the value is either + * {@link #InEdges} or {@link #OutEdges} then it is promoted to + * {@link #AllEdges}. + */ + public EdgesEnum asUndirectedTraversal() { + switch (this) { + case NoEdges: + case AllEdges: + // No change. + return this; + case InEdges: + case OutEdges: + // promote to AllEdges. + return AllEdges; + default: + throw new UnsupportedOperationException(); + } + } + } \ No newline at end of file Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -67,6 +67,22 @@ IGraphAccessor getGraphAccessor(); /** + * Specify whether the visited edges of the graph are to be interpreted as + * directed or undirected (default <code>directed</code>). + * <p> + * The value specified here is used to determine how the {@link EdgesEnum} + * will be interpreted for the GATHER and SCATTER phases. See + * {@link EdgesEnum#asUndirectedTraversal()}. + */ + void setDirectedTraversal(boolean newVal); + + /** + * Return <code>true</code> if the graph should be interpreted as a directed + * graph. + */ + boolean isDirectedTraversal(); + + /** * Specify the maximum number of iterations for the algorithm. A value of * ONE means that the algorithm will halt after the first round. * Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASOptions.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASOptions.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASOptions.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -50,8 +50,10 @@ EdgesEnum getSampleEdgesFilter(); /** - * Return the set of edges to which the GATHER is applied -or- - * {@link EdgesEnum#NoEdges} to skip the GATHER phase. + * Return the set of edges to which the GATHER is applied for a + * <em>directed</em> graph -or- {@link EdgesEnum#NoEdges} to skip the GATHER + * phase. This will be interpreted based on the value reported by + * {@link IGASContext#isDirectedTraversal()}. * * TODO We may need to set dynamically when visting the vertex in the * frontier rather than having it be a one-time property of the vertex @@ -60,8 +62,10 @@ EdgesEnum getGatherEdges(); /** - * Return the set of edges to which the SCATTER is applied -or- - * {@link EdgesEnum#NoEdges} to skip the SCATTER phase. + * Return the set of edges to which the SCATTER is applied for a + * <em>directed</em> graph -or- {@link EdgesEnum#NoEdges} to skip the + * SCATTER phase. This will be interpreted based on the value reported by + * {@link IGASContext#isDirectedTraversal()}. */ EdgesEnum getScatterEdges(); Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -239,7 +239,9 @@ final IGASScheduler sch, final Value u, final Statement e) { // remote vertex state. - final VS otherState = state.getState(e.getObject()/* v */); + final Value v = state.getOtherVertex(u, e); + final VS otherState = state.getState(v); +// final VS otherState = state.getState(e.getObject()/* v */); // visit. if (otherState.visit(state.round() + 1, u/* predecessor */)) { @@ -249,7 +251,7 @@ * schedule for the next iteration. */ - sch.schedule(e.getObject()); + sch.schedule(v); } Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -291,10 +291,6 @@ /** * The remote vertex is scheduled for activation unless it has already been * visited. - * <p> - * Note: We are scattering to out-edges. Therefore, this vertex is - * {@link Statement#getSubject()}. The remote vertex is - * {@link Statement#getObject()}. */ @Override public void scatter(final IGASState<CC.VS, CC.ES, Value> state, Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -296,9 +296,10 @@ public Integer gather(final IGASState<SSSP.VS, SSSP.ES, Integer> state, final Value u, final Statement e) { -// assert e.o().equals(u); +// assert e.getObject().equals(u); - final VS src = state.getState(e.getSubject()); +// final VS src = state.getState(e.getSubject()); + final VS src = state.getState(u); final int d = src.dist(); @@ -420,7 +421,7 @@ + newDist); // Then add the remote vertex to the next frontier. - sch.schedule(e.getObject()); + sch.schedule(other); } Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -32,7 +32,6 @@ import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGASProgram; import com.bigdata.rdf.graph.IGASState; -import com.bigdata.rdf.graph.IReducer; import com.bigdata.rdf.graph.impl.util.VertexDistribution; /** @@ -65,6 +64,8 @@ * The default implementation returns {@link #getGatherEdges()} and the * {@link #getScatterEdges()} if {@link #getGatherEdges()} returns * {@value EdgesEnum#NoEdges}. + * + * TODO This ignores {@link IGASContext#isDirectedTraversal()} */ @Override public EdgesEnum getSampleEdgesFilter() { Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -19,6 +19,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; @@ -63,6 +64,12 @@ private final IGASProgram<VS, ES, ST> program; /** + * Whether or not the edges of the graph will be traversed with directed + * graph semantics (default is TRUE). + */ + private final AtomicBoolean directedGraph = new AtomicBoolean(true); + + /** * The maximum number of iterations (defaults to {@link Integer#MAX_VALUE}). */ private final AtomicInteger maxIterations = new AtomicInteger( @@ -251,8 +258,12 @@ * APPLY is done before the SCATTER - this would not work if we pushed * down the APPLY into the SCATTER). */ - final EdgesEnum gatherEdges = program.getGatherEdges(); - final EdgesEnum scatterEdges = program.getScatterEdges(); + final EdgesEnum gatherEdges = isDirectedTraversal() ? program + .getGatherEdges() : program.getGatherEdges() + .asUndirectedTraversal(); + final EdgesEnum scatterEdges = isDirectedTraversal() ? program + .getScatterEdges() : program.getScatterEdges() + .asUndirectedTraversal(); final boolean pushDownApplyInGather; final boolean pushDownApplyInScatter; final boolean runApplyStage; @@ -805,6 +816,20 @@ } @Override + public boolean isDirectedTraversal() { + + return directedGraph.get(); + + } + + @Override + public void setDirectedTraversal(final boolean newVal) { + + directedGraph.set(newVal); + + } + + @Override public int getMaxIterations() { return maxIterations.get(); Modified: branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java =================================================================== --- branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java 2014-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -102,4 +102,151 @@ } + /** + * Variant test in which we choose a vertex (<code>foaf:person</code>) in + * the middle of the graph and insist on directed edges. Since the edges + * point from the person to the <code>foaf:person</code> vertex, this BSF + * traversal does not discover any connected vertices. + */ + public void testBFS_directed() throws Exception { + + final SmallGraphProblem p = setupSmallGraphProblem(); + + final IGASEngine gasEngine = getGraphFixture() + .newGASEngine(1/* nthreads */); + + try { + + final SailConnection cxn = getGraphFixture().getSail() + .getConnection(); + + try { + + final IGraphAccessor graphAccessor = getGraphFixture() + .newGraphAccessor(cxn); + + final IGASContext<BFS.VS, BFS.ES, Void> gasContext = gasEngine + .newGASContext(graphAccessor, new BFS()); + + final IGASState<BFS.VS, BFS.ES, Void> gasState = gasContext + .getGASState(); + + // Initialize the froniter. + gasState.setFrontier(gasContext, p.getFoafPerson()); + + // directed traversal. + gasContext.setDirectedTraversal(true); + + // Converge. + gasContext.call(); + + // starting vertex at (0,null). + assertEquals(0, gasState.getState(p.getFoafPerson()).depth()); + assertEquals(null, gasState.getState(p.getFoafPerson()) + .predecessor()); + + // no other vertices are visited. + assertEquals(-1, gasState.getState(p.getMike()).depth()); + assertEquals(null, gasState.getState(p.getMike()).predecessor()); + + assertEquals(-1, gasState.getState(p.getBryan()).depth()); + assertEquals(null, gasState.getState(p.getBryan()) + .predecessor()); + + assertEquals(-1, gasState.getState(p.getMartyn()).depth()); + assertEquals(null, gasState.getState(p.getMartyn()) + .predecessor()); + + } finally { + + try { + cxn.rollback(); + } finally { + cxn.close(); + } + + } + + } finally { + + gasEngine.shutdownNow(); + + } + + } + + /** + * Variant test in which we choose a vertex (<code>foaf:person</code>) in + * the middle of the graph and insist on directed edges. Since the edges + * point from the person to the <code>foaf:person</code> vertex, this BSF + * traversal does not discover any connected vertices. + */ + public void testBFS_undirected() throws Exception { + + final SmallGraphProblem p = setupSmallGraphProblem(); + + final IGASEngine gasEngine = getGraphFixture() + .newGASEngine(1/* nthreads */); + + try { + + final SailConnection cxn = getGraphFixture().getSail() + .getConnection(); + + try { + + final IGraphAccessor graphAccessor = getGraphFixture() + .newGraphAccessor(cxn); + + final IGASContext<BFS.VS, BFS.ES, Void> gasContext = gasEngine + .newGASContext(graphAccessor, new BFS()); + + final IGASState<BFS.VS, BFS.ES, Void> gasState = gasContext + .getGASState(); + + // Initialize the froniter. + gasState.setFrontier(gasContext, p.getFoafPerson()); + + // undirected traversal. + gasContext.setDirectedTraversal(false); + + // Converge. + gasContext.call(); + + // starting vertex at (0,null). + assertEquals(0, gasState.getState(p.getFoafPerson()).depth()); + assertEquals(null, gasState.getState(p.getFoafPerson()) + .predecessor()); + + // All other vertices are 1-hop. + assertEquals(1, gasState.getState(p.getMike()).depth()); + assertEquals(p.getFoafPerson(), gasState.getState(p.getMike()) + .predecessor()); + + assertEquals(1, gasState.getState(p.getBryan()).depth()); + assertEquals(p.getFoafPerson(), gasState.getState(p.getBryan()) + .predecessor()); + + assertEquals(1, gasState.getState(p.getMartyn()).depth()); + assertEquals(p.getFoafPerson(), gasState + .getState(p.getMartyn()).predecessor()); + + } finally { + + try { + cxn.rollback(); + } finally { + cxn.close(); + } + + } + + } finally { + + gasEngine.shutdownNow(); + + } + + } + } 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-03-14 23:21:07 UTC (rev 7971) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-03-14 23:44:38 UTC (rev 7972) @@ -185,6 +185,16 @@ int DEFAULT_NTHREADS = 4; /** + * This option determines whether the traversal of the graph will + * interpret the edges as directed or undirected. + * + * @see IGASContext#setDirectedTraversal(boolean) + */ + URI DIRECTED_TRAVERSAL = new URIImpl(NAMESPACE + "directedTraversal"); + + boolean DEFAULT_DIRECTED_TRAVERSAL = true; + + /** * The maximum #of iterations for the GAS program (optional, default * {@value #DEFAULT_MAX_ITERATIONS}). * @@ -375,6 +385,7 @@ // options extracted from the SERVICE's graph pattern. private final int nthreads; + private final boolean directedTraversal; private final int maxIterations; private final int maxVisited; private final URI linkType, linkAttrType; @@ -408,6 +419,11 @@ store.getValueFactory().createLiteral( Options.DEFAULT_NTHREADS))).intValue(); + this.directedTraversal = ((Literal) getOnlyArg(Options.PROGRAM, + Options.DIRECTED_TRAVERSAL, store.getValueFactory() + .createLiteral(Options.DEFAULT_DIRECTED_TRAVERSAL))) + .booleanValue(); + this.maxIterations = ((Literal) getOnlyArg(Options.PROGRAM, Options.MAX_ITERATIONS, store.getValueFactory() .createLiteral(Options.DEFAULT_MAX_ITERATIONS))) @@ -728,6 +744,8 @@ final IGASContext<VS, ES, ST> gasContext = gasEngine.newGASContext( graphAccessor, gasProgram); + gasContext.setDirectedTraversal(directedTraversal); + gasContext.setMaxIterations(maxIterations); gasContext.setMaxVisited(maxVisited); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-14 23:21:10
|
Revision: 7971 http://sourceforge.net/p/bigdata/code/7971 Author: tobycraig Date: 2014-03-14 23:21:07 +0000 (Fri, 14 Mar 2014) Log Message: ----------- #827 - Support SIDs in explore panel Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js branches/RDR/bigdata-war/src/html/new.html Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 21:58:32 UTC (rev 7970) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 23:21:07 UTC (rev 7971) @@ -588,8 +588,7 @@ } else { var text = binding.value; } - // hack to escape HTML characters - text = $('<div/>').text(text).html(); + text = escapeHTML(text); if(binding.type == 'typed-literal') { var tdData = ' class="literal" data-datatype="' + binding.datatype + '"'; } else { @@ -612,7 +611,6 @@ $('#query-response a').click(function(e) { e.preventDefault(); - // var uri = $(this).text(); explore(this.textContent); }); } @@ -626,56 +624,72 @@ $('#query-response').text('Error! ' + textStatus + ' ' + errorThrown); } -function getSID(binding) { - return '<< <' + binding.value['sid-s'].value + '> <' + binding.value['sid-p'].value + '> <' + binding.value['sid-o'].value + '> >>'; -} - -function parseSID(sid) { - var re = /<< <([^<>]*)> <([^<>]*)> <([^<>]*)> >>/; - var matches = sid.match(re); - return {'s': matches[1], 'p': matches[2], 'o': matches[3]}; -} - /* Explore */ $('#explore-form').submit(function(e) { e.preventDefault(); var uri = $(this).find('input').val(); if(uri) { - loadURI(uri); + loadURI(uri); + $('#explore-header h1').text(uri); } }); -function loadURI(uri) { - // send query to server - var query = 'select * \ - where { \ - bind (<URI> as ?vertex) . \ - { \ - bind (<<?vertex ?p ?o>> as ?sid) . \ - optional \ - { \ - { \ - ?sid ?sidP ?sidO . \ - } union { \ - ?sidS ?sidP ?sid . \ - } \ - } \ - } union { \ - bind (<<?s ?p ?vertex>> as ?sid) . \ - optional \ - { \ - { \ - ?sid ?sidP ?sidO . \ - } union { \ - ?sidS ?sidP ?sid . \ - } \ - } \ - } \ - }'; - - query = query.replace('URI', uri); - console.log('Explore query'); +function loadURI(target) { + // identify if this is a vertex or a SID + var re = /< (?:<[^<>]*> ){3}>/; + var vertex = !target.match(re); + + var vertexQuery = '\ +select ?col1 ?col2 ?incoming (count(?star) as ?star) {\n\ + bind (<URI> as ?explore ) .\n\ + {\n\ + bind (<<?explore ?col1 ?col2>> as ?sid) . \n\ + bind (false as ?incoming) . \n\ + optional {\n\ + { ?sid ?sidP ?star } union { ?star ?sidP ?sid }\n\ + }\n\ + } union {\n\ + bind (<<?col1 ?col2 ?explore>> as ?sid) .\n\ + bind (true as ?incoming) . \n\ + optional {\n\ + { ?sid ?sidP ?star } union { ?star ?sidP ?sid }\n\ + }\n\ + }\n\ +}\n\ +group by ?col1 ?col2 ?incoming'; + + var edgeQuery = '\ +select ?col1 ?col2 ?incoming (count(?star) as ?star)\n\ +with {\n\ + select ?explore where {\n\ + bind (<SID> as ?explore) .\n\ + }\n\ +} as %_explore\n\ +where {\n\ + include %_explore .\n\ + {\n\ + bind (<<?explore ?col1 ?col2>> as ?sid) . \n\ + bind (false as ?incoming) . \n\ + optional {\n\ + { ?sid ?sidP ?star } union { ?star ?sidP ?sid }\n\ + }\n\ + } union {\n\ + bind (<<?col1 ?col2 ?explore>> as ?sid) .\n\ + bind (true as ?incoming) . \n\ + optional {\n\ + { ?sid ?sidP ?star } union { ?star ?sidP ?sid }\n\ + }\n\ + }\n\ +}\n\ +group by ?col1 ?col2 ?incoming'; + + if(vertex) { + var query = vertexQuery.replace('URI', target); + } else { + var query = edgeQuery.replace('SID', target); + } + console.log('Explore query for ' + (vertex ? 'vertex ' : 'edge ') + target); console.log(query); var settings = { type: 'POST', @@ -701,20 +715,72 @@ return; } - var vertex = data.results.bindings[0].vertex; - $('#explore-header h1').text(vertex.value); - var outbound=[], inbound=[], attributes=[]; + // clear tables + $('#explore-incoming table, #explore-outgoing table, #explore-attributes table').html(''); + + // go through each binding, adding it to the appropriate table + $.each(data.results.bindings, function(i, binding) { + var cols = [binding.col1, binding.col2].map(function(col) { + if(col.type == 'sid') { + var output = getSID(col); + } else { + var output = col.value; + } + output = escapeHTML(output); + if(col.type == 'uri' || col.type == 'sid') { + output = '<a href="#">' + output + '</a>'; + } + return output; + }); + var star = parseInt(binding.star.value); + if(star > 0) { + if(binding.incoming.value == 'true') { + var sid = '< <' + binding.col1.value + '> <' + binding.col2.value + '> <' + $('#explore-form input[type=text]').val() + '> >'; + } else { + var sid = '< <' + $('#explore-form input[type=text]').val() + '> <' + binding.col1.value + '> <' + binding.col2.value + '> >'; + } + star = '<a href="#" data-sid="' + sid + '">*</a> (' + star + ')'; + } else { + star = ''; + } + var row = '<tr><td>' + cols[0] + '</td><td>' + cols[1] + '</td><td>' + star + '</td></tr>'; + if(binding.incoming.value == 'true') { + $('#explore-incoming table').append(row); + } else { + // either attribute or outgoing + if(binding.col2.type == 'uri') { + // outgoing + $('#explore-outgoing table').append(row); + } else { + // attribute + $('#explore-attributes table').append(row); + } + } + }); + + $('#explore-results a').click(function(e) { + e.preventDefault(); + explore($(this).data('sid') ? $(this).data('sid') : this.text); + }); + + return; + + var outbound={}, inbound={}, attributes={}; for(var i=0; i<data.results.bindings.length; i++) { var binding = data.results.bindings[i]; - // TODO: are attributes always on outbound relationships? + var star = typeof(binding.sidP) != 'undefined'; if('o' in binding) { + var key = [binding.p.value, binding.o.value]; if(binding.o.type == 'uri') { - outbound.push(binding); + // leave star true if it was before, or set it to current value + outbound[key] = !!outbound[key] || star; } else { - attributes.push(binding); + // do not show star for attributes + attributes[key] = false; } } else { - inbound.push(binding); + var key = [binding.s.value, binding.p.value] + inbound[key] == !!inbound[key] || star; } } @@ -723,9 +789,8 @@ if(outbound.length) { outgoingContainer.append('<h2>Outgoing links</h2>'); var table = $('<table>').appendTo(outgoingContainer); - for(var i=0; i<outbound.length; i++) { - var linkAttributes = outbound[i].sidP.value + ': ' + outbound[i].sidO.value; - table.append('<tr><td>' + outbound[i].p.value + '</td><td><a href="#">' + outbound[i].o.value + '</a></td><td>' + linkAttributes + '</td></tr>'); + for(key in outbound) { + table.append('<tr><td>' + key[0] + '</td><td><a href="#">' + key[1] + '</a></td><td>' + (outbound[key] ? '*' : '') + '</td></tr>'); } } else { outgoingContainer.append('<h2>No outgoing links</h2>'); @@ -736,9 +801,8 @@ if(inbound.length) { incomingContainer.append('<h2>Inbound links</h2>'); var table = $('<table>').appendTo(incomingContainer); - for(var i=0; i<inbound.length; i++) { - var linkAttributes = inbound[i].sidP.value + ': ' + inbound[i].sidO.value; - table.append('<tr><td><a href="#">' + inbound[i].s.value + '</a></td><td>' + inbound[i].p.value + '</td><td>' + linkAttributes + '</td></tr>'); + for(key in inbound) { + table.append('<tr><td>' + key[0] + '</td><td><a href="#">' + key[1] + '</a></td><td>' + (inbound[key] ? '*' : '') + '</td></tr>'); } } else { incomingContainer.append('<h2>No incoming links</h2>'); @@ -790,4 +854,20 @@ }); }); +/* Utility functions */ + +function getSID(binding) { + return '< <' + binding.value['sid-s'].value + '> <' + binding.value['sid-p'].value + '> <' + binding.value['sid-o'].value + '> >'; +} + +function parseSID(sid) { + var re = /<< <([^<>]*)> <([^<>]*)> <([^<>]*)> >>/; + var matches = sid.match(re); + return {'s': matches[1], 'p': matches[2], 'o': matches[3]}; +} + +function escapeHTML(text) { + return $('<div/>').text(text).html(); +} + }); Modified: branches/RDR/bigdata-war/src/html/new.html =================================================================== --- branches/RDR/bigdata-war/src/html/new.html 2014-03-14 21:58:32 UTC (rev 7970) +++ branches/RDR/bigdata-war/src/html/new.html 2014-03-14 23:21:07 UTC (rev 7971) @@ -145,9 +145,18 @@ <div id="explore-results"> <div class="box" id="explore-header"><h1></h1></div> - <div class="box" id="explore-incoming"></div> - <div class="box" id="explore-outgoing"></div> - <div class="box" id="explore-attributes"></div> + <div class="box" id="explore-incoming"> + <h2>Incoming links</h2> + <table></table> + </div> + <div class="box" id="explore-outgoing"> + <h2>Outgoing links</h2> + <table></table> + </div> + <div class="box" id="explore-attributes"> + <h2>Attributes</h2> + <table></table> + </div> </div> <div class="box" id="explore-no-results"></div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-14 21:58:36
|
Revision: 7970 http://sourceforge.net/p/bigdata/code/7970 Author: thompsonbry Date: 2014-03-14 21:58:32 +0000 (Fri, 14 Mar 2014) Log Message: ----------- Removed an unused method. Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java 2014-03-14 21:39:12 UTC (rev 7969) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASProgram.java 2014-03-14 21:58:32 UTC (rev 7970) @@ -53,14 +53,14 @@ */ void before(IGASContext<VS, ES, ST> ctx); - /** - * Return a default reduction that will be applied after the - * {@link IGASProgram} is executed. - * - * @return The default reduction -or- <code>null</code> if no such reduction - * is defined. - */ - <T> IReducer<VS, ES, ST, T> getDefaultAfterOp(); +// /** +// * Return a default reduction that will be applied after the +// * {@link IGASProgram} is executed. +// * +// * @return The default reduction -or- <code>null</code> if no such reduction +// * is defined. +// */ +// <T> IReducer<VS, ES, ST, T> getDefaultAfterOp(); /** * Callback to initialize the state for each vertex in the initial frontier Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-14 21:39:12 UTC (rev 7969) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-14 21:58:32 UTC (rev 7970) @@ -125,18 +125,18 @@ } - /** - * {@inheritDoc} - * <p> - * The default implementation is a NOP. - */ - @Override - public <T> IReducer<VS, ES, ST, T> getDefaultAfterOp() { +// /** +// * {@inheritDoc} +// * <p> +// * The default implementation is a NOP. +// */ +// @Override +// public <T> IReducer<VS, ES, ST, T> getDefaultAfterOp() { +// +// return null; // NOP +// +// } - return null; // NOP - - } - /** * Populate the initial frontier using all vertices in the graph. * 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-03-14 21:39:12 UTC (rev 7969) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/GASService.java 2014-03-14 21:58:32 UTC (rev 7970) @@ -721,10 +721,10 @@ } + final IGraphAccessor graphAccessor = newGraphAccessor(store); + final IGASProgram<VS, ES, ST> gasProgram = newGASProgram(gasClass); - final IGraphAccessor graphAccessor = newGraphAccessor(store); - final IGASContext<VS, ES, ST> gasContext = gasEngine.newGASContext( graphAccessor, gasProgram); @@ -882,28 +882,6 @@ this.binderList = gasProgram.getBinderList(); - // int i = 0; -// -// for (Value v : visitedSet) { -// -// int j = 0; -// if (outVar != null) { -// vals[j++] = new Constant(v); -// } -// if (stateVar != null && gasProgram instanceof BFS) { -// /* -// * FIXME Need an API for self-reporting of an IV by -// * the IGASProgram. -// */ -// final int depth = ((BFS.VS)gasState.getState(v)).depth(); -// final IV depthIV = new XSDNumericIV(depth); -// vals[j++] = new Constant(depthIV); -// } -// -// out[i++] = new ListBindingSet(vars, vals); -// -// } - } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-14 21:39:16
|
Revision: 7969 http://sourceforge.net/p/bigdata/code/7969 Author: thompsonbry Date: 2014-03-14 21:39:12 +0000 (Fri, 14 Mar 2014) Log Message: ----------- Modified build.xml in the main branch and the RDR branch to fix the javadoc build. Removed a character in both branches in the PR.java file that was causing problems with javadoc generation (non-UTF-8). See #810 (Expose GAS Service) Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java branches/BIGDATA_RELEASE_1_3_0/build.xml branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java branches/RDR/build.xml Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-14 21:23:52 UTC (rev 7968) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-14 21:39:12 UTC (rev 7969) @@ -54,7 +54,7 @@ * <dd>sum( neighbor_value / neighbor_num_out_edges ) over the in-edges of the * graph.</dd> * <dt>Apply</dt> - * <dd>value = <i>resetProb</i> + (1.0 \xD0 <i>resetProb</i>) * gatherSum</dd> + * <dd>value = <i>resetProb</i> + (1.0 - <i>resetProb</i>) * gatherSum</dd> * <dt>Scatter</dt> * <dd>if (a) value has significantly changed <code>(fabs(old-new) GT * <i>epsilon</i>)</code>; or (b) iterations LT limit</dd> Modified: branches/BIGDATA_RELEASE_1_3_0/build.xml =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/build.xml 2014-03-14 21:23:52 UTC (rev 7968) +++ branches/BIGDATA_RELEASE_1_3_0/build.xml 2014-03-14 21:39:12 UTC (rev 7969) @@ -385,9 +385,6 @@ overview="${bigdata.dir}/overview.html" windowtitle="bigdata® v${build.ver}" classpathref="build.classpath" - package="true" - protected="true" - public="true" private="false" > <arg value="-J-Xmx1000m" /> @@ -401,6 +398,7 @@ <packageset dir="${bigdata.dir}/bigdata-sails/src/samples" /> <packageset dir="${bigdata.dir}/bigdata-gom/src/java" /> <packageset dir="${bigdata.dir}/bigdata-gom/src/samples" /> + <packageset dir="${bigdata.dir}/bigdata-gas/src/java" /> <packageset dir="${bigdata.dir}/ctc-striterators/src/java" /> <doctitle> <![CDATA[<h1>bigdata® v${build.ver}</h1>]]></doctitle> Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-14 21:23:52 UTC (rev 7968) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-14 21:39:12 UTC (rev 7969) @@ -55,7 +55,7 @@ * <dd>sum( neighbor_value / neighbor_num_out_edges ) over the in-edges of the * graph.</dd> * <dt>Apply</dt> - * <dd>value = <i>resetProb</i> + (1.0 \xD0 <i>resetProb</i>) * gatherSum</dd> + * <dd>value = <i>resetProb</i> + (1.0 - <i>resetProb</i>) * gatherSum</dd> * <dt>Scatter</dt> * <dd>if (a) value has significantly changed <code>(fabs(old-new) GT * <i>epsilon</i>)</code>; or (b) iterations LT limit</dd> Modified: branches/RDR/build.xml =================================================================== --- branches/RDR/build.xml 2014-03-14 21:23:52 UTC (rev 7968) +++ branches/RDR/build.xml 2014-03-14 21:39:12 UTC (rev 7969) @@ -394,9 +394,6 @@ overview="${bigdata.dir}/overview.html" windowtitle="bigdata® v${build.ver}" classpathref="build.classpath" - package="true" - protected="true" - public="true" private="false" > <arg value="-J-Xmx1000m" /> @@ -410,6 +407,7 @@ <packageset dir="${bigdata.dir}/bigdata-sails/src/samples" /> <packageset dir="${bigdata.dir}/bigdata-gom/src/java" /> <packageset dir="${bigdata.dir}/bigdata-gom/src/samples" /> + <packageset dir="${bigdata.dir}/bigdata-gas/src/java" /> <packageset dir="${bigdata.dir}/ctc-striterators/src/java" /> <doctitle> <![CDATA[<h1>bigdata® v${build.ver}</h1>]]></doctitle> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-14 21:23:56
|
Revision: 7968 http://sourceforge.net/p/bigdata/code/7968 Author: thompsonbry Date: 2014-03-14 21:23:52 +0000 (Fri, 14 Mar 2014) Log Message: ----------- Added logic to extract the label for CC and the rank for PageRank. Updated the wiki page to document the outX variables for each of these algorithms. See #810 (Expose GAS as a SERVICE). Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-14 20:59:25 UTC (rev 7967) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/CC.java 2014-03-14 21:23:52 UTC (rev 7968) @@ -16,6 +16,7 @@ package com.bigdata.rdf.graph.analytics; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; @@ -24,6 +25,7 @@ import org.apache.log4j.Logger; import org.openrdf.model.Statement; import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; @@ -305,6 +307,57 @@ } /** + * {@inheritDoc} + * <p> + * <dl> + * <dt>{@value Bindings#LABEL}</dt> + * <dd>The label associated with all of the vertices in the same subgraph. + * The label is a vertex identifier and can be used to jump into the + * subgraph.</dd> + * </dl> + */ + @Override + public List<IBinder<CC.VS, CC.ES, Value>> getBinderList() { + + final List<IBinder<CC.VS, CC.ES, Value>> tmp = super.getBinderList(); + + tmp.add(new IBinder<CC.VS, CC.ES, Value>() { + + @Override + public int getIndex() { + return Bindings.LABEL; + } + + @Override + public Value bind(final ValueFactory vf, + final IGASState<CC.VS, CC.ES, Value> state, final Value u) { + + return state.getState(u).label.get(); + + } + }); + + return tmp; + + } + + /** + * Additional {@link IBinder}s exposed by {@link CC}. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + public interface Bindings extends BaseGASProgram.Bindings { + + /** + * The label associated with all of the vertices in a subgraph. The + * label is a vertex identifier and can be used to jump into the + * subgraph. + */ + int LABEL = 1; + + } + + /** * Returns a map containing the labels assigned to each connected component * (which gives you a vertex in that connected component) and the #of * vertices in each connected component. Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-14 20:59:25 UTC (rev 7967) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/PR.java 2014-03-14 21:23:52 UTC (rev 7968) @@ -16,12 +16,14 @@ package com.bigdata.rdf.graph.analytics; import java.util.Collections; +import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.log4j.Logger; import org.openrdf.model.Statement; import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.Factory; @@ -30,6 +32,8 @@ import com.bigdata.rdf.graph.IGASScheduler; import com.bigdata.rdf.graph.IGASState; import com.bigdata.rdf.graph.IReducer; +import com.bigdata.rdf.graph.IGASProgram.IBinder; +import com.bigdata.rdf.graph.analytics.CC.Bindings; import com.bigdata.rdf.graph.impl.BaseGASProgram; /** @@ -115,8 +119,12 @@ * updated in each iteration to the new estimated value by apply(). */ public double getValue() { + + synchronized (this) { - return value; + return value; + + } } @@ -196,10 +204,15 @@ final PR.VS us = state.getState(u); - us.value = resetProb; + synchronized (us) { - us.outEdges = ctx.getGraphAccessor().getEdgeCount(ctx, u, - EdgesEnum.OutEdges); + us.value = resetProb; + + us.outEdges = ctx.getGraphAccessor().getEdgeCount(ctx, u, + EdgesEnum.OutEdges); + + } + } /** @@ -219,7 +232,11 @@ * that we used to discover [v] is an out-edge of [v]. */ - return (vs.value / vs.outEdges); + synchronized (vs) { + + return (vs.value / vs.outEdges); + + } } @@ -255,7 +272,9 @@ * from the frontier. */ - us.lastChange = 0d; + synchronized (us) { + us.lastChange = 0d; + } return null; @@ -263,10 +282,14 @@ final double newval = resetProb + (1.0 - resetProb) * sum; - us.lastChange = (newval - us.value); + synchronized (us) { - us.value = newval; + us.lastChange = (newval - us.value); + us.value = newval; + + } + return us; } @@ -317,6 +340,53 @@ } /** + * {@inheritDoc} + * <p> + * <dl> + * <dt>{@value Bindings#RANK}</dt> + * <dd>The page rank associated with the vertex..</dd> + * </dl> + */ + @Override + public List<IBinder<PR.VS, PR.ES, Double>> getBinderList() { + + final List<IBinder<PR.VS, PR.ES, Double>> tmp = super.getBinderList(); + + tmp.add(new IBinder<PR.VS, PR.ES, Double>() { + + @Override + public int getIndex() { + return Bindings.RANK; + } + + @Override + public Value bind(final ValueFactory vf, + final IGASState<PR.VS, PR.ES, Double> state, final Value u) { + + return vf.createLiteral(state.getState(u).getValue()); + + } + }); + + return tmp; + + } + + /** + * Additional {@link IBinder}s exposed by {@link PR}. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + public interface Bindings extends BaseGASProgram.Bindings { + + /** + * The computed page rank for the vertex. + */ + int RANK = 1; + + } + + /** * Class reports a map containing the page rank associated with each visited * vertex. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-14 20:59:29
|
Revision: 7967 http://sourceforge.net/p/bigdata/code/7967 Author: thompsonbry Date: 2014-03-14 20:59:25 +0000 (Fri, 14 Mar 2014) Log Message: ----------- Added the ability to extract the predecessor from BFS. We can not do this yet for SSSP because the algorithm is using a gather phase. The predecessor would have to be communicated over the gather phase along with the distance. However, rather than do this, I want to change SSSP to use a push style scatter (1/2 the traversed edges). See #810 (Expose a GAS SERVICE). Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestBFS.java Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-14 16:43:25 UTC (rev 7966) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/BFS.java 2014-03-14 20:59:25 UTC (rev 7967) @@ -21,6 +21,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; +import java.util.concurrent.atomic.AtomicReference; import org.openrdf.model.Statement; import org.openrdf.model.Value; @@ -62,8 +63,14 @@ * scheduled. */ private final AtomicInteger depth = new AtomicInteger(-1); - + /** + * The predecessor is the first source vertex to visit a given target + * vertex. + */ + private final AtomicReference<Value> predecessor = new AtomicReference<Value>(); + + /** * The depth at which this vertex was first visited (origin ZERO) and * <code>-1</code> if the vertex has not been visited. */ @@ -74,6 +81,15 @@ } /** + * Return the first vertex to discover this vertex during BFS traversal. + */ + public Value predecessor() { + + return predecessor.get(); + + } + + /** * Note: This marks the vertex at the current traversal depth. * * @return <code>true</code> if the vertex was visited for the first @@ -81,8 +97,9 @@ * first visited the vertex (this helps to avoid multiple * scheduling of a vertex). */ - public boolean visit(final int depth) { + public boolean visit(final int depth, final Value predecessor) { if (this.depth.compareAndSet(-1/* expect */, depth/* newValue */)) { + this.predecessor.set(predecessor); // Scheduled by this thread. return true; } @@ -163,8 +180,8 @@ public void initVertex(final IGASContext<BFS.VS, BFS.ES, Void> ctx, final IGASState<BFS.VS, BFS.ES, Void> state, final Value u) { - state.getState(u).visit(0); - + state.getState(u).visit(0, null/* predecessor */); + } /** @@ -222,10 +239,10 @@ final IGASScheduler sch, final Value u, final Statement e) { // remote vertex state. - final VS otherState = state.getState(e.getObject()); + final VS otherState = state.getState(e.getObject()/* v */); // visit. - if (otherState.visit(state.round() + 1)) { + if (otherState.visit(state.round() + 1, u/* predecessor */)) { /* * This is the first visit for the remote vertex. Add it to the @@ -249,8 +266,12 @@ * {@inheritDoc} * <p> * <dl> - * <dt>1</dt> - * <dd>The depth at which the vertex was first encountered during traversal.</dd> + * <dt>{@value Bindings#DEPTH}</dt> + * <dd>The depth at which the vertex was first encountered during traversal. + * </dd> + * <dt>{@value Bindings#PREDECESSOR}</dt> + * <dd>The predecessor is the first vertex that discovers a given vertex + * during traversal.</dd> * </dl> */ @Override @@ -262,7 +283,7 @@ @Override public int getIndex() { - return 1; + return Bindings.DEPTH; } @Override @@ -274,11 +295,47 @@ } }); + tmp.add(new IBinder<BFS.VS, BFS.ES, Void>() { + + @Override + public int getIndex() { + return Bindings.PREDECESSOR; + } + + @Override + public Value bind(final ValueFactory vf, + final IGASState<BFS.VS, BFS.ES, Void> state, final Value u) { + + return state.getState(u).predecessor.get(); + + } + }); + return tmp; } /** + * Additional {@link IBinder}s exposed by {@link BFS}. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + public interface Bindings extends BaseGASProgram.Bindings { + + /** + * The depth at which the vertex was visited. + */ + int DEPTH = 1; + + /** + * The BFS predecessor is the first vertex to discover a given vertex. + * + */ + int PREDECESSOR = 2; + + } + + /** * Reduce the active vertex state, returning a histogram reporting the #of * vertices at each distance from the starting vertex. There will always be * one vertex at depth zero - this is the starting vertex. For each Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-14 16:43:25 UTC (rev 7966) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/analytics/SSSP.java 2014-03-14 20:59:25 UTC (rev 7967) @@ -146,6 +146,77 @@ } + /** + * Mark this as a starting vertex (distance:=ZERO, changed:=true). + */ + synchronized private void setStartingVertex() { + + // Set distance to zero for starting vertex. + dist = 0; + + // Must be true to trigger scatter in the 1st round! + changed = true; + + } + + /** + * Update the vertex state to the minimum of the combined sum and its + * current state. + * + * @param u + * The vertex that is the owner of this {@link VS vertex + * state} (used only for debug info). + * @param sum + * The combined sum from the gather phase. + * + * @return <code>this</code> iff the vertex state was modified. + * + * FIXME PREDECESSOR: We can not track the predecessor because + * the SSSP algorithm currently uses a GATHER phase and a + * SCATTER phase rather than doing all the work in a push-style + * SCATTER phase. + */ + synchronized private VS apply(final Value u, final Integer sum) { + + final int minDist = sum; + + changed = false; + if (dist > minDist) { + dist = minDist; + changed = true; + if (log.isDebugEnabled()) + log.debug("u=" + u + ", us=" + this + ", minDist=" + + minDist); + return this; + } + + return null; + + } + + /** + * Update the vertex state to the new (reduced) distance. + * + * @param predecessor + * The vertex that propagated the update to this vertex. + * @param newDist + * The new distance. + * + * @return <code>true</code> iff this vertex state was changed. + */ + synchronized private boolean scatter(final Value predecessor, + final int newDist) { + /* + * Validate that the distance has decreased while holding the lock. + */ + if (newDist < dist) { + dist = newDist; + changed = true; + return true; + } + return false; + } + }// class VS /** @@ -212,15 +283,7 @@ final VS us = state.getState(u); - synchronized (us) { - - // Set distance to zero for starting vertex. - us.dist = 0; - - // Must be true to trigger scatter in the 1st round! - us.changed = true; - - } + us.setStartingVertex(); } @@ -278,18 +341,8 @@ // Get the state for that vertex. final SSSP.VS us = state.getState(u); - final int minDist = sum; - - synchronized(us) { - us.changed = false; - if (us.dist > minDist) { - us.dist = minDist; - us.changed = true; - if (log.isDebugEnabled()) - log.debug("u=" + u + ", us=" + us + ", minDist=" + minDist); - return us; - } - } + return us.apply(u, sum); + } // No change. @@ -351,26 +404,26 @@ final VS otherState = state.getState(other); - // last observed distance for the remote vertex. - final int otherDist = otherState.dist(); - // new distance for the remote vertex. final int newDist = selfState.dist() + EDGE_LENGTH; + // last observed distance for the remote vertex. + final int otherDist = otherState.dist(); + if (newDist < otherDist) { - synchronized (otherState) { - otherState.dist = newDist; - otherState.changed = true; + if (otherState.scatter(u/* predecessor */, newDist)) { + + if (log.isDebugEnabled()) + log.debug("u=" + u + " @ " + selfState.dist() + + ", scheduling: " + other + " with newDist=" + + newDist); + + // Then add the remote vertex to the next frontier. + sch.schedule(e.getObject()); + } - - if (log.isDebugEnabled()) - log.debug("u=" + u + " @ " + selfState.dist() - + ", scheduling: " + other + " with newDist=" + newDist); - // Then add the remote vertex to the next frontier. - sch.schedule(e.getObject()); - } } @@ -400,7 +453,7 @@ @Override public int getIndex() { - return 1; + return Bindings.DISTANCE; } @Override @@ -417,4 +470,18 @@ } + /** + * Additional {@link IBinder}s exposed by {@link SSSP}. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + public interface Bindings extends BaseGASProgram.Bindings { + + /** + * The shortest distance to the vertex. + */ + int DISTANCE = 1; + + } + } Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-14 16:43:25 UTC (rev 7966) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/BaseGASProgram.java 2014-03-14 20:59:25 UTC (rev 7967) @@ -222,48 +222,55 @@ } /** - * Return an {@link IBinder} for the vertex itself + * {@inheritDoc} + * <p> + * <dl> + * <dt>{@value Bindings#VISITED}</dt> + * <dd>The visited vertex itself.</dd> + * </dl> */ - private IBinder<VS, ES, ST> getBinder0() { + @Override + public List<IBinder<VS, ES, ST>> getBinderList() { - return new IBinder<VS, ES, ST>() { + final List<IBinder<VS, ES, ST>> tmp = new LinkedList<IBinder<VS, ES, ST>>(); + tmp.add(new IBinder<VS, ES, ST>() { + @Override public int getIndex() { - - return 0; - + + return Bindings.VISITED; + } @Override public Value bind(final ValueFactory vf, final IGASState<VS, ES, ST> state, final Value u) { - + return u; - + } - }; - + }); + + return tmp; + } /** - * {@inheritDoc} - * <p> - * <dl> - * <dt>0</dt> - * <dd>The visited vertex itself.</dd> - * </dl> + * Interface declares symbolic constants for the {@link IBinder}s reported + * by {@link BaseGASProgram#getBinderList()}. + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> */ - @Override - public List<IBinder<VS, ES, ST>> getBinderList() { + public interface Bindings { + + /** + * The visited vertex identifier. + */ + int VISITED = 0; - final List<IBinder<VS, ES, ST>> tmp = new LinkedList<IBinder<VS, ES, ST>>(); - - tmp.add(getBinder0()); - - return tmp; - } - + } Modified: branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java =================================================================== --- branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java 2014-03-14 16:43:25 UTC (rev 7966) +++ branches/RDR/bigdata-gas/src/test/com/bigdata/rdf/graph/analytics/TestBFS.java 2014-03-14 20:59:25 UTC (rev 7967) @@ -70,12 +70,19 @@ gasContext.call(); assertEquals(0, gasState.getState(p.getMike()).depth()); + assertEquals(null, gasState.getState(p.getMike()).predecessor()); assertEquals(1, gasState.getState(p.getFoafPerson()).depth()); + assertEquals(p.getMike(), gasState.getState(p.getFoafPerson()) + .predecessor()); assertEquals(1, gasState.getState(p.getBryan()).depth()); + assertEquals(p.getMike(), gasState.getState(p.getBryan()) + .predecessor()); assertEquals(2, gasState.getState(p.getMartyn()).depth()); + assertEquals(p.getBryan(), gasState.getState(p.getMartyn()) + .predecessor()); } finally { Modified: branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestBFS.java =================================================================== --- branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestBFS.java 2014-03-14 16:43:25 UTC (rev 7966) +++ branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestBFS.java 2014-03-14 20:59:25 UTC (rev 7967) @@ -71,12 +71,19 @@ gasContext.call(); assertEquals(0, gasState.getState(p.getMike()).depth()); + assertEquals(null, gasState.getState(p.getMike()).predecessor()); assertEquals(1, gasState.getState(p.getFoafPerson()).depth()); + assertEquals(p.getMike(), gasState.getState(p.getFoafPerson()) + .predecessor()); assertEquals(1, gasState.getState(p.getBryan()).depth()); + assertEquals(p.getMike(), gasState.getState(p.getBryan()) + .predecessor()); assertEquals(2, gasState.getState(p.getMartyn()).depth()); + assertEquals(p.getBryan(), gasState.getState(p.getMartyn()) + .predecessor()); } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-14 16:43:27
|
Revision: 7966 http://sourceforge.net/p/bigdata/code/7966 Author: tobycraig Date: 2014-03-14 16:43:25 +0000 (Fri, 14 Mar 2014) Log Message: ----------- #827 - Output explore query & results in JS console Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 16:41:01 UTC (rev 7965) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 16:43:25 UTC (rev 7966) @@ -675,6 +675,8 @@ }'; query = query.replace('URI', uri); + console.log('Explore query'); + console.log(query); var settings = { type: 'POST', data: 'query=' + encodeURI(query), @@ -687,6 +689,8 @@ } function updateExploreStart(data) { + console.log('Explore results'); + console.log(data); var results = data.results.bindings.length > 0; $('#explore-results').toggle(results); $('#explore-no-results').toggle(!results); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-14 16:41:04
|
Revision: 7965 http://sourceforge.net/p/bigdata/code/7965 Author: tobycraig Date: 2014-03-14 16:41:01 +0000 (Fri, 14 Mar 2014) Log Message: ----------- #848 - Print SIDs correctly in query panel Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 15:05:24 UTC (rev 7964) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 16:41:01 UTC (rev 7965) @@ -583,11 +583,17 @@ for(var j=0; j<vars.length; j++) { if(vars[j] in data.results.bindings[i]) { var binding = data.results.bindings[i][vars[j]]; - var text = binding.value; + if(binding.type == 'sid') { + var text = getSID(binding); + } else { + var text = binding.value; + } + // hack to escape HTML characters + text = $('<div/>').text(text).html(); if(binding.type == 'typed-literal') { var tdData = ' class="literal" data-datatype="' + binding.datatype + '"'; } else { - if(binding.type == 'uri') { + if(binding.type == 'uri' || binding.type == 'sid') { text = '<a href="#">' + text + '</a>'; } var tdData = ' class="' + binding.type + '"'; @@ -620,7 +626,16 @@ $('#query-response').text('Error! ' + textStatus + ' ' + errorThrown); } +function getSID(binding) { + return '<< <' + binding.value['sid-s'].value + '> <' + binding.value['sid-p'].value + '> <' + binding.value['sid-o'].value + '> >>'; +} +function parseSID(sid) { + var re = /<< <([^<>]*)> <([^<>]*)> <([^<>]*)> >>/; + var matches = sid.match(re); + return {'s': matches[1], 'p': matches[2], 'o': matches[3]}; +} + /* Explore */ $('#explore-form').submit(function(e) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-14 15:05:28
|
Revision: 7964 http://sourceforge.net/p/bigdata/code/7964 Author: thompsonbry Date: 2014-03-14 15:05:24 +0000 (Fri, 14 Mar 2014) Log Message: ----------- Checkpoint on refactor to support RDR style constraint on the link attribute type to be visited by the GAS algorithm. There is a known problem (http://trac.bigdata.com/ticket/851) where the RDR link attribute statements are not correctly decomposed. This causes visitation algorithms which impose the link attribute type constraint to fail. #851 lays out the issue and the approach for a fix. See #810 (Expose GAS as a SERVICE). Modified Paths: -------------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestSSSP.java Added Paths: ----------- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/EdgeOnlyFilter.java Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java 2014-03-14 00:44:09 UTC (rev 7963) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/IGASContext.java 2014-03-14 15:05:24 UTC (rev 7964) @@ -21,8 +21,6 @@ import org.openrdf.model.URI; import org.openrdf.model.Value; -import cutthecrap.utils.striterators.IStriterator; - /** * Execution context for an {@link IGASProgram}. This is distinct from the * {@link IGASEngine} so we can support distributed evaluation and concurrent @@ -176,23 +174,23 @@ */ <T> IReducer<VS, ES, ST, T> getRunAfterOp(); - /** - * Hook to impose a constraint on the visited edges and/or property values. - * - * @param itr - * The iterator visiting those edges and/or property values. - * - * @return Either the same iterator or a constrained iterator. - * - * TODO Rename as constrainEdgeFilter or even split into a - * constrainGatherFilter and a constraintScatterFilter. - * - * TODO APPLY : If we need access to the vertex property values in - * APPLY (which we probably do, at least optionally), then perhaps - * there should be a similar method to decide whether the property - * values for the vertex are made available during the APPLY. - */ - IStriterator constrainFilter(IStriterator eitr); +// /** +// * Hook to impose a constraint on the visited edges and/or property values. +// * +// * @param itr +// * The iterator visiting those edges and/or property values. +// * +// * @return Either the same iterator or a constrained iterator. +// * +// * TODO Split into a constrainGatherFilter and a +// * constraintScatterFilter? +// * +// * TODO APPLY : If we need access to the vertex property values in +// * APPLY (which we probably do, at least optionally), then perhaps +// * there should be a similar method to decide whether the property +// * values for the vertex are made available during the APPLY. +// */ +// IStriterator getConstrainEdgeFilter(IStriterator eitr); /** * Execute one iteration. Added: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/EdgeOnlyFilter.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/EdgeOnlyFilter.java (rev 0) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/EdgeOnlyFilter.java 2014-03-14 15:05:24 UTC (rev 7964) @@ -0,0 +1,49 @@ +/** + Copyright (C) SYSTAP, LLC 2006-2012. All rights reserved. + + Licensed 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 com.bigdata.rdf.graph.impl; + +import org.openrdf.model.Statement; + +import com.bigdata.rdf.graph.IGASContext; +import com.bigdata.rdf.graph.IGASState; + +import cutthecrap.utils.striterators.Filter; + +/** + * Filter visits only edges (filters out attribute values). + * <p> + * Note: This filter is pushed down onto the AP and evaluated close to the data. + */ +public class EdgeOnlyFilter<VS, ES, ST> extends Filter { + + private static final long serialVersionUID = 1L; + + private final IGASState<VS, ES, ST> gasState; + + public EdgeOnlyFilter(final IGASContext<VS, ES, ST> ctx) { + + this.gasState = ctx.getGASState(); + + } + + @Override + public boolean isValid(final Object e) { + + return gasState.isEdge((Statement) e); + + } + +} Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java 2014-03-14 00:44:09 UTC (rev 7963) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/GASContext.java 2014-03-14 15:05:24 UTC (rev 7964) @@ -40,7 +40,6 @@ import cutthecrap.utils.striterators.Filter; import cutthecrap.utils.striterators.IFilter; -import cutthecrap.utils.striterators.IStriterator; public class GASContext<VS, ES, ST> implements IGASContext<VS, ES, ST> { @@ -857,48 +856,48 @@ } - /** - * {@inheritDoc} - * <p> - * The default implementation only visits the edges. - */ - @Override - public IStriterator constrainFilter(final IStriterator itr) { +// /** +// * {@inheritDoc} +// * <p> +// * The default implementation only visits the edges. +// */ +// @Override +// public IStriterator getConstrainEdgeFilter(final IStriterator itr) { +// +// return itr.addFilter(getEdgeOnlyFilter()); +// +// } - return itr.addFilter(getEdgeOnlyFilter()); - - } - - /** - * Return an {@link IFilter} that will only visit the edges of the graph. - * - * @see IGASState#isEdge(Statement) - */ - protected IFilter getEdgeOnlyFilter() { - - return new EdgeOnlyFilter(this); - - } +// /** +// * Return an {@link IFilter} that will only visit the edges of the graph. +// * +// * @see IGASState#isEdge(Statement) +// */ +// protected IFilter getEdgeOnlyFilter() { +// +// return new EdgeOnlyFilter(this); +// +// } +// +// /** +// * Filter visits only edges (filters out attribute values). +// * <p> +// * Note: This filter is pushed down onto the AP and evaluated close to the +// * data. +// */ +// private class EdgeOnlyFilter extends Filter { +// private static final long serialVersionUID = 1L; +// private final IGASState<VS, ES, ST> gasState; +// private EdgeOnlyFilter(final IGASContext<VS, ES, ST> ctx) { +// this.gasState = ctx.getGASState(); +// } +// @Override +// public boolean isValid(final Object e) { +// return gasState.isEdge((Statement) e); +// } +// }; /** - * Filter visits only edges (filters out attribute values). - * <p> - * Note: This filter is pushed down onto the AP and evaluated close to the - * data. - */ - private class EdgeOnlyFilter extends Filter { - private static final long serialVersionUID = 1L; - private final IGASState<VS, ES, ST> gasState; - private EdgeOnlyFilter(final IGASContext<VS, ES, ST> ctx) { - this.gasState = ctx.getGASState(); - } - @Override - public boolean isValid(final Object e) { - return gasState.isEdge((Statement) e); - } - }; - - /** * Return a filter that only visits the edges of graph that are instances of * the specified link attribute type. * <p> Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java 2014-03-14 00:44:09 UTC (rev 7963) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/ram/RAMGASEngine.java 2014-03-14 15:05:24 UTC (rev 7964) @@ -33,6 +33,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGraphAccessor; +import com.bigdata.rdf.graph.impl.EdgeOnlyFilter; import com.bigdata.rdf.graph.impl.GASEngine; import com.bigdata.rdf.graph.impl.util.VertexDistribution; @@ -349,7 +350,10 @@ /* * Optionally wrap the program specified filter. */ - return ctx.constrainFilter(sitr); +// return ctx.getConstrainEdgeFilter(sitr); + sitr.addFilter(new EdgeOnlyFilter(ctx)); + + return sitr; } Modified: branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java =================================================================== --- branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java 2014-03-14 00:44:09 UTC (rev 7963) +++ branches/RDR/bigdata-gas/src/java/com/bigdata/rdf/graph/impl/sail/SAILGASEngine.java 2014-03-14 15:05:24 UTC (rev 7964) @@ -32,6 +32,7 @@ import com.bigdata.rdf.graph.EdgesEnum; import com.bigdata.rdf.graph.IGASContext; import com.bigdata.rdf.graph.IGraphAccessor; +import com.bigdata.rdf.graph.impl.EdgeOnlyFilter; import com.bigdata.rdf.graph.impl.GASEngine; import com.bigdata.rdf.graph.impl.util.VertexDistribution; @@ -238,8 +239,11 @@ * striterators is just as efficient.) */ - return ctx.constrainFilter(sitr); +// return ctx.getConstrainEdgeFilter(sitr); + sitr.addFilter(new EdgeOnlyFilter(ctx)); + return sitr; + } @Override Modified: branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java =================================================================== --- branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java 2014-03-14 00:44:09 UTC (rev 7963) +++ branches/RDR/bigdata-rdf/src/java/com/bigdata/rdf/graph/impl/bd/BigdataGASEngine.java 2014-03-14 15:05:24 UTC (rev 7964) @@ -31,6 +31,7 @@ import com.bigdata.rdf.graph.IGASState; import com.bigdata.rdf.graph.IGraphAccessor; import com.bigdata.rdf.graph.IStaticFrontier; +import com.bigdata.rdf.graph.impl.EdgeOnlyFilter; import com.bigdata.rdf.graph.impl.GASEngine; import com.bigdata.rdf.graph.impl.util.VertexDistribution; import com.bigdata.rdf.internal.IV; @@ -385,7 +386,8 @@ * test to verify expected benefit. Watch out for the in-edges * vs out-edges since only one is optimized. */ - posOptimization = linkTypeIV != null && inEdges; + posOptimization = linkTypeIV != null && linkAttrTypeIV == null + && inEdges; if (posOptimization) { @@ -401,62 +403,20 @@ keyBuilder.reset(); -// if (linkAttrTypeIV != null) { -// -// /* -// * RDR optimization for POS(C) index: -// * -// * P:= linkAttributeType -// * -// * O:= unbound (the SID is in SPO(C) order, but we do -// * not have S. P would be the linkType, but without S we -// * can not form a prefix). -// * -// * S:= unbound -// * -// * C:= unbound -// * -// * Note: We can only optimize this when both the -// * linkType and linkAttributeType are specified. -// */ -// -// // P -// IVUtility.encode(keyBuilder, linkAttrTypeIV); -// -// // O is a SID prefix. -// { -// -// // RDR prefix byte. -// keyBuilder.append(SidIV.toFlags()); -// -// // SID.P:=linkType -// IVUtility.encode(keyBuilder, linkTypeIV); -// -// // SID.O:=u -// IVUtility.encode(keyBuilder, u); -// -// } -// -// // The rest of the key is unbound. -// -// } else { + // Bind P as a constant. + IVUtility.encode(keyBuilder, linkTypeIV); - // Bind P as a constant. - IVUtility.encode(keyBuilder, linkTypeIV); + // Bind O for this key-range scan. + IVUtility.encode(keyBuilder, u); - // Bind O for this key-range scan. - IVUtility.encode(keyBuilder, u); - -// } - } else { /* * SPO(C) or OSP(C) * - * FIXME RDR: For RDR link attribute access, the keys are - * formed differently. Lower case letters are used for - * variables. Upper case letters for constants. + * Note: For RDR link attribute access, the keys are formed + * differently. Lower case letters are used for variables. + * Upper case letters for constants. * * For SPO(C): S:=SID(Spo(c)), P:=linkAttributeType (must * filter), O:=linkAttributeValue (read it off the index @@ -466,9 +426,9 @@ * filter), S:=linkAttributeValue (read it off the index * when the filter is satisfied). * - * FIXME RDR should also be supported in the SAIL and RAM - * GAS engine implementations. The statements about - * statements would be modeled as reified statement models. + * TODO RDR should also be supported in the SAIL and RAM GAS + * engine implementations. The statements about statements + * would be modeled as reified statement models. */ keyOrder = getKeyOrder(kb, inEdges); @@ -478,7 +438,18 @@ keyBuilder = ndx.getIndexMetadata().getKeyBuilder(); keyBuilder.reset(); + + if (linkAttrTypeIV != null) { + + /* + * Restrict to the SID region of the index. See + * SidIV.encode(). + */ + keyBuilder.appendSigned(SidIV.toFlags()); + + } + // Append [u] to the key. IVUtility.encode(keyBuilder, u); } @@ -557,32 +528,100 @@ if (linkTypeIV != null && !posOptimization) { /* - * A link type constraint was specified, but we were not able to - * use the POS(C) index optimization. In this case we have to - * add a filter to impose that link type constraint. + * A link type constraint was specified, but we were not + * able to use the POS(C) index optimization. In this case + * we have to add a filter to impose that link type + * constraint. */ + if (linkAttrTypeIV == null) { + /* + * The linkTypeIV is the Predicate. + */ + sitr.addFilter(new Filter() { + private static final long serialVersionUID = 1L; + + @Override + public boolean isValid(final Object e) { + return ((ISPO) e).p().equals(linkTypeIV); + } + }); + } else { + /* + * The linkTypeIV is part of the SIDIV of the Subject. + */ + sitr.addFilter(new Filter() { + private static final long serialVersionUID = 1L; + @Override + public boolean isValid(final Object e) { + final SidIV<?> subj = (SidIV<?>) ((ISPO) e).s(); + final ISPO linkAttr = subj.getInlineValue(); + final IV<?, ?> p = linkAttr.p(); + final boolean matched = p.equals(linkTypeIV); + return matched; + } + }); + } + } + + if (linkAttrTypeIV != null) { + /* + * A link attribute type constraint was specified. + */ sitr.addFilter(new Filter() { private static final long serialVersionUID = 1L; @Override public boolean isValid(final Object e) { - return ((ISPO) e).p().equals(linkTypeIV); + final IV<?,?> p = ((ISPO) e).p(); + final boolean matched = p.equals(linkAttrTypeIV); + return matched; } }); } - /* - * Optionally wrap the specified filter. This filter will be - * pushed down onto the index. If the index is remote, then this - * is much more efficient. (If the index is local, then simply - * stacking striterators is just as efficient.) - */ + if (linkTypeIV == null && linkAttrTypeIV == null) { - return ctx.constrainFilter(sitr); + /* + * Wrap the iterator with a filter that will exclude any + * non-link Statements. + * + * Note: This is handled automatically by the fromkey, toKey + * constraint if the linkTypeIV is specified. + * + * TODO This is NOT handled automatically by the fromKey, + * toKey constraint if the linkAttrTypeIV is specified. In + * fact, it might not be handled. + */ + + sitr.addFilter(new EdgeOnlyFilter(ctx)); + } + + return sitr; + +// /* +// * Optionally wrap the specified filter. This filter will be +// * pushed down onto the index. If the index is remote, then this +// * is much more efficient. (If the index is local, then simply +// * stacking striterators is just as efficient.) +// */ +// +// return ctx.getConstrainEdgeFilter(sitr); + } } // class AP +// /** +// * Return an {@link IFilter} that will only visit the edges of the graph. +// * +// * @see IGASState#isEdge(Statement) +// */ +// protected IFilter getEdgeOnlyFilter() { +// +// return new EdgeOnlyFilter(this); +// +// } + @SuppressWarnings({ "rawtypes" }) private IStriterator getEdges(final AbstractTripleStore kb, final boolean inEdges, final IGASContext<?, ?, ?> ctx, @@ -601,7 +640,7 @@ } - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings("unchecked") @Override public Iterator<Statement> getEdges(final IGASContext<?, ?, ?> ctx, final Value u, final EdgesEnum edges) { Modified: branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestSSSP.java =================================================================== --- branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestSSSP.java 2014-03-14 00:44:09 UTC (rev 7963) +++ branches/RDR/bigdata-rdf/src/test/com/bigdata/rdf/graph/impl/bd/TestSSSP.java 2014-03-14 15:05:24 UTC (rev 7964) @@ -175,6 +175,7 @@ // Converge. gasContext.call(); + // Check weighted distance. assertEquals(0, gasState.getState(p.getV1()).dist()); assertEquals(100, gasState.getState(p.getV2()).dist()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-14 00:44:12
|
Revision: 7963 http://sourceforge.net/p/bigdata/code/7963 Author: tobycraig Date: 2014-03-14 00:44:09 +0000 (Fri, 14 Mar 2014) Log Message: ----------- #827 - Fixed explore error not appearing Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-13 23:15:40 UTC (rev 7962) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-14 00:44:09 UTC (rev 7963) @@ -750,7 +750,9 @@ } function updateExploreError(jqXHR, textStatus, errorThrown) { - $('#explore-results').html('Error! ' + textStatus + ' ' + errorThrown); + $('#explore-results').hide(); + $('#explore-no-results').show(); + $('#explore-no-results').html('Error! ' + textStatus + ' ' + errorThrown); } /* Status */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-03-13 23:15:43
|
Revision: 7962 http://sourceforge.net/p/bigdata/code/7962 Author: thompsonbry Date: 2014-03-13 23:15:40 +0000 (Thu, 13 Mar 2014) Log Message: ----------- bumping the RDR branch to java 7 to see if it builds and gets through CI. It builds locally and I am unable to replicate the CI failures locally. See #724. Modified Paths: -------------- branches/RDR/build.properties Modified: branches/RDR/build.properties =================================================================== --- branches/RDR/build.properties 2014-03-13 20:30:32 UTC (rev 7961) +++ branches/RDR/build.properties 2014-03-13 23:15:40 UTC (rev 7962) @@ -24,8 +24,8 @@ # debuglevel=lines,vars,source (or any combination thereof). javac.debuglevel=lines,vars,source javac.verbose=off -javac.source=1.6 -javac.target=1.6 +javac.source=1.7 +javac.target=1.7 javac.encoding=Cp1252 # javacc is required to compile the SPARQL grammar. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-13 20:30:36
|
Revision: 7961 http://sourceforge.net/p/bigdata/code/7961 Author: tobycraig Date: 2014-03-13 20:30:32 +0000 (Thu, 13 Mar 2014) Log Message: ----------- #857 - Wider header input field Modified Paths: -------------- branches/RDR/bigdata-war/src/html/css/style.css Modified: branches/RDR/bigdata-war/src/html/css/style.css =================================================================== --- branches/RDR/bigdata-war/src/html/css/style.css 2014-03-13 20:28:36 UTC (rev 7960) +++ branches/RDR/bigdata-war/src/html/css/style.css 2014-03-13 20:30:32 UTC (rev 7961) @@ -171,6 +171,10 @@ text-align: right; } +#explore-form input[type=text] { + width: 50%; +} + #advanced-features, #query-explanation, #explore-results, #namespace-properties { display: none; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-13 20:28:42
|
Revision: 7960 http://sourceforge.net/p/bigdata/code/7960 Author: tobycraig Date: 2014-03-13 20:28:36 +0000 (Thu, 13 Mar 2014) Log Message: ----------- #857 - Display exploration target in header box Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-13 20:15:00 UTC (rev 7959) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-13 20:28:36 UTC (rev 7960) @@ -606,9 +606,8 @@ $('#query-response a').click(function(e) { e.preventDefault(); - var uri = $(this).text(); - loadURI(uri); - showTab('explore'); + // var uri = $(this).text(); + explore(this.textContent); }); } } @@ -738,9 +737,18 @@ attributesContainer.append('<h2>No attributes</h2>'); } - $('#explore-results a').click(function(e) { e.preventDefault(); loadURI(this.text); }); + $('#explore-results a').click(function(e) { + e.preventDefault(); + explore(this.text); + }); } +function explore(uri) { + $('#explore-form input[type=text]').val(uri); + $('#explore-form').submit(); + showTab('explore'); +} + function updateExploreError(jqXHR, textStatus, errorThrown) { $('#explore-results').html('Error! ' + textStatus + ' ' + errorThrown); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-13 20:15:03
|
Revision: 7959 http://sourceforge.net/p/bigdata/code/7959 Author: tobycraig Date: 2014-03-13 20:15:00 +0000 (Thu, 13 Mar 2014) Log Message: ----------- #856 - Update current namespace in list when one is selected Modified Paths: -------------- branches/RDR/bigdata-war/src/html/js/workbench.js Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-13 20:11:25 UTC (rev 7958) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-13 20:15:00 UTC (rev 7959) @@ -97,6 +97,7 @@ $('#current-namespace').html(name); NAMESPACE = name; NAMESPACE_URL = url; + getNamespaces(); } function deleteNamespace(namespace) { @@ -160,7 +161,6 @@ DEFAULT_NAMESPACE = defaultDataset.find('title')[0].textContent; var url = defaultDataset.find('sparqlEndpoint')[0].attributes['rdf:resource'].textContent; useNamespace(DEFAULT_NAMESPACE, url); - getNamespaces(); }); } var DEFAULT_NAMESPACE, NAMESPACE, NAMESPACE_URL, fileContents; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tob...@us...> - 2014-03-13 20:11:30
|
Revision: 7958 http://sourceforge.net/p/bigdata/code/7958 Author: tobycraig Date: 2014-03-13 20:11:25 +0000 (Thu, 13 Mar 2014) Log Message: ----------- #827 - Split results up into separate sections Modified Paths: -------------- branches/RDR/bigdata-war/src/html/css/style.css branches/RDR/bigdata-war/src/html/js/workbench.js branches/RDR/bigdata-war/src/html/new.html Modified: branches/RDR/bigdata-war/src/html/css/style.css =================================================================== --- branches/RDR/bigdata-war/src/html/css/style.css 2014-03-13 16:57:19 UTC (rev 7957) +++ branches/RDR/bigdata-war/src/html/css/style.css 2014-03-13 20:11:25 UTC (rev 7958) @@ -59,6 +59,11 @@ margin-bottom: 10px; } +h2 { + font-size: 110%; + margin-bottom: 10px; +} + #container { /*max-width: 600px;*/ } @@ -106,11 +111,9 @@ } .box { - border: 1px solid; padding: 10px; border: 1px solid; border-bottom: none; - min-height: 100px; overflow-x: scroll; } @@ -168,7 +171,7 @@ text-align: right; } -#advanced-features, #query-explanation { +#advanced-features, #query-explanation, #explore-results, #namespace-properties { display: none; } @@ -180,7 +183,3 @@ pre { font-family: monospace; } - -#namespace-properties { - display: none; -} Modified: branches/RDR/bigdata-war/src/html/js/workbench.js =================================================================== --- branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-13 16:57:19 UTC (rev 7957) +++ branches/RDR/bigdata-war/src/html/js/workbench.js 2014-03-13 20:11:25 UTC (rev 7958) @@ -673,16 +673,18 @@ } function updateExploreStart(data) { - var disp = $('#explore-results'); - disp.html(''); + var results = data.results.bindings.length > 0; + $('#explore-results').toggle(results); + $('#explore-no-results').toggle(!results); + // see if we got any results - if(data.results.bindings.length == 0) { - disp.append('No vertex found!'); + if(!results) { + $('#explore-no-results').html('<h1>No results found!</h1>'); return; } var vertex = data.results.bindings[0].vertex; - disp.append('<h3>' + vertex.value + '</h3>'); + $('#explore-header h1').text(vertex.value); var outbound=[], inbound=[], attributes=[]; for(var i=0; i<data.results.bindings.length; i++) { var binding = data.results.bindings[i]; @@ -698,33 +700,45 @@ } } + var outgoingContainer = $('#explore-outgoing'); + outgoingContainer.html(''); if(outbound.length) { - disp.append('<h4>Outbound links</h4>'); - var table = $('<table>').appendTo(disp); + outgoingContainer.append('<h2>Outgoing links</h2>'); + var table = $('<table>').appendTo(outgoingContainer); for(var i=0; i<outbound.length; i++) { var linkAttributes = outbound[i].sidP.value + ': ' + outbound[i].sidO.value; table.append('<tr><td>' + outbound[i].p.value + '</td><td><a href="#">' + outbound[i].o.value + '</a></td><td>' + linkAttributes + '</td></tr>'); } + } else { + outgoingContainer.append('<h2>No outgoing links</h2>'); } + var incomingContainer = $('#explore-incoming'); + incomingContainer.html(''); if(inbound.length) { - disp.append('<h4>Inbound links</h4>'); - var table = $('<table>').appendTo(disp); + incomingContainer.append('<h2>Inbound links</h2>'); + var table = $('<table>').appendTo(incomingContainer); for(var i=0; i<inbound.length; i++) { var linkAttributes = inbound[i].sidP.value + ': ' + inbound[i].sidO.value; table.append('<tr><td><a href="#">' + inbound[i].s.value + '</a></td><td>' + inbound[i].p.value + '</td><td>' + linkAttributes + '</td></tr>'); } + } else { + incomingContainer.append('<h2>No incoming links</h2>'); } + var attributesContainer = $('#explore-attributes'); + attributesContainer.html(''); if(attributes.length) { - disp.append('<h4>Attributes</h4>'); - var table = $('<table>').appendTo(disp); + attributesContainer.append('<h4>Attributes</h4>'); + var table = $('<table>').appendTo(attributesContainer); for(var i=0; i<attributes.length; i++) { table.append('<tr><td>' + attributes[i].p.value + '</td><td>' + attributes[i].o.value + '</td></tr>'); } + } else { + attributesContainer.append('<h2>No attributes</h2>'); } - disp.find('a').click(function(e) { e.preventDefault(); loadURI(this.text); }); + $('#explore-results a').click(function(e) { e.preventDefault(); loadURI(this.text); }); } function updateExploreError(jqXHR, textStatus, errorThrown) { Modified: branches/RDR/bigdata-war/src/html/new.html =================================================================== --- branches/RDR/bigdata-war/src/html/new.html 2014-03-13 16:57:19 UTC (rev 7957) +++ branches/RDR/bigdata-war/src/html/new.html 2014-03-13 20:11:25 UTC (rev 7958) @@ -143,8 +143,15 @@ <p>Enter a URI to begin navigation <form id="explore-form"><input type="text"> <input type="submit"></form></p> </div> - <div class="box" id="explore-results"> + <div id="explore-results"> + <div class="box" id="explore-header"><h1></h1></div> + <div class="box" id="explore-incoming"></div> + <div class="box" id="explore-outgoing"></div> + <div class="box" id="explore-attributes"></div> </div> + + <div class="box" id="explore-no-results"></div> + </div> <div class="tab" id="status-tab"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |