From: <tho...@us...> - 2013-12-30 15:36:09
|
Revision: 7700 http://bigdata.svn.sourceforge.net/bigdata/?rev=7700&view=rev Author: thompsonbry Date: 2013-12-30 15:36:02 +0000 (Mon, 30 Dec 2013) Log Message: ----------- Added parallel expansion of the join paths. Each join path is expanded in a separate thread. However, if there are multiple possible expansions for a given join path, then those expansions are processed in sequence. Note: This change required the introduction of a thread-safe collection for the edgeSamples map within the scope of the expand() method. @see #64 (RTO) Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2013-12-30 15:05:21 UTC (rev 7699) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2013-12-30 15:36:02 UTC (rev 7700) @@ -1004,7 +1004,7 @@ */ public Path[] expand(final QueryEngine queryEngine, int limitIn, final int round, final Path[] a, - final Map<PathIds, EdgeSample> edgeSamples) throws Exception { + Map<PathIds, EdgeSample> edgeSamples) throws Exception { if (queryEngine == null) throw new IllegalArgumentException(); @@ -1016,7 +1016,14 @@ throw new IllegalArgumentException(); if (a.length == 0) throw new IllegalArgumentException(); - + + /* + * Ensure that we use a synchronized view of this collection since we + * will write on it from parallel threads when we expand the join paths + * in parallel. + */ + edgeSamples = Collections.synchronizedMap(edgeSamples); + // // increment the limit by itself in each round. // final int limit = (round + 1) * limitIn; @@ -1031,164 +1038,214 @@ if (log.isDebugEnabled()) log.debug("Expanding paths: #paths(in)=" + a.length); - final List<Path> tmp = new LinkedList<Path>(); + // The new set of paths to be explored. + final List<Path> tmpAll = new LinkedList<Path>(); + // Setup tasks to expand the current join paths. + final List<Callable<List<Path>>> tasks = new LinkedList<Callable<List<Path>>>(); for (Path x : a) { - /* - * We already increased the sample limit for the path in the loop - * above. - */ - final int limit = x.edgeSample.limit; + tasks.add(new ExpandPathTask(queryEngine, x, edgeSamples)); - /* - * The set of vertices used to expand this path in this round. - */ - final Set<Vertex> used = new LinkedHashSet<Vertex>(); + } - { + // Expand paths in parallel. + final List<Future<List<Path>>> futures = queryEngine.getIndexManager().getExecutorService() + .invokeAll(tasks); + + // Check future, collecting new paths from each task. + for(Future<List<Path>> f : futures) { - /* - * Any vertex which (a) does not appear in the path to be - * extended; (b) has not already been used to extend the path; - * and (c) does not share any variables indirectly via - * constraints is added to this collection. - * - * If we are not able to extend the path at least once using a - * constrained join then we will use this collection as the - * source of unconnected edges which need to be used to extend - * the path. - */ - final Set<Vertex> nothingShared = new LinkedHashSet<Vertex>(); - - // Consider all vertices. - for (Vertex tVertex : V) { + tmpAll.addAll(f.get()); + + } - // Figure out which vertices are already part of this path. - final boolean vFound = x.contains(tVertex); + /* + * Now examine the set of generated and sampled join paths. If any paths + * span the same vertices then they are alternatives and we can pick the + * best alternative now and prune the other alternatives for those + * vertices. + */ + final Path[] paths_tp1 = tmpAll.toArray(new Path[tmpAll.size()]); - if (vFound) { - // Vertex is already part of this path. - if (log.isTraceEnabled()) - log.trace("Vertex: " + tVertex - + " - already part of this path."); - continue; - } + final Path[] paths_tp1_pruned = pruneJoinPaths(paths_tp1, edgeSamples); - if (used.contains(tVertex)) { - // Vertex already used to extend this path. - if (log.isTraceEnabled()) - log - .trace("Vertex: " - + tVertex - + " - already used to extend this path."); - continue; - } + if (log.isDebugEnabled()) // shows which paths were pruned. + log.info("\n*** round=" + round + ": paths{in=" + a.length + + ",considered=" + paths_tp1.length + ",out=" + + paths_tp1_pruned.length + "}\n" + + JGraph.showTable(paths_tp1, paths_tp1_pruned)); - // FIXME RTO: Replace with StaticAnalysis. - if (!PartitionedJoinGroup.canJoinUsingConstraints(// - x.getPredicates(),// path - tVertex.pred,// vertex - C// constraints - )) { - /* - * Vertex does not share variables either directly - * or indirectly. - */ - if (log.isTraceEnabled()) - log - .trace("Vertex: " - + tVertex - + " - unconstrained join for this path."); - nothingShared.add(tVertex); - continue; - } + if (log.isInfoEnabled()) // only shows the surviving paths. + log.info("\n*** round=" + round + + ": paths{in=" + a.length + ",considered=" + + paths_tp1.length + ",out=" + paths_tp1_pruned.length + + "}\n" + JGraph.showTable(paths_tp1_pruned)); - // add the new vertex to the set of used vertices. - used.add(tVertex); + return paths_tp1_pruned; - // Extend the path to the new vertex. - final Path p = x - .addEdge(queryEngine, limit, tVertex, /* dynamicEdge, */ - C, x.getVertexCount() + 1 == V.length/* pathIsComplete */); + } - // Add to the set of paths for this round. - tmp.add(p); + /** + * Task expands a path by one edge into one or more new paths. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + private class ExpandPathTask implements Callable<List<Path>> { - // Record the sample for the new path. - if (edgeSamples.put(new PathIds(p.getVertexIds()), - p.edgeSample) != null) - throw new AssertionError(); + private final QueryEngine queryEngine; + private final Path x; + /** + * Note: The collection provided by the caller MUST be thread-safe since + * this task will be run by parallel threads over the different join + * paths from the last round. There will not be any conflict over writes + * on this map since each {@link PathIds} instance resulting from the + * expansion will be unique, but we still need to use a thread-safe + * collection since there will be concurrent modifications to this map. + */ + private final Map<PathIds, EdgeSample> edgeSamples; - if (log.isTraceEnabled()) - log.trace("Extended path with dynamic edge: vnew=" - + tVertex.pred.getId() + ", new path=" + p); + public ExpandPathTask(final QueryEngine queryEngine, final Path x, + final Map<PathIds, EdgeSample> edgeSamples) { + this.queryEngine = queryEngine; + this.x = x; + this.edgeSamples = edgeSamples; + } + + @Override + public List<Path> call() throws Exception { + /* + * We already increased the sample limit for the path in the loop + * above. + */ + final int limit = x.edgeSample.limit; - } // next vertex. + /* + * The set of vertices used to expand this path in this round. + */ + final Set<Vertex> used = new LinkedHashSet<Vertex>(); - if (tmp.isEmpty()) { + /* + * Any vertex which (a) does not appear in the path to be + * extended; (b) has not already been used to extend the path; + * and (c) does not share any variables indirectly via + * constraints is added to this collection. + * + * If we are not able to extend the path at least once using a + * constrained join then we will use this collection as the + * source of unconnected edges which need to be used to extend + * the path. + */ + final Set<Vertex> nothingShared = new LinkedHashSet<Vertex>(); + + // The new set of paths to be explored as extensions to this path. + final List<Path> tmp = new LinkedList<Path>(); + + // Consider all vertices. + for (Vertex tVertex : V) { - /* - * No constrained joins were identified so we must consider - * edges which represent fully unconstrained joins. - */ + // Figure out which vertices are already part of this path. + final boolean vFound = x.contains(tVertex); - assert !nothingShared.isEmpty(); + if (vFound) { + // Vertex is already part of this path. + if (log.isTraceEnabled()) + log.trace("Vertex: " + tVertex + + " - already part of this path."); + continue; + } + if (used.contains(tVertex)) { + // Vertex already used to extend this path. + if (log.isTraceEnabled()) + log + .trace("Vertex: " + + tVertex + + " - already used to extend this path."); + continue; + } + + // FIXME RTO: Replace with StaticAnalysis. + if (!PartitionedJoinGroup.canJoinUsingConstraints(// + x.getPredicates(),// path + tVertex.pred,// vertex + C// constraints + )) { /* - * Choose any vertex from the set of those which do - * not share any variables with the join path. Since - * all of these are fully unconstrained joins we do - * not want to expand the join path along multiple - * edges in this iterator, just along a single - * unconstrained edge. + * Vertex does not share variables either directly + * or indirectly. */ - final Vertex tVertex = nothingShared.iterator().next(); - - // Extend the path to the new vertex. - final Path p = x - .addEdge(queryEngine, limit, tVertex,/* dynamicEdge */ - C, x.getVertexCount() + 1 == V.length/* pathIsComplete */); + if (log.isTraceEnabled()) + log + .trace("Vertex: " + + tVertex + + " - unconstrained join for this path."); + nothingShared.add(tVertex); + continue; + } - // Add to the set of paths for this round. - tmp.add(p); + // add the new vertex to the set of used vertices. + used.add(tVertex); - if (log.isTraceEnabled()) - log.trace("Extended path with dynamic edge: vnew=" - + tVertex.pred.getId() + ", new path=" + p); + // Extend the path to the new vertex. + final Path p = x + .addEdge(queryEngine, limit, tVertex, /* dynamicEdge, */ + C, x.getVertexCount() + 1 == V.length/* pathIsComplete */); - } + // Add to the set of paths for this round. + tmp.add(p); - } + // Record the sample for the new path. + if (edgeSamples.put(new PathIds(p.getVertexIds()), + p.edgeSample) != null) + throw new AssertionError(); - } // next path + if (log.isTraceEnabled()) + log.trace("Extended path with dynamic edge: vnew=" + + tVertex.pred.getId() + ", new path=" + p); - /* - * Now examine the set of generated and sampled join paths. If any paths - * span the same vertices then they are alternatives and we can pick the - * best alternative now and prune the other alternatives for those - * vertices. - */ - final Path[] paths_tp1 = tmp.toArray(new Path[tmp.size()]); + } // next target vertex. - final Path[] paths_tp1_pruned = pruneJoinPaths(paths_tp1, edgeSamples); + if (tmp.isEmpty()) { - if (log.isDebugEnabled()) // shows which paths were pruned. - log.info("\n*** round=" + round + ": paths{in=" + a.length - + ",considered=" + paths_tp1.length + ",out=" - + paths_tp1_pruned.length + "}\n" - + JGraph.showTable(paths_tp1, paths_tp1_pruned)); + /* + * No constrained joins were identified as extensions of this + * join path, so we must consider edges which represent fully + * unconstrained joins. + */ - if (log.isInfoEnabled()) // only shows the surviving paths. - log.info("\n*** round=" + round - + ": paths{in=" + a.length + ",considered=" - + paths_tp1.length + ",out=" + paths_tp1_pruned.length - + "}\n" + JGraph.showTable(paths_tp1_pruned)); + assert !nothingShared.isEmpty(); - return paths_tp1_pruned; + /* + * Choose any vertex from the set of those which do + * not share any variables with the join path. Since + * all of these are fully unconstrained joins we do + * not want to expand the join path along multiple + * edges in this iterator, just along a single + * unconstrained edge. + */ + final Vertex tVertex = nothingShared.iterator().next(); + + // Extend the path to the new vertex. + final Path p = x + .addEdge(queryEngine, limit, tVertex,/* dynamicEdge */ + C, x.getVertexCount() + 1 == V.length/* pathIsComplete */); + // Add to the set of paths for this round. + tmp.add(p); + + if (log.isTraceEnabled()) + log.trace("Extended path with dynamic edge: vnew=" + + tVertex.pred.getId() + ", new path=" + p); + + } // if(tmp.isEmpty()) + + return tmp; + + } + } - + /** * Return the {@link Vertex} whose {@link IPredicate} is associated with * the given {@link BOp.Annotations#BOP_ID}. Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java 2013-12-30 15:05:21 UTC (rev 7699) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java 2013-12-30 15:36:02 UTC (rev 7700) @@ -83,6 +83,7 @@ * vertices may be expressed and also recognizes that the vertex hash codes * are based on the bop ids, which are often small integers. */ + @Override public int hashCode() { int h = hash; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-01-05 19:23:14
|
Revision: 7729 http://bigdata.svn.sourceforge.net/bigdata/?rev=7729&view=rev Author: thompsonbry Date: 2014-01-05 19:23:06 +0000 (Sun, 05 Jan 2014) Log Message: ----------- Increased parallelism in the RTO. The cutoff joins for the initial edges in round zero are now executed in parallel. See #64. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Path.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2014-01-05 17:35:43 UTC (rev 7728) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2014-01-05 19:23:06 UTC (rev 7729) @@ -720,30 +720,30 @@ } - /** - * Resample the initial vertices for the specified join paths and then - * resample the cutoff join for each given join path in path order. - * - * @param queryEngine - * The query engine. - * @param limitIn - * The original limit. - * @param round - * The round number in [1:n]. - * @param a - * The set of paths from the previous round. For the first round, - * this is formed from the initial set of edges to consider. - * @param edgeSamples - * A map used to associate join path segments (expressed as an - * ordered array of bopIds) with {@link EdgeSample}s to avoid - * redundant effort. - * - * @return The number of join paths which are experiencing cardinality - * estimate underflow. - * - * @throws Exception - */ - public int resamplePaths(final QueryEngine queryEngine, int limitIn, + /** + * Resample the initial vertices for the specified join paths and then + * resample the cutoff join for each given join path in path order. + * + * @param queryEngine + * The query engine. + * @param limitIn + * The original limit. + * @param round + * The round number in [1:n]. + * @param a + * The set of paths from the previous round. For the first round, + * this is formed from the initial set of edges to consider. + * @param edgeSamples + * A map used to associate join path segments (expressed as an + * ordered array of bopIds) with {@link EdgeSample}s to avoid + * redundant effort. + * + * @return The number of join paths which are experiencing cardinality + * estimate underflow. + * + * @throws Exception + */ + protected int resamplePaths(final QueryEngine queryEngine, int limitIn, final int round, final Path[] a, final Map<PathIds, EdgeSample> edgeSamples) throws Exception { @@ -799,43 +799,90 @@ } - // re-sample vertices. + // re-sample vertices (this is done in parallel). sampleVertices(queryEngine, vertexLimit); - -// for (Map.Entry<Vertex, AtomicInteger> e : vertexLimit.entrySet()) { -// -//// final Vertex v = x.vertices[0]; -//// final int limit = vertexLimit.get(v).intValue(); -// -// final Vertex v = e.getKey(); -// -// final int limit = e.getValue().get(); -// -// v.sample(queryEngine, limit, sampleType); -// -// } } /* - * Re-sample the cutoff join for each edge in each of the existing - * paths using the newly re-sampled vertices. + * Re-sample the cutoff join for each edge in each of the existing paths + * using the newly re-sampled vertices. * * Note: The only way to increase the accuracy of our estimates for - * edges as we extend the join paths is to re-sample each edge in - * the join path in path order. + * edges as we extend the join paths is to re-sample each edge in the + * join path in path order. * - * Note: An edge must be sampled for each distinct join path prefix - * in which it appears within each round. However, it is common for - * surviving paths to share a join path prefix, so do not re-sample - * a given path prefix more than once per round. + * Note: An edge must be sampled for each distinct join path prefix in + * which it appears within each round. However, it is common for + * surviving paths to share a join path prefix, so do not re-sample a + * given path prefix more than once per round. + * + * FIXME PARALLELIZE: Parallelize the re-sampling for the active paths. + * This step is responsible for deepening the samples on the non-pruned + * paths. There is a data race that can occur since the [edgeSamples] + * map can contain samples for the same sequence of edges in different + * paths. This is because two paths can shared a common prefix sequence + * of edges, e.g., [2, 4, 6, 7] and [2, 4, 6, 9] share the path prefix + * [2, 4, 6]. Therefore both inspection and update of the [edgeSamples] + * map MUST be synchronized. This code is single threaded since that + * synchronization mechanism has not yet been put into place. The + * obvious way to handle this is to use a memoization pattern for the + * [ids] key for the [edgeSamples] map. This will ensure that the + * threads that need to resample a given edge will coordinate with the + * first such thread doing the resampling and the other thread(s) + * blocking until the resampled edge is available. */ if (log.isDebugEnabled()) log.debug("Re-sampling in-use path segments."); + // #of paths with cardinality estimate underflow. int nunderflow = 0; + final List<Callable<Boolean>> tasks = new LinkedList<Callable<Boolean>>(); for (Path x : a) { + tasks.add(new ResamplePathTask(queryEngine, x, limitIn, edgeSamples)); + + } // next Path [x]. + + // Execute in the caller's thread. + for (Callable<Boolean> task : tasks) { + + if (task.call()) { + + nunderflow++; + + } + + } + + return nunderflow; + + } + + /** + * Resample the edges along a join path. Edges are resampled based on the + * desired cutoff limit and only as necessary. + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + */ + private class ResamplePathTask implements Callable<Boolean> { + + private final QueryEngine queryEngine; + private final Path x; + private final int limitIn; + private final Map<PathIds, EdgeSample> edgeSamples; + + public ResamplePathTask(final QueryEngine queryEngine, final Path x, + final int limitIn, final Map<PathIds, EdgeSample> edgeSamples) { + this.queryEngine = queryEngine; + this.x = x; + this.limitIn = limitIn; + this.edgeSamples = edgeSamples; + } + + @Override + public Boolean call() throws Exception { /* * Get the new sample limit for the path. * @@ -845,9 +892,9 @@ * round of expansion, which means that we are reading more data * than we really need to read. */ - final int limit = x.getNewLimit(limitIn); + final int limit = x.getNewLimit(limitIn); - // The cutoff join sample of the one step shorter path segment. + // The cutoff join sample of the one step shorter path segment. EdgeSample priorEdgeSample = null; for (int segmentLength = 2; segmentLength <= x.vertices.length; segmentLength++) { @@ -893,7 +940,7 @@ queryEngine, limit,// x.getPathSegment(2),// 1st edge. C,// constraints - V.length == 2,// pathIsComplete + V.length == 2,// pathIsComplete x.vertices[0].sample// source sample. ); @@ -955,19 +1002,19 @@ // Save the result on the path. x.edgeSample = priorEdgeSample; - - if (x.edgeSample.estimateEnum == EstimateEnum.Underflow) { - if (log.isDebugEnabled()) - log.debug("Cardinality underflow: " + x); - nunderflow++; + + final boolean underflow = x.edgeSample.estimateEnum == EstimateEnum.Underflow; + if (underflow) { + if (log.isDebugEnabled()) + log.debug("Cardinality underflow: " + x); } - } // next Path [x]. - - return nunderflow; - + // Done. + return underflow; + } + } - + /** * Do one breadth first expansion. In each breadth first expansion we extend * each of the active join paths by one vertex for each remaining vertex @@ -1269,30 +1316,36 @@ return null; } - /** - * Obtain a sample and estimated cardinality (fast range count) for each - * vertex. - * - * @param queryEngine - * The query engine. - * @param limit - * The sample size. - * - * TODO Only sample vertices with an index. - * - * TODO Consider other cases where we can avoid sampling a vertex - * or an initial edge. - * <p> - * Be careful about rejecting high cardinality vertices here as - * they can lead to good solutions (see the "bar" data set - * example). - * <p> - * BSBM Q5 provides a counter example where (unless we translate - * it into a key-range constraint on an index) some vertices do - * not share a variable directly and hence will materialize the - * full cross product before filtering which is *really* - * expensive. - */ + /** + * Obtain a sample and estimated cardinality (fast range count) for each + * vertex. + * + * @param queryEngine + * The query engine. + * @param limit + * The sample size. + * + * TODO Only sample vertices with an index. + * + * TODO Consider other cases where we can avoid sampling a vertex + * or an initial edge. + * <p> + * Be careful about rejecting high cardinality vertices here as + * they can lead to good solutions (see the "bar" data set + * example). + * <p> + * BSBM Q5 provides a counter example where (unless we translate + * it into a key-range constraint on an index) some vertices do + * not share a variable directly and hence will materialize the + * full cross product before filtering which is *really* + * expensive. + * + * FIXME We need attach any access path filters that are required + * for named graphs or scale-out for the RTO to function in those + * environments. We DO NOT need to attach SPARQL FILTERs here - + * those get applied when we evaluate the cutoff joins from one + * vertex to another. + */ public void sampleAllVertices(final QueryEngine queryEngine, final int limit) { final Map<Vertex, AtomicInteger> vertexLimit = new LinkedHashMap<Vertex, AtomicInteger>(); @@ -1436,7 +1489,7 @@ private Path[] estimateInitialEdgeWeights(final QueryEngine queryEngine, final int limit) throws Exception { - final List<Path> paths = new LinkedList<Path>(); + final List<Callable<Path>> tasks = new LinkedList<Callable<Path>>(); /* * Examine all unordered vertex pairs (v1,v2) once. If any vertex has @@ -1519,30 +1572,86 @@ } - // The path segment - final IPredicate<?>[] preds = new IPredicate[] { v.pred, vp.pred }; + tasks.add(new CutoffJoinTask(queryEngine, limit, v, vp, + pathIsComplete)); - // cutoff join of the edge (v,vp) - final EdgeSample edgeSample = Path.cutoffJoin(queryEngine,// - limit, // sample limit - preds, // ordered path segment. - C, // constraints - pathIsComplete,// - v.sample // sourceSample - ); + } // next other vertex. + + } // next vertex - final Path p = new Path(v, vp, edgeSample); + /* + * Now sample those paths in parallel. + */ - paths.add(p); + final List<Path> paths = new LinkedList<Path>(); - } // next other vertex. +// // Sample the paths in the caller's thread. +// for(Callable<Path> task : tasks) { +// +// paths.add(task.call()); +// +// } - } // next vertex - + // Sample the paths in parallel. + final List<Future<Path>> futures = queryEngine.getIndexManager() + .getExecutorService().invokeAll(tasks); + + // Check future, collecting new paths from each task. + for (Future<Path> f : futures) { + + paths.add(f.get()); + + } + return paths.toArray(new Path[paths.size()]); } + + /** + * Cutoff sample an initial join path consisting of two vertices. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + */ + private class CutoffJoinTask implements Callable<Path> { + private final QueryEngine queryEngine; + private final int limit; + private final Vertex v; + private final Vertex vp; + private final boolean pathIsComplete; + + public CutoffJoinTask(final QueryEngine queryEngine, final int limit, + final Vertex v, final Vertex vp, final boolean pathIsComplete) { + this.queryEngine = queryEngine; + this.limit = limit; + this.v = v; + this.vp = vp; + this.pathIsComplete = pathIsComplete; + } + + @Override + public Path call() throws Exception { + + // The path segment + final IPredicate<?>[] preds = new IPredicate[] { v.pred, vp.pred }; + + // cutoff join of the edge (v,vp) + final EdgeSample edgeSample = Path.cutoffJoin(queryEngine,// + limit, // sample limit + preds, // ordered path segment. + C, // constraints + pathIsComplete,// + v.sample // sourceSample + ); + + final Path p = new Path(v, vp, edgeSample); + + return p; + + } + + } + /** * Prune paths which are dominated by other paths. Paths are extended in * each round. Paths from previous rounds are always pruned. Of the new @@ -1607,10 +1716,10 @@ final Path Pj = a[j]; if (Pj.edgeSample == null) throw new RuntimeException("Not sampled: " + Pj); - if (pruned.contains(Pj)) { - // already pruned. + if (pruned.contains(Pj)) { + // already pruned. continue; - } + } final boolean isPiSuperSet = Pi.isUnorderedVariant(Pj); if (!isPiSuperSet) { // Can not directly compare these join paths. Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Path.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Path.java 2014-01-05 17:35:43 UTC (rev 7728) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Path.java 2014-01-05 19:23:06 UTC (rev 7729) @@ -1,3 +1,26 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2011. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ package com.bigdata.bop.joinGraph.rto; import java.util.Arrays; @@ -847,7 +870,7 @@ final List<IBindingSet> result = new LinkedList<IBindingSet>(); try { - int nresults = 0; + int nresults = 0; try { IBindingSet bset = null; // Figure out the #of source samples consumed. @@ -862,7 +885,7 @@ } } } finally { - // ensure terminated regardless. + // ensure terminated regardless. runningQuery.cancel(true/* mayInterruptIfRunning */); } } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-01-07 18:24:47
|
Revision: 7742 http://bigdata.svn.sourceforge.net/bigdata/?rev=7742&view=rev Author: thompsonbry Date: 2014-01-07 18:24:40 +0000 (Tue, 07 Jan 2014) Log Message: ----------- @Overrides and javadoc. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JoinGraph.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Vertex.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2014-01-07 11:05:13 UTC (rev 7741) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2014-01-07 18:24:40 UTC (rev 7742) @@ -208,6 +208,10 @@ * will be no paths identified by the optimizer and the final path length * becomes zero. * + * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/64">Runtime + * Query Optimization</a> + * @see <a href="https://sourceforge.net/apps/trac/bigdata/ticket/258">Integrate + * RTO into SAIL</a> * @see <a * href="http://www-db.informatik.uni-tuebingen.de/files/research/pathfinder/publications/rox-demo.pdf"> * ROX </a> @@ -286,7 +290,7 @@ * @todo unit test when the join graph has a single vertex. */ public JGraph(final IPredicate<?>[] v, final IConstraint[] constraints, - final SampleType sampleType) { + final SampleType sampleType) { if (v == null) throw new IllegalArgumentException(); Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JoinGraph.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JoinGraph.java 2014-01-07 11:05:13 UTC (rev 7741) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JoinGraph.java 2014-01-07 18:24:40 UTC (rev 7742) @@ -50,6 +50,7 @@ import com.bigdata.bop.ap.SampleIndex.SampleType; import com.bigdata.bop.controller.AbstractSubqueryOp; import com.bigdata.bop.engine.AbstractRunningQuery; +import com.bigdata.bop.engine.BOpStats; import com.bigdata.bop.engine.IRunningQuery; import com.bigdata.bop.engine.QueryEngine; import com.bigdata.rdf.sparql.ast.IJoinNode; @@ -206,6 +207,9 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * + * TODO This could also be put on a {@link BOpStats} interface, + * which is the other way for accessing shared state. */ public interface Attributes { Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Vertex.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Vertex.java 2014-01-07 11:05:13 UTC (rev 7741) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/Vertex.java 2014-01-07 18:24:40 UTC (rev 7742) @@ -83,6 +83,7 @@ } + @Override public String toString() { return "Vertex{pred=" + pred + ",sample=" + sample + "}"; @@ -92,6 +93,7 @@ /** * Equals is based on a reference test. */ + @Override public boolean equals(Object o) { return this == o; } @@ -100,6 +102,7 @@ * The hash code is just the {@link BOp.Annotations#BOP_ID} of the * associated {@link IPredicate}. */ + @Override public int hashCode() { return pred.getId(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2014-01-14 12:59:16
|
Revision: 7792 http://bigdata.svn.sourceforge.net/bigdata/?rev=7792&view=rev Author: thompsonbry Date: 2014-01-14 12:59:09 +0000 (Tue, 14 Jan 2014) Log Message: ----------- Fixing an NPE in RTO logging. Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2014-01-14 12:55:58 UTC (rev 7791) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/JGraph.java 2014-01-14 12:59:09 UTC (rev 7792) @@ -555,7 +555,7 @@ for(Path p : paths) { final EdgeSample edgeSample; synchronized(edgeSamples) { - edgeSample = edgeSamples.get(p.getVertexIds()); + edgeSample = edgeSamples.get(new PathIds(p)); } if (edgeSample.isUnderflow()) { log.warn("Underflow on path::" Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java 2014-01-14 12:55:58 UTC (rev 7791) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/joinGraph/rto/PathIds.java 2014-01-14 12:59:09 UTC (rev 7792) @@ -50,6 +50,25 @@ } + /** + * Convenience constructor. + * + * @param p + * A path. + */ + public PathIds(final Path p) { + + this(p.getVertexIds()); + + } + + /** + * Core constructor. + * + * @param ids + * The ordered set of vertex identifiers for some join path + * segment. + */ public PathIds(final int[] ids) { if (ids == null) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |