Return-Path: X-Original-To: apmail-asterixdb-commits-archive@minotaur.apache.org Delivered-To: apmail-asterixdb-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D74CE18FF5 for ; Tue, 25 Aug 2015 17:41:35 +0000 (UTC) Received: (qmail 96953 invoked by uid 500); 25 Aug 2015 17:41:35 -0000 Delivered-To: apmail-asterixdb-commits-archive@asterixdb.apache.org Received: (qmail 96916 invoked by uid 500); 25 Aug 2015 17:41:35 -0000 Mailing-List: contact commits-help@asterixdb.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.incubator.apache.org Delivered-To: mailing list commits@asterixdb.incubator.apache.org Received: (qmail 96906 invoked by uid 99); 25 Aug 2015 17:41:35 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2015 17:41:35 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 29B8C182348 for ; Tue, 25 Aug 2015 17:41:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.794 X-Spam-Level: X-Spam-Status: No, score=0.794 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.006] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id DrnA74EsUe13 for ; Tue, 25 Aug 2015 17:41:15 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 972BE255AC for ; Tue, 25 Aug 2015 17:41:15 +0000 (UTC) Received: (qmail 69563 invoked by uid 99); 25 Aug 2015 16:41:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2015 16:41:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 24FADE3612; Tue, 25 Aug 2015 16:41:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: imaxon@apache.org To: commits@asterixdb.incubator.apache.org Date: Tue, 25 Aug 2015 16:41:55 -0000 Message-Id: <739df66bb0e64ed2b2ee0371f830af22@git.apache.org> In-Reply-To: <339f74e1fc5c4aabb18d5e46ecf6ba11@git.apache.org> References: <339f74e1fc5c4aabb18d5e46ecf6ba11@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [42/51] [partial] incubator-asterixdb-hyracks git commit: Change folder structure for Java repackage http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/logical/visitors/VariableUtilities.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/logical/visitors/VariableUtilities.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/logical/visitors/VariableUtilities.java deleted file mode 100644 index f3cf0a4..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/logical/visitors/VariableUtilities.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors; - -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang3.mutable.Mutable; - -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; - -public class VariableUtilities { - - public static void getUsedVariables(ILogicalOperator op, Collection usedVariables) - throws AlgebricksException { - ILogicalOperatorVisitor visitor = new UsedVariableVisitor(usedVariables); - op.accept(visitor, null); - } - - public static void getProducedVariables(ILogicalOperator op, Collection producedVariables) - throws AlgebricksException { - ILogicalOperatorVisitor visitor = new ProducedVariableVisitor(producedVariables); - op.accept(visitor, null); - } - - public static void getLiveVariables(ILogicalOperator op, Collection schemaVariables) - throws AlgebricksException { - ILogicalOperatorVisitor visitor = new SchemaVariableVisitor(schemaVariables); - op.accept(visitor, null); - } - - public static void getUsedVariablesInDescendantsAndSelf(ILogicalOperator op, Collection vars) - throws AlgebricksException { - // DFS traversal - VariableUtilities.getUsedVariables(op, vars); - for (Mutable c : op.getInputs()) { - getUsedVariablesInDescendantsAndSelf(c.getValue(), vars); - } - } - - public static void getProducedVariablesInDescendantsAndSelf(ILogicalOperator op, Collection vars) - throws AlgebricksException { - // DFS traversal - VariableUtilities.getProducedVariables(op, vars); - for (Mutable c : op.getInputs()) { - getProducedVariablesInDescendantsAndSelf(c.getValue(), vars); - } - } - - public static void substituteVariables(ILogicalOperator op, LogicalVariable v1, LogicalVariable v2, - ITypingContext ctx) throws AlgebricksException { - substituteVariables(op, v1, v2, true, ctx); - } - - public static void substituteVariablesInDescendantsAndSelf(ILogicalOperator op, LogicalVariable v1, - LogicalVariable v2, ITypingContext ctx) throws AlgebricksException { - for (Mutable childOp : op.getInputs()) { - substituteVariablesInDescendantsAndSelf(childOp.getValue(), v1, v2, ctx); - } - substituteVariables(op, v1, v2, true, ctx); - } - - public static void substituteVariables(ILogicalOperator op, LogicalVariable v1, LogicalVariable v2, - boolean goThroughNts, ITypingContext ctx) throws AlgebricksException { - ILogicalOperatorVisitor> visitor = new SubstituteVariableVisitor( - goThroughNts, ctx); - op.accept(visitor, new Pair(v1, v2)); - } - - public static boolean varListEqualUnordered(List var, List varArg) { - Set varSet = new HashSet(); - Set varArgSet = new HashSet(); - varSet.addAll(var); - varArgSet.addAll(varArg); - return varSet.equals(varArgSet); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractExchangePOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractExchangePOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractExchangePOperator.java deleted file mode 100644 index 42d964d..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractExchangePOperator.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder.TargetConstraint; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; -import edu.uci.ics.hyracks.api.dataflow.IConnectorDescriptor; -import edu.uci.ics.hyracks.api.job.IConnectorDescriptorRegistry; - -public abstract class AbstractExchangePOperator extends AbstractPhysicalOperator { - public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, - IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) - throws AlgebricksException { - Pair connPair = createConnectorDescriptor(builder.getJobSpec(), op, - opSchema, context); - builder.contributeConnectorWithTargetConstraint(op, connPair.first, connPair.second); - ILogicalOperator src = op.getInputs().get(0).getValue(); - builder.contributeGraphEdge(src, 0, op, 0); - } - - @Override - public boolean isMicroOperator() { - return false; - } - - @Override - public boolean expensiveThanMaterialization() { - return false; - } - - public abstract Pair createConnectorDescriptor( - IConnectorDescriptorRegistry spec, ILogicalOperator op, IOperatorSchema opSchema, JobGenContext context) - throws AlgebricksException; -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractHashJoinPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractHashJoinPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractHashJoinPOperator.java deleted file mode 100644 index 764159d..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractHashJoinPOperator.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException; -import edu.uci.ics.hyracks.algebricks.common.utils.ListSet; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.EquivalenceClass; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator.JoinKind; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.BroadcastPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningRequirementsCoordinator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty; - -public abstract class AbstractHashJoinPOperator extends AbstractJoinPOperator { - - protected List keysLeftBranch; - protected List keysRightBranch; - - public AbstractHashJoinPOperator(JoinKind kind, JoinPartitioningType partitioningType, - List sideLeftOfEqualities, List sideRightOfEqualities) { - super(kind, partitioningType); - this.keysLeftBranch = sideLeftOfEqualities; - this.keysRightBranch = sideRightOfEqualities; - } - - public List getKeysLeftBranch() { - return keysLeftBranch; - } - - public List getKeysRightBranch() { - return keysRightBranch; - } - - @Override - public void computeDeliveredProperties(ILogicalOperator iop, IOptimizationContext context) - throws AlgebricksException { - IPartitioningProperty pp; - AbstractLogicalOperator op = (AbstractLogicalOperator) iop; - - if (op.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) { - AbstractLogicalOperator op0 = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); - IPhysicalPropertiesVector pv0 = op0.getPhysicalOperator().getDeliveredProperties(); - AbstractLogicalOperator op1 = (AbstractLogicalOperator) op.getInputs().get(1).getValue(); - IPhysicalPropertiesVector pv1 = op1.getPhysicalOperator().getDeliveredProperties(); - - if (pv0 == null || pv1 == null) { - pp = null; - } else { - pp = pv0.getPartitioningProperty(); - } - } else { - pp = IPartitioningProperty.UNPARTITIONED; - } - this.deliveredProperties = new StructuralPropertiesVector(pp, deliveredLocalProperties(iop, context)); - } - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator iop, - IPhysicalPropertiesVector reqdByParent) { - StructuralPropertiesVector[] pv = new StructuralPropertiesVector[2]; - // In a cost-based optimizer, we would also try to propagate the - // parent's partitioning requirements. - AbstractLogicalOperator op = (AbstractLogicalOperator) iop; - - IPartitioningProperty pp1 = null; - IPartitioningProperty pp2 = null; - if (op.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) { - switch (partitioningType) { - case PAIRWISE: { - pp1 = new UnorderedPartitionedProperty(new ListSet(keysLeftBranch), null); - pp2 = new UnorderedPartitionedProperty(new ListSet(keysRightBranch), null); - break; - } - case BROADCAST: { - pp2 = new BroadcastPartitioningProperty(null); - break; - } - default: { - throw new IllegalStateException(); - } - } - } - - pv[0] = new StructuralPropertiesVector(pp1, null); - pv[1] = new StructuralPropertiesVector(pp2, null); - - IPartitioningRequirementsCoordinator prc; - switch (kind) { - case INNER: { - prc = IPartitioningRequirementsCoordinator.EQCLASS_PARTITIONING_COORDINATOR; - break; - } - case LEFT_OUTER: { - prc = new IPartitioningRequirementsCoordinator() { - - @Override - public Pair coordinateRequirements( - IPartitioningProperty requirements, IPartitioningProperty firstDeliveredPartitioning, - ILogicalOperator op, IOptimizationContext context) throws AlgebricksException { - if (firstDeliveredPartitioning != null - && firstDeliveredPartitioning.getPartitioningType() == requirements - .getPartitioningType()) { - switch (requirements.getPartitioningType()) { - case UNORDERED_PARTITIONED: { - UnorderedPartitionedProperty upp1 = (UnorderedPartitionedProperty) firstDeliveredPartitioning; - Set set1 = upp1.getColumnSet(); - UnorderedPartitionedProperty uppreq = (UnorderedPartitionedProperty) requirements; - Set modifuppreq = new ListSet(); - Map eqmap = context.getEquivalenceClassMap(op); - Set covered = new ListSet(); - for (LogicalVariable r : uppreq.getColumnSet()) { - EquivalenceClass ecSnd = eqmap.get(r); - boolean found = false; - int j = 0; - for (LogicalVariable rvar : keysRightBranch) { - if (rvar == r || ecSnd != null && eqmap.get(rvar) == ecSnd) { - found = true; - break; - } - j++; - } - if (!found) { - throw new IllegalStateException("Did not find a variable equivalent to " - + r + " among " + keysRightBranch); - } - LogicalVariable v2 = keysLeftBranch.get(j); - EquivalenceClass ecFst = eqmap.get(v2); - for (LogicalVariable vset1 : set1) { - if (vset1 == v2 || ecFst != null && eqmap.get(vset1) == ecFst) { - covered.add(vset1); - modifuppreq.add(r); - break; - } - } - } - if (!covered.equals(set1)) { - throw new AlgebricksException("Could not modify " + requirements - + " to agree with partitioning property " + firstDeliveredPartitioning - + " delivered by previous input operator."); - } - UnorderedPartitionedProperty upp2 = new UnorderedPartitionedProperty(modifuppreq, - requirements.getNodeDomain()); - return new Pair(false, upp2); - } - case ORDERED_PARTITIONED: { - throw new NotImplementedException(); - } - } - } - return new Pair(true, requirements); - } - }; - break; - } - default: { - throw new IllegalStateException(); - } - } - - return new PhysicalRequirements(pv, prc); - } - - protected abstract List deliveredLocalProperties(ILogicalOperator op, - IOptimizationContext context) throws AlgebricksException; -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractJoinPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractJoinPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractJoinPOperator.java deleted file mode 100644 index fcc04ab..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractJoinPOperator.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractBinaryJoinOperator.JoinKind; - -public abstract class AbstractJoinPOperator extends AbstractPhysicalOperator { - - public enum JoinPartitioningType { - PAIRWISE, BROADCAST - } - - protected final JoinKind kind; - protected final JoinPartitioningType partitioningType; - - public AbstractJoinPOperator(JoinKind kind, JoinPartitioningType partitioningType) { - this.kind = kind; - this.partitioningType = partitioningType; - } - - public JoinKind getKind() { - return kind; - } - - public JoinPartitioningType getPartitioningType() { - return partitioningType; - } - - @Override - public Pair getInputOutputDependencyLabels(ILogicalOperator op) { - int[] inputDependencyLabels = new int[] { 1, 0 }; - int[] outputDependencyLabels = new int[] { 1 }; - return new Pair(inputDependencyLabels, outputDependencyLabels); - } - - @Override - public boolean expensiveThanMaterialization() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPhysicalOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPhysicalOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPhysicalOperator.java deleted file mode 100644 index 66e7b98..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPhysicalOperator.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.Map; - -import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint; -import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint; -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalPlan; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IPhysicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator.ExecutionMode; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningRequirementsCoordinator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.PlanCompiler; -import edu.uci.ics.hyracks.algebricks.runtime.base.AlgebricksPipeline; -import edu.uci.ics.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor; -import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor; -import edu.uci.ics.hyracks.api.dataflow.OperatorDescriptorId; -import edu.uci.ics.hyracks.api.job.JobSpecification; - -public abstract class AbstractPhysicalOperator implements IPhysicalOperator { - - protected IPhysicalPropertiesVector deliveredProperties; - private boolean disableJobGenBelow = false; - private Object hostQueryContext; - - @Override - public final IPhysicalPropertiesVector getDeliveredProperties() { - return deliveredProperties; - } - - @Override - public String toString() { - return getOperatorTag().toString(); - } - - public void setHostQueryContext(Object context) { - this.hostQueryContext = context; - } - - public Object getHostQueryContext() { - return hostQueryContext; - } - - protected PhysicalRequirements emptyUnaryRequirements() { - StructuralPropertiesVector[] req = new StructuralPropertiesVector[] { StructuralPropertiesVector.EMPTY_PROPERTIES_VECTOR }; - return new PhysicalRequirements(req, IPartitioningRequirementsCoordinator.NO_COORDINATION); - } - - protected PhysicalRequirements emptyUnaryRequirements(int numberOfChildren) { - StructuralPropertiesVector[] req = new StructuralPropertiesVector[numberOfChildren]; - for (int i = 0; i < numberOfChildren; i++) { - req[i] = StructuralPropertiesVector.EMPTY_PROPERTIES_VECTOR; - } - return new PhysicalRequirements(req, IPartitioningRequirementsCoordinator.NO_COORDINATION); - } - - @Override - public void disableJobGenBelowMe() { - this.disableJobGenBelow = true; - } - - @Override - public boolean isJobGenDisabledBelowMe() { - return disableJobGenBelow; - } - - /** - * @return labels (0 or 1) for each input and output indicating the dependency between them. - * The edges labeled as 1 must wait for the edges with label 0. - */ - @Override - public Pair getInputOutputDependencyLabels(ILogicalOperator op) { - int[] inputDependencyLabels = new int[op.getInputs().size()]; // filled with 0's - int[] outputDependencyLabels = new int[] { 0 }; - return new Pair(inputDependencyLabels, outputDependencyLabels); - } - - protected void contributeOpDesc(IHyracksJobBuilder builder, AbstractLogicalOperator op, IOperatorDescriptor opDesc) { - if (op.getExecutionMode() == ExecutionMode.UNPARTITIONED) { - AlgebricksPartitionConstraint apc = new AlgebricksCountPartitionConstraint(1); - builder.contributeAlgebricksPartitionConstraint(opDesc, apc); - } - builder.contributeHyracksOperator(op, opDesc); - } - - protected AlgebricksPipeline[] compileSubplans(IOperatorSchema outerPlanSchema, - AbstractOperatorWithNestedPlans npOp, IOperatorSchema opSchema, JobGenContext context) - throws AlgebricksException { - AlgebricksPipeline[] subplans = new AlgebricksPipeline[npOp.getNestedPlans().size()]; - PlanCompiler pc = new PlanCompiler(context); - int i = 0; - for (ILogicalPlan p : npOp.getNestedPlans()) { - subplans[i++] = buildPipelineWithProjection(p, outerPlanSchema, npOp, opSchema, pc); - } - return subplans; - } - - private AlgebricksPipeline buildPipelineWithProjection(ILogicalPlan p, IOperatorSchema outerPlanSchema, - AbstractOperatorWithNestedPlans npOp, IOperatorSchema opSchema, PlanCompiler pc) throws AlgebricksException { - if (p.getRoots().size() > 1) { - throw new NotImplementedException("Nested plans with several roots are not supported."); - } - JobSpecification nestedJob = pc.compilePlan(p, outerPlanSchema, null); - ILogicalOperator topOpInSubplan = p.getRoots().get(0).getValue(); - JobGenContext context = pc.getContext(); - IOperatorSchema topOpInSubplanScm = context.getSchema(topOpInSubplan); - opSchema.addAllVariables(topOpInSubplanScm); - - Map opMap = nestedJob.getOperatorMap(); - if (opMap.size() != 1) { - throw new AlgebricksException( - "Attempting to construct a nested plan with " - + opMap.size() - + " operator descriptors. Currently, nested plans can only consist in linear pipelines of Asterix micro operators."); - } - - for (OperatorDescriptorId oid : opMap.keySet()) { - IOperatorDescriptor opd = opMap.get(oid); - if (!(opd instanceof AlgebricksMetaOperatorDescriptor)) { - throw new AlgebricksException( - "Can only generate Hyracks jobs for pipelinable Asterix nested plans, not for " - + opd.getClass().getName()); - } - AlgebricksMetaOperatorDescriptor amod = (AlgebricksMetaOperatorDescriptor) opd; - - return amod.getPipeline(); - // we suppose that the top operator in the subplan already does the - // projection for us - } - - throw new IllegalStateException(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPreclusteredGroupByPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPreclusteredGroupByPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPreclusteredGroupByPOperator.java deleted file mode 100644 index 41711cb..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPreclusteredGroupByPOperator.java +++ /dev/null @@ -1,265 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import org.apache.commons.lang3.mutable.Mutable; - -import edu.uci.ics.hyracks.algebricks.common.utils.ListSet; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.EquivalenceClass; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalPlan; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IPhysicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalExpressionTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalOperatorTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator.ExecutionMode; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.FunctionalDependency; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty.PropertyType; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningRequirementsCoordinator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.LocalGroupingProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.LocalOrderProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.OrderColumn; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PropertiesUtil; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty; - -public abstract class AbstractPreclusteredGroupByPOperator extends AbstractPhysicalOperator { - - protected List columnList; - - public AbstractPreclusteredGroupByPOperator(List columnList) { - this.columnList = columnList; - } - - @Override - public String toString() { - return getOperatorTag().toString() + columnList; - } - - public List getGbyColumns() { - return columnList; - } - - public void setGbyColumns(List gByColumns) { - this.columnList = gByColumns; - } - - // Obs: We don't propagate properties corresponding to decors, since they - // are func. dep. on the group-by variables. - @Override - public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) { - List propsLocal = new LinkedList(); - GroupByOperator gby = (GroupByOperator) op; - ILogicalOperator op2 = gby.getInputs().get(0).getValue(); - IPhysicalPropertiesVector childProp = op2.getDeliveredPhysicalProperties(); - IPartitioningProperty pp = childProp.getPartitioningProperty(); - List childLocals = childProp.getLocalProperties(); - if (childLocals != null) { - for (ILocalStructuralProperty lsp : childLocals) { - boolean failed = false; - switch (lsp.getPropertyType()) { - case LOCAL_GROUPING_PROPERTY: { - LocalGroupingProperty lgp = (LocalGroupingProperty) lsp; - Set colSet = new ListSet(); - for (LogicalVariable v : lgp.getColumnSet()) { - LogicalVariable v2 = getLhsGbyVar(gby, v); - if (v2 != null) { - colSet.add(v2); - } else { - failed = true; - } - } - if (!failed) { - propsLocal.add(new LocalGroupingProperty(colSet)); - } - break; - } - case LOCAL_ORDER_PROPERTY: { - LocalOrderProperty lop = (LocalOrderProperty) lsp; - List orderColumns = new ArrayList(); - for (OrderColumn oc : lop.getOrderColumns()) { - LogicalVariable v2 = getLhsGbyVar(gby, oc.getColumn()); - if (v2 != null) { - orderColumns.add(new OrderColumn(v2, oc.getOrder())); - } else { - failed = true; - } - } - if (!failed) { - propsLocal.add(new LocalOrderProperty(orderColumns)); - } - break; - } - default: { - throw new IllegalStateException(); - } - } - if (failed) { - break; - } - } - } - deliveredProperties = new StructuralPropertiesVector(pp, propsLocal); - } - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, - IPhysicalPropertiesVector reqdByParent) { - StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1]; - List localProps = null; - - localProps = new ArrayList(1); - Set gbvars = new ListSet(columnList); - LocalGroupingProperty groupProp = new LocalGroupingProperty(gbvars, new ArrayList(columnList)); - - GroupByOperator gby = (GroupByOperator) op; - boolean goon = true; - for (ILogicalPlan p : gby.getNestedPlans()) { - // try to propagate secondary order requirements from nested - // groupings - for (Mutable r : p.getRoots()) { - AbstractLogicalOperator op1 = (AbstractLogicalOperator) r.getValue(); - if (op1.getOperatorTag() == LogicalOperatorTag.AGGREGATE) { - AbstractLogicalOperator op2 = (AbstractLogicalOperator) op1.getInputs().get(0).getValue(); - IPhysicalOperator pop2 = op2.getPhysicalOperator(); - if (pop2 instanceof AbstractPreclusteredGroupByPOperator) { - List sndOrder = ((AbstractPreclusteredGroupByPOperator) pop2).getGbyColumns(); - groupProp.getColumnSet().addAll(sndOrder); - groupProp.getPreferredOrderEnforcer().addAll(sndOrder); - goon = false; - break; - } - } - } - if (!goon) { - break; - } - } - - localProps.add(groupProp); - - if (reqdByParent != null) { - // propagate parent requirements - List lpPar = reqdByParent.getLocalProperties(); - if (lpPar != null) { - boolean allOk = true; - List props = new ArrayList(lpPar.size()); - for (ILocalStructuralProperty prop : lpPar) { - if (prop.getPropertyType() != PropertyType.LOCAL_ORDER_PROPERTY) { - allOk = false; - break; - } - LocalOrderProperty lop = (LocalOrderProperty) prop; - List orderColumns = new ArrayList(); - List ords = lop.getOrderColumns(); - for (OrderColumn ord : ords) { - Pair> p = getGbyPairByRhsVar(gby, ord.getColumn()); - if (p == null) { - p = getDecorPairByRhsVar(gby, ord.getColumn()); - if (p == null) { - allOk = false; - break; - } - } - ILogicalExpression e = p.second.getValue(); - if (e.getExpressionTag() != LogicalExpressionTag.VARIABLE) { - throw new IllegalStateException( - "Right hand side of group-by assignment should have been normalized to a variable reference."); - } - LogicalVariable v = ((VariableReferenceExpression) e).getVariableReference(); - orderColumns.add(new OrderColumn(v, ord.getOrder())); - } - props.add(new LocalOrderProperty(orderColumns)); - } - List fdList = new ArrayList(); - for (Pair> decorPair : gby.getDecorList()) { - List hd = gby.getGbyVarList(); - List tl = new ArrayList(1); - tl.add(((VariableReferenceExpression) decorPair.second.getValue()).getVariableReference()); - fdList.add(new FunctionalDependency(hd, tl)); - } - if (allOk - && PropertiesUtil.matchLocalProperties(localProps, props, - new HashMap(), fdList)) { - localProps = props; - } - } - } - - IPartitioningProperty pp = null; - AbstractLogicalOperator aop = (AbstractLogicalOperator) op; - if (aop.getExecutionMode() == ExecutionMode.PARTITIONED) { - pp = new UnorderedPartitionedProperty(new ListSet(columnList), null); - } - pv[0] = new StructuralPropertiesVector(pp, localProps); - return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION); - } - - private static Pair> getGbyPairByRhsVar(GroupByOperator gby, - LogicalVariable var) { - for (Pair> ve : gby.getGroupByList()) { - if (ve.first == var) { - return ve; - } - } - return null; - } - - private static Pair> getDecorPairByRhsVar(GroupByOperator gby, - LogicalVariable var) { - for (Pair> ve : gby.getDecorList()) { - if (ve.first == var) { - return ve; - } - } - return null; - } - - private static LogicalVariable getLhsGbyVar(GroupByOperator gby, LogicalVariable var) { - for (Pair> ve : gby.getGroupByList()) { - ILogicalExpression e = ve.second.getValue(); - if (e.getExpressionTag() != LogicalExpressionTag.VARIABLE) { - throw new IllegalStateException( - "Right hand side of group by assignment should have been normalized to a variable reference."); - } - LogicalVariable v = ((VariableReferenceExpression) e).getVariableReference(); - if (v == var) { - return ve.first; - } - } - return null; - } - - @Override - public boolean expensiveThanMaterialization() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPropagatePropertiesForUsedVariablesPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPropagatePropertiesForUsedVariablesPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPropagatePropertiesForUsedVariablesPOperator.java deleted file mode 100644 index c77222b..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractPropagatePropertiesForUsedVariablesPOperator.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; - -public abstract class AbstractPropagatePropertiesForUsedVariablesPOperator extends AbstractPhysicalOperator { - - public void computeDeliveredPropertiesForUsedVariables(ILogicalOperator op, List usedVariables) { - ILogicalOperator op2 = op.getInputs().get(0).getValue(); - IPartitioningProperty pp = op2.getDeliveredPhysicalProperties().getPartitioningProperty(); - List downPropsLocal = op2.getDeliveredPhysicalProperties().getLocalProperties(); - List propsLocal = new ArrayList(); - for (ILocalStructuralProperty lsp : downPropsLocal) { - LinkedList cols = new LinkedList(); - lsp.getColumns(cols); - ILocalStructuralProperty propagatedProp = lsp.retainVariables(usedVariables); - if (propagatedProp != null) { - propsLocal.add(propagatedProp); - } - } - deliveredProperties = new StructuralPropertiesVector(pp, propsLocal); - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractScanPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractScanPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractScanPOperator.java deleted file mode 100644 index 299f519..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractScanPOperator.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; - -public abstract class AbstractScanPOperator extends AbstractPhysicalOperator { - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, - IPhysicalPropertiesVector reqdByParent) { - return emptyUnaryRequirements(); - } - - @Override - public boolean expensiveThanMaterialization() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java deleted file mode 100644 index 4b85c56..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AbstractStableSortPOperator.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang3.mutable.Mutable; - -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalExpressionTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.OrderOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningRequirementsCoordinator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.LocalOrderProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.OrderColumn; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; - -public abstract class AbstractStableSortPOperator extends AbstractPhysicalOperator { - - protected OrderColumn[] sortColumns; - protected ILocalStructuralProperty orderProp; - - public AbstractStableSortPOperator() { - } - - public OrderColumn[] getSortColumns() { - return sortColumns; - } - - @Override - public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) { - // if (orderProps == null) { // to do caching, we need some mechanism to - // invalidate cache - computeLocalProperties(op); - // } - AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); - StructuralPropertiesVector childProp = (StructuralPropertiesVector) op2.getDeliveredPhysicalProperties(); - deliveredProperties = new StructuralPropertiesVector(childProp.getPartitioningProperty(), - Collections.singletonList(orderProp)); - } - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator iop, - IPhysicalPropertiesVector reqdByParent) { - AbstractLogicalOperator op = (AbstractLogicalOperator) iop; - if (op.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) { - if (orderProp == null) { - computeLocalProperties(op); - } - StructuralPropertiesVector[] r = new StructuralPropertiesVector[] { new StructuralPropertiesVector( - IPartitioningProperty.UNPARTITIONED, Collections.singletonList(orderProp)) }; - return new PhysicalRequirements(r, IPartitioningRequirementsCoordinator.NO_COORDINATION); - } else { - return emptyUnaryRequirements(); - } - } - - public void computeLocalProperties(ILogicalOperator op) { - OrderOperator ord = (OrderOperator) op; - List orderColumns = new ArrayList(); - for (Pair> p : ord.getOrderExpressions()) { - ILogicalExpression expr = p.second.getValue(); - if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) { - VariableReferenceExpression varRef = (VariableReferenceExpression) expr; - LogicalVariable var = varRef.getVariableReference(); - orderColumns.add(new OrderColumn(var, p.first.getKind())); - } else { - throw new IllegalStateException(); - } - } - sortColumns = orderColumns.toArray(new OrderColumn[orderColumns.size()]); - orderProp = new LocalOrderProperty(orderColumns); - } - - public ILocalStructuralProperty getOrderProperty() { - return orderProp; - } - - @Override - public String toString() { - if (orderProp == null) { - return getOperatorTag().toString(); - } else { - return getOperatorTag().toString() + " " + orderProp; - } - } - - @Override - public Pair getInputOutputDependencyLabels(ILogicalOperator op) { - int[] inputDependencyLabels = new int[] { 0 }; - int[] outputDependencyLabels = new int[] { 1 }; - return new Pair(inputDependencyLabels, outputDependencyLabels); - } - - @Override - public boolean expensiveThanMaterialization() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AggregatePOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AggregatePOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AggregatePOperator.java deleted file mode 100644 index 8b1b447..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AggregatePOperator.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang3.mutable.Mutable; - -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression; -import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningRequirementsCoordinator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenHelper; -import edu.uci.ics.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory; -import edu.uci.ics.hyracks.algebricks.runtime.operators.aggreg.AggregateRuntimeFactory; -import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor; - -public class AggregatePOperator extends AbstractPhysicalOperator { - - public AggregatePOperator() { - } - - @Override - public PhysicalOperatorTag getOperatorTag() { - return PhysicalOperatorTag.AGGREGATE; - } - - @Override - public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) { - AggregateOperator aggOp = (AggregateOperator) op; - ILogicalOperator op2 = op.getInputs().get(0).getValue(); - if (aggOp.getExecutionMode() != AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) { - deliveredProperties = new StructuralPropertiesVector(op2.getDeliveredPhysicalProperties() - .getPartitioningProperty(), new ArrayList()); - } else { - deliveredProperties = new StructuralPropertiesVector(IPartitioningProperty.UNPARTITIONED, - new ArrayList()); - } - } - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, - IPhysicalPropertiesVector reqdByParent) { - AggregateOperator aggOp = (AggregateOperator) op; - StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1]; - if (aggOp.isGlobal() && aggOp.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) { - pv[0] = new StructuralPropertiesVector(IPartitioningProperty.UNPARTITIONED, null); - return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION); - } else { - return emptyUnaryRequirements(); - } - - } - - @Override - public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, - IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) - throws AlgebricksException { - AggregateOperator aggOp = (AggregateOperator) op; - List variables = aggOp.getVariables(); - List> expressions = aggOp.getExpressions(); - int[] outColumns = new int[variables.size()]; - for (int i = 0; i < outColumns.length; i++) { - outColumns[i] = opSchema.findVariable(variables.get(i)); - } - IAggregateEvaluatorFactory[] aggFactories = new IAggregateEvaluatorFactory[expressions.size()]; - IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); - for (int i = 0; i < aggFactories.length; i++) { - AggregateFunctionCallExpression aggFun = (AggregateFunctionCallExpression) expressions.get(i).getValue(); - aggFactories[i] = expressionRuntimeProvider.createAggregateFunctionFactory(aggFun, - context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas, context); - } - - AggregateRuntimeFactory runtime = new AggregateRuntimeFactory(aggFactories); - - // contribute one Asterix framewriter - RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); - builder.contributeMicroOperator(aggOp, runtime, recDesc); - // and contribute one edge from its child - ILogicalOperator src = aggOp.getInputs().get(0).getValue(); - builder.contributeGraphEdge(src, 0, aggOp, 0); - } - - @Override - public boolean isMicroOperator() { - return true; - } - - @Override - public boolean expensiveThanMaterialization() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AssignPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AssignPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AssignPOperator.java deleted file mode 100644 index 0a67ced..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/AssignPOperator.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.List; - -import org.apache.commons.lang3.mutable.Mutable; - -import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint; -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AssignOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenHelper; -import edu.uci.ics.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory; -import edu.uci.ics.hyracks.algebricks.runtime.operators.std.AssignRuntimeFactory; -import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor; - -public class AssignPOperator extends AbstractPhysicalOperator { - - private boolean flushFramesRapidly; - private int cardinalityConstraint = 0; - - @Override - public PhysicalOperatorTag getOperatorTag() { - return PhysicalOperatorTag.ASSIGN; - } - - @Override - public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) { - AssignOperator assignOp = (AssignOperator) op; - ILogicalOperator op2 = op.getInputs().get(0).getValue(); - deliveredProperties = op2.getDeliveredPhysicalProperties().clone(); - if (assignOp.getExplicitOrderingProperty() != null) { - deliveredProperties.getLocalProperties().add(assignOp.getExplicitOrderingProperty()); - } - } - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, - IPhysicalPropertiesVector reqdByParent) { - return emptyUnaryRequirements(); - } - - @Override - public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, - IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) - throws AlgebricksException { - AssignOperator assign = (AssignOperator) op; - List variables = assign.getVariables(); - List> expressions = assign.getExpressions(); - int[] outColumns = new int[variables.size()]; - for (int i = 0; i < outColumns.length; i++) { - outColumns[i] = opSchema.findVariable(variables.get(i)); - } - IScalarEvaluatorFactory[] evalFactories = new IScalarEvaluatorFactory[expressions.size()]; - IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider(); - for (int i = 0; i < evalFactories.length; i++) { - evalFactories[i] = expressionRuntimeProvider.createEvaluatorFactory(expressions.get(i).getValue(), - context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas, context); - } - - // TODO push projections into the operator - int[] projectionList = JobGenHelper.projectAllVariables(opSchema); - - AssignRuntimeFactory runtime = new AssignRuntimeFactory(outColumns, evalFactories, projectionList, - flushFramesRapidly); - - // contribute one Asterix framewriter - RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); - if (cardinalityConstraint > 0) { - AlgebricksCountPartitionConstraint countConstraint = new AlgebricksCountPartitionConstraint( - cardinalityConstraint); - builder.contributeMicroOperator(assign, runtime, recDesc, countConstraint); - } else { - builder.contributeMicroOperator(assign, runtime, recDesc); - } - // and contribute one edge from its child - ILogicalOperator src = assign.getInputs().get(0).getValue(); - builder.contributeGraphEdge(src, 0, assign, 0); - - } - - @Override - public boolean isMicroOperator() { - return true; - } - - public void setRapidFrameFlush(boolean flushFramesRapidly) { - this.flushFramesRapidly = flushFramesRapidly; - } - - public void setCardinalityConstraint(int cardinality) { - this.cardinalityConstraint = cardinality; - } - - - @Override - public boolean expensiveThanMaterialization() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BroadcastPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BroadcastPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BroadcastPOperator.java deleted file mode 100644 index b210d56..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BroadcastPOperator.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder.TargetConstraint; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.BroadcastPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.INodeDomain; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; -import edu.uci.ics.hyracks.api.dataflow.IConnectorDescriptor; -import edu.uci.ics.hyracks.api.job.IConnectorDescriptorRegistry; -import edu.uci.ics.hyracks.dataflow.std.connectors.MToNReplicatingConnectorDescriptor; - -public class BroadcastPOperator extends AbstractExchangePOperator { - - private INodeDomain domain; - - public BroadcastPOperator(INodeDomain domain) { - this.domain = domain; - } - - @Override - public PhysicalOperatorTag getOperatorTag() { - return PhysicalOperatorTag.BROADCAST_EXCHANGE; - } - - @Override - public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) { - AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); - IPartitioningProperty pp = new BroadcastPartitioningProperty(domain); - this.deliveredProperties = new StructuralPropertiesVector(pp, op2.getDeliveredPhysicalProperties() - .getLocalProperties()); - } - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, - IPhysicalPropertiesVector reqdByParent) { - return emptyUnaryRequirements(); - } - - @Override - public Pair createConnectorDescriptor(IConnectorDescriptorRegistry spec, - ILogicalOperator op, IOperatorSchema opSchema, JobGenContext context) throws AlgebricksException { - IConnectorDescriptor conn = new MToNReplicatingConnectorDescriptor(spec); - return new Pair(conn, null); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BulkloadPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BulkloadPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BulkloadPOperator.java deleted file mode 100644 index 23652f6..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/BulkloadPOperator.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.ArrayList; -import java.util.List; - -import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint; -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; -import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSource; -import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteOperator.Kind; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningRequirementsCoordinator; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; -import edu.uci.ics.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenHelper; -import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor; -import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor; -import edu.uci.ics.hyracks.api.job.JobSpecification; - -public class BulkloadPOperator extends AbstractPhysicalOperator { - - private final LogicalVariable payload; - private final List primaryKeys; - private final List additionalFilteringKeys; - private final IDataSource dataSource; - - public BulkloadPOperator(LogicalVariable payload, List keys, - List additionalFilteringKeys, IDataSource dataSource) { - this.payload = payload; - this.primaryKeys = keys; - this.additionalFilteringKeys = additionalFilteringKeys; - this.dataSource = dataSource; - } - - @Override - public PhysicalOperatorTag getOperatorTag() { - return PhysicalOperatorTag.BULKLOAD; - } - - @Override - public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, - IPhysicalPropertiesVector reqdByParent) { - List scanVariables = new ArrayList<>(); - scanVariables.addAll(primaryKeys); - scanVariables.add(new LogicalVariable(-1)); - IPhysicalPropertiesVector physicalProps = dataSource.getPropertiesProvider().computePropertiesVector( - scanVariables); - StructuralPropertiesVector spv = new StructuralPropertiesVector(physicalProps.getPartitioningProperty(), - physicalProps.getLocalProperties()); - return new PhysicalRequirements(new IPhysicalPropertiesVector[] { spv }, - IPartitioningRequirementsCoordinator.NO_COORDINATION); - } - - @Override - public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) - throws AlgebricksException { - AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(0).getValue(); - deliveredProperties = (StructuralPropertiesVector) op2.getDeliveredPhysicalProperties().clone(); - } - - @Override - public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, - IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) - throws AlgebricksException { - InsertDeleteOperator insertDeleteOp = (InsertDeleteOperator) op; - assert insertDeleteOp.getOperation() == Kind.INSERT; - assert insertDeleteOp.isBulkload(); - - IMetadataProvider mp = context.getMetadataProvider(); - IVariableTypeEnvironment typeEnv = context.getTypeEnvironment(op); - JobSpecification spec = builder.getJobSpec(); - RecordDescriptor inputDesc = JobGenHelper.mkRecordDescriptor( - context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas[0], context); - Pair runtimeAndConstraints = mp.getInsertRuntime( - dataSource, propagatedSchema, typeEnv, primaryKeys, payload, additionalFilteringKeys, - inputDesc, context, spec, true); - builder.contributeHyracksOperator(insertDeleteOp, runtimeAndConstraints.first); - builder.contributeAlgebricksPartitionConstraint(runtimeAndConstraints.first, runtimeAndConstraints.second); - ILogicalOperator src = insertDeleteOp.getInputs().get(0).getValue(); - builder.contributeGraphEdge(src, 0, insertDeleteOp, 0); - } - - @Override - public boolean isMicroOperator() { - return false; - } - - @Override - public boolean expensiveThanMaterialization() { - return false; - } - - -} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/DataSourceScanPOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/DataSourceScanPOperator.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/DataSourceScanPOperator.java deleted file mode 100644 index f1cb937..0000000 --- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/operators/physical/DataSourceScanPOperator.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2009-2013 by The Regents of the University of California - * Licensed 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 from - * - * 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 edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical; - -import java.util.List; - -import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint; -import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; -import edu.uci.ics.hyracks.algebricks.common.utils.Pair; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; -import edu.uci.ics.hyracks.algebricks.core.algebra.base.PhysicalOperatorTag; -import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; -import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSource; -import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSourcePropertiesProvider; -import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator; -import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; -import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; -import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor; - -@SuppressWarnings("rawtypes") -public class DataSourceScanPOperator extends AbstractScanPOperator { - - private IDataSource dataSource; - private Object implConfig; - - public DataSourceScanPOperator(IDataSource dataSource) { - this.dataSource = dataSource; - } - - public void setImplConfig(Object implConfig) { - this.implConfig = implConfig; - } - - public Object getImplConfig() { - return implConfig; - } - - @Override - public PhysicalOperatorTag getOperatorTag() { - return PhysicalOperatorTag.DATASOURCE_SCAN; - } - - @Override - public boolean isMicroOperator() { - return false; - } - - @Override - public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) { - // partitioning properties - DataSourceScanOperator dssOp = (DataSourceScanOperator) op; - IDataSourcePropertiesProvider dspp = dataSource.getPropertiesProvider(); - deliveredProperties = dspp.computePropertiesVector(dssOp.getVariables()); - } - - @SuppressWarnings("unchecked") - @Override - public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, - IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) - throws AlgebricksException { - DataSourceScanOperator scan = (DataSourceScanOperator) op; - IMetadataProvider mp = context.getMetadataProvider(); - IVariableTypeEnvironment typeEnv = context.getTypeEnvironment(op); - List vars = scan.getVariables(); - List projectVars = scan.getProjectVariables(); - - Pair p = mp.getScannerRuntime(dataSource, vars, - projectVars, scan.isProjectPushed(), scan.getMinFilterVars(), scan.getMaxFilterVars(), opSchema, - typeEnv, context, builder.getJobSpec(), implConfig); - builder.contributeHyracksOperator(scan, p.first); - if (p.second != null) { - builder.contributeAlgebricksPartitionConstraint(p.first, p.second); - } - - ILogicalOperator srcExchange = scan.getInputs().get(0).getValue(); - builder.contributeGraphEdge(srcExchange, 0, scan, 0); - } -}