From: <tho...@us...> - 2011-01-04 00:23:48
|
Revision: 4049 http://bigdata.svn.sourceforge.net/bigdata/?rev=4049&view=rev Author: thompsonbry Date: 2011-01-04 00:23:40 +0000 (Tue, 04 Jan 2011) Log Message: ----------- Removed the push()/pop() support on IBindingSet in order to reduce the data on the heap when we have a bunch of binding sets during query processing. The push()/pop() logic did not work out for the optional join groups, so it is just overhead. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IBindingSet.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ArrayBindingSet.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/EmptyBindingSet.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/HashBindingSet.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ListBindingSet.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/ChunkedRunningQuery.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/QueryEngine.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionBuffer.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionMetadata.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/StandaloneChainedRunningQuery.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/TestBOpUtility.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/bindingSet/TestIBindingSet.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/controller/TestOptionalJoinGroup.java branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/mutation/TestInsert.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpUtility.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -425,56 +425,56 @@ return Collections.unmodifiableMap(map); } - /** - * Lookup the first operator in the specified conditional binding group and - * return its bopId. - * - * @param query - * The query plan. - * @param groupId - * The identifier for the desired conditional binding group. - * - * @return The bopId of the first operator in that conditional binding group - * -or- <code>null</code> if the specified conditional binding group - * does not exist in the query plan. - * - * @throws IllegalArgumentException - * if either argument is <code>null</code>. - * - * @see PipelineOp.Annotations#CONDITIONAL_GROUP - * @see PipelineOp.Annotations#ALT_SINK_GROUP - */ - static public Integer getFirstBOpIdForConditionalGroup(final BOp query, - final Integer groupId) { - if (query == null) - throw new IllegalArgumentException(); - if (groupId == null) - throw new IllegalArgumentException(); - final Iterator<BOp> itr = postOrderIterator(query); - while (itr.hasNext()) { - final BOp t = itr.next(); - final Object x = t.getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); - if (x != null) { - if (!(x instanceof Integer)) { - throw new BadConditionalGroupIdTypeException( - "Must be Integer, not: " + x.getClass() + ": " - + PipelineOp.Annotations.CONDITIONAL_GROUP); - } - final Integer id = (Integer) t - .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); - if(id.equals(groupId)) { - /* - * Return the BOpId associated with the first operator in - * the pre-order traversal of the query plan which has the - * specified groupId. - */ - return t.getId(); - } - } - } - // No such groupId in the query plan. - return null; - } +// /** +// * Lookup the first operator in the specified conditional binding group and +// * return its bopId. +// * +// * @param query +// * The query plan. +// * @param groupId +// * The identifier for the desired conditional binding group. +// * +// * @return The bopId of the first operator in that conditional binding group +// * -or- <code>null</code> if the specified conditional binding group +// * does not exist in the query plan. +// * +// * @throws IllegalArgumentException +// * if either argument is <code>null</code>. +// * +// * @see PipelineOp.Annotations#CONDITIONAL_GROUP +// * @see PipelineOp.Annotations#ALT_SINK_GROUP +// */ +// static public Integer getFirstBOpIdForConditionalGroup(final BOp query, +// final Integer groupId) { +// if (query == null) +// throw new IllegalArgumentException(); +// if (groupId == null) +// throw new IllegalArgumentException(); +// final Iterator<BOp> itr = postOrderIterator(query); +// while (itr.hasNext()) { +// final BOp t = itr.next(); +// final Object x = t.getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// if (x != null) { +// if (!(x instanceof Integer)) { +// throw new BadConditionalGroupIdTypeException( +// "Must be Integer, not: " + x.getClass() + ": " +// + PipelineOp.Annotations.CONDITIONAL_GROUP); +// } +// final Integer id = (Integer) t +// .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// if(id.equals(groupId)) { +// /* +// * Return the BOpId associated with the first operator in +// * the pre-order traversal of the query plan which has the +// * specified groupId. +// */ +// return t.getId(); +// } +// } +// } +// // No such groupId in the query plan. +// return null; +// } /** * Return the parent of the operator in the operator tree (this does not Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IBindingSet.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IBindingSet.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/IBindingSet.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -157,38 +157,38 @@ */ public int hashCode(); - /** - * Make a copy of the current symbol table (aka current variable bindings) - * and push it onto onto the stack. Variable bindings will be made against - * the current symbol table. The symbol table stack is propagated by - * {@link #clone()} and {@link #copy(IVariable[])}. Symbols tables may be - * used to propagate conditional bindings through a data flow until a - * decision point is reached, at which point they may be either discarded or - * committed. This mechanism may be used to support SPARQL style optional - * join groups. - * - * @throws UnsupportedOperationException - * if the {@link IBindingSet} is not mutable. - * - * @see #pop(boolean) - */ - public void push(); +// /** +// * Make a copy of the current symbol table (aka current variable bindings) +// * and push it onto onto the stack. Variable bindings will be made against +// * the current symbol table. The symbol table stack is propagated by +// * {@link #clone()} and {@link #copy(IVariable[])}. Symbols tables may be +// * used to propagate conditional bindings through a data flow until a +// * decision point is reached, at which point they may be either discarded or +// * committed. This mechanism may be used to support SPARQL style optional +// * join groups. +// * +// * @throws UnsupportedOperationException +// * if the {@link IBindingSet} is not mutable. +// * +// * @see #pop(boolean) +// */ +// public void push(); +// +// /** +// * Pop the current symbol table off of the stack. +// * +// * @param save +// * When <code>true</code>, the bindings on the current symbol +// * table are copied to the parent symbol table before the current +// * symbol table is popped off of the stack. If <code>false</code> +// * , any bindings associated with that symbol table are +// * discarded. +// * +// * @throws IllegalStateException +// * if there is no nested symbol table. +// * +// * @see #push() +// */ +// public void pop(boolean save); - /** - * Pop the current symbol table off of the stack. - * - * @param save - * When <code>true</code>, the bindings on the current symbol - * table are copied to the parent symbol table before the current - * symbol table is popped off of the stack. If <code>false</code> - * , any bindings associated with that symbol table are - * discarded. - * - * @throws IllegalStateException - * if there is no nested symbol table. - * - * @see #push() - */ - public void pop(boolean save); - } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/PipelineOp.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -33,7 +33,6 @@ import com.bigdata.bop.engine.BOpStats; import com.bigdata.bop.engine.QueryEngine; -import com.bigdata.bop.solutions.SliceOp; /** * Abstract base class for pipeline operators where the data moving along the @@ -106,70 +105,70 @@ */ String JOIN_GRAPH = PipelineOp.class.getName() + ".joinGraph"; - /** - * Annotation used to mark a set of operators belonging to a conditional - * binding group. Bindings within with the group will be discarded if - * any required operator in the group fails. For example, if a binding - * set exits via the alternative sink for a required join then any - * conditional bindings within the group will be discarded. - * <p> - * Together with {@link #ALT_SINK_GROUP}, the {@link #CONDITIONAL_GROUP} - * annotation provides the information necessary in order to decide the - * re-entry point in the query plan when a join within an conditional - * binding group fails. - * <p> - * The {@link #CONDITIONAL_GROUP} annotation controls the - * {@link IBindingSet#push()} and {@link IBindingSet#pop(boolean)} of - * individual solutions as they propagate through the pipeline. When a - * pipeline starts, the {@link IBindingSet} stack contains only the top - * level symbol table (i.e., name/value bindings). When an intermediate - * solution enters a {@link PipelineOp} marked as belonging to a - * {@link #CONDITIONAL_GROUP}, a new symbol table is - * {@link IBindingSet#push() pushed} onto the stack for that solution. - * If the solution leaves the optional join group via the default sink, - * then the symbol table is "saved" when it is - * {@link IBindingSet#pop(boolean) popped} off of the stack. If the - * solution leaves the join group via the alternative sink, then the - * symbol table is discarded when it is {@link IBindingSet#pop(boolean) - * popped} off of the stack. This provides for conditional binding of - * variables within the operators of the group. - * <p> - * The value of the {@link #CONDITIONAL_GROUP} is an {@link Integer} - * which uniquely identifies the group within the query. - * - * @deprecated The binding set stack push/pop mechanisms are not - * sufficient to support optional join groups. This - * annotation will be removed unless it proves valuable for - * marking the elements of a join group, in which case the - * javadoc needs to be updated. - */ - String CONDITIONAL_GROUP = PipelineOp.class.getName() + ".conditionalGroup"; +// /** +// * Annotation used to mark a set of operators belonging to a conditional +// * binding group. Bindings within with the group will be discarded if +// * any required operator in the group fails. For example, if a binding +// * set exits via the alternative sink for a required join then any +// * conditional bindings within the group will be discarded. +// * <p> +// * Together with {@link #ALT_SINK_GROUP}, the {@link #CONDITIONAL_GROUP} +// * annotation provides the information necessary in order to decide the +// * re-entry point in the query plan when a join within an conditional +// * binding group fails. +// * <p> +// * The {@link #CONDITIONAL_GROUP} annotation controls the +// * {@link IBindingSet#push()} and {@link IBindingSet#pop(boolean)} of +// * individual solutions as they propagate through the pipeline. When a +// * pipeline starts, the {@link IBindingSet} stack contains only the top +// * level symbol table (i.e., name/value bindings). When an intermediate +// * solution enters a {@link PipelineOp} marked as belonging to a +// * {@link #CONDITIONAL_GROUP}, a new symbol table is +// * {@link IBindingSet#push() pushed} onto the stack for that solution. +// * If the solution leaves the optional join group via the default sink, +// * then the symbol table is "saved" when it is +// * {@link IBindingSet#pop(boolean) popped} off of the stack. If the +// * solution leaves the join group via the alternative sink, then the +// * symbol table is discarded when it is {@link IBindingSet#pop(boolean) +// * popped} off of the stack. This provides for conditional binding of +// * variables within the operators of the group. +// * <p> +// * The value of the {@link #CONDITIONAL_GROUP} is an {@link Integer} +// * which uniquely identifies the group within the query. +// * +// * @deprecated The binding set stack push/pop mechanisms are not +// * sufficient to support optional join groups. This +// * annotation will be removed unless it proves valuable for +// * marking the elements of a join group, in which case the +// * javadoc needs to be updated. +// */ +// String CONDITIONAL_GROUP = PipelineOp.class.getName() + ".conditionalGroup"; - /** - * Annotation used to designate the target when a required operator - * within an {@link #CONDITIONAL_GROUP} fails. The value of this - * annotation must be the {@link #CONDITIONAL_GROUP} identifier - * corresponding to the next conditional binding group in the query - * plan. If there is no such group, then the {@link #ALT_SINK_REF} - * should be used instead to specify the target operator in the - * pipeline, e.g., a {@link SliceOp}. - * <p> - * The target {@link #CONDITIONAL_GROUP} is specified (rather than the - * bopId of the target join) since the non-optional joins in the target - * {@link #CONDITIONAL_GROUP} be reordered by the query optimizer. The - * entry point for solutions redirected to the {@link #ALT_SINK_GROUP} - * is therefore the first operator in the target - * {@link #CONDITIONAL_GROUP}. This decouples the routing decisions from - * the join ordering decisions. - * - * @see #CONDITIONAL_GROUP - * @see #ALT_SINK_REF - * - * @deprecated The binding set stack push/pop mechanisms are not - * sufficient to support optional join groups. This - * annotation will be removed. - */ - String ALT_SINK_GROUP = PipelineOp.class.getName() + ".altSinkGroup"; +// /** +// * Annotation used to designate the target when a required operator +// * within an {@link #CONDITIONAL_GROUP} fails. The value of this +// * annotation must be the {@link #CONDITIONAL_GROUP} identifier +// * corresponding to the next conditional binding group in the query +// * plan. If there is no such group, then the {@link #ALT_SINK_REF} +// * should be used instead to specify the target operator in the +// * pipeline, e.g., a {@link SliceOp}. +// * <p> +// * The target {@link #CONDITIONAL_GROUP} is specified (rather than the +// * bopId of the target join) since the non-optional joins in the target +// * {@link #CONDITIONAL_GROUP} be reordered by the query optimizer. The +// * entry point for solutions redirected to the {@link #ALT_SINK_GROUP} +// * is therefore the first operator in the target +// * {@link #CONDITIONAL_GROUP}. This decouples the routing decisions from +// * the join ordering decisions. +// * +// * @see #CONDITIONAL_GROUP +// * @see #ALT_SINK_REF +// * +// * @deprecated The binding set stack push/pop mechanisms are not +// * sufficient to support optional join groups. This +// * annotation will be removed. +// */ +// String ALT_SINK_GROUP = PipelineOp.class.getName() + ".altSinkGroup"; } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ArrayBindingSet.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ArrayBindingSet.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ArrayBindingSet.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -33,7 +33,6 @@ import java.util.Collections; import java.util.Iterator; import java.util.Map; -import java.util.Stack; import java.util.Map.Entry; import com.bigdata.bop.IBindingSet; @@ -206,60 +205,62 @@ * pushed onto the stack or popped off of the stack, but the stack MAY NOT * become empty. */ - private final Stack<ST> stack; +// private final Stack<ST> stack; + private final ST current; /** * Return the symbol table on the top of the stack. */ private ST current() { - return stack.peek(); + return current; +// return stack.peek(); } - public void push() { +// public void push() { +// +// // The current symbol table. +// final ST cur = current(); +// +// // Create a new symbol table. +// final ST tmp = new ST(cur.nbound, cur.vars.clone(), cur.vals.clone()); +// +// // Push the new symbol table onto the stack. +// stack.push(tmp); +// +// } +// +// public void pop(final boolean save) { +// +// if (stack.size() < 2) { +// /* +// * The stack may never become empty. Therefore there must be at +// * least two symbol tables on the stack for a pop() request. +// */ +// throw new IllegalArgumentException(); +// } +// +// // Pop the symbol table off of the top of the stack. +// final ST old = stack.pop(); +// +// if (save) { +// +// // discard the current symbol table. +// stack.pop(); +// +// // replacing it with the symbol table which we popped off the stack. +// stack.push(old); +// +// } else { +// +// // clear the hash code. +// hash = 0; +// +// } +// +// } - // The current symbol table. - final ST cur = current(); - - // Create a new symbol table. - final ST tmp = new ST(cur.nbound, cur.vars.clone(), cur.vals.clone()); - - // Push the new symbol table onto the stack. - stack.push(tmp); - - } - - public void pop(final boolean save) { - - if (stack.size() < 2) { - /* - * The stack may never become empty. Therefore there must be at - * least two symbol tables on the stack for a pop() request. - */ - throw new IllegalArgumentException(); - } - - // Pop the symbol table off of the top of the stack. - final ST old = stack.pop(); - - if (save) { - - // discard the current symbol table. - stack.pop(); - - // replacing it with the symbol table which we popped off the stack. - stack.push(old); - - } else { - - // clear the hash code. - hash = 0; - - } - - } - /** * Copy constructor (used by clone, copy). * @@ -272,30 +273,32 @@ protected ArrayBindingSet(final ArrayBindingSet src, final IVariable[] variablesToKeep) { - stack = new Stack<ST>(); +// stack = new Stack<ST>(); +// +// final int stackSize = src.stack.size(); +// +// int depth = 1; +// +// for (ST srcLst : src.stack) { +// +// /* +// * Copy the source bindings. +// * +// * Note: If a restriction exists on the variables to be copied, then +// * it is applied onto the the top level of the stack. If the symbol +// * table is saved when it is pop()'d, then the modified bindings +// * will replace the parent symbol table on the stack. +// */ +// final ST tmp = copy(srcLst, +// depth == stackSize ? variablesToKeep : null); +// +// // Push onto the stack. +// stack.push(tmp); +// +// } - final int stackSize = src.stack.size(); - - int depth = 1; + current = copy(src.current, variablesToKeep); - for (ST srcLst : src.stack) { - - /* - * Copy the source bindings. - * - * Note: If a restriction exists on the variables to be copied, then - * it is applied onto the the top level of the stack. If the symbol - * table is saved when it is pop()'d, then the modified bindings - * will replace the parent symbol table on the stack. - */ - final ST tmp = copy(srcLst, - depth == stackSize ? variablesToKeep : null); - - // Push onto the stack. - stack.push(tmp); - - } - } /** @@ -458,9 +461,11 @@ if(vars.length != vals.length) throw new IllegalArgumentException(); - stack = new Stack<ST>(); +// stack = new Stack<ST>(); +// +// stack.push(new ST(vars.length, vars, vals)); - stack.push(new ST(vars.length, vars, vals)); + current = new ST(vars.length, vars, vals); } @@ -478,11 +483,14 @@ if (capacity < 0) throw new IllegalArgumentException(); - stack = new Stack<ST>(); +// stack = new Stack<ST>(); +// +// stack.push(new ST(0/* nbound */, new IVariable[capacity], +// new IConstant[capacity])); - stack.push(new ST(0/* nbound */, new IVariable[capacity], - new IConstant[capacity])); - + current = new ST(0/* nbound */, new IVariable[capacity], + new IConstant[capacity]); + } /** Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/EmptyBindingSet.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/EmptyBindingSet.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/EmptyBindingSet.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -161,12 +161,12 @@ } - public void push() { - throw new IllegalStateException(); - } - - public void pop(boolean save) { - throw new UnsupportedOperationException(); - } +// public void push() { +// throw new IllegalStateException(); +// } +// +// public void pop(boolean save) { +// throw new UnsupportedOperationException(); +// } } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/HashBindingSet.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/HashBindingSet.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/HashBindingSet.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -32,7 +32,6 @@ import java.util.Iterator; import java.util.LinkedHashMap; import java.util.Map; -import java.util.Stack; import java.util.Map.Entry; import com.bigdata.bop.IBindingSet; @@ -60,92 +59,98 @@ // */ // private final LinkedHashMap<IVariable, IConstant> map; - /** - * The stack of symbol tables. Each symbol table is a mapping from an - * {@link IVariable} onto its non-<code>null</code> bound {@link IConstant}. - * The stack is initialized with an empty symbol table. Symbol tables may be - * pushed onto the stack or popped off of the stack, but the stack MAY NOT - * become empty. - */ - private final Stack<LinkedHashMap<IVariable, IConstant>> stack; +// /** +// * The stack of symbol tables. Each symbol table is a mapping from an +// * {@link IVariable} onto its non-<code>null</code> bound {@link IConstant}. +// * The stack is initialized with an empty symbol table. Symbol tables may be +// * pushed onto the stack or popped off of the stack, but the stack MAY NOT +// * become empty. +// */ +// private final Stack<LinkedHashMap<IVariable, IConstant>> stack; + final private LinkedHashMap<IVariable,IConstant> current; + /** * Return the symbol table on the top of the stack. */ private LinkedHashMap<IVariable, IConstant> current() { - return stack.peek(); + return current; + +// return stack.peek(); } - public void push() { +// public void push() { +// +// // The current symbol table. +// final LinkedHashMap<IVariable, IConstant> cur = current(); +// +// // Create a new symbol table. +// final LinkedHashMap<IVariable, IConstant> tmp = new LinkedHashMap<IVariable, IConstant>( +// cur.size()); +// +// // Push the new symbol table onto the stack. +// stack.push(tmp); +// +// /* +// * Make a copy of each entry in the symbol table which was on the top of +// * the stack when we entered this method, inserting the entries into the +// * new symbol table as we go. This avoids side effects of mutation on +// * the nested symbol tables and also ensures that we do not need to read +// * through to the nested symbol tables when answering a query about the +// * current symbol table. The only down side of this is that naive +// * serialization is that much less compact. +// */ +// for (Map.Entry<IVariable, IConstant> e : cur.entrySet()) { +// +// tmp.put(e.getKey(), e.getValue()); +// +// } +// +// } - // The current symbol table. - final LinkedHashMap<IVariable, IConstant> cur = current(); +// public void pop(final boolean save) { +// +// if (stack.size() < 2) { +// /* +// * The stack may never become empty. Therefore there must be at +// * least two symbol tables on the stack for a pop() request. +// */ +// throw new IllegalArgumentException(); +// } +// +// // Pop the symbol table off of the top of the stack. +// final LinkedHashMap<IVariable,IConstant> old = stack.pop(); +// +// if (save) { +// +// // discard the current symbol table. +// stack.pop(); +// +// // replacing it with the symbol table which we popped off the stack. +// stack.push(old); +// +// } else { +// +// // clear the hash code. +// hash = 0; +// +// } +// +// } - // Create a new symbol table. - final LinkedHashMap<IVariable, IConstant> tmp = new LinkedHashMap<IVariable, IConstant>( - cur.size()); - - // Push the new symbol table onto the stack. - stack.push(tmp); - - /* - * Make a copy of each entry in the symbol table which was on the top of - * the stack when we entered this method, inserting the entries into the - * new symbol table as we go. This avoids side effects of mutation on - * the nested symbol tables and also ensures that we do not need to read - * through to the nested symbol tables when answering a query about the - * current symbol table. The only down side of this is that naive - * serialization is that much less compact. - */ - for (Map.Entry<IVariable, IConstant> e : cur.entrySet()) { - - tmp.put(e.getKey(), e.getValue()); - - } - - } - - public void pop(final boolean save) { - - if (stack.size() < 2) { - /* - * The stack may never become empty. Therefore there must be at - * least two symbol tables on the stack for a pop() request. - */ - throw new IllegalArgumentException(); - } - - // Pop the symbol table off of the top of the stack. - final LinkedHashMap<IVariable,IConstant> old = stack.pop(); - - if (save) { - - // discard the current symbol table. - stack.pop(); - - // replacing it with the symbol table which we popped off the stack. - stack.push(old); - - } else { - - // clear the hash code. - hash = 0; - - } - - } - /** * New empty binding set. */ public HashBindingSet() { - stack = new Stack<LinkedHashMap<IVariable, IConstant>>(); - - stack.push(new LinkedHashMap<IVariable, IConstant>()); +// stack = new Stack<LinkedHashMap<IVariable, IConstant>>(); +// +// stack.push(new LinkedHashMap<IVariable, IConstant>()); + current = new LinkedHashMap<IVariable, IConstant>(); + } /** @@ -155,30 +160,32 @@ */ protected HashBindingSet(final HashBindingSet src, final IVariable[] variablesToKeep) { - stack = new Stack<LinkedHashMap<IVariable,IConstant>>(); +// stack = new Stack<LinkedHashMap<IVariable,IConstant>>(); +// +// final int stackSize = src.stack.size(); +// +// int depth = 1; +// +// for (LinkedHashMap<IVariable, IConstant> srcLst : src.stack) { +// +// /* +// * Copy the source bindings. +// * +// * Note: If a restriction exists on the variables to be copied, then +// * it is applied onto the the top level of the stack. If the symbol +// * table is saved when it is pop()'d, then the modified bindings +// * will replace the parent symbol table on the stack. +// */ +// final LinkedHashMap<IVariable,IConstant> tmp = copy(srcLst, +// depth == stackSize ? variablesToKeep : null); +// +// // Push onto the stack. +// stack.push(tmp); +// +// } - final int stackSize = src.stack.size(); + current = copy(src.current, variablesToKeep); - int depth = 1; - - for (LinkedHashMap<IVariable, IConstant> srcLst : src.stack) { - - /* - * Copy the source bindings. - * - * Note: If a restriction exists on the variables to be copied, then - * it is applied onto the the top level of the stack. If the symbol - * table is saved when it is pop()'d, then the modified bindings - * will replace the parent symbol table on the stack. - */ - final LinkedHashMap<IVariable,IConstant> tmp = copy(srcLst, - depth == stackSize ? variablesToKeep : null); - - // Push onto the stack. - stack.push(tmp); - - } - } /** Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ListBindingSet.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ListBindingSet.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/bindingSet/ListBindingSet.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -6,7 +6,6 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; -import java.util.Stack; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.IConstant; @@ -82,90 +81,94 @@ } }; - /** - * The stack of symbol tables. Each symbol table is a mapping from an - * {@link IVariable} onto its non-<code>null</code> bound {@link IConstant}. - * The stack is initialized with an empty symbol table. Symbol tables may be - * pushed onto the stack or popped off of the stack, but the stack MAY NOT - * become empty. - */ - private final Stack<List<E>> stack; +// /** +// * The stack of symbol tables. Each symbol table is a mapping from an +// * {@link IVariable} onto its non-<code>null</code> bound {@link IConstant}. +// * The stack is initialized with an empty symbol table. Symbol tables may be +// * pushed onto the stack or popped off of the stack, but the stack MAY NOT +// * become empty. +// */ +// private final Stack<List<E>> stack; + private final List<E> current; /** * Return the symbol table on the top of the stack. */ - private List<E> current() { + final private List<E> current() { - return stack.peek(); + return current; +// return stack.peek(); } - public void push() { +// public void push() { +// +// // The current symbol table. +// final List<E> cur = current(); +// +// // Create a new symbol table. +// final List<E> tmp = new LinkedList<E>(); +// +// // Push the new symbol table onto the stack. +// stack.push(tmp); +// +// /* +// * Make a copy of each entry in the symbol table which was on the top of +// * the stack when we entered this method, inserting the entries into the +// * new symbol table as we go. This avoids side effects of mutation on +// * the nested symbol tables and also ensures that we do not need to read +// * through to the nested symbol tables when answering a query about the +// * current symbol table. The only down side of this is that naive +// * serialization is that much less compact. +// */ +// for (E e : cur) { +// +// tmp.add(new E(e.var, e.val)); +// +// } +// +// } +// +// public void pop(final boolean save) { +// +// if (stack.size() < 2) { +// /* +// * The stack may never become empty. Therefore there must be at +// * least two symbol tables on the stack for a pop() request. +// */ +// throw new IllegalArgumentException(); +// } +// +// // Pop the symbol table off of the top of the stack. +// final List<E> old = stack.pop(); +// +// if (save) { +// +// // discard the current symbol table. +// stack.pop(); +// +// // replacing it with the symbol table which we popped off the stack. +// stack.push(old); +// +// } else { +// +// // clear the hash code. +// hash = 0; +// +// } +// +// } - // The current symbol table. - final List<E> cur = current(); - - // Create a new symbol table. - final List<E> tmp = new LinkedList<E>(); - - // Push the new symbol table onto the stack. - stack.push(tmp); - - /* - * Make a copy of each entry in the symbol table which was on the top of - * the stack when we entered this method, inserting the entries into the - * new symbol table as we go. This avoids side effects of mutation on - * the nested symbol tables and also ensures that we do not need to read - * through to the nested symbol tables when answering a query about the - * current symbol table. The only down side of this is that naive - * serialization is that much less compact. - */ - for (E e : cur) { - - tmp.add(new E(e.var, e.val)); - - } - - } - - public void pop(final boolean save) { - - if (stack.size() < 2) { - /* - * The stack may never become empty. Therefore there must be at - * least two symbol tables on the stack for a pop() request. - */ - throw new IllegalArgumentException(); - } - - // Pop the symbol table off of the top of the stack. - final List<E> old = stack.pop(); - - if (save) { - - // discard the current symbol table. - stack.pop(); - - // replacing it with the symbol table which we popped off the stack. - stack.push(old); - - } else { - - // clear the hash code. - hash = 0; - - } - - } - /** * Create an empty binding set. */ public ListBindingSet() { - stack = new Stack<List<E>>(); - - stack.push(new LinkedList<E>()); +// stack = new Stack<List<E>>(); +// +// stack.push(new LinkedList<E>()); + + current = new LinkedList<E>(); } @@ -207,30 +210,32 @@ protected ListBindingSet(final ListBindingSet src, final IVariable[] variablesToKeep) { - stack = new Stack<List<E>>(); +// stack = new Stack<List<E>>(); +// +// final int stackSize = src.stack.size(); +// +// int depth = 1; +// +// for (List<E> srcLst : src.stack) { +// +// /* +// * Copy the source bindings. +// * +// * Note: If a restriction exists on the variables to be copied, then +// * it is applied onto the the top level of the stack. If the symbol +// * table is saved when it is pop()'d, then the modified bindings +// * will replace the parent symbol table on the stack. +// */ +// final List<E> tmp = copy(srcLst, +// depth == stackSize ? variablesToKeep : null); +// +// // Push onto the stack. +// stack.push(tmp); +// +// } - final int stackSize = src.stack.size(); + current = copy(src.current, variablesToKeep); - int depth = 1; - - for (List<E> srcLst : src.stack) { - - /* - * Copy the source bindings. - * - * Note: If a restriction exists on the variables to be copied, then - * it is applied onto the the top level of the stack. If the symbol - * table is saved when it is pop()'d, then the modified bindings - * will replace the parent symbol table on the stack. - */ - final List<E> tmp = copy(srcLst, - depth == stackSize ? variablesToKeep : null); - - // Push onto the stack. - stack.push(tmp); - - } - } /** Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/ChunkedRunningQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/ChunkedRunningQuery.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/ChunkedRunningQuery.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -1070,30 +1070,33 @@ */ sinkId = BOpUtility.getEffectiveDefaultSink(bop, p); - { - // altSink (null when not specified). - final Integer altSinkId = (Integer) op - .getProperty(PipelineOp.Annotations.ALT_SINK_REF); - final Integer altSinkGroup = (Integer) op - .getProperty(PipelineOp.Annotations.ALT_SINK_GROUP); - if (altSinkId != null && altSinkGroup != null) - throw new RuntimeException( - "Annotations are mutually exclusive: " - + PipelineOp.Annotations.ALT_SINK_REF - + " and " - + PipelineOp.Annotations.ALT_SINK_GROUP); - if (altSinkGroup != null) { - /* - * Lookup the first pipeline op in the conditional binding - * group and use its bopId as the altSinkId. - */ - this.altSinkId = BOpUtility.getFirstBOpIdForConditionalGroup( - getQuery(), altSinkGroup); - } else { - // MAY be null. - this.altSinkId = altSinkId; - } - } + // altSink (null when not specified). + altSinkId = (Integer) op + .getProperty(PipelineOp.Annotations.ALT_SINK_REF); +// { +// // altSink (null when not specified). +// final Integer altSinkId = (Integer) op +// .getProperty(PipelineOp.Annotations.ALT_SINK_REF); +// final Integer altSinkGroup = (Integer) op +// .getProperty(PipelineOp.Annotations.ALT_SINK_GROUP); +// if (altSinkId != null && altSinkGroup != null) +// throw new RuntimeException( +// "Annotations are mutually exclusive: " +// + PipelineOp.Annotations.ALT_SINK_REF +// + " and " +// + PipelineOp.Annotations.ALT_SINK_GROUP); +// if (altSinkGroup != null) { +// /* +// * Lookup the first pipeline op in the conditional binding +// * group and use its bopId as the altSinkId. +// */ +// this.altSinkId = BOpUtility.getFirstBOpIdForConditionalGroup( +// getQuery(), altSinkGroup); +// } else { +// // MAY be null. +// this.altSinkId = altSinkId; +// } +// } if (altSinkId != null && !getBOpIndex().containsKey(altSinkId)) throw new NoSuchBOpException(altSinkId); @@ -1131,18 +1134,19 @@ } assert stats != null; - // The groupId (if any) for this operator. - final Integer fromGroupId = (Integer) op - .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// // The groupId (if any) for this operator. +// final Integer fromGroupId = (Integer) op +// .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); if (p == null) { sink = getQueryBuffer(); } else { - final BOp targetOp = getBOpIndex().get(sinkId); - final Integer toGroupId = (Integer) targetOp - .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); - sink = newBuffer(op, sinkId, new SinkTransitionMetadata( - fromGroupId, toGroupId, true/* isSink */), +// final BOp targetOp = getBOpIndex().get(sinkId); +// final Integer toGroupId = (Integer) targetOp +// .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// final SinkTransitionMetadata stm = new SinkTransitionMetadata( +// fromGroupId, toGroupId, true/* isSink */); + sink = newBuffer(op, sinkId, //null/*stm*/, sinkMessagesOut, stats); } @@ -1156,11 +1160,12 @@ */ // altSink = sink; } else { - final BOp targetOp = getBOpIndex().get(altSinkId); - final Integer toGroupId = (Integer) targetOp - .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); - altSink = newBuffer(op, altSinkId, new SinkTransitionMetadata( - fromGroupId, toGroupId, false/* isSink */), +// final BOp targetOp = getBOpIndex().get(altSinkId); +// final Integer toGroupId = (Integer) targetOp +// .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// final SinkTransitionMetadata stm = new SinkTransitionMetadata( +// fromGroupId, toGroupId, false/* isSink */); + altSink = newBuffer(op, altSinkId, //null/* stm */, altSinkMessagesOut, stats); } @@ -1192,7 +1197,7 @@ */ private IBlockingBuffer<IBindingSet[]> newBuffer(final PipelineOp op, final int sinkId, - final SinkTransitionMetadata sinkTransitionMetadata, +// final SinkTransitionMetadata sinkTransitionMetadata, final AtomicInteger sinkMessagesOut, final BOpStats stats) { // final MultiplexBlockingBuffer<IBindingSet[]> factory = inputBufferMap == null ? null @@ -1218,10 +1223,14 @@ // .getChunkTimeout(), // BufferAnnotations.chunkTimeoutUnit); - return new SinkTransitionBuffer(new HandleChunkBuffer( + return +// new SinkTransitionBuffer( + new HandleChunkBuffer( ChunkedRunningQuery.this, bopId, sinkId, op - .getChunkCapacity(), sinkMessagesOut, stats), - sinkTransitionMetadata); + .getChunkCapacity(), sinkMessagesOut, stats) +// , +// sinkTransitionMetadata) + ; } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/QueryEngine.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/QueryEngine.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/QueryEngine.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -52,7 +52,7 @@ import com.bigdata.bop.BOpUtility; import com.bigdata.bop.IBindingSet; import com.bigdata.bop.PipelineOp; -import com.bigdata.bop.bindingSet.HashBindingSet; +import com.bigdata.bop.bindingSet.ListBindingSet; import com.bigdata.bop.fed.QueryEngineFactory; import com.bigdata.btree.BTree; import com.bigdata.btree.IndexSegment; @@ -798,7 +798,7 @@ return eval(queryId, (PipelineOp) op, new LocalChunkMessage<IBindingSet>(this/* queryEngine */, queryId, startId, -1 /* partitionId */, - newBindingSetIterator(new HashBindingSet()))); + newBindingSetIterator(new ListBindingSet()))); } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionBuffer.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionBuffer.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionBuffer.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -34,6 +34,8 @@ /** * Delegation pattern handles the {@link SinkTransitionMetadata}. + * + * @deprecated along with {@link SinkTransitionMetadata} */ class SinkTransitionBuffer implements IBlockingBuffer<IBindingSet[]> { Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionMetadata.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionMetadata.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/SinkTransitionMetadata.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -53,10 +53,10 @@ * * @todo Unit tests of this class in isolation. * - * @todo It appears that this design can not be made to satisfy SPARQL optional - * group semantics. Therefore, we may be able to drop this class, support - * for it in the {@link ChunkedRunningQuery} and support for the symbol - * table stack in {@link IBindingSet}. + * @deprecated It appears that this design can not be made to satisfy SPARQL + * optional group semantics. Therefore, we may be able to drop this + * class, support for it in the {@link ChunkedRunningQuery} and + * support for the symbol table stack in {@link IBindingSet}. */ class SinkTransitionMetadata { @@ -91,24 +91,25 @@ * The binding set. */ public void handleBindingSet(final IBindingSet bset) { - if (fromGroupId == null) { - if (toGroupId == null) - return; - // Transition from no group to some group. - bset.push(); - return; - } else { - if (toGroupId == null) - // Transition from a group to no group. - bset.pop(isSink/* save */); - else if (toGroupId.equals(fromGroupId)) { - // NOP (transition to the same group) - } else { - // Transition to a different group. - bset.pop(isSink/* save */); - bset.push(); - } - } +// if (fromGroupId == null) { +// if (toGroupId == null) +// return; +// // Transition from no group to some group. +// bset.push(); +// return; +// } else { +// if (toGroupId == null) +// // Transition from a group to no group. +// bset.pop(isSink/* save */); +// else if (toGroupId.equals(fromGroupId)) { +// // NOP (transition to the same group) +// } else { +// // Transition to a different group. +// bset.pop(isSink/* save */); +// bset.push(); +// } +// } + throw new UnsupportedOperationException(); } } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/StandaloneChainedRunningQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/StandaloneChainedRunningQuery.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/StandaloneChainedRunningQuery.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -622,30 +622,33 @@ */ sinkId = BOpUtility.getEffectiveDefaultSink(bop, p); - { - // altSink (null when not specified). - final Integer altSinkId = (Integer) op - .getProperty(PipelineOp.Annotations.ALT_SINK_REF); - final Integer altSinkGroup = (Integer) op - .getProperty(PipelineOp.Annotations.ALT_SINK_GROUP); - if (altSinkId != null && altSinkGroup != null) - throw new RuntimeException( - "Annotations are mutually exclusive: " - + PipelineOp.Annotations.ALT_SINK_REF - + " and " - + PipelineOp.Annotations.ALT_SINK_GROUP); - if (altSinkGroup != null) { - /* - * Lookup the first pipeline op in the conditional binding - * group and use its bopId as the altSinkId. - */ - this.altSinkId = BOpUtility.getFirstBOpIdForConditionalGroup( - getQuery(), altSinkGroup); - } else { - // MAY be null. - this.altSinkId = altSinkId; - } - } + // altSink (null when not specified). + altSinkId = (Integer) op + .getProperty(PipelineOp.Annotations.ALT_SINK_REF); +// { +// // altSink (null when not specified). +// final Integer altSinkId = (Integer) op +// .getProperty(PipelineOp.Annotations.ALT_SINK_REF); +// final Integer altSinkGroup = (Integer) op +// .getProperty(PipelineOp.Annotations.ALT_SINK_GROUP); +// if (altSinkId != null && altSinkGroup != null) +// throw new RuntimeException( +// "Annotations are mutually exclusive: " +// + PipelineOp.Annotations.ALT_SINK_REF +// + " and " +// + PipelineOp.Annotations.ALT_SINK_GROUP); +// if (altSinkGroup != null) { +// /* +// * Lookup the first pipeline op in the conditional binding +// * group and use its bopId as the altSinkId. +// */ +// this.altSinkId = BOpUtility.getFirstBOpIdForConditionalGroup( +// getQuery(), altSinkGroup); +// } else { +// // MAY be null. +// this.altSinkId = altSinkId; +// } +// } if (altSinkId != null && !getBOpIndex().containsKey(altSinkId)) throw new NoSuchBOpException(altSinkId); @@ -683,19 +686,20 @@ } assert stats != null; - // The groupId (if any) for this operator. - final Integer fromGroupId = (Integer) op - .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// // The groupId (if any) for this operator. +// final Integer fromGroupId = (Integer) op +// .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); if (p == null) { sink = getQueryBuffer(); } else { - final BOp targetOp = getBOpIndex().get(sinkId); - final Integer toGroupId = (Integer) targetOp - .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); - sink = newBuffer(op, sinkId, new SinkTransitionMetadata( - fromGroupId, toGroupId, true/* isSink */), - /*sinkMessagesOut,*/ stats); +// final BOp targetOp = getBOpIndex().get(sinkId); +// final Integer toGroupId = (Integer) targetOp +// .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// final SinkTransitionMetadata stm = new SinkTransitionMetadata( +// fromGroupId, toGroupId, true/* isSink */); + sink = newBuffer(op, sinkId, //null/* stm */, + /* sinkMessagesOut, */stats); } if (altSinkId == null) { @@ -708,11 +712,12 @@ */ // altSink = sink; } else { - final BOp targetOp = getBOpIndex().get(altSinkId); - final Integer toGroupId = (Integer) targetOp - .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); - altSink = newBuffer(op, altSinkId, new SinkTransitionMetadata( - fromGroupId, toGroupId, false/* isSink */), +// final BOp targetOp = getBOpIndex().get(altSinkId); +// final Integer toGroupId = (Integer) targetOp +// .getProperty(PipelineOp.Annotations.CONDITIONAL_GROUP); +// final SinkTransitionMetadata stm = new SinkTransitionMetadata( +// fromGroupId, toGroupId, false/* isSink */); + altSink = newBuffer(op, altSinkId, //null/*stm*/, /*altSinkMessagesOut,*/ stats); } @@ -744,7 +749,7 @@ */ private IBlockingBuffer<IBindingSet[]> newBuffer(final PipelineOp op, final int sinkId, - final SinkTransitionMetadata sinkTransitionMetadata, +// final SinkTransitionMetadata sinkTransitionMetadata, /* final AtomicInteger sinkMessagesOut, */final BOpStats stats) { final MultiplexBlockingBuffer<IBindingSet[]> factory = operatorQueues @@ -760,9 +765,11 @@ * operator writing on this sink. Wrap that to handle the sink * transition metadata. */ - return new SinkTransitionBuffer( + return //new SinkTransitionBuffer( new OutputStatsBuffer<IBindingSet[]>(factory.newInstance(), - stats), sinkTransitionMetadata); + stats) + //, sinkTransitionMetadata) + ; } Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/TestBOpUtility.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/TestBOpUtility.java 2011-01-03 18:25:34 UTC (rev 4048) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/TestBOpUtility.java 2011-01-04 00:23:40 UTC (rev 4049) @@ -586,119 +586,119 @@ } - /** - * A conditional join group: - * - * <pre> - * (a b) - * optional { - * (b c) - * (c d) - * } - * </pre> - * - * where the groupId for the optional join group is ONE (1). The test should - * locate the first {@link PipelineJoin} in that join group, which is the - * one reading on the <code>(b c)</code> access path. - */ - public void test_getFirstBOpIdForConditionalGroup() { - - final String namespace = "kb"; - - final int startId = 1; // - final int joinId1 = 2; // : base join group. - final int predId1 = 3; // (a b) - final int joinId2 = 4; // : joinGroup1 - final int predId2 = 5; // (b c) - final int joinId3 = 6; // : joinGroup1 - final int predId3 = 7; // (c d) - final int sliceId = 8; // - - final IVariable<?> a = Var.var("a"); - final IVariable<?> b = Var.var("b"); - final IVariable<?> c = Var.var("c"); - final IVariable<?> d = Var.var("d"); - - final Integer joinGroup1 = Integer.valueOf(1); - - final PipelineOp startOp = new StartOp(new BOp[] {}, - NV.asMap(new NV[] {// - new NV(Predicate.Annotations.BOP_ID, startId),// - new NV(SliceOp.Annotations.EVALUATION_CONTEXT, - BOpEvaluationContext.CONTROLLER),// - })); - - final Predicate<?> pred1Op = new Predicate<E>( - new IVariableOrConstant[] { a, b }, NV - .asMap(new NV[] {// - new NV(Predicate.Annotations.RELATION_NAME, - new String[] { namespace }),// - new NV(Predicate.Annotations.BOP_ID, predId1),// - new NV(Annotations.TIMESTAMP, ITx.READ_COMMITTED),// - })); - - final Predicate<?> pred2Op = new Predicate<E>( - new IVariableOrConstant[] { b, c }, NV - .asMap(new NV[] {// - new NV(Predicate.Annotations.RELATION_NAME, - new String[] { namespace }),// - new NV(Predicate.Annotations.BOP_ID, predId2),// - new NV(Annotations.TIMESTAMP, ITx.READ_COMMITTED),// - })); - - final Predicate<?> pred3Op = new Predicate<E>( - new IVariableOrConstant[] { c, d }, NV - .asMap(new NV[] {// - new NV(Predicate.Annotations.RELATION_NAME, - new String[] { namespace }),// - new NV(Predicate.Annotations.BOP_ID, predId3),// - new NV(Annotations.TIMESTAMP, ITx.READ_COMMITTED),// - })); - - final PipelineOp join1Op = new PipelineJoin<E>(// - new BOp[]{startOp},// - new NV(Predicate.Annotations.BOP_ID, joinId1),// - new NV(PipelineJoin.Annotations.PREDICATE,pred1Op)); - - final PipelineOp join2Op = new PipelineJoin<E>(// - new BOp[] { join1Op },// - new NV(Predicate.Annotations.BOP_ID, joinId2),// - new NV(PipelineOp.Annotations.CONDITIONAL_GROUP, joinGroup1),// - new NV(PipelineJoin.Annotations.PREDICATE, pred2Op),// - // join is optional. - new NV(PipelineJoin.Annotations.OPTIONAL, true),// - // optional target is the same as the default target. - new NV(PipelineOp.Annotations.ALT_SINK_REF, sliceId)); - - final PipelineOp join3Op = ... [truncated message content] |