http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java index a24b87b..359cdb3 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java @@ -48,7 +48,7 @@ import org.apache.hyracks.api.dataflow.value.IBinaryComparator; import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory; import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory; import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFamily; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory; import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider; import org.apache.hyracks.api.dataflow.value.ITuplePairComparator; @@ -110,7 +110,7 @@ public class HybridHashJoinPOperator extends AbstractHashJoinPOperator { @Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) - throws AlgebricksException { + throws AlgebricksException { int[] keysLeft = JobGenHelper.variablesToFieldIndexes(keysLeftBranch, inputSchemas[0]); int[] keysRight = JobGenHelper.variablesToFieldIndexes(keysRightBranch, inputSchemas[1]); IVariableTypeEnvironment env = context.getTypeEnvironment(op); @@ -128,14 +128,13 @@ public class HybridHashJoinPOperator extends AbstractHashJoinPOperator { IPredicateEvaluatorFactoryProvider predEvaluatorFactoryProvider = context .getPredicateEvaluatorFactoryProvider(); - IPredicateEvaluatorFactory predEvaluatorFactory = (predEvaluatorFactoryProvider == null ? null - : predEvaluatorFactoryProvider.getPredicateEvaluatorFactory(keysLeft, keysRight)); + IPredicateEvaluatorFactory predEvaluatorFactory = predEvaluatorFactoryProvider == null ? null + : predEvaluatorFactoryProvider.getPredicateEvaluatorFactory(keysLeft, keysRight); RecordDescriptor recDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), propagatedSchema, context); IOperatorDescriptorRegistry spec = builder.getJobSpec(); - IOperatorDescriptor opDesc = null; - + IOperatorDescriptor opDesc; boolean optimizedHashJoin = true; for (IBinaryHashFunctionFamily family : hashFunFamilies) { if (family == null) { @@ -144,65 +143,12 @@ public class HybridHashJoinPOperator extends AbstractHashJoinPOperator { } } - if (!optimizedHashJoin) { - try { - switch (kind) { - case INNER: { - opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), - maxInputBuildSizeInFrames, aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, - hashFunFactories, comparatorFactories, recDescriptor, predEvaluatorFactory, false, null); - break; - } - case LEFT_OUTER: { - INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()]; - for (int j = 0; j < nullWriterFactories.length; j++) { - nullWriterFactories[j] = context.getNullWriterFactory(); - } - opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), - maxInputBuildSizeInFrames, aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, - hashFunFactories, comparatorFactories, recDescriptor, predEvaluatorFactory, true, - nullWriterFactories); - break; - } - default: { - throw new NotImplementedException(); - } - } - } catch (HyracksDataException e) { - throw new AlgebricksException(e); - } + if (optimizedHashJoin) { + opDesc = generateOptimizedHashJoinRuntime(context, inputSchemas, keysLeft, keysRight, hashFunFamilies, + comparatorFactories, predEvaluatorFactory, recDescriptor, spec); } else { - try { - switch (kind) { - case INNER: { - opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), - maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies, - comparatorFactories, recDescriptor, - new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight), - new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft), - predEvaluatorFactory); - break; - } - case LEFT_OUTER: { - INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()]; - for (int j = 0; j < nullWriterFactories.length; j++) { - nullWriterFactories[j] = context.getNullWriterFactory(); - } - opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), - maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies, - comparatorFactories, recDescriptor, - new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight), - new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft), - predEvaluatorFactory, true, nullWriterFactories); - break; - } - default: { - throw new NotImplementedException(); - } - } - } catch (HyracksDataException e) { - throw new AlgebricksException(e); - } + opDesc = generateHashJoinRuntime(context, inputSchemas, keysLeft, keysRight, hashFunFactories, + comparatorFactories, predEvaluatorFactory, recDescriptor, spec); } contributeOpDesc(builder, (AbstractLogicalOperator) op, opDesc); @@ -212,30 +158,101 @@ public class HybridHashJoinPOperator extends AbstractHashJoinPOperator { builder.contributeGraphEdge(src2, 0, op, 1); } + private IOperatorDescriptor generateHashJoinRuntime(JobGenContext context, IOperatorSchema[] inputSchemas, + int[] keysLeft, int[] keysRight, IBinaryHashFunctionFactory[] hashFunFactories, + IBinaryComparatorFactory[] comparatorFactories, IPredicateEvaluatorFactory predEvaluatorFactory, + RecordDescriptor recDescriptor, IOperatorDescriptorRegistry spec) throws AlgebricksException { + IOperatorDescriptor opDesc; + try { + switch (kind) { + case INNER: + opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), maxInputBuildSizeInFrames, + aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, hashFunFactories, + comparatorFactories, recDescriptor, predEvaluatorFactory, false, null); + break; + case LEFT_OUTER: + IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[inputSchemas[1] + .getSize()]; + for (int j = 0; j < nonMatchWriterFactories.length; j++) { + nonMatchWriterFactories[j] = context.getNullWriterFactory(); + } + opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), maxInputBuildSizeInFrames, + aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, hashFunFactories, + comparatorFactories, recDescriptor, predEvaluatorFactory, true, nonMatchWriterFactories); + break; + default: + throw new NotImplementedException(); + } + } catch (HyracksDataException e) { + throw new AlgebricksException(e); + } + return opDesc; + } + + private IOperatorDescriptor generateOptimizedHashJoinRuntime(JobGenContext context, IOperatorSchema[] inputSchemas, + int[] keysLeft, int[] keysRight, IBinaryHashFunctionFamily[] hashFunFamilies, + IBinaryComparatorFactory[] comparatorFactories, IPredicateEvaluatorFactory predEvaluatorFactory, + RecordDescriptor recDescriptor, IOperatorDescriptorRegistry spec) throws AlgebricksException { + IOperatorDescriptor opDesc; + try { + switch (kind) { + case INNER: + opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), + maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies, + comparatorFactories, recDescriptor, + new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight), + new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft), + predEvaluatorFactory); + break; + case LEFT_OUTER: + IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[inputSchemas[1] + .getSize()]; + for (int j = 0; j < nonMatchWriterFactories.length; j++) { + nonMatchWriterFactories[j] = context.getNullWriterFactory(); + } + opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), + maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies, + comparatorFactories, recDescriptor, + new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight), + new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft), + predEvaluatorFactory, true, nonMatchWriterFactories); + break; + default: + throw new NotImplementedException(); + } + } catch (HyracksDataException e) { + throw new AlgebricksException(e); + } + return opDesc; + } + @Override protected List<ILocalStructuralProperty> deliveredLocalProperties(ILogicalOperator op, IOptimizationContext context) throws AlgebricksException { - List<ILocalStructuralProperty> deliveredLocalProperties = new ArrayList<ILocalStructuralProperty>(); + List<ILocalStructuralProperty> deliveredLocalProperties = new ArrayList<>(); // Inner join can kick off the "role reversal" optimization, which can kill data properties for the probe side. - if (kind == JoinKind.LEFT_OUTER) { - AbstractLogicalOperator probeOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); - IPhysicalPropertiesVector probeSideProperties = probeOp.getPhysicalOperator().getDeliveredProperties(); - List<ILocalStructuralProperty> probeSideLocalProperties = probeSideProperties.getLocalProperties(); - if (probeSideLocalProperties != null) { - // The local grouping property in the probe side will be maintained - // and the local ordering property in the probe side will be turned into a local grouping property - // if the grouping variables (or sort columns) in the local property contain all the join key variables - // for the left branch: - // 1. in case spilling is not kicked off, the ordering property is maintained and hence local grouping property is maintained. - // 2. if spilling is kicked off, the grouping property is still maintained though the ordering property is destroyed. - for (ILocalStructuralProperty property : probeSideLocalProperties) { - Set<LogicalVariable> groupingVars = new ListSet<LogicalVariable>(); - Set<LogicalVariable> leftBranchVars = new ListSet<LogicalVariable>(); - property.getVariables(groupingVars); - leftBranchVars.addAll(getKeysLeftBranch()); - if (groupingVars.containsAll(leftBranchVars)) { - deliveredLocalProperties.add(new LocalGroupingProperty(groupingVars)); - } + if (kind != JoinKind.LEFT_OUTER) { + return deliveredLocalProperties; + } + AbstractLogicalOperator probeOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); + IPhysicalPropertiesVector probeSideProperties = probeOp.getPhysicalOperator().getDeliveredProperties(); + List<ILocalStructuralProperty> probeSideLocalProperties = probeSideProperties.getLocalProperties(); + if (probeSideLocalProperties != null) { + // The local grouping property in the probe side will be maintained + // and the local ordering property in the probe side will be turned into a local grouping property + // if the grouping variables (or sort columns) in the local property contain all the join key variables + // for the left branch: + // 1. in case spilling is not kicked off, the ordering property is maintained and hence local grouping + // property is maintained. + // 2. if spilling is kicked off, the grouping property is still maintained though the ordering property + // is destroyed. + for (ILocalStructuralProperty property : probeSideLocalProperties) { + Set<LogicalVariable> groupingVars = new ListSet<>(); + Set<LogicalVariable> leftBranchVars = new ListSet<>(); + property.getVariables(groupingVars); + leftBranchVars.addAll(getKeysLeftBranch()); + if (groupingVars.containsAll(leftBranchVars)) { + deliveredLocalProperties.add(new LocalGroupingProperty(groupingVars)); } } }
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java index a92bd70..49a087f 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java @@ -40,7 +40,7 @@ import org.apache.hyracks.algebricks.data.IBinaryComparatorFactoryProvider; import org.apache.hyracks.api.dataflow.IOperatorDescriptor; import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory; import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory; import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider; import org.apache.hyracks.api.dataflow.value.RecordDescriptor; @@ -108,7 +108,7 @@ public class InMemoryHashJoinPOperator extends AbstractHashJoinPOperator { break; } case LEFT_OUTER: { - INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()]; + IMissingWriterFactory[] nullWriterFactories = new IMissingWriterFactory[inputSchemas[1].getSize()]; for (int j = 0; j < nullWriterFactories.length; j++) { nullWriterFactories[j] = context.getNullWriterFactory(); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java index 99acddb..c2b78a0 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java @@ -44,7 +44,7 @@ import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; import org.apache.hyracks.api.comm.IFrameTupleAccessor; import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.dataflow.IOperatorDescriptor; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.ITuplePairComparator; import org.apache.hyracks.api.dataflow.value.ITuplePairComparatorFactory; import org.apache.hyracks.api.dataflow.value.RecordDescriptor; @@ -145,7 +145,7 @@ public class NLJoinPOperator extends AbstractJoinPOperator { break; } case LEFT_OUTER: { - INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()]; + IMissingWriterFactory[] nullWriterFactories = new IMissingWriterFactory[inputSchemas[1].getSize()]; for (int j = 0; j < nullWriterFactories.length; j++) { nullWriterFactories[j] = context.getNullWriterFactory(); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java index 9fc0dd4..a67efd6 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java @@ -40,7 +40,7 @@ import org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext; import org.apache.hyracks.algebricks.core.jobgen.impl.JobGenHelper; import org.apache.hyracks.algebricks.runtime.base.AlgebricksPipeline; import org.apache.hyracks.algebricks.runtime.operators.meta.SubplanRuntimeFactory; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.RecordDescriptor; public class SubplanPOperator extends AbstractPhysicalOperator { @@ -94,7 +94,7 @@ public class SubplanPOperator extends AbstractPhysicalOperator { AlgebricksPipeline np = subplans[0]; RecordDescriptor inputRecordDesc = JobGenHelper.mkRecordDescriptor( context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas[0], context); - INullWriterFactory[] nullWriterFactories = new INullWriterFactory[np.getOutputWidth()]; + IMissingWriterFactory[] nullWriterFactories = new IMissingWriterFactory[np.getOutputWidth()]; for (int i = 0; i < nullWriterFactories.length; i++) { nullWriterFactories[i] = context.getNullWriterFactory(); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java index e011a7f..061b272 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java @@ -22,7 +22,7 @@ import java.util.List; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable; -import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer; +import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; import org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer; @@ -30,7 +30,7 @@ public abstract class TypePropagationPolicy { public static final TypePropagationPolicy ALL = new TypePropagationPolicy() { @Override - public Object getVarType(LogicalVariable var, INullableTypeComputer ntc, + public Object getVarType(LogicalVariable var, IMissableTypeComputer ntc, List<LogicalVariable> nonNullVariableList, List<List<LogicalVariable>> correlatedNullableVariableLists, ITypeEnvPointer... typeEnvs) throws AlgebricksException { for (ITypeEnvPointer p : typeEnvs) { @@ -41,7 +41,7 @@ public abstract class TypePropagationPolicy { } Object t = env.getVarType(var, nonNullVariableList, correlatedNullableVariableLists); if (t != null) { - if (ntc != null && ntc.canBeNull(t)) { + if (ntc != null && ntc.canBeMissing(t)) { for (List<LogicalVariable> list : correlatedNullableVariableLists) { if (list.contains(var)) { for (LogicalVariable v : list) { @@ -62,41 +62,46 @@ public abstract class TypePropagationPolicy { public static final TypePropagationPolicy LEFT_OUTER = new TypePropagationPolicy() { @Override - public Object getVarType(LogicalVariable var, INullableTypeComputer ntc, + public Object getVarType(LogicalVariable var, IMissableTypeComputer ntc, List<LogicalVariable> nonNullVariableList, List<List<LogicalVariable>> correlatedNullableVariableLists, ITypeEnvPointer... typeEnvs) throws AlgebricksException { int n = typeEnvs.length; for (int i = 0; i < n; i++) { Object t = typeEnvs[i].getTypeEnv().getVarType(var, nonNullVariableList, correlatedNullableVariableLists); - if (t != null) { - if (i == 0) { // outer branch - return t; - } else { // inner branch - boolean nonNullVarIsProduced = false; - for (LogicalVariable v : nonNullVariableList) { - if (v == var) { - nonNullVarIsProduced = true; - break; - } - if (typeEnvs[i].getTypeEnv().getVarType(v) != null) { - nonNullVarIsProduced = true; - break; - } - } - if (nonNullVarIsProduced) { - return t; - } else { - return ntc.makeNullableType(t); - } + if (t == null) { + continue; + } + if (i == 0) { // outer branch + return t; + } + + // inner branch + boolean nonMissingVarIsProduced = false; + for (LogicalVariable v : nonNullVariableList) { + boolean toBreak = false; + if (v == var) { + nonMissingVarIsProduced = true; + toBreak = true; + } else if (typeEnvs[i].getTypeEnv().getVarType(v) != null) { + nonMissingVarIsProduced = true; + toBreak = true; } + if (toBreak) { + break; + } + } + if (nonMissingVarIsProduced) { + return t; + } else { + return ntc.makeMissableType(t); } } return null; } }; - public abstract Object getVarType(LogicalVariable var, INullableTypeComputer ntc, + public abstract Object getVarType(LogicalVariable var, IMissableTypeComputer ntc, List<LogicalVariable> nonNullVariableList, List<List<LogicalVariable>> correlatedNullableVariableLists, ITypeEnvPointer... typeEnvs) throws AlgebricksException; } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java index 4d85111..7b77083 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java @@ -21,7 +21,7 @@ package org.apache.hyracks.algebricks.core.algebra.typing; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer; -import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer; +import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; @@ -32,7 +32,7 @@ public interface ITypingContext { public IExpressionTypeComputer getExpressionTypeComputer(); - public INullableTypeComputer getNullableTypeComputer(); + public IMissableTypeComputer getMissableTypeComputer(); public IMetadataProvider<?, ?> getMetadataProvider(); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java index 076992f..a1be35d 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java @@ -24,7 +24,7 @@ import java.util.List; import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer; -import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer; +import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer; import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; import org.apache.hyracks.algebricks.core.algebra.properties.TypePropagationPolicy; @@ -32,7 +32,7 @@ public class PropagatingTypeEnvironment extends AbstractTypeEnvironment { private final TypePropagationPolicy policy; - private final INullableTypeComputer nullableTypeComputer; + private final IMissableTypeComputer nullableTypeComputer; private final ITypeEnvPointer[] envPointers; @@ -41,7 +41,7 @@ public class PropagatingTypeEnvironment extends AbstractTypeEnvironment { private final List<List<LogicalVariable>> correlatedNullableVariableLists = new ArrayList<List<LogicalVariable>>(); public PropagatingTypeEnvironment(IExpressionTypeComputer expressionTypeComputer, - INullableTypeComputer nullableTypeComputer, IMetadataProvider<?, ?> metadataProvider, + IMissableTypeComputer nullableTypeComputer, IMetadataProvider<?, ?> metadataProvider, TypePropagationPolicy policy, ITypeEnvPointer[] envPointers) { super(expressionTypeComputer, metadataProvider); this.nullableTypeComputer = nullableTypeComputer; http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java index e78db9b..353a782 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java @@ -210,7 +210,7 @@ public class OperatorPropertiesUtil { } } - public static boolean isNullTest(AbstractLogicalOperator op) { + public static boolean isMissingTest(AbstractLogicalOperator op) { if (op.getOperatorTag() != LogicalOperatorTag.SELECT) { return false; } @@ -231,7 +231,7 @@ public class OperatorPropertiesUtil { return false; } AbstractFunctionCallExpression f2 = (AbstractFunctionCallExpression) a1; - if (!f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_NULL)) { + if (!f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_MISSING)) { return false; } return true; http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java index 4b94dcf..caa46c8 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java @@ -29,7 +29,6 @@ import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer; -import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IPartialAggregationTypeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; @@ -44,7 +43,7 @@ import org.apache.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider; import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider; import org.apache.hyracks.algebricks.data.ISerializerDeserializerProvider; import org.apache.hyracks.algebricks.data.ITypeTraitProvider; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider; public class JobGenContext { @@ -57,7 +56,7 @@ public class JobGenContext { private final IPrinterFactoryProvider printerFactoryProvider; private final ITypeTraitProvider typeTraitProvider; private final IMetadataProvider<?, ?> metadataProvider; - private final INullWriterFactory nullWriterFactory; + private final IMissingWriterFactory nonMatchWriterFactory; private final INormalizedKeyComputerFactoryProvider normalizedKeyComputerFactoryProvider; private final Object appContext; private final IBinaryBooleanInspectorFactory booleanInspectorFactory; @@ -79,11 +78,10 @@ public class JobGenContext { IBinaryComparatorFactoryProvider comparatorFactoryProvider, ITypeTraitProvider typeTraitProvider, IBinaryBooleanInspectorFactory booleanInspectorFactory, IBinaryIntegerInspectorFactory integerInspectorFactory, IPrinterFactoryProvider printerFactoryProvider, - INullWriterFactory nullWriterFactory, + IMissingWriterFactory nullWriterFactory, INormalizedKeyComputerFactoryProvider normalizedKeyComputerFactoryProvider, IExpressionRuntimeProvider expressionRuntimeProvider, IExpressionTypeComputer expressionTypeComputer, - INullableTypeComputer nullableTypeComputer, ITypingContext typingContext, - IExpressionEvalSizeComputer expressionEvalSizeComputer, + ITypingContext typingContext, IExpressionEvalSizeComputer expressionEvalSizeComputer, IPartialAggregationTypeComputer partialAggregationTypeComputer, IPredicateEvaluatorFactoryProvider predEvaluatorFactoryProvider, int frameSize, AlgebricksAbsolutePartitionConstraint clusterLocations) { @@ -100,7 +98,7 @@ public class JobGenContext { this.printerFactoryProvider = printerFactoryProvider; this.clusterLocations = clusterLocations; this.normalizedKeyComputerFactoryProvider = normalizedKeyComputerFactoryProvider; - this.nullWriterFactory = nullWriterFactory; + this.nonMatchWriterFactory = nullWriterFactory; this.expressionRuntimeProvider = expressionRuntimeProvider; this.expressionTypeComputer = expressionTypeComputer; this.typingContext = typingContext; @@ -185,8 +183,8 @@ public class JobGenContext { return expressionTypeComputer.getType(expr, typingContext.getMetadataProvider(), env); } - public INullWriterFactory getNullWriterFactory() { - return nullWriterFactory; + public IMissingWriterFactory getNullWriterFactory() { + return nonMatchWriterFactory; } public INormalizedKeyComputerFactoryProvider getNormalizedKeyComputerFactoryProvider() { http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java index 154f4a1..86f61ad 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java @@ -33,7 +33,7 @@ import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory; -import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer; +import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableEvalSizeEnvironment; import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; @@ -79,13 +79,13 @@ public class AlgebricksOptimizationContext implements IOptimizationContext { protected final Map<ILogicalOperator, ILogicalPropertiesVector> logicalProps = new HashMap<ILogicalOperator, ILogicalPropertiesVector>(); private final IExpressionTypeComputer expressionTypeComputer; - private final INullableTypeComputer nullableTypeComputer; + private final IMissableTypeComputer nullableTypeComputer; private final INodeDomain defaultNodeDomain; private final LogicalOperatorPrettyPrintVisitor prettyPrintVisitor; public AlgebricksOptimizationContext(int varCounter, IExpressionEvalSizeComputer expressionEvalSizeComputer, IMergeAggregationExpressionFactory mergeAggregationExpressionFactory, - IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer, + IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer nullableTypeComputer, PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations) { this(varCounter, expressionEvalSizeComputer, mergeAggregationExpressionFactory, expressionTypeComputer, nullableTypeComputer, physicalOptimizationConfig, clusterLocations, @@ -94,7 +94,7 @@ public class AlgebricksOptimizationContext implements IOptimizationContext { public AlgebricksOptimizationContext(int varCounter, IExpressionEvalSizeComputer expressionEvalSizeComputer, IMergeAggregationExpressionFactory mergeAggregationExpressionFactory, - IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer, + IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer nullableTypeComputer, PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations, LogicalOperatorPrettyPrintVisitor prettyPrintVisitor) { this.varCounter = varCounter; @@ -281,7 +281,7 @@ public class AlgebricksOptimizationContext implements IOptimizationContext { } @Override - public INullableTypeComputer getNullableTypeComputer() { + public IMissableTypeComputer getMissableTypeComputer() { return nullableTypeComputer; } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java index ce77942..0e5cf9c 100644 --- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java +++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java @@ -23,12 +23,12 @@ import org.apache.hyracks.algebricks.core.algebra.base.IOptimizationContext; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer; import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory; -import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer; +import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer; public interface IOptimizationContextFactory { public IOptimizationContext createOptimizationContext(int varCounter, IExpressionEvalSizeComputer expressionEvalSizeComputer, IMergeAggregationExpressionFactory mergeAggregationExpressionFactory, - IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer, + IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer missableTypeComputer, PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopMissingWriterFactory.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopMissingWriterFactory.java b/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopMissingWriterFactory.java new file mode 100644 index 0000000..5ca8d3b --- /dev/null +++ b/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopMissingWriterFactory.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hyracks.algebricks.data.impl; + +import org.apache.hyracks.api.dataflow.value.IMissingWriter; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; +import org.apache.hyracks.api.exceptions.HyracksDataException; + +public class NoopMissingWriterFactory implements IMissingWriterFactory { + + private static final long serialVersionUID = 1L; + public static final NoopMissingWriterFactory INSTANCE = new NoopMissingWriterFactory(); + + private NoopMissingWriterFactory() { + } + + @Override + public IMissingWriter createMissingWriter() { + return out -> writeMissing(); + } + + private static void writeMissing() throws HyracksDataException { + // do nothing + } + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopNullWriterFactory.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopNullWriterFactory.java b/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopNullWriterFactory.java deleted file mode 100644 index 841891a..0000000 --- a/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopNullWriterFactory.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.data.impl; - -import java.io.DataOutput; - -import org.apache.hyracks.api.dataflow.value.INullWriter; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; -import org.apache.hyracks.api.exceptions.HyracksDataException; - -public class NoopNullWriterFactory implements INullWriterFactory { - - private static final long serialVersionUID = 1L; - public static final NoopNullWriterFactory INSTANCE = new NoopNullWriterFactory(); - - private NoopNullWriterFactory() { - } - - @Override - public INullWriter createNullWriter() { - - return new INullWriter() { - - @Override - public void writeNull(DataOutput out) throws HyracksDataException { - // do nothing - } - }; - } - -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java index 278a585..90d5b83 100644 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java +++ b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java @@ -45,6 +45,11 @@ public final class ConstantValue implements IAlgebricksConstantValue { } @Override + public boolean isMissing() { + return false; + } + + @Override public boolean isNull() { return false; } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java index 3ebbea1..44c76e0 100644 --- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java +++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java @@ -169,23 +169,23 @@ public class PushSelectIntoJoinRule implements IAlgebraicRewriteRule { for (int j = 0; j < intersectsBranch.length; j++) { Mutable<ILogicalOperator> branch = branchIter.next(); boolean inter = intersectsBranch[j]; - if (inter) { - if (j > 0 && isLoj) { - // if a left outer join, if the select condition is not-null filtering, - // we rewrite left outer join - // to inner join for this case. - if (containsNotNullFiltering(selectCondition)) { - lojToInner = true; - } - } - if ((j > 0 && isLoj) && containsNullFiltering(selectCondition)) { - // Select is-null($$var) cannot be pushed in the right branch of a LOJ; - notPushedStack.addFirst(select); - } else { - // Conditions for the left branch can always be pushed. - // Other conditions can be pushed to the right branch of a LOJ. - copySelectToBranch(select, branch, context); - } + if (!inter) { + continue; + } + + // if a left outer join, if the select condition is not-missing filtering, + // we rewrite left outer join + // to inner join for this case. + if (j > 0 && isLoj && containsNotMissingFiltering(selectCondition)) { + lojToInner = true; + } + if ((j > 0 && isLoj) && containsMissingFiltering(selectCondition)) { + // Select "is-not-missing($$var)" cannot be pushed in the right branch of a LOJ; + notPushedStack.addFirst(select); + } else { + // Conditions for the left branch can always be pushed. + // Other conditions can be pushed to the right branch of a LOJ. + copySelectToBranch(select, branch, context); } } if (lojToInner) { @@ -262,19 +262,19 @@ public class PushSelectIntoJoinRule implements IAlgebraicRewriteRule { } /** - * Whether the expression contains a not-null filtering + * Whether the expression contains a not-missing filtering * * @param expr - * @return true if the expression contains a not-null filtering function call; false otherwise. + * @return true if the expression contains a not-missing filtering function call; false otherwise. */ - private boolean containsNotNullFiltering(ILogicalExpression expr) { + private boolean containsNotMissingFiltering(ILogicalExpression expr) { if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return false; } ScalarFunctionCallExpression func = (ScalarFunctionCallExpression) expr; if (func.getFunctionIdentifier() == AlgebricksBuiltinFunctions.AND) { for (Mutable<ILogicalExpression> argumentRef : func.getArguments()) { - if (containsNotNullFiltering(argumentRef.getValue())) { + if (containsNotMissingFiltering(argumentRef.getValue())) { return true; } } @@ -288,32 +288,32 @@ public class PushSelectIntoJoinRule implements IAlgebraicRewriteRule { return false; } ScalarFunctionCallExpression func2 = (ScalarFunctionCallExpression) arg; - if (func2.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_NULL) { + if (func2.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_MISSING) { return false; } return true; } /** - * Whether the expression contains a null filtering + * Whether the expression contains a missing filtering * * @param expr - * @return true if the expression contains a null filtering function call; false otherwise. + * @return true if the expression contains a missing filtering function call; false otherwise. */ - private boolean containsNullFiltering(ILogicalExpression expr) { + private boolean containsMissingFiltering(ILogicalExpression expr) { if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) { return false; } ScalarFunctionCallExpression func = (ScalarFunctionCallExpression) expr; if (func.getFunctionIdentifier() == AlgebricksBuiltinFunctions.AND) { for (Mutable<ILogicalExpression> argumentRef : func.getArguments()) { - if (containsNullFiltering(argumentRef.getValue())) { + if (containsMissingFiltering(argumentRef.getValue())) { return true; } } return false; } - if (func.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_NULL) { + if (func.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_MISSING) { return false; } return true; http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java index 3e65d91..836f266 100644 --- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java +++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java @@ -243,7 +243,7 @@ public class IntroduceGroupByForSubplanRule implements IAlgebraicRewriteRule { context.computeAndSetTypeEnvironmentForOperator(tmpAsgn); } - IFunctionInfo finfoEq = context.getMetadataProvider().lookupFunction(AlgebricksBuiltinFunctions.IS_NULL); + IFunctionInfo finfoEq = context.getMetadataProvider().lookupFunction(AlgebricksBuiltinFunctions.IS_MISSING); ILogicalExpression isNullTest = new ScalarFunctionCallExpression(finfoEq, new MutableObject<ILogicalExpression>(new VariableReferenceExpression(testForNull))); IFunctionInfo finfoNot = context.getMetadataProvider().lookupFunction(AlgebricksBuiltinFunctions.NOT); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java index 93af981..f809e96 100644 --- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java +++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java @@ -65,7 +65,7 @@ public class IntroduceLeftOuterJoinForSubplanRule implements IAlgebraicRewriteRu AbstractLogicalOperator op1 = (AbstractLogicalOperator) subplanRoot.getValue(); Mutable<ILogicalOperator> opUnder = subplan.getInputs().get(0); - if (OperatorPropertiesUtil.isNullTest((AbstractLogicalOperator) opUnder.getValue())) { + if (OperatorPropertiesUtil.isMissingTest((AbstractLogicalOperator) opUnder.getValue())) { return false; } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java index 0aba194..049e853 100644 --- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java +++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java @@ -82,7 +82,7 @@ public class SubplanOutOfGroupRule implements IAlgebraicRewriteRule { if (op1.getOperatorTag() == LogicalOperatorTag.SUBPLAN) { SubplanOperator subplan = (SubplanOperator) op1; AbstractLogicalOperator op2 = (AbstractLogicalOperator) subplan.getInputs().get(0).getValue(); - if (OperatorPropertiesUtil.isNullTest(op2)) { + if (OperatorPropertiesUtil.isMissingTest(op2)) { if (subplan.getNestedPlans().size() == 1) { ILogicalPlan p1 = subplan.getNestedPlans().get(0); if (p1.getRoots().size() == 1) { http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java index ac9bae2..9a9fb72 100644 --- a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java +++ b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java @@ -31,8 +31,8 @@ import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneO import org.apache.hyracks.algebricks.runtime.operators.std.NestedTupleSourceRuntimeFactory.NestedTupleSourceRuntime; import org.apache.hyracks.api.comm.IFrameWriter; import org.apache.hyracks.api.context.IHyracksTaskContext; -import org.apache.hyracks.api.dataflow.value.INullWriter; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriter; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.RecordDescriptor; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder; @@ -44,13 +44,13 @@ public class SubplanRuntimeFactory extends AbstractOneInputOneOutputRuntimeFacto private final AlgebricksPipeline pipeline; private final RecordDescriptor inputRecordDesc; - private final INullWriterFactory[] nullWriterFactories; + private final IMissingWriterFactory[] missingWriterFactories; - public SubplanRuntimeFactory(AlgebricksPipeline pipeline, INullWriterFactory[] nullWriterFactories, + public SubplanRuntimeFactory(AlgebricksPipeline pipeline, IMissingWriterFactory[] missingWriterFactories, RecordDescriptor inputRecordDesc, int[] projectionList) { super(projectionList); this.pipeline = pipeline; - this.nullWriterFactories = nullWriterFactories; + this.missingWriterFactories = missingWriterFactories; this.inputRecordDesc = inputRecordDesc; if (projectionList != null) { throw new NotImplementedException(); @@ -76,9 +76,9 @@ public class SubplanRuntimeFactory extends AbstractOneInputOneOutputRuntimeFacto final PipelineAssembler pa = new PipelineAssembler(pipeline, 1, 1, inputRecordDesc, pipelineOutputRecordDescriptor); - final INullWriter[] nullWriters = new INullWriter[nullWriterFactories.length]; - for (int i = 0; i < nullWriterFactories.length; i++) { - nullWriters[i] = nullWriterFactories[i].createNullWriter(); + final IMissingWriter[] nullWriters = new IMissingWriter[missingWriterFactories.length]; + for (int i = 0; i < missingWriterFactories.length; i++) { + nullWriters[i] = missingWriterFactories[i].createMissingWriter(); } return new AbstractOneInputOneOutputOneFramePushRuntime() { @@ -132,7 +132,7 @@ public class SubplanRuntimeFactory extends AbstractOneInputOneOutputRuntimeFacto } DataOutput dos = tb.getDataOutput(); for (int i = 0; i < nullWriters.length; i++) { - nullWriters[i].writeNull(dos); + nullWriters[i].writeMissing(dos); tb.addFieldEndOffset(); } } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java index 5eb4604..1bc5d51 100644 --- a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java +++ b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java @@ -30,8 +30,8 @@ import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneO import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputOneFramePushRuntime; import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputRuntimeFactory; import org.apache.hyracks.api.context.IHyracksTaskContext; -import org.apache.hyracks.api.dataflow.value.INullWriter; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriter; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.data.std.api.IPointable; import org.apache.hyracks.data.std.primitive.VoidPointable; @@ -45,30 +45,30 @@ public class StreamSelectRuntimeFactory extends AbstractOneInputOneOutputRuntime private final IBinaryBooleanInspectorFactory binaryBooleanInspectorFactory; - private final boolean retainNull; + private final boolean retainMissing; - private final int nullPlaceholderVariableIndex; + private final int missingPlaceholderVariableIndex; - private final INullWriterFactory nullWriterFactory; + private final IMissingWriterFactory missingWriterFactory; /** * @param cond * @param projectionList * if projectionList is null, then no projection is performed - * @param retainNull - * @param nullPlaceholderVariableIndex - * @param nullWriterFactory + * @param retainMissing + * @param missingPlaceholderVariableIndex + * @param missingWriterFactory * @throws HyracksDataException */ public StreamSelectRuntimeFactory(IScalarEvaluatorFactory cond, int[] projectionList, - IBinaryBooleanInspectorFactory binaryBooleanInspectorFactory, boolean retainNull, - int nullPlaceholderVariableIndex, INullWriterFactory nullWriterFactory) { + IBinaryBooleanInspectorFactory binaryBooleanInspectorFactory, boolean retainMissing, + int missingPlaceholderVariableIndex, IMissingWriterFactory missingWriterFactory) { super(projectionList); this.cond = cond; this.binaryBooleanInspectorFactory = binaryBooleanInspectorFactory; - this.retainNull = retainNull; - this.nullPlaceholderVariableIndex = nullPlaceholderVariableIndex; - this.nullWriterFactory = nullWriterFactory; + this.retainMissing = retainMissing; + this.missingPlaceholderVariableIndex = missingPlaceholderVariableIndex; + this.missingWriterFactory = missingWriterFactory; } @Override @@ -82,8 +82,8 @@ public class StreamSelectRuntimeFactory extends AbstractOneInputOneOutputRuntime return new AbstractOneInputOneOutputOneFieldFramePushRuntime() { private IPointable p = VoidPointable.FACTORY.createPointable(); private IScalarEvaluator eval; - private INullWriter nullWriter = null; - private ArrayTupleBuilder nullTupleBuilder = null; + private IMissingWriter missingWriter = null; + private ArrayTupleBuilder missingTupleBuilder = null; private boolean isOpen = false; @Override @@ -100,12 +100,12 @@ public class StreamSelectRuntimeFactory extends AbstractOneInputOneOutputRuntime writer.open(); //prepare nullTupleBuilder - if (retainNull && nullWriter == null) { - nullWriter = nullWriterFactory.createNullWriter(); - nullTupleBuilder = new ArrayTupleBuilder(1); - DataOutput out = nullTupleBuilder.getDataOutput(); - nullWriter.writeNull(out); - nullTupleBuilder.addFieldEndOffset(); + if (retainMissing && missingWriter == null) { + missingWriter = missingWriterFactory.createMissingWriter(); + missingTupleBuilder = new ArrayTupleBuilder(1); + DataOutput out = missingTupleBuilder.getDataOutput(); + missingWriter.writeMissing(out); + missingTupleBuilder.addFieldEndOffset(); } } @@ -145,10 +145,10 @@ public class StreamSelectRuntimeFactory extends AbstractOneInputOneOutputRuntime appendTupleToFrame(t); } } else { - if (retainNull) { + if (retainMissing) { for (int i = 0; i < tRef.getFieldCount(); i++) { - if (i == nullPlaceholderVariableIndex) { - appendField(nullTupleBuilder.getByteArray(), 0, nullTupleBuilder.getSize()); + if (i == missingPlaceholderVariableIndex) { + appendField(missingTupleBuilder.getByteArray(), 0, missingTupleBuilder.getSize()); } else { appendField(tAccess, t, i); } http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java b/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java index 0dc1961..4dafd0e 100644 --- a/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java +++ b/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java @@ -33,7 +33,7 @@ import org.apache.hyracks.algebricks.data.IPrinterFactory; import org.apache.hyracks.algebricks.data.impl.BinaryBooleanInspectorImpl; import org.apache.hyracks.algebricks.data.impl.BinaryIntegerInspectorImpl; import org.apache.hyracks.algebricks.data.impl.IntegerPrinterFactory; -import org.apache.hyracks.algebricks.data.impl.NoopNullWriterFactory; +import org.apache.hyracks.algebricks.data.impl.NoopMissingWriterFactory; import org.apache.hyracks.algebricks.data.impl.UTF8StringPrinterFactory; import org.apache.hyracks.algebricks.runtime.aggregators.TupleCountAggregateFunctionFactory; import org.apache.hyracks.algebricks.runtime.aggregators.TupleCountRunningAggregateFunctionFactory; @@ -66,7 +66,7 @@ import org.apache.hyracks.algebricks.tests.util.AlgebricksHyracksIntegrationUtil import org.apache.hyracks.api.constraints.PartitionConstraintHelper; import org.apache.hyracks.api.dataflow.IOperatorDescriptor; import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer; import org.apache.hyracks.api.dataflow.value.RecordDescriptor; import org.apache.hyracks.api.io.FileReference; @@ -701,7 +701,7 @@ public class PushRuntimeTest { new RecordDescriptor[] { assign1Desc, assign2Desc, project1Desc }); SubplanRuntimeFactory subplan = new SubplanRuntimeFactory(pipeline, - new INullWriterFactory[] { NoopNullWriterFactory.INSTANCE }, assign1Desc, null); + new IMissingWriterFactory[] { NoopMissingWriterFactory.INSTANCE }, assign1Desc, null); RecordDescriptor subplanDesc = new RecordDescriptor(new ISerializerDeserializer[] { IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE }); http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/BinaryComparatorConstant.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/BinaryComparatorConstant.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/BinaryComparatorConstant.java deleted file mode 100644 index de0e3ee..0000000 --- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/BinaryComparatorConstant.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.api.dataflow.value; - -public final class BinaryComparatorConstant { - - // Result code for isComparable() - // TRUE: can be comparable - // FALSE: can not be comparable - // UNKNOWN: can not be decided whether two arguments are comparable or not - usually NULL - - public static enum ComparableResultCode { - TRUE, - FALSE, - UNKNOWN - } - -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriter.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriter.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriter.java new file mode 100644 index 0000000..1309233 --- /dev/null +++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriter.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hyracks.api.dataflow.value; + +import java.io.DataOutput; + +import org.apache.hyracks.api.exceptions.HyracksDataException; + +@FunctionalInterface +public interface IMissingWriter { + public void writeMissing(DataOutput out) throws HyracksDataException; +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriterFactory.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriterFactory.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriterFactory.java new file mode 100644 index 0000000..bf15489 --- /dev/null +++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriterFactory.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.hyracks.api.dataflow.value; + +import java.io.Serializable; + +@FunctionalInterface +public interface IMissingWriterFactory extends Serializable { + public IMissingWriter createMissingWriter(); +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriter.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriter.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriter.java deleted file mode 100644 index 9105146..0000000 --- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriter.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.api.dataflow.value; - -import java.io.DataOutput; - -import org.apache.hyracks.api.exceptions.HyracksDataException; - -public interface INullWriter { - public void writeNull(DataOutput out) throws HyracksDataException; -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriterFactory.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriterFactory.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriterFactory.java deleted file mode 100644 index 9cd46e5..0000000 --- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriterFactory.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.api.dataflow.value; - -import java.io.Serializable; - -public interface INullWriterFactory extends Serializable { - public INullWriter createNullWriter(); -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/535d86b5/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java index 4e4256e..2f7b1c2 100644 --- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java +++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java @@ -25,7 +25,7 @@ import org.apache.hyracks.api.dataflow.IOperatorNodePushable; import org.apache.hyracks.api.dataflow.TaskId; import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory; import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory; -import org.apache.hyracks.api.dataflow.value.INullWriterFactory; +import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory; import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator; import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory; import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider; @@ -50,7 +50,7 @@ public class GraceHashJoinOperatorDescriptor extends AbstractOperatorDescriptor private final IBinaryComparatorFactory[] comparatorFactories; private final IPredicateEvaluatorFactory predEvaluatorFactory; private final boolean isLeftOuter; - private final INullWriterFactory[] nullWriterFactories1; + private final IMissingWriterFactory[] nullWriterFactories1; public GraceHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int memsize, int inputsize0, int recordsPerFrame, double factor, int[] keys0, int[] keys1, @@ -74,7 +74,8 @@ public class GraceHashJoinOperatorDescriptor extends AbstractOperatorDescriptor public GraceHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int memsize, int inputsize0, int recordsPerFrame, double factor, int[] keys0, int[] keys1, IBinaryHashFunctionFactory[] hashFunctionFactories, IBinaryComparatorFactory[] comparatorFactories, - RecordDescriptor recordDescriptor, boolean isLeftOuter, INullWriterFactory[] nullWriterFactories1, IPredicateEvaluatorFactory predEvalFactory) { + RecordDescriptor recordDescriptor, boolean isLeftOuter, IMissingWriterFactory[] nullWriterFactories1, + IPredicateEvaluatorFactory predEvalFactory) { super(spec, 2, 1); this.memsize = memsize; this.inputsize0 = inputsize0; @@ -117,9 +118,9 @@ public class GraceHashJoinOperatorDescriptor extends AbstractOperatorDescriptor private class HashPartitionActivityNode extends AbstractActivityNode { private static final long serialVersionUID = 1L; - private int keys[]; + private int[] keys; - public HashPartitionActivityNode(ActivityId id, int keys[]) { + public HashPartitionActivityNode(ActivityId id, int[] keys) { super(id); this.keys = keys; } @@ -128,8 +129,9 @@ public class GraceHashJoinOperatorDescriptor extends AbstractOperatorDescriptor public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx, IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) { return new GraceHashJoinPartitionBuildOperatorNodePushable(ctx, new TaskId(getActivityId(), partition), - keys, hashFunctionFactories, comparatorFactories, (int) Math.ceil(Math.sqrt(inputsize0 * factor - / nPartitions)), recordDescProvider.getInputRecordDescriptor(getActivityId(), 0)); + keys, hashFunctionFactories, comparatorFactories, + (int) Math.ceil(Math.sqrt(inputsize0 * factor / nPartitions)), + recordDescProvider.getInputRecordDescriptor(getActivityId(), 0)); } } @@ -152,13 +154,14 @@ public class GraceHashJoinOperatorDescriptor extends AbstractOperatorDescriptor final RecordDescriptor rd0 = recordDescProvider.getInputRecordDescriptor(rpartAid, 0); final RecordDescriptor rd1 = recordDescProvider.getInputRecordDescriptor(spartAid, 0); int numPartitions = (int) Math.ceil(Math.sqrt(inputsize0 * factor / nPartitions)); - final IPredicateEvaluator predEvaluator = ( predEvaluatorFactory == null ? null : predEvaluatorFactory.createPredicateEvaluator() ); - - return new GraceHashJoinOperatorNodePushable(ctx, new TaskId(new ActivityId(getOperatorId(), - RPARTITION_ACTIVITY_ID), partition), new TaskId(new ActivityId(getOperatorId(), - SPARTITION_ACTIVITY_ID), partition), recordsPerFrame, factor, keys0, keys1, hashFunctionFactories, - comparatorFactories, nullWriterFactories1, rd1, rd0, recordDescriptors[0], numPartitions, - predEvaluator, isLeftOuter); + final IPredicateEvaluator predEvaluator = predEvaluatorFactory == null ? null + : predEvaluatorFactory.createPredicateEvaluator(); + + return new GraceHashJoinOperatorNodePushable(ctx, + new TaskId(new ActivityId(getOperatorId(), RPARTITION_ACTIVITY_ID), partition), + new TaskId(new ActivityId(getOperatorId(), SPARTITION_ACTIVITY_ID), partition), recordsPerFrame, + factor, keys0, keys1, hashFunctionFactories, comparatorFactories, nullWriterFactories1, rd1, rd0, + recordDescriptors[0], numPartitions, predEvaluator, isLeftOuter); } } }
