From: <tho...@us...> - 2014-01-10 15:14:38
|
Revision: 7758 http://bigdata.svn.sourceforge.net/bigdata/?rev=7758&view=rev Author: thompsonbry Date: 2014-01-10 15:14:32 +0000 (Fri, 10 Jan 2014) Log Message: ----------- Modified AbstractRunningQuery.getChildren() to be recursive since we were missing any sub-queries that were executed from within a named subquery. This showed up in the explain view of govtrack/queries/query0011.rq. See #64 (RTO). Modified Paths: -------------- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/engine/AbstractRunningQuery.java Modified: branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/engine/AbstractRunningQuery.java =================================================================== --- branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/engine/AbstractRunningQuery.java 2014-01-10 13:17:37 UTC (rev 7757) +++ branches/BIGDATA_RELEASE_1_3_0/bigdata/src/java/com/bigdata/bop/engine/AbstractRunningQuery.java 2014-01-10 15:14:32 UTC (rev 7758) @@ -29,9 +29,12 @@ import java.nio.ByteBuffer; import java.nio.channels.ClosedByInterruptException; +import java.util.Arrays; import java.util.Collections; import java.util.Iterator; import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; @@ -1642,7 +1645,8 @@ /** * Report a snapshot of the known (declared) child {@link IRunningQuery}s - * for this {@link IRunningQuery}. + * for this {@link IRunningQuery} and (recursively) for any children of this + * {@link IRunningQuery}. * * @return An array providing a snapshot of the known child * {@link IRunningQuery}s and never <code>null</code>. @@ -1651,13 +1655,35 @@ synchronized (children) { - return children.values() - .toArray(new IRunningQuery[children.size()]); + if (children.isEmpty()) { + // Fast path if no children. + return EMPTY_ARRAY; + + } + + // Add in all direct child queries. + final List<IRunningQuery> tmp = new LinkedList<IRunningQuery>( + children.values()); + + // Note: Do not iterator over [tmp] to avoid concurrent modification. + for (IRunningQuery c : children.values()) { + + // Recursive for each child. + tmp.addAll(Arrays.asList(((AbstractRunningQuery) c) + .getChildren())); + + } + + // Convert to array. + return tmp.toArray(new IRunningQuery[tmp.size()]); + } - + } - + + private static final IRunningQuery[] EMPTY_ARRAY = new IRunningQuery[0]; + /** * Attach a child query. * <p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |