From: <mrp...@us...> - 2013-04-26 18:26:26
|
Revision: 7085 http://bigdata.svn.sourceforge.net/bigdata/?rev=7085&view=rev Author: mrpersonick Date: 2013-04-26 18:26:18 +0000 (Fri, 26 Apr 2013) Log Message: ----------- added a "project in" var set to the hash index and graph pattern group so that we can decide what variables to project into a hash join Modified Paths: -------------- branches/BIGDATA_RELEASE_1_2_0/bigdata/src/java/com/bigdata/bop/join/HashJoinAnnotations.java branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GraphPatternGroup.java branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSubGroupJoinVarOptimizer.java branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestNegation.java Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata/src/java/com/bigdata/bop/join/HashJoinAnnotations.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata/src/java/com/bigdata/bop/join/HashJoinAnnotations.java 2013-04-26 16:53:48 UTC (rev 7084) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata/src/java/com/bigdata/bop/join/HashJoinAnnotations.java 2013-04-26 18:26:18 UTC (rev 7085) @@ -84,4 +84,13 @@ */ long DEFAULT_NO_JOIN_VARS_LIMIT = Long.MAX_VALUE; + + /** + * The {@link IVariable[]} specifying what variables need to flow into + * the right operator of the hash join (i.e. what visible variables inside + * the right operator have appeared previously in the query and may be + * bound). + */ + String PROJECT_IN_VARS = HashJoinAnnotations.class.getName() + ".projectInVars"; + } Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GraphPatternGroup.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GraphPatternGroup.java 2013-04-26 16:53:48 UTC (rev 7084) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/GraphPatternGroup.java 2013-04-26 18:26:18 UTC (rev 7085) @@ -63,6 +63,15 @@ */ String JOIN_VARS = "joinVars"; + /** + * An {@link IVariable}[] of the variables that are used by the + * group and that have already appeared in the query up to this point + * (and thus may be bound and should be projected into the group). + * + * @see ASTSubGroupJoinVarOptimizer + */ + String PROJECT_IN_VARS = "projectInVars"; + } /** @@ -102,4 +111,17 @@ setProperty(Annotations.JOIN_VARS, joinVars); } + /** + * The variables that should be projected into the group. + * + * @see Annotations#PROJECT_IN_VARS + */ + public IVariable<?>[] getProjectInVars() { + return (IVariable[]) getProperty(Annotations.PROJECT_IN_VARS); + } + + public void setProjectInVars(final IVariable<?>[] projectInVars) { + setProperty(Annotations.PROJECT_IN_VARS, projectInVars); + } + } Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java 2013-04-26 16:53:48 UTC (rev 7084) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/eval/AST2BOpUtility.java 2013-04-26 18:26:18 UTC (rev 7085) @@ -3417,6 +3417,7 @@ new NV(HTreeHashIndexOp.Annotations.RELATION_NAME, new String[]{ctx.getLexiconNamespace()}),// new NV(HTreeHashIndexOp.Annotations.JOIN_TYPE, joinType),// new NV(HTreeHashIndexOp.Annotations.JOIN_VARS, joinVars),// + new NV(HTreeHashIndexOp.Annotations.PROJECT_IN_VARS, subgroup.getProjectInVars()),// new NV(HTreeHashIndexOp.Annotations.SELECT, selectVars),// new NV(HTreeHashIndexOp.Annotations.NAMED_SET_REF, namedSolutionSet)// ); @@ -3430,6 +3431,7 @@ new NV(PipelineOp.Annotations.SHARED_STATE, true),// live stats. new NV(JVMHashIndexOp.Annotations.JOIN_TYPE, joinType),// new NV(JVMHashIndexOp.Annotations.JOIN_VARS, joinVars),// + new NV(HTreeHashIndexOp.Annotations.PROJECT_IN_VARS, subgroup.getProjectInVars()),// new NV(JVMHashIndexOp.Annotations.SELECT, selectVars),// new NV(JVMHashIndexOp.Annotations.NAMED_SET_REF, namedSolutionSet)// ); Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSubGroupJoinVarOptimizer.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSubGroupJoinVarOptimizer.java 2013-04-26 16:53:48 UTC (rev 7084) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/java/com/bigdata/rdf/sparql/ast/optimizers/ASTSubGroupJoinVarOptimizer.java 2013-04-26 18:26:18 UTC (rev 7085) @@ -27,6 +27,7 @@ package com.bigdata.rdf.sparql.ast.optimizers; +import java.util.Arrays; import java.util.LinkedHashSet; import java.util.Set; @@ -126,7 +127,35 @@ final IVariable[] joinVars = boundByGroup.toArray(new IVariable[0]); group.setJoinVars(joinVars); + + /* + * The variables used by the group and its children, including + * filters. + */ + final Set<IVariable<?>> usedByGroup = sa + .getSpannedVariables(group, + true /*filters*/, new LinkedHashSet<IVariable<?>>()); + /* + * Find the set of variables which have appeared in the query and + * may be bound by the time the group is evaluated. + */ + final Set<IVariable<?>> maybeIncomingBindings = sa + .getMaybeIncomingBindings( + (GraphPatternGroup<?>) group, + new LinkedHashSet<IVariable<?>>()); + + /* + * Retain the variables used by the group that have already + * appeared previously in the query up to this point. + */ + usedByGroup.retainAll(maybeIncomingBindings); + + @SuppressWarnings("rawtypes") + final IVariable[] projectInVars = usedByGroup.toArray(new IVariable[0]); + + group.setProjectInVars(projectInVars); + } /* Modified: branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestNegation.java =================================================================== --- branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestNegation.java 2013-04-26 16:53:48 UTC (rev 7084) +++ branches/BIGDATA_RELEASE_1_2_0/bigdata-rdf/src/test/com/bigdata/rdf/sparql/ast/eval/TestNegation.java 2013-04-26 18:26:18 UTC (rev 7085) @@ -33,6 +33,7 @@ import org.openrdf.model.vocabulary.RDF; import com.bigdata.bop.IVariable; +import com.bigdata.bop.Var; import com.bigdata.rdf.model.BigdataURI; import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.model.BigdataValueFactory; @@ -704,6 +705,7 @@ // // group.setJoinVars(new IVariable[]{Var.var("ar")}); group.setJoinVars(new IVariable[]{}); + group.setProjectInVars(new IVariable[]{}); } // end group This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |