You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by im...@apache.org on 2015/08/25 18:41:49 UTC
[36/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/util/OperatorManipulationUtil.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/util/OperatorManipulationUtil.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/util/OperatorManipulationUtil.java
deleted file mode 100644
index adb7a8f..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/util/OperatorManipulationUtil.java
+++ /dev/null
@@ -1,225 +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.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.mutable.Mutable;
-import org.apache.commons.lang3.mutable.MutableObject;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-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.LogicalOperatorTag;
-import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.LimitOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.NestedTupleSourceOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors.OperatorDeepCopyVisitor;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
-import edu.uci.ics.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl;
-import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext;
-
-public class OperatorManipulationUtil {
-
- // Transforms all NestedTupleSource operators to EmptyTupleSource operators
- public static void ntsToEts(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
- throws AlgebricksException {
- AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
- if (op.getOperatorTag() == LogicalOperatorTag.NESTEDTUPLESOURCE) {
- EmptyTupleSourceOperator ets = new EmptyTupleSourceOperator();
- context.computeAndSetTypeEnvironmentForOperator(ets);
- opRef.setValue(ets);
- } else {
- for (Mutable<ILogicalOperator> i : opRef.getValue().getInputs()) {
- ntsToEts(i, context);
- }
- }
- }
-
- public static ILogicalOperator eliminateSingleSubplanOverEts(SubplanOperator subplan) {
- if (subplan.getNestedPlans().size() > 1) {
- // not a single subplan
- List<Mutable<ILogicalOperator>> subInpList = subplan.getInputs();
- subInpList.clear();
- subInpList.add(new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator()));
- return subplan;
- }
- ILogicalPlan plan = subplan.getNestedPlans().get(0);
- if (plan.getRoots().size() > 1) {
- // not a single subplan
- List<Mutable<ILogicalOperator>> subInpList = subplan.getInputs();
- subInpList.clear();
- subInpList.add(new MutableObject<ILogicalOperator>(new EmptyTupleSourceOperator()));
- return subplan;
- }
- return plan.getRoots().get(0).getValue();
- }
-
- public static boolean setOperatorMode(AbstractLogicalOperator op) {
- boolean change = false;
- switch (op.getOperatorTag()) {
- case DATASOURCESCAN: {
- op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED);
- AbstractLogicalOperator currentOp = op;
- while (currentOp.getInputs().size() == 1) {
- AbstractLogicalOperator child = (AbstractLogicalOperator) currentOp.getInputs().get(0).getValue();
- if (child.getOperatorTag() == LogicalOperatorTag.EXCHANGE) {
- break;
- }
- child.setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED);
- currentOp = child;
- }
- change = true;
- break;
- }
- case NESTEDTUPLESOURCE: {
- NestedTupleSourceOperator nts = (NestedTupleSourceOperator) op;
- AbstractLogicalOperator prevOp = (AbstractLogicalOperator) nts.getDataSourceReference().getValue()
- .getInputs().get(0).getValue();
- if (prevOp.getExecutionMode() != AbstractLogicalOperator.ExecutionMode.UNPARTITIONED) {
- nts.setExecutionMode(AbstractLogicalOperator.ExecutionMode.LOCAL);
- change = true;
- }
- break;
- }
- default: {
- boolean forceUnpartitioned = false;
- if (op.getOperatorTag() == LogicalOperatorTag.LIMIT) {
- LimitOperator opLim = (LimitOperator) op;
- if (opLim.isTopmostLimitOp()) {
- opLim.setExecutionMode(AbstractLogicalOperator.ExecutionMode.UNPARTITIONED);
- change = true;
- forceUnpartitioned = true;
- }
- }
- if (op.getOperatorTag() == LogicalOperatorTag.AGGREGATE) {
- AggregateOperator aggOp = (AggregateOperator) op;
- if (aggOp.isGlobal()) {
- op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.UNPARTITIONED);
- change = true;
- forceUnpartitioned = true;
- }
- }
-
- for (Mutable<ILogicalOperator> i : op.getInputs()) {
- boolean exit = false;
- AbstractLogicalOperator inputOp = (AbstractLogicalOperator) i.getValue();
- switch (inputOp.getExecutionMode()) {
- case PARTITIONED: {
- if (forceUnpartitioned)
- break;
- op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED);
- change = true;
- exit = true;
- break;
- }
- case LOCAL: {
- op.setExecutionMode(AbstractLogicalOperator.ExecutionMode.LOCAL);
- change = true;
- break;
- }
- }
- if (exit) {
- break;
- }
- }
- break;
- }
- }
- return change;
- }
-
- public static void substituteVarRec(AbstractLogicalOperator op, LogicalVariable v1, LogicalVariable v2,
- boolean goThroughNts, ITypingContext ctx) throws AlgebricksException {
- VariableUtilities.substituteVariables(op, v1, v2, goThroughNts, ctx);
- for (Mutable<ILogicalOperator> opRef2 : op.getInputs()) {
- substituteVarRec((AbstractLogicalOperator) opRef2.getValue(), v1, v2, goThroughNts, ctx);
- }
- if (op.getOperatorTag() == LogicalOperatorTag.NESTEDTUPLESOURCE && goThroughNts) {
- NestedTupleSourceOperator nts = (NestedTupleSourceOperator) op;
- if (nts.getDataSourceReference() != null) {
- AbstractLogicalOperator op2 = (AbstractLogicalOperator) nts.getDataSourceReference().getValue()
- .getInputs().get(0).getValue();
- substituteVarRec(op2, v1, v2, goThroughNts, ctx);
- }
- }
- if (op.hasNestedPlans()) {
- AbstractOperatorWithNestedPlans aonp = (AbstractOperatorWithNestedPlans) op;
- for (ILogicalPlan p : aonp.getNestedPlans()) {
- for (Mutable<ILogicalOperator> ref : p.getRoots()) {
- AbstractLogicalOperator aop = (AbstractLogicalOperator) ref.getValue();
- substituteVarRec(aop, v1, v2, goThroughNts, ctx);
- }
- }
- }
- }
-
- public static ILogicalPlan deepCopy(ILogicalPlan plan) throws AlgebricksException {
- List<Mutable<ILogicalOperator>> roots = plan.getRoots();
- List<Mutable<ILogicalOperator>> newRoots = clonePipeline(roots);
- return new ALogicalPlanImpl(newRoots);
- }
-
- public static ILogicalPlan deepCopy(ILogicalPlan plan, IOptimizationContext ctx) throws AlgebricksException {
- List<Mutable<ILogicalOperator>> roots = plan.getRoots();
- List<Mutable<ILogicalOperator>> newRoots = clonePipeline(roots);
- cloneTypeEnvironments(ctx, roots, newRoots);
- return new ALogicalPlanImpl(newRoots);
- }
-
- private static List<Mutable<ILogicalOperator>> clonePipeline(List<Mutable<ILogicalOperator>> roots)
- throws AlgebricksException {
- List<Mutable<ILogicalOperator>> newRoots = new ArrayList<Mutable<ILogicalOperator>>();
- for (Mutable<ILogicalOperator> opRef : roots) {
- newRoots.add(new MutableObject<ILogicalOperator>(bottomUpCopyOperators(opRef.getValue())));
- }
- return newRoots;
- }
-
- private static void cloneTypeEnvironments(IOptimizationContext ctx, List<Mutable<ILogicalOperator>> roots,
- List<Mutable<ILogicalOperator>> newRoots) {
- for (int i = 0; i < newRoots.size(); i++) {
- Mutable<ILogicalOperator> opRef = newRoots.get(i);
- Mutable<ILogicalOperator> oldOpRef = roots.get(i);
- while (opRef.getValue().getInputs().size() > 0) {
- ctx.setOutputTypeEnvironment(opRef.getValue(), ctx.getOutputTypeEnvironment(oldOpRef.getValue()));
- opRef = opRef.getValue().getInputs().get(0);
- oldOpRef = oldOpRef.getValue().getInputs().get(0);
- }
- ctx.setOutputTypeEnvironment(opRef.getValue(), ctx.getOutputTypeEnvironment(oldOpRef.getValue()));
- }
- }
-
- public static ILogicalOperator bottomUpCopyOperators(ILogicalOperator op) throws AlgebricksException {
- ILogicalOperator newOp = deepCopy(op);
- newOp.getInputs().clear();
- for (Mutable<ILogicalOperator> child : op.getInputs())
- newOp.getInputs().add(new MutableObject<ILogicalOperator>(bottomUpCopyOperators(child.getValue())));
- return newOp;
- }
-
- public static ILogicalOperator deepCopy(ILogicalOperator op) throws AlgebricksException {
- OperatorDeepCopyVisitor visitor = new OperatorDeepCopyVisitor();
- return op.accept(visitor, 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/util/OperatorPropertiesUtil.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java
deleted file mode 100644
index ec9b403..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java
+++ /dev/null
@@ -1,300 +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.util;
-
-import java.util.Collection;
-import java.util.HashSet;
-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.ListSet;
-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.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.AbstractFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractOperatorWithNestedPlans;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.SelectOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
-
-public class OperatorPropertiesUtil {
-
- public static <T> boolean disjoint(Collection<T> c1, Collection<T> c2) {
- for (T m : c1) {
- if (c2.contains(m)) {
- return false;
- }
- }
- return true;
- }
-
- // Obs: doesn't return expected result for op. with nested plans.
- private static void getFreeVariablesInOp(ILogicalOperator op, Set<LogicalVariable> freeVars)
- throws AlgebricksException {
- VariableUtilities.getUsedVariables(op, freeVars);
- HashSet<LogicalVariable> produced = new HashSet<LogicalVariable>();
- VariableUtilities.getProducedVariables(op, produced);
- for (LogicalVariable v : produced) {
- freeVars.remove(v);
- }
- }
-
- /**
- * Adds the free variables of the plan rooted at that operator to the
- * collection provided.
- *
- * @param op
- * @param vars
- * - The collection to which the free variables will be added.
- */
- public static void getFreeVariablesInSelfOrDesc(AbstractLogicalOperator op, Set<LogicalVariable> freeVars)
- throws AlgebricksException {
- HashSet<LogicalVariable> produced = new HashSet<LogicalVariable>();
- VariableUtilities.getProducedVariables(op, produced);
- for (LogicalVariable v : produced) {
- freeVars.remove(v);
- }
-
- HashSet<LogicalVariable> used = new HashSet<LogicalVariable>();
- VariableUtilities.getUsedVariables(op, used);
- for (LogicalVariable v : used) {
- if (!freeVars.contains(v)) {
- freeVars.add(v);
- }
- }
-
- if (op.hasNestedPlans()) {
- AbstractOperatorWithNestedPlans s = (AbstractOperatorWithNestedPlans) op;
- for (ILogicalPlan p : s.getNestedPlans()) {
- for (Mutable<ILogicalOperator> r : p.getRoots()) {
- getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) r.getValue(), freeVars);
- }
- }
- s.getUsedVariablesExceptNestedPlans(freeVars);
- HashSet<LogicalVariable> produced2 = new HashSet<LogicalVariable>();
- s.getProducedVariablesExceptNestedPlans(produced2);
- freeVars.removeAll(produced);
- }
- for (Mutable<ILogicalOperator> i : op.getInputs()) {
- getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) i.getValue(), freeVars);
- }
- }
-
- /**
- * Adds the free variables of the operator path from
- * op to dest, where dest is a direct/indirect input operator of op in the query plan.
- *
- * @param op
- * , the start operator.
- * @param dest
- * , the destination operator (a direct/indirect input operator).
- * @param freeVars
- * - The collection to which the free variables will be added.
- */
- public static void getFreeVariablesInPath(ILogicalOperator op, ILogicalOperator dest, Set<LogicalVariable> freeVars)
- throws AlgebricksException {
- Set<LogicalVariable> producedVars = new ListSet<LogicalVariable>();
- VariableUtilities.getLiveVariables(op, freeVars);
- collectUsedAndProducedVariablesInPath(op, dest, freeVars, producedVars);
- freeVars.removeAll(producedVars);
- }
-
- /**
- * @param op
- * , the start operator.
- * @param dest
- * , the destination operator (a direct/indirect input operator).
- * @param usedVars
- * , the collection of used variables.
- * @param producedVars
- * , the collection of produced variables.
- * @return if the current operator is on the path from the original start operator to the destination operator.
- * @throws AlgebricksException
- */
- private static boolean collectUsedAndProducedVariablesInPath(ILogicalOperator op, ILogicalOperator dest,
- Set<LogicalVariable> usedVars, Set<LogicalVariable> producedVars) throws AlgebricksException {
- if (op == dest) {
- return true;
- }
- boolean onPath = false;
- if (((AbstractLogicalOperator) op).hasNestedPlans()) {
- AbstractOperatorWithNestedPlans a = (AbstractOperatorWithNestedPlans) op;
- for (ILogicalPlan p : a.getNestedPlans()) {
- for (Mutable<ILogicalOperator> r : p.getRoots()) {
- if (isDestInNestedPath((AbstractLogicalOperator) r.getValue(), dest)) {
- onPath = true;
- }
- }
- }
- }
- for (Mutable<ILogicalOperator> childRef : op.getInputs()) {
- if (collectUsedAndProducedVariablesInPath(childRef.getValue(), dest, usedVars, producedVars)) {
- onPath = true;
- }
- }
- if (onPath) {
- VariableUtilities.getUsedVariables(op, usedVars);
- VariableUtilities.getProducedVariables(op, producedVars);
- }
- return onPath;
- }
-
- /***
- * Recursively checks if the dest operator is in the path of a nested plan
- *
- * @param op
- * @param dest
- * @return
- */
- private static boolean isDestInNestedPath(AbstractLogicalOperator op, ILogicalOperator dest) {
- if (op == dest) {
- return true;
- }
- for (Mutable<ILogicalOperator> i : op.getInputs()) {
- if (isDestInNestedPath((AbstractLogicalOperator) i.getValue(), dest)) {
- return true;
- }
- }
- if (op.hasNestedPlans()) {
- AbstractOperatorWithNestedPlans a = (AbstractOperatorWithNestedPlans) op;
- for (ILogicalPlan p : a.getNestedPlans()) {
- for (Mutable<ILogicalOperator> r : p.getRoots()) {
- if (isDestInNestedPath((AbstractLogicalOperator) r.getValue(), dest)) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- public static void getFreeVariablesInSubplans(AbstractOperatorWithNestedPlans op, Set<LogicalVariable> freeVars)
- throws AlgebricksException {
- for (ILogicalPlan p : op.getNestedPlans()) {
- for (Mutable<ILogicalOperator> r : p.getRoots()) {
- getFreeVariablesInSelfOrDesc((AbstractLogicalOperator) r.getValue(), freeVars);
- }
- }
- }
-
- public static boolean hasFreeVariablesInSelfOrDesc(AbstractLogicalOperator op) throws AlgebricksException {
- HashSet<LogicalVariable> free = new HashSet<LogicalVariable>();
- getFreeVariablesInSelfOrDesc(op, free);
- return !free.isEmpty();
- }
-
- public static boolean hasFreeVariables(ILogicalOperator op) throws AlgebricksException {
- HashSet<LogicalVariable> free = new HashSet<LogicalVariable>();
- getFreeVariablesInOp(op, free);
- return !free.isEmpty();
- }
-
- public static void computeSchemaAndPropertiesRecIfNull(AbstractLogicalOperator op, IOptimizationContext context)
- throws AlgebricksException {
- if (op.getSchema() == null) {
- for (Mutable<ILogicalOperator> i : op.getInputs()) {
- computeSchemaAndPropertiesRecIfNull((AbstractLogicalOperator) i.getValue(), context);
- }
- if (op.hasNestedPlans()) {
- AbstractOperatorWithNestedPlans a = (AbstractOperatorWithNestedPlans) op;
- for (ILogicalPlan p : a.getNestedPlans()) {
- for (Mutable<ILogicalOperator> r : p.getRoots()) {
- computeSchemaAndPropertiesRecIfNull((AbstractLogicalOperator) r.getValue(), context);
- }
- }
- }
- op.recomputeSchema();
- op.computeDeliveredPhysicalProperties(context);
- }
- }
-
- public static void computeSchemaRecIfNull(AbstractLogicalOperator op) throws AlgebricksException {
- if (op.getSchema() == null) {
- for (Mutable<ILogicalOperator> i : op.getInputs()) {
- computeSchemaRecIfNull((AbstractLogicalOperator) i.getValue());
- }
- if (op.hasNestedPlans()) {
- AbstractOperatorWithNestedPlans a = (AbstractOperatorWithNestedPlans) op;
- for (ILogicalPlan p : a.getNestedPlans()) {
- for (Mutable<ILogicalOperator> r : p.getRoots()) {
- computeSchemaRecIfNull((AbstractLogicalOperator) r.getValue());
- }
- }
- }
- op.recomputeSchema();
- }
- }
-
- public static boolean isNullTest(AbstractLogicalOperator op) {
- if (op.getOperatorTag() != LogicalOperatorTag.SELECT) {
- return false;
- }
- AbstractLogicalOperator doubleUnder = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
- if (doubleUnder.getOperatorTag() != LogicalOperatorTag.NESTEDTUPLESOURCE) {
- return false;
- }
- ILogicalExpression eu = ((SelectOperator) op).getCondition().getValue();
- if (eu.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
- return false;
- }
- AbstractFunctionCallExpression f1 = (AbstractFunctionCallExpression) eu;
- if (!f1.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.NOT)) {
- return false;
- }
- ILogicalExpression a1 = f1.getArguments().get(0).getValue();
- if (!a1.getExpressionTag().equals(LogicalExpressionTag.FUNCTION_CALL)) {
- return false;
- }
- AbstractFunctionCallExpression f2 = (AbstractFunctionCallExpression) a1;
- if (!f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_NULL)) {
- return false;
- }
- return true;
- }
-
- public static void typePlan(ILogicalPlan p, IOptimizationContext context) throws AlgebricksException {
- for (Mutable<ILogicalOperator> r : p.getRoots()) {
- typeOpRec(r, context);
- }
- }
-
- public static void typeOpRec(Mutable<ILogicalOperator> r, IOptimizationContext context) throws AlgebricksException {
- AbstractLogicalOperator op = (AbstractLogicalOperator) r.getValue();
- for (Mutable<ILogicalOperator> i : op.getInputs()) {
- typeOpRec(i, context);
- }
- if (op.hasNestedPlans()) {
- for (ILogicalPlan p : ((AbstractOperatorWithNestedPlans) op).getNestedPlans()) {
- typePlan(p, context);
- }
- }
- context.computeAndSetTypeEnvironmentForOperator(op);
- }
-
- public static boolean isAlwaysTrueCond(ILogicalExpression cond) {
- if (cond.getExpressionTag() == LogicalExpressionTag.CONSTANT) {
- return ((ConstantExpression) cond).getValue().isTrue();
- }
- 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/visitors/AbstractConstVarFunVisitor.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/AbstractConstVarFunVisitor.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/AbstractConstVarFunVisitor.java
deleted file mode 100644
index c7424f0..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/AbstractConstVarFunVisitor.java
+++ /dev/null
@@ -1,46 +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.visitors;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.StatefulFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression;
-
-public abstract class AbstractConstVarFunVisitor<R, T> implements ILogicalExpressionVisitor<R, T> {
-
- public abstract R visitFunctionCallExpression(AbstractFunctionCallExpression expr, T arg)
- throws AlgebricksException;
-
- public R visitAggregateFunctionCallExpression(AggregateFunctionCallExpression expr, T arg)
- throws AlgebricksException {
- return visitFunctionCallExpression(expr, arg);
- }
-
- public R visitScalarFunctionCallExpression(ScalarFunctionCallExpression expr, T arg) throws AlgebricksException {
- return visitFunctionCallExpression(expr, arg);
- }
-
- public R visitStatefulFunctionCallExpression(StatefulFunctionCallExpression expr, T arg) throws AlgebricksException {
- return visitFunctionCallExpression(expr, arg);
- }
-
- public R visitUnnestingFunctionCallExpression(UnnestingFunctionCallExpression expr, T arg)
- throws AlgebricksException {
- return visitFunctionCallExpression(expr, arg);
- }
-}
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/visitors/ILogicalExpressionReferenceTransform.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalExpressionReferenceTransform.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalExpressionReferenceTransform.java
deleted file mode 100644
index 06cec65..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalExpressionReferenceTransform.java
+++ /dev/null
@@ -1,25 +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.visitors;
-
-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.ILogicalExpression;
-
-public interface ILogicalExpressionReferenceTransform {
- // returns true if any change is made to the expression
- public boolean transform(Mutable<ILogicalExpression> expression) 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/visitors/ILogicalExpressionVisitor.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalExpressionVisitor.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalExpressionVisitor.java
deleted file mode 100644
index 3448db8..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalExpressionVisitor.java
+++ /dev/null
@@ -1,39 +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.visitors;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.StatefulFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
-
-public interface ILogicalExpressionVisitor<R, T> {
- public R visitConstantExpression(ConstantExpression expr, T arg) throws AlgebricksException;
-
- public R visitVariableReferenceExpression(VariableReferenceExpression expr, T arg) throws AlgebricksException;
-
- public R visitAggregateFunctionCallExpression(AggregateFunctionCallExpression expr, T arg)
- throws AlgebricksException;
-
- public R visitScalarFunctionCallExpression(ScalarFunctionCallExpression expr, T arg) throws AlgebricksException;
-
- public R visitStatefulFunctionCallExpression(StatefulFunctionCallExpression expr, T arg) throws AlgebricksException;
-
- public R visitUnnestingFunctionCallExpression(UnnestingFunctionCallExpression expr, T arg)
- 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/visitors/ILogicalOperatorVisitor.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalOperatorVisitor.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalOperatorVisitor.java
deleted file mode 100644
index 359e243..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/algebra/visitors/ILogicalOperatorVisitor.java
+++ /dev/null
@@ -1,117 +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.visitors;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AssignOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistinctOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistributeResultOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ExchangeOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ExtensionOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ExternalDataLookupOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IndexInsertDeleteOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.InnerJoinOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.InsertDeleteOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.LeftOuterJoinOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.LimitOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.MaterializeOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.NestedTupleSourceOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.OrderOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.PartitioningSplitOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ReplicateOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.RunningAggregateOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ScriptOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.SelectOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.SinkOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.SubplanOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.TokenizeOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnionAllOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnnestMapOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnnestOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.WriteOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.WriteResultOperator;
-
-public interface ILogicalOperatorVisitor<R, T> {
-
- public R visitAggregateOperator(AggregateOperator op, T arg) throws AlgebricksException;
-
- public R visitRunningAggregateOperator(RunningAggregateOperator op, T arg) throws AlgebricksException;
-
- public R visitEmptyTupleSourceOperator(EmptyTupleSourceOperator op, T arg) throws AlgebricksException;
-
- public R visitGroupByOperator(GroupByOperator op, T arg) throws AlgebricksException;
-
- public R visitLimitOperator(LimitOperator op, T arg) throws AlgebricksException;
-
- public R visitInnerJoinOperator(InnerJoinOperator op, T arg) throws AlgebricksException;
-
- public R visitLeftOuterJoinOperator(LeftOuterJoinOperator op, T arg) throws AlgebricksException;
-
- public R visitNestedTupleSourceOperator(NestedTupleSourceOperator op, T arg) throws AlgebricksException;
-
- public R visitOrderOperator(OrderOperator op, T arg) throws AlgebricksException;
-
- public R visitAssignOperator(AssignOperator op, T arg) throws AlgebricksException;
-
- public R visitSelectOperator(SelectOperator op, T arg) throws AlgebricksException;
-
- public R visitExtensionOperator(ExtensionOperator op, T arg) throws AlgebricksException;
-
- public R visitProjectOperator(ProjectOperator op, T arg) throws AlgebricksException;
-
- public R visitPartitioningSplitOperator(PartitioningSplitOperator op, T arg) throws AlgebricksException;
-
- public R visitReplicateOperator(ReplicateOperator op, T arg) throws AlgebricksException;
-
- public R visitMaterializeOperator(MaterializeOperator op, T arg) throws AlgebricksException;
-
- public R visitScriptOperator(ScriptOperator op, T arg) throws AlgebricksException;
-
- public R visitSubplanOperator(SubplanOperator op, T arg) throws AlgebricksException;
-
- public R visitSinkOperator(SinkOperator op, T arg) throws AlgebricksException;
-
- public R visitUnionOperator(UnionAllOperator op, T arg) throws AlgebricksException;
-
- public R visitUnnestOperator(UnnestOperator op, T arg) throws AlgebricksException;
-
- public R visitUnnestMapOperator(UnnestMapOperator op, T arg) throws AlgebricksException;
-
- public R visitDataScanOperator(DataSourceScanOperator op, T arg) throws AlgebricksException;
-
- public R visitDistinctOperator(DistinctOperator op, T arg) throws AlgebricksException;
-
- public R visitExchangeOperator(ExchangeOperator op, T arg) throws AlgebricksException;
-
- public R visitWriteOperator(WriteOperator op, T arg) throws AlgebricksException;
-
- public R visitDistributeResultOperator(DistributeResultOperator op, T arg) throws AlgebricksException;
-
- public R visitWriteResultOperator(WriteResultOperator op, T arg) throws AlgebricksException;
-
- public R visitInsertDeleteOperator(InsertDeleteOperator op, T tag) throws AlgebricksException;
-
- public R visitIndexInsertDeleteOperator(IndexInsertDeleteOperator op, T tag) throws AlgebricksException;
-
- public R visitExternalDataLookupOperator(ExternalDataLookupOperator op, T arg) throws AlgebricksException;
-
- public R visitTokenizeOperator(TokenizeOperator op, T arg) 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/config/AlgebricksConfig.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/config/AlgebricksConfig.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/config/AlgebricksConfig.java
deleted file mode 100644
index abdd6d1..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/config/AlgebricksConfig.java
+++ /dev/null
@@ -1,23 +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.config;
-
-import java.util.logging.Logger;
-
-public class AlgebricksConfig {
- public static final boolean DEBUG = true;
- public static final String ALGEBRICKS_LOGGER_NAME = "edu.uci.ics.hyracks.algebricks";
- public static final Logger ALGEBRICKS_LOGGER = Logger.getLogger(ALGEBRICKS_LOGGER_NAME);
-}
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/config/SysoutFormatter.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/config/SysoutFormatter.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/config/SysoutFormatter.java
deleted file mode 100644
index d449f92..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/config/SysoutFormatter.java
+++ /dev/null
@@ -1,35 +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.config;
-
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-
-public class SysoutFormatter extends Formatter {
- public String format(LogRecord rec) {
- StringBuffer buf = new StringBuffer(5000);
- buf.append(formatMessage(rec));
- return buf.toString();
- }
-
- public String getHead(Handler h) {
- return "";
- }
-
- public String getTail(Handler h) {
- return "";
- }
-}
\ No newline at end of file
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/jobgen/impl/ConnectorPolicyAssignmentPolicy.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/ConnectorPolicyAssignmentPolicy.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/ConnectorPolicyAssignmentPolicy.java
deleted file mode 100644
index 4cb111d..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/ConnectorPolicyAssignmentPolicy.java
+++ /dev/null
@@ -1,38 +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.jobgen.impl;
-
-import edu.uci.ics.hyracks.api.dataflow.IConnectorDescriptor;
-import edu.uci.ics.hyracks.api.dataflow.connectors.IConnectorPolicy;
-import edu.uci.ics.hyracks.api.dataflow.connectors.IConnectorPolicyAssignmentPolicy;
-import edu.uci.ics.hyracks.api.dataflow.connectors.PipeliningConnectorPolicy;
-import edu.uci.ics.hyracks.api.dataflow.connectors.SendSideMaterializedPipeliningConnectorPolicy;
-import edu.uci.ics.hyracks.dataflow.std.connectors.MToNPartitioningMergingConnectorDescriptor;
-
-public class ConnectorPolicyAssignmentPolicy implements IConnectorPolicyAssignmentPolicy {
- private static final long serialVersionUID = 1L;
- private IConnectorPolicy senderSideMaterializePolicy = new SendSideMaterializedPipeliningConnectorPolicy();
- private IConnectorPolicy pipeliningPolicy = new PipeliningConnectorPolicy();
-
- @Override
- public IConnectorPolicy getConnectorPolicyAssignment(IConnectorDescriptor c, int nProducers, int nConsumers,
- int[] fanouts) {
- if (c instanceof MToNPartitioningMergingConnectorDescriptor) {
- return senderSideMaterializePolicy;
- } else {
- return pipeliningPolicy;
- }
- }
-}
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/jobgen/impl/JobBuilder.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobBuilder.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobBuilder.java
deleted file mode 100644
index e1f897c..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobBuilder.java
+++ /dev/null
@@ -1,330 +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.jobgen.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-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.constraints.AlgebricksPartitionConstraintHelper;
-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.operators.logical.AbstractLogicalOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator.ExecutionMode;
-import edu.uci.ics.hyracks.algebricks.runtime.base.IPushRuntimeFactory;
-import edu.uci.ics.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor;
-import edu.uci.ics.hyracks.api.dataflow.ConnectorDescriptorId;
-import edu.uci.ics.hyracks.api.dataflow.IConnectorDescriptor;
-import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor;
-import edu.uci.ics.hyracks.api.dataflow.OperatorDescriptorId;
-import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
-import edu.uci.ics.hyracks.api.job.JobSpecification;
-
-public class JobBuilder implements IHyracksJobBuilder {
-
- private JobSpecification jobSpec;
- private AlgebricksPartitionConstraint clusterLocations;
-
- private Map<ILogicalOperator, ArrayList<ILogicalOperator>> outEdges = new HashMap<ILogicalOperator, ArrayList<ILogicalOperator>>();
- private Map<ILogicalOperator, ArrayList<ILogicalOperator>> inEdges = new HashMap<ILogicalOperator, ArrayList<ILogicalOperator>>();
- private Map<ILogicalOperator, Pair<IConnectorDescriptor, TargetConstraint>> connectors = new HashMap<ILogicalOperator, Pair<IConnectorDescriptor, TargetConstraint>>();
-
- private Map<ILogicalOperator, Pair<IPushRuntimeFactory, RecordDescriptor>> microOps = new HashMap<ILogicalOperator, Pair<IPushRuntimeFactory, RecordDescriptor>>();
- private Map<IPushRuntimeFactory, ILogicalOperator> revMicroOpMap = new HashMap<IPushRuntimeFactory, ILogicalOperator>();
- private Map<ILogicalOperator, IOperatorDescriptor> hyracksOps = new HashMap<ILogicalOperator, IOperatorDescriptor>();
- private Map<ILogicalOperator, AlgebricksPartitionConstraint> pcForMicroOps = new HashMap<ILogicalOperator, AlgebricksPartitionConstraint>();
-
- private int aodCounter = 0;
- private Map<ILogicalOperator, Integer> algebraicOpBelongingToMetaAsterixOp = new HashMap<ILogicalOperator, Integer>();
- private Map<Integer, List<Pair<IPushRuntimeFactory, RecordDescriptor>>> metaAsterixOpSkeletons = new HashMap<Integer, List<Pair<IPushRuntimeFactory, RecordDescriptor>>>();
- private Map<Integer, AlgebricksMetaOperatorDescriptor> metaAsterixOps = new HashMap<Integer, AlgebricksMetaOperatorDescriptor>();
- private final Map<IOperatorDescriptor, AlgebricksPartitionConstraint> partitionConstraintMap = new HashMap<IOperatorDescriptor, AlgebricksPartitionConstraint>();
-
- public JobBuilder(JobSpecification jobSpec, AlgebricksPartitionConstraint clusterLocations) {
- this.jobSpec = jobSpec;
- this.clusterLocations = clusterLocations;
- }
-
- @Override
- public void contributeMicroOperator(ILogicalOperator op, IPushRuntimeFactory runtime, RecordDescriptor recDesc) {
- contributeMicroOperator(op, runtime, recDesc, null);
- }
-
- @Override
- public void contributeMicroOperator(ILogicalOperator op, IPushRuntimeFactory runtime, RecordDescriptor recDesc,
- AlgebricksPartitionConstraint pc) {
- microOps.put(op, new Pair<IPushRuntimeFactory, RecordDescriptor>(runtime, recDesc));
- revMicroOpMap.put(runtime, op);
- if (pc != null) {
- pcForMicroOps.put(op, pc);
- }
- AbstractLogicalOperator logicalOp = (AbstractLogicalOperator) op;
- if (logicalOp.getExecutionMode() == ExecutionMode.UNPARTITIONED && pc == null) {
- AlgebricksPartitionConstraint apc = new AlgebricksCountPartitionConstraint(1);
- pcForMicroOps.put(logicalOp, apc);
- }
- }
-
- @Override
- public void contributeConnector(ILogicalOperator exchgOp, IConnectorDescriptor conn) {
- connectors.put(exchgOp, new Pair<IConnectorDescriptor, TargetConstraint>(conn, null));
- }
-
- @Override
- public void contributeConnectorWithTargetConstraint(ILogicalOperator exchgOp, IConnectorDescriptor conn,
- TargetConstraint numberOfTargetPartitions) {
- connectors.put(exchgOp, new Pair<IConnectorDescriptor, TargetConstraint>(conn, numberOfTargetPartitions));
- }
-
- @Override
- public void contributeGraphEdge(ILogicalOperator src, int srcOutputIndex, ILogicalOperator dest, int destInputIndex) {
- ArrayList<ILogicalOperator> outputs = outEdges.get(src);
- if (outputs == null) {
- outputs = new ArrayList<ILogicalOperator>();
- outEdges.put(src, outputs);
- }
- addAtPos(outputs, dest, srcOutputIndex);
-
- ArrayList<ILogicalOperator> inp = inEdges.get(dest);
- if (inp == null) {
- inp = new ArrayList<ILogicalOperator>();
- inEdges.put(dest, inp);
- }
- addAtPos(inp, src, destInputIndex);
- }
-
- @Override
- public void contributeHyracksOperator(ILogicalOperator op, IOperatorDescriptor opDesc) {
- hyracksOps.put(op, opDesc);
- }
-
- @Override
- public void contributeAlgebricksPartitionConstraint(IOperatorDescriptor opDesc, AlgebricksPartitionConstraint apc) {
- partitionConstraintMap.put(opDesc, apc);
- }
-
- @Override
- public JobSpecification getJobSpec() {
- return jobSpec;
- }
-
- @Override
- public void buildSpec(List<ILogicalOperator> roots) throws AlgebricksException {
- buildAsterixComponents();
- Map<IConnectorDescriptor, TargetConstraint> tgtConstraints = setupConnectors();
- for (ILogicalOperator r : roots) {
- IOperatorDescriptor opDesc = findOpDescForAlgebraicOp(r);
- jobSpec.addRoot(opDesc);
- }
- setAllPartitionConstraints(tgtConstraints);
- }
-
- private void setAllPartitionConstraints(Map<IConnectorDescriptor, TargetConstraint> tgtConstraints) {
- List<OperatorDescriptorId> roots = jobSpec.getRoots();
- setSpecifiedPartitionConstraints();
- for (OperatorDescriptorId rootId : roots) {
- setPartitionConstraintsDFS(rootId, tgtConstraints, null);
- }
- }
-
- private void setSpecifiedPartitionConstraints() {
- for (ILogicalOperator op : pcForMicroOps.keySet()) {
- AlgebricksPartitionConstraint pc = pcForMicroOps.get(op);
- Integer k = algebraicOpBelongingToMetaAsterixOp.get(op);
- AlgebricksMetaOperatorDescriptor amod = metaAsterixOps.get(k);
- partitionConstraintMap.put(amod, pc);
- }
- for (IOperatorDescriptor opDesc : partitionConstraintMap.keySet()) {
- AlgebricksPartitionConstraint pc = partitionConstraintMap.get(opDesc);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(jobSpec, opDesc, pc);
- }
- }
-
- private void setPartitionConstraintsDFS(OperatorDescriptorId opId,
- Map<IConnectorDescriptor, TargetConstraint> tgtConstraints, IOperatorDescriptor parentOp) {
- List<IConnectorDescriptor> opInputs = jobSpec.getOperatorInputMap().get(opId);
- AlgebricksPartitionConstraint opConstraint = null;
- IOperatorDescriptor opDesc = jobSpec.getOperatorMap().get(opId);
- if (opInputs != null) {
- for (IConnectorDescriptor conn : opInputs) {
- ConnectorDescriptorId cid = conn.getConnectorId();
- org.apache.commons.lang3.tuple.Pair<org.apache.commons.lang3.tuple.Pair<IOperatorDescriptor, Integer>, org.apache.commons.lang3.tuple.Pair<IOperatorDescriptor, Integer>> p = jobSpec
- .getConnectorOperatorMap().get(cid);
- IOperatorDescriptor src = p.getLeft().getLeft();
- // DFS
- setPartitionConstraintsDFS(src.getOperatorId(), tgtConstraints, opDesc);
-
- TargetConstraint constraint = tgtConstraints.get(conn);
- if (constraint != null) {
- switch (constraint) {
- case ONE: {
- opConstraint = new AlgebricksCountPartitionConstraint(1);
- break;
- }
- case SAME_COUNT: {
- opConstraint = partitionConstraintMap.get(src);
- break;
- }
- }
- }
- }
- }
- if (partitionConstraintMap.get(opDesc) == null) {
- if (opConstraint == null) {
- if (parentOp != null) {
- AlgebricksPartitionConstraint pc = partitionConstraintMap.get(parentOp);
- if (pc != null) {
- opConstraint = pc;
- } else if (opInputs == null || opInputs.size() == 0) {
- opConstraint = new AlgebricksCountPartitionConstraint(1);
- }
- }
- if (opConstraint == null) {
- opConstraint = clusterLocations;
- }
- }
- partitionConstraintMap.put(opDesc, opConstraint);
- AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(jobSpec, opDesc, opConstraint);
- }
- }
-
- private Map<IConnectorDescriptor, TargetConstraint> setupConnectors() throws AlgebricksException {
- Map<IConnectorDescriptor, TargetConstraint> tgtConstraints = new HashMap<IConnectorDescriptor, TargetConstraint>();
- for (ILogicalOperator exchg : connectors.keySet()) {
- ILogicalOperator inOp = inEdges.get(exchg).get(0);
- ILogicalOperator outOp = outEdges.get(exchg).get(0);
- IOperatorDescriptor inOpDesc = findOpDescForAlgebraicOp(inOp);
- IOperatorDescriptor outOpDesc = findOpDescForAlgebraicOp(outOp);
- Pair<IConnectorDescriptor, TargetConstraint> connPair = connectors.get(exchg);
- IConnectorDescriptor conn = connPair.first;
- int producerPort = outEdges.get(inOp).indexOf(exchg);
- int consumerPort = inEdges.get(outOp).indexOf(exchg);
- jobSpec.connect(conn, inOpDesc, producerPort, outOpDesc, consumerPort);
- if (connPair.second != null) {
- tgtConstraints.put(conn, connPair.second);
- }
- }
- return tgtConstraints;
- }
-
- private IOperatorDescriptor findOpDescForAlgebraicOp(ILogicalOperator op) throws AlgebricksException {
- IOperatorDescriptor hOpDesc = hyracksOps.get(op);
- if (hOpDesc != null) {
- return hOpDesc;
- }
- Integer metaOpKey = algebraicOpBelongingToMetaAsterixOp.get(op);
- if (metaOpKey == null) {
- throw new AlgebricksException("Could not generate operator descriptor for operator " + op);
- }
- return metaAsterixOps.get(metaOpKey);
- }
-
- private void buildAsterixComponents() {
- for (ILogicalOperator aop : microOps.keySet()) {
- addMicroOpToMetaRuntimeOp(aop);
- }
- for (Integer k : metaAsterixOpSkeletons.keySet()) {
- List<Pair<IPushRuntimeFactory, RecordDescriptor>> opContents = metaAsterixOpSkeletons.get(k);
- AlgebricksMetaOperatorDescriptor amod = buildMetaAsterixOpDesc(opContents);
- metaAsterixOps.put(k, amod);
- }
- }
-
- private AlgebricksMetaOperatorDescriptor buildMetaAsterixOpDesc(
- List<Pair<IPushRuntimeFactory, RecordDescriptor>> opContents) {
- // RecordDescriptor outputRecordDesc = null;
- int n = opContents.size();
- IPushRuntimeFactory[] runtimeFactories = new IPushRuntimeFactory[n];
- RecordDescriptor[] internalRecordDescriptors = new RecordDescriptor[n];
- int i = 0;
- for (Pair<IPushRuntimeFactory, RecordDescriptor> p : opContents) {
- runtimeFactories[i] = p.first;
- internalRecordDescriptors[i] = p.second;
- // if (i == n - 1) {
- // outputRecordDesc = p.second;
- // }
- i++;
- }
- ILogicalOperator lastLogicalOp = revMicroOpMap.get(runtimeFactories[n - 1]);
- ArrayList<ILogicalOperator> outOps = outEdges.get(lastLogicalOp);
- int outArity = (outOps == null) ? 0 : outOps.size();
- ILogicalOperator firstLogicalOp = revMicroOpMap.get(runtimeFactories[0]);
- ArrayList<ILogicalOperator> inOps = inEdges.get(firstLogicalOp);
- int inArity = (inOps == null) ? 0 : inOps.size();
- // boolean isLeafOp = inEdges.get(firstLogicalOp) == null;
- return new AlgebricksMetaOperatorDescriptor(jobSpec, inArity, outArity, runtimeFactories,
- internalRecordDescriptors);
- }
-
- private void addMicroOpToMetaRuntimeOp(ILogicalOperator aop) {
- Integer k = algebraicOpBelongingToMetaAsterixOp.get(aop);
- if (k == null) {
- k = createNewMetaOpInfo(aop);
- }
- ArrayList<ILogicalOperator> destList = outEdges.get(aop);
- if (destList == null || destList.size() != 1) {
- // for now, we only support linear plans inside meta-ops.
- return;
- }
- ILogicalOperator dest = destList.get(0);
- Integer j = algebraicOpBelongingToMetaAsterixOp.get(dest);
- if (j == null && microOps.get(dest) != null) {
- algebraicOpBelongingToMetaAsterixOp.put(dest, k);
- List<Pair<IPushRuntimeFactory, RecordDescriptor>> aodContent1 = metaAsterixOpSkeletons.get(k);
- aodContent1.add(microOps.get(dest));
- } else if (j != null && j.intValue() != k.intValue()) {
- // merge the j component into the k component
- List<Pair<IPushRuntimeFactory, RecordDescriptor>> aodContent1 = metaAsterixOpSkeletons.get(k);
- List<Pair<IPushRuntimeFactory, RecordDescriptor>> aodContent2 = metaAsterixOpSkeletons.get(j);
- aodContent1.addAll(aodContent2);
- metaAsterixOpSkeletons.remove(j);
- for (ILogicalOperator m : algebraicOpBelongingToMetaAsterixOp.keySet()) {
- Integer g = algebraicOpBelongingToMetaAsterixOp.get(m);
- if (g.intValue() == j.intValue()) {
- algebraicOpBelongingToMetaAsterixOp.put(m, k);
- }
- }
- }
-
- }
-
- private int createNewMetaOpInfo(ILogicalOperator aop) {
- int n = aodCounter;
- aodCounter++;
- List<Pair<IPushRuntimeFactory, RecordDescriptor>> metaOpContents = new ArrayList<Pair<IPushRuntimeFactory, RecordDescriptor>>();
- metaOpContents.add(microOps.get(aop));
- metaAsterixOpSkeletons.put(n, metaOpContents);
- algebraicOpBelongingToMetaAsterixOp.put(aop, n);
- return n;
- }
-
- private <E> void addAtPos(ArrayList<E> a, E elem, int pos) {
- int n = a.size();
- if (n > pos) {
- a.set(pos, elem);
- } else {
- for (int k = n; k < pos; k++) {
- a.add(null);
- }
- a.add(elem);
- }
- }
-
-}
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/jobgen/impl/JobGenContext.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobGenContext.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobGenContext.java
deleted file mode 100644
index a181304..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobGenContext.java
+++ /dev/null
@@ -1,208 +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.jobgen.impl;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-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.LogicalVariable;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IPartialAggregationTypeComputer;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryBooleanInspectorFactory;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryComparatorFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryHashFunctionFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryHashFunctionFamilyProvider;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryIntegerInspectorFactory;
-import edu.uci.ics.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.ISerializerDeserializerProvider;
-import edu.uci.ics.hyracks.algebricks.data.ITypeTraitProvider;
-import edu.uci.ics.hyracks.api.dataflow.value.INullWriterFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider;
-
-public class JobGenContext {
- private final IOperatorSchema outerFlowSchema;
- private final Map<ILogicalOperator, IOperatorSchema> schemaMap = new HashMap<ILogicalOperator, IOperatorSchema>();
- private final ISerializerDeserializerProvider serializerDeserializerProvider;
- private final IBinaryHashFunctionFactoryProvider hashFunctionFactoryProvider;
- private final IBinaryHashFunctionFamilyProvider hashFunctionFamilyProvider;
- private final IBinaryComparatorFactoryProvider comparatorFactoryProvider;
- private final IPrinterFactoryProvider printerFactoryProvider;
- private final ITypeTraitProvider typeTraitProvider;
- private final IMetadataProvider<?, ?> metadataProvider;
- private final INullWriterFactory nullWriterFactory;
- private final INormalizedKeyComputerFactoryProvider normalizedKeyComputerFactoryProvider;
- private final Object appContext;
- private final IBinaryBooleanInspectorFactory booleanInspectorFactory;
- private final IBinaryIntegerInspectorFactory integerInspectorFactory;
- private final IExpressionRuntimeProvider expressionRuntimeProvider;
- private final IExpressionTypeComputer expressionTypeComputer;
- private final IExpressionEvalSizeComputer expressionEvalSizeComputer;
- private final IPartialAggregationTypeComputer partialAggregationTypeComputer;
- private final IPredicateEvaluatorFactoryProvider predEvaluatorFactoryProvider;
- private final int frameSize;
- private AlgebricksPartitionConstraint clusterLocations;
- private int varCounter;
- private final ITypingContext typingContext;
-
- public JobGenContext(IOperatorSchema outerFlowSchema, IMetadataProvider<?, ?> metadataProvider, Object appContext,
- ISerializerDeserializerProvider serializerDeserializerProvider,
- IBinaryHashFunctionFactoryProvider hashFunctionFactoryProvider,
- IBinaryHashFunctionFamilyProvider hashFunctionFamilyProvider,
- IBinaryComparatorFactoryProvider comparatorFactoryProvider, ITypeTraitProvider typeTraitProvider,
- IBinaryBooleanInspectorFactory booleanInspectorFactory,
- IBinaryIntegerInspectorFactory integerInspectorFactory, IPrinterFactoryProvider printerFactoryProvider,
- INullWriterFactory nullWriterFactory,
- INormalizedKeyComputerFactoryProvider normalizedKeyComputerFactoryProvider,
- IExpressionRuntimeProvider expressionRuntimeProvider, IExpressionTypeComputer expressionTypeComputer,
- INullableTypeComputer nullableTypeComputer, ITypingContext typingContext,
- IExpressionEvalSizeComputer expressionEvalSizeComputer,
- IPartialAggregationTypeComputer partialAggregationTypeComputer,
- IPredicateEvaluatorFactoryProvider predEvaluatorFactoryProvider, int frameSize,
- AlgebricksPartitionConstraint clusterLocations) {
- this.outerFlowSchema = outerFlowSchema;
- this.metadataProvider = metadataProvider;
- this.appContext = appContext;
- this.serializerDeserializerProvider = serializerDeserializerProvider;
- this.hashFunctionFactoryProvider = hashFunctionFactoryProvider;
- this.hashFunctionFamilyProvider = hashFunctionFamilyProvider;
- this.comparatorFactoryProvider = comparatorFactoryProvider;
- this.typeTraitProvider = typeTraitProvider;
- this.booleanInspectorFactory = booleanInspectorFactory;
- this.integerInspectorFactory = integerInspectorFactory;
- this.printerFactoryProvider = printerFactoryProvider;
- this.clusterLocations = clusterLocations;
- this.normalizedKeyComputerFactoryProvider = normalizedKeyComputerFactoryProvider;
- this.nullWriterFactory = nullWriterFactory;
- this.expressionRuntimeProvider = expressionRuntimeProvider;
- this.expressionTypeComputer = expressionTypeComputer;
- this.typingContext = typingContext;
- this.expressionEvalSizeComputer = expressionEvalSizeComputer;
- this.partialAggregationTypeComputer = partialAggregationTypeComputer;
- this.predEvaluatorFactoryProvider = predEvaluatorFactoryProvider;
- this.frameSize = frameSize;
- this.varCounter = 0;
- }
-
- public IOperatorSchema getOuterFlowSchema() {
- return outerFlowSchema;
- }
-
- public AlgebricksPartitionConstraint getClusterLocations() {
- return clusterLocations;
- }
-
- public IMetadataProvider<?, ?> getMetadataProvider() {
- return metadataProvider;
- }
-
- public Object getAppContext() {
- return appContext;
- }
-
- public ISerializerDeserializerProvider getSerializerDeserializerProvider() {
- return serializerDeserializerProvider;
- }
-
- public IBinaryHashFunctionFactoryProvider getBinaryHashFunctionFactoryProvider() {
- return hashFunctionFactoryProvider;
- }
-
- public IBinaryHashFunctionFamilyProvider getBinaryHashFunctionFamilyProvider() {
- return hashFunctionFamilyProvider;
- }
-
- public IBinaryComparatorFactoryProvider getBinaryComparatorFactoryProvider() {
- return comparatorFactoryProvider;
- }
-
- public ITypeTraitProvider getTypeTraitProvider() {
- return typeTraitProvider;
- }
-
- public IBinaryBooleanInspectorFactory getBinaryBooleanInspectorFactory() {
- return booleanInspectorFactory;
- }
-
- public IBinaryIntegerInspectorFactory getBinaryIntegerInspectorFactory() {
- return integerInspectorFactory;
- }
-
- public IPrinterFactoryProvider getPrinterFactoryProvider() {
- return printerFactoryProvider;
- }
-
- public IPredicateEvaluatorFactoryProvider getPredicateEvaluatorFactoryProvider() {
- return predEvaluatorFactoryProvider;
- }
-
- public IExpressionRuntimeProvider getExpressionRuntimeProvider() {
- return expressionRuntimeProvider;
- }
-
- public IOperatorSchema getSchema(ILogicalOperator op) {
- return schemaMap.get(op);
- }
-
- public void putSchema(ILogicalOperator op, IOperatorSchema schema) {
- schemaMap.put(op, schema);
- }
-
- public LogicalVariable createNewVar() {
- varCounter++;
- LogicalVariable var = new LogicalVariable(-varCounter);
- return var;
- }
-
- public Object getType(ILogicalExpression expr, IVariableTypeEnvironment env) throws AlgebricksException {
- return expressionTypeComputer.getType(expr, typingContext.getMetadataProvider(), env);
- }
-
- public INullWriterFactory getNullWriterFactory() {
- return nullWriterFactory;
- }
-
- public INormalizedKeyComputerFactoryProvider getNormalizedKeyComputerFactoryProvider() {
- return normalizedKeyComputerFactoryProvider;
- }
-
- public IExpressionEvalSizeComputer getExpressionEvalSizeComputer() {
- return expressionEvalSizeComputer;
- }
-
- public int getFrameSize() {
- return frameSize;
- }
-
- public IPartialAggregationTypeComputer getPartialAggregationTypeComputer() {
- return partialAggregationTypeComputer;
- }
-
- public IVariableTypeEnvironment getTypeEnvironment(ILogicalOperator op) {
- return typingContext.getOutputTypeEnvironment(op);
- }
-
-}
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/jobgen/impl/JobGenHelper.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobGenHelper.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobGenHelper.java
deleted file mode 100644
index 2d195e4..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/JobGenHelper.java
+++ /dev/null
@@ -1,182 +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.jobgen.impl;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.logging.Logger;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryComparatorFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryHashFunctionFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.IBinaryHashFunctionFamilyProvider;
-import edu.uci.ics.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory;
-import edu.uci.ics.hyracks.algebricks.data.IPrinterFactoryProvider;
-import edu.uci.ics.hyracks.algebricks.data.ISerializerDeserializerProvider;
-import edu.uci.ics.hyracks.algebricks.data.ITypeTraitProvider;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunctionFamily;
-import edu.uci.ics.hyracks.api.dataflow.value.INormalizedKeyComputerFactory;
-import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
-import edu.uci.ics.hyracks.api.dataflow.value.ITypeTraits;
-import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
-
-public final class JobGenHelper {
-
- private static final Logger LOGGER = Logger.getLogger(JobGenHelper.class.getName());
-
- @SuppressWarnings("rawtypes")
- public static RecordDescriptor mkRecordDescriptor(IVariableTypeEnvironment env, IOperatorSchema opSchema,
- JobGenContext context) throws AlgebricksException {
- ISerializerDeserializer[] fields = new ISerializerDeserializer[opSchema.getSize()];
- ITypeTraits[] typeTraits = new ITypeTraits[opSchema.getSize()];
- ISerializerDeserializerProvider sdp = context.getSerializerDeserializerProvider();
- ITypeTraitProvider ttp = context.getTypeTraitProvider();
- int i = 0;
- for (LogicalVariable var : opSchema) {
- Object t = env.getVarType(var);
- if (t == null) {
- LOGGER.warning("No type for variable " + var);
- }
- fields[i] = sdp.getSerializerDeserializer(t);
- typeTraits[i] = ttp.getTypeTrait(t);
- i++;
- }
- return new RecordDescriptor(fields, typeTraits);
- }
-
- public static IPrinterFactory[] mkPrinterFactories(IOperatorSchema opSchema, IVariableTypeEnvironment env,
- JobGenContext context, int[] printColumns) throws AlgebricksException {
- IPrinterFactory[] pf = new IPrinterFactory[printColumns.length];
- IPrinterFactoryProvider pff = context.getPrinterFactoryProvider();
- for (int i = 0; i < pf.length; i++) {
- LogicalVariable v = opSchema.getVariable(printColumns[i]);
- Object t = env.getVarType(v);
- pf[i] = pff.getPrinterFactory(t);
- }
- return pf;
- }
-
- public static int[] variablesToFieldIndexes(Collection<LogicalVariable> varLogical, IOperatorSchema opSchema) {
- int[] tuplePos = new int[varLogical.size()];
- int i = 0;
- for (LogicalVariable var : varLogical) {
- tuplePos[i] = opSchema.findVariable(var);
- i++;
- }
- return tuplePos;
- }
-
- public static IBinaryHashFunctionFactory[] variablesToBinaryHashFunctionFactories(
- Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
- IBinaryHashFunctionFactory[] funFactories = new IBinaryHashFunctionFactory[varLogical.size()];
- int i = 0;
- IBinaryHashFunctionFactoryProvider bhffProvider = context.getBinaryHashFunctionFactoryProvider();
- for (LogicalVariable var : varLogical) {
- Object type = env.getVarType(var);
- funFactories[i++] = bhffProvider.getBinaryHashFunctionFactory(type);
- }
- return funFactories;
- }
-
- public static IBinaryHashFunctionFamily[] variablesToBinaryHashFunctionFamilies(
- Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
- IBinaryHashFunctionFamily[] funFamilies = new IBinaryHashFunctionFamily[varLogical.size()];
- int i = 0;
- IBinaryHashFunctionFamilyProvider bhffProvider = context.getBinaryHashFunctionFamilyProvider();
- for (LogicalVariable var : varLogical) {
- Object type = env.getVarType(var);
- funFamilies[i++] = bhffProvider.getBinaryHashFunctionFamily(type);
- }
- return funFamilies;
- }
-
- public static IBinaryComparatorFactory[] variablesToAscBinaryComparatorFactories(
- Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
- IBinaryComparatorFactory[] compFactories = new IBinaryComparatorFactory[varLogical.size()];
- IBinaryComparatorFactoryProvider bcfProvider = context.getBinaryComparatorFactoryProvider();
- int i = 0;
- for (LogicalVariable v : varLogical) {
- Object type = env.getVarType(v);
- compFactories[i++] = bcfProvider.getBinaryComparatorFactory(type, true);
- }
- return compFactories;
- }
-
- public static IBinaryComparatorFactory[] variablesToAscBinaryComparatorFactories(List<LogicalVariable> varLogical,
- int start, int size, IVariableTypeEnvironment env, JobGenContext context) throws AlgebricksException {
- IBinaryComparatorFactory[] compFactories = new IBinaryComparatorFactory[size];
- IBinaryComparatorFactoryProvider bcfProvider = context.getBinaryComparatorFactoryProvider();
- for (int i = 0; i < size; i++) {
- Object type = env.getVarType(varLogical.get(start + i));
- compFactories[i] = bcfProvider.getBinaryComparatorFactory(type, true);
- }
- return compFactories;
- }
-
- public static INormalizedKeyComputerFactory variablesToAscNormalizedKeyComputerFactory(
- Collection<LogicalVariable> varLogical, IVariableTypeEnvironment env, JobGenContext context)
- throws AlgebricksException {
- INormalizedKeyComputerFactoryProvider nkcfProvider = context.getNormalizedKeyComputerFactoryProvider();
- if (nkcfProvider == null)
- return null;
- for (LogicalVariable v : varLogical) {
- Object type = env.getVarType(v);
- return nkcfProvider.getNormalizedKeyComputerFactory(type, true);
- }
- return null;
- }
-
- public static ITypeTraits[] variablesToTypeTraits(Collection<LogicalVariable> varLogical,
- IVariableTypeEnvironment env, JobGenContext context) throws AlgebricksException {
- ITypeTraits[] typeTraits = new ITypeTraits[varLogical.size()];
- ITypeTraitProvider typeTraitProvider = context.getTypeTraitProvider();
- int i = 0;
- for (LogicalVariable v : varLogical) {
- Object type = env.getVarType(v);
- typeTraits[i++] = typeTraitProvider.getTypeTrait(type);
- }
- return typeTraits;
- }
-
- public static ITypeTraits[] variablesToTypeTraits(List<LogicalVariable> varLogical, int start, int size,
- IVariableTypeEnvironment env, JobGenContext context) throws AlgebricksException {
- ITypeTraits[] typeTraits = new ITypeTraits[size];
- ITypeTraitProvider typeTraitProvider = context.getTypeTraitProvider();
- for (int i = 0; i < size; i++) {
- Object type = env.getVarType(varLogical.get(start + i));
- typeTraits[i] = typeTraitProvider.getTypeTrait(type);
- }
- return typeTraits;
- }
-
- public static int[] projectAllVariables(IOperatorSchema opSchema) {
- int[] projectionList = new int[opSchema.getSize()];
- int k = 0;
- for (LogicalVariable v : opSchema) {
- projectionList[k++] = opSchema.findVariable(v);
- }
- return projectionList;
- }
-
-}
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/jobgen/impl/OperatorSchemaImpl.java
----------------------------------------------------------------------
diff --git a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/OperatorSchemaImpl.java b/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/OperatorSchemaImpl.java
deleted file mode 100644
index dc1fb35..0000000
--- a/algebricks/algebricks-core/src/main/java/edu/uci/ics/hyracks/algebricks/core/jobgen/impl/OperatorSchemaImpl.java
+++ /dev/null
@@ -1,96 +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.jobgen.impl;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-
-public class OperatorSchemaImpl implements IOperatorSchema {
- private final Map<LogicalVariable, Integer> varMap;
-
- private final List<LogicalVariable> varList;
-
- public OperatorSchemaImpl() {
- varMap = new HashMap<LogicalVariable, Integer>();
- varList = new ArrayList<LogicalVariable>();
- }
-
- @Override
- public void addAllVariables(IOperatorSchema source) {
- for (LogicalVariable v : source) {
- varMap.put(v, varList.size());
- varList.add(v);
- }
- }
-
- @Override
- public void addAllNewVariables(IOperatorSchema source) {
- for (LogicalVariable v : source) {
- if (varMap.get(v) == null) {
- varMap.put(v, varList.size());
- varList.add(v);
- }
- }
- }
-
- @Override
- public int addVariable(LogicalVariable var) {
- int idx = varList.size();
- varMap.put(var, idx);
- varList.add(var);
- return idx;
- }
-
- @Override
- public void clear() {
- varMap.clear();
- varList.clear();
- }
-
- @Override
- public int findVariable(LogicalVariable var) {
- Integer i = varMap.get(var);
- if (i == null) {
- return -1;
- }
- return i;
- }
-
- @Override
- public int getSize() {
- return varList.size();
- }
-
- @Override
- public LogicalVariable getVariable(int index) {
- return varList.get(index);
- }
-
- @Override
- public Iterator<LogicalVariable> iterator() {
- return varList.iterator();
- }
-
- @Override
- public String toString() {
- return varMap.toString();
- }
-}
\ No newline at end of file