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:44:38 UTC
[50/51] [partial] incubator-asterixdb git commit: Change folder
structure for Java repackage
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java
deleted file mode 100644
index 1ce5b5f..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/AsterixOperatorAnnotations.java
+++ /dev/null
@@ -1,22 +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.asterix.algebra.base;
-
-public interface AsterixOperatorAnnotations {
- public static final String FIELD_ACCESS = "FIELD_ACCESS";
- public static final String PUSHED_FIELD_ACCESS = "PUSHED_FIELD_ACCESS";
- public static final String PUSHED_RUNNABLE_FIELD_ACCESS = "PUSHED_RUNNABLE_FIELD_ACCESS";
- public static final String FIELD_TYPE = "FIELD_TYPE";
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalExpressionDeepCopyVisitor.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalExpressionDeepCopyVisitor.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalExpressionDeepCopyVisitor.java
deleted file mode 100644
index a6ae0b1..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalExpressionDeepCopyVisitor.java
+++ /dev/null
@@ -1,149 +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.asterix.algebra.base;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-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.Counter;
-import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-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.AggregateFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.ConstantExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IExpressionAnnotation;
-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;
-import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionVisitor;
-
-public class LogicalExpressionDeepCopyVisitor implements ILogicalExpressionVisitor<ILogicalExpression, Void> {
- private final Counter counter;
- private final Map<LogicalVariable, LogicalVariable> inVarMapping;
- private final Map<LogicalVariable, LogicalVariable> outVarMapping;
-
- public LogicalExpressionDeepCopyVisitor(Counter counter, Map<LogicalVariable, LogicalVariable> inVarMapping,
- Map<LogicalVariable, LogicalVariable> variableMapping) {
- this.counter = counter;
- this.inVarMapping = inVarMapping;
- this.outVarMapping = variableMapping;
- }
-
- public ILogicalExpression deepCopy(ILogicalExpression expr) throws AlgebricksException {
- return expr.accept(this, null);
- }
-
- private void deepCopyAnnotations(AbstractFunctionCallExpression src, AbstractFunctionCallExpression dest) {
- Map<Object, IExpressionAnnotation> srcAnnotations = src.getAnnotations();
- Map<Object, IExpressionAnnotation> destAnnotations = dest.getAnnotations();
- for (Object k : srcAnnotations.keySet()) {
- IExpressionAnnotation annotation = srcAnnotations.get(k).copy();
- destAnnotations.put(k, annotation);
- }
- }
-
- private void deepCopyOpaqueParameters(AbstractFunctionCallExpression src, AbstractFunctionCallExpression dest) {
- Object[] srcOpaqueParameters = src.getOpaqueParameters();
- Object[] newOpaqueParameters = null;
- if (srcOpaqueParameters != null) {
- newOpaqueParameters = new Object[srcOpaqueParameters.length];
- for (int i = 0; i < srcOpaqueParameters.length; i++) {
- newOpaqueParameters[i] = srcOpaqueParameters[i];
- }
- }
- dest.setOpaqueParameters(newOpaqueParameters);
- }
-
- public MutableObject<ILogicalExpression> deepCopyExpressionReference(Mutable<ILogicalExpression> exprRef)
- throws AlgebricksException {
- return new MutableObject<ILogicalExpression>(deepCopy(exprRef.getValue()));
- }
-
- // TODO return List<...>
- public ArrayList<Mutable<ILogicalExpression>> deepCopyExpressionReferenceList(List<Mutable<ILogicalExpression>> list)
- throws AlgebricksException {
- ArrayList<Mutable<ILogicalExpression>> listCopy = new ArrayList<Mutable<ILogicalExpression>>(list.size());
- for (Mutable<ILogicalExpression> exprRef : list) {
- listCopy.add(deepCopyExpressionReference(exprRef));
- }
- return listCopy;
- }
-
- @Override
- public ILogicalExpression visitAggregateFunctionCallExpression(AggregateFunctionCallExpression expr, Void arg)
- throws AlgebricksException {
- AggregateFunctionCallExpression exprCopy = new AggregateFunctionCallExpression(expr.getFunctionInfo(),
- expr.isTwoStep(), deepCopyExpressionReferenceList(expr.getArguments()));
- deepCopyAnnotations(expr, exprCopy);
- deepCopyOpaqueParameters(expr, exprCopy);
- return exprCopy;
- }
-
- @Override
- public ILogicalExpression visitConstantExpression(ConstantExpression expr, Void arg) throws AlgebricksException {
- return new ConstantExpression(expr.getValue());
- }
-
- @Override
- public ILogicalExpression visitScalarFunctionCallExpression(ScalarFunctionCallExpression expr, Void arg)
- throws AlgebricksException {
- ScalarFunctionCallExpression exprCopy = new ScalarFunctionCallExpression(expr.getFunctionInfo(),
- deepCopyExpressionReferenceList(expr.getArguments()));
- deepCopyAnnotations(expr, exprCopy);
- deepCopyOpaqueParameters(expr, exprCopy);
- return exprCopy;
-
- }
-
- @Override
- public ILogicalExpression visitStatefulFunctionCallExpression(StatefulFunctionCallExpression expr, Void arg)
- throws AlgebricksException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalExpression visitUnnestingFunctionCallExpression(UnnestingFunctionCallExpression expr, Void arg)
- throws AlgebricksException {
- UnnestingFunctionCallExpression exprCopy = new UnnestingFunctionCallExpression(expr.getFunctionInfo(),
- deepCopyExpressionReferenceList(expr.getArguments()));
- deepCopyAnnotations(expr, exprCopy);
- deepCopyOpaqueParameters(expr, exprCopy);
- return exprCopy;
- }
-
- @Override
- public ILogicalExpression visitVariableReferenceExpression(VariableReferenceExpression expr, Void arg)
- throws AlgebricksException {
- LogicalVariable var = expr.getVariableReference();
- LogicalVariable givenVarReplacement = inVarMapping.get(var);
- if (givenVarReplacement != null) {
- outVarMapping.put(var, givenVarReplacement);
- return new VariableReferenceExpression(givenVarReplacement);
- }
- LogicalVariable varCopy = outVarMapping.get(var);
- if (varCopy == null) {
- counter.inc();
- varCopy = new LogicalVariable(counter.get());
- outVarMapping.put(var, varCopy);
- }
- return new VariableReferenceExpression(varCopy);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
deleted file mode 100644
index cedc962..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
+++ /dev/null
@@ -1,469 +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.asterix.algebra.base;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-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.common.utils.Pair;
-import edu.uci.ics.hyracks.algebricks.core.algebra.base.Counter;
-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.LogicalVariable;
-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.OrderOperator.IOrder;
-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;
-import edu.uci.ics.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl;
-import edu.uci.ics.hyracks.algebricks.core.algebra.properties.FunctionalDependency;
-import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor;
-
-public class LogicalOperatorDeepCopyVisitor implements ILogicalOperatorVisitor<ILogicalOperator, ILogicalOperator> {
- private final Counter counter;
- private final LogicalExpressionDeepCopyVisitor exprDeepCopyVisitor;
-
- // Key: Variable in the original plan. Value: New variable replacing the original one in the copied plan.
- private final Map<LogicalVariable, LogicalVariable> outVarMapping = new HashMap<LogicalVariable, LogicalVariable>();
-
- // Key: Variable in the original plan. Value: Variable with which to replace original variable in the plan copy.
- private final Map<LogicalVariable, LogicalVariable> inVarMapping;
-
- public LogicalOperatorDeepCopyVisitor(Counter counter) {
- this.counter = counter;
- this.inVarMapping = Collections.emptyMap();
- exprDeepCopyVisitor = new LogicalExpressionDeepCopyVisitor(counter, inVarMapping, outVarMapping);
- }
-
- /**
- * @param counter
- * Starting variable counter.
- * @param inVarMapping
- * Variable mapping keyed by variables in the original plan.
- * Those variables are replaced by their corresponding value in the map in the copied plan.
- */
- public LogicalOperatorDeepCopyVisitor(Counter counter, Map<LogicalVariable, LogicalVariable> inVarMapping) {
- this.counter = counter;
- this.inVarMapping = inVarMapping;
- exprDeepCopyVisitor = new LogicalExpressionDeepCopyVisitor(counter, inVarMapping, outVarMapping);
- }
-
- private void copyAnnotations(ILogicalOperator src, ILogicalOperator dest) {
- dest.getAnnotations().putAll(src.getAnnotations());
- }
-
- public ILogicalOperator deepCopy(ILogicalOperator op, ILogicalOperator arg) throws AlgebricksException {
- return op.accept(this, arg);
- }
-
- private void deepCopyInputs(ILogicalOperator src, ILogicalOperator dest, ILogicalOperator arg)
- throws AlgebricksException {
- List<Mutable<ILogicalOperator>> inputs = src.getInputs();
- List<Mutable<ILogicalOperator>> inputsCopy = dest.getInputs();
- for (Mutable<ILogicalOperator> input : inputs) {
- inputsCopy.add(deepCopyOperatorReference(input, arg));
- }
- }
-
- private Mutable<ILogicalOperator> deepCopyOperatorReference(Mutable<ILogicalOperator> opRef, ILogicalOperator arg)
- throws AlgebricksException {
- return new MutableObject<ILogicalOperator>(deepCopy(opRef.getValue(), arg));
- }
-
- private List<Mutable<ILogicalOperator>> deepCopyOperatorReferenceList(List<Mutable<ILogicalOperator>> list,
- ILogicalOperator arg) throws AlgebricksException {
- List<Mutable<ILogicalOperator>> listCopy = new ArrayList<Mutable<ILogicalOperator>>(list.size());
- for (Mutable<ILogicalOperator> opRef : list) {
- listCopy.add(deepCopyOperatorReference(opRef, arg));
- }
- return listCopy;
- }
-
- private IOrder deepCopyOrder(IOrder order) {
- switch (order.getKind()) {
- case ASC:
- case DESC:
- return order;
- case FUNCTIONCALL:
- default:
- throw new UnsupportedOperationException();
- }
- }
-
- private List<Pair<IOrder, Mutable<ILogicalExpression>>> deepCopyOrderExpressionReferencePairList(
- List<Pair<IOrder, Mutable<ILogicalExpression>>> list) throws AlgebricksException {
- ArrayList<Pair<IOrder, Mutable<ILogicalExpression>>> listCopy = new ArrayList<Pair<IOrder, Mutable<ILogicalExpression>>>(
- list.size());
- for (Pair<IOrder, Mutable<ILogicalExpression>> pair : list) {
- listCopy.add(new Pair<OrderOperator.IOrder, Mutable<ILogicalExpression>>(deepCopyOrder(pair.first),
- exprDeepCopyVisitor.deepCopyExpressionReference(pair.second)));
- }
- return listCopy;
- }
-
- private ILogicalPlan deepCopyPlan(ILogicalPlan plan, ILogicalOperator arg) throws AlgebricksException {
- List<Mutable<ILogicalOperator>> rootsCopy = deepCopyOperatorReferenceList(plan.getRoots(), arg);
- ILogicalPlan planCopy = new ALogicalPlanImpl(rootsCopy);
- return planCopy;
- }
-
- private List<ILogicalPlan> deepCopyPlanList(List<ILogicalPlan> list, List<ILogicalPlan> listCopy,
- ILogicalOperator arg) throws AlgebricksException {
- for (ILogicalPlan plan : list) {
- listCopy.add(deepCopyPlan(plan, arg));
- }
- return listCopy;
- }
-
- private LogicalVariable deepCopyVariable(LogicalVariable var) {
- if (var == null) {
- return null;
- }
- LogicalVariable givenVarReplacement = inVarMapping.get(var);
- if (givenVarReplacement != null) {
- outVarMapping.put(var, givenVarReplacement);
- return givenVarReplacement;
- }
- LogicalVariable varCopy = outVarMapping.get(var);
- if (varCopy == null) {
- counter.inc();
- varCopy = new LogicalVariable(counter.get());
- outVarMapping.put(var, varCopy);
- }
- return varCopy;
- }
-
- private List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> deepCopyVariableExpressionReferencePairList(
- List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> list) throws AlgebricksException {
- List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> listCopy = new ArrayList<Pair<LogicalVariable, Mutable<ILogicalExpression>>>(
- list.size());
- for (Pair<LogicalVariable, Mutable<ILogicalExpression>> pair : list) {
- listCopy.add(new Pair<LogicalVariable, Mutable<ILogicalExpression>>(deepCopyVariable(pair.first),
- exprDeepCopyVisitor.deepCopyExpressionReference(pair.second)));
- }
- return listCopy;
- }
-
- // TODO return List<...>
- private ArrayList<LogicalVariable> deepCopyVariableList(List<LogicalVariable> list) {
- ArrayList<LogicalVariable> listCopy = new ArrayList<LogicalVariable>(list.size());
- for (LogicalVariable var : list) {
- listCopy.add(deepCopyVariable(var));
- }
- return listCopy;
- }
-
- public void reset() {
- outVarMapping.clear();
- }
-
- public void updatePrimaryKeys(IOptimizationContext context) {
- for (Map.Entry<LogicalVariable, LogicalVariable> entry : outVarMapping.entrySet()) {
- List<LogicalVariable> primaryKey = context.findPrimaryKey(entry.getKey());
- if (primaryKey != null) {
- List<LogicalVariable> head = new ArrayList<LogicalVariable>();
- for (LogicalVariable variable : primaryKey) {
- head.add(outVarMapping.get(variable));
- }
- List<LogicalVariable> tail = new ArrayList<LogicalVariable>(1);
- tail.add(entry.getValue());
- context.addPrimaryKey(new FunctionalDependency(head, tail));
- }
- }
- }
-
- public LogicalVariable varCopy(LogicalVariable var) throws AlgebricksException {
- return outVarMapping.get(var);
- }
-
- @Override
- public ILogicalOperator visitAggregateOperator(AggregateOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- AggregateOperator opCopy = new AggregateOperator(deepCopyVariableList(op.getVariables()),
- exprDeepCopyVisitor.deepCopyExpressionReferenceList(op.getExpressions()));
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitAssignOperator(AssignOperator op, ILogicalOperator arg) throws AlgebricksException {
- AssignOperator opCopy = new AssignOperator(deepCopyVariableList(op.getVariables()),
- exprDeepCopyVisitor.deepCopyExpressionReferenceList(op.getExpressions()));
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitDataScanOperator(DataSourceScanOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- DataSourceScanOperator opCopy = new DataSourceScanOperator(deepCopyVariableList(op.getVariables()),
- op.getDataSource());
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitDistinctOperator(DistinctOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitEmptyTupleSourceOperator(EmptyTupleSourceOperator op, ILogicalOperator arg) {
- EmptyTupleSourceOperator opCopy = new EmptyTupleSourceOperator();
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitExchangeOperator(ExchangeOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitGroupByOperator(GroupByOperator op, ILogicalOperator arg) throws AlgebricksException {
- List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> groupByListCopy = deepCopyVariableExpressionReferencePairList(op
- .getGroupByList());
- List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> decorListCopy = deepCopyVariableExpressionReferencePairList(op
- .getDecorList());
- List<ILogicalPlan> nestedPlansCopy = new ArrayList<ILogicalPlan>();
-
- GroupByOperator opCopy = new GroupByOperator(groupByListCopy, decorListCopy, nestedPlansCopy);
- deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitInnerJoinOperator(InnerJoinOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- InnerJoinOperator opCopy = new InnerJoinOperator(exprDeepCopyVisitor.deepCopyExpressionReference(op
- .getCondition()), deepCopyOperatorReference(op.getInputs().get(0), null), deepCopyOperatorReference(op
- .getInputs().get(1), null));
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitLeftOuterJoinOperator(LeftOuterJoinOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitLimitOperator(LimitOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- NestedTupleSourceOperator opCopy = new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(arg));
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitOrderOperator(OrderOperator op, ILogicalOperator arg) throws AlgebricksException {
- OrderOperator opCopy = new OrderOperator(deepCopyOrderExpressionReferencePairList(op.getOrderExpressions()));
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitPartitioningSplitOperator(PartitioningSplitOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitProjectOperator(ProjectOperator op, ILogicalOperator arg) throws AlgebricksException {
- ProjectOperator opCopy = new ProjectOperator(deepCopyVariableList(op.getVariables()));
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitReplicateOperator(ReplicateOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitMaterializeOperator(MaterializeOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitRunningAggregateOperator(RunningAggregateOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitScriptOperator(ScriptOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitSelectOperator(SelectOperator op, ILogicalOperator arg) throws AlgebricksException {
- SelectOperator opCopy = new SelectOperator(exprDeepCopyVisitor.deepCopyExpressionReference(op.getCondition()),
- op.getRetainNull(), deepCopyVariable(op.getNullPlaceholderVariable()));
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitSubplanOperator(SubplanOperator op, ILogicalOperator arg) throws AlgebricksException {
- List<ILogicalPlan> nestedPlansCopy = new ArrayList<ILogicalPlan>();
-
- SubplanOperator opCopy = new SubplanOperator(nestedPlansCopy);
- deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitUnionOperator(UnionAllOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitUnnestMapOperator(UnnestMapOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- UnnestMapOperator opCopy = new UnnestMapOperator(deepCopyVariableList(op.getVariables()),
- exprDeepCopyVisitor.deepCopyExpressionReference(op.getExpressionRef()), op.getVariableTypes(),
- op.propagatesInput());
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitUnnestOperator(UnnestOperator op, ILogicalOperator arg) throws AlgebricksException {
- UnnestOperator opCopy = new UnnestOperator(deepCopyVariable(op.getVariable()),
- exprDeepCopyVisitor.deepCopyExpressionReference(op.getExpressionRef()),
- deepCopyVariable(op.getPositionalVariable()), op.getPositionalVariableType(), op.getPositionWriter());
- deepCopyInputs(op, opCopy, arg);
- copyAnnotations(op, opCopy);
- opCopy.setExecutionMode(op.getExecutionMode());
- return opCopy;
- }
-
- @Override
- public ILogicalOperator visitWriteOperator(WriteOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitDistributeResultOperator(DistributeResultOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitWriteResultOperator(WriteResultOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitInsertDeleteOperator(InsertDeleteOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitIndexInsertDeleteOperator(IndexInsertDeleteOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitTokenizeOperator(TokenizeOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitSinkOperator(SinkOperator op, ILogicalOperator arg) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ILogicalOperator visitExtensionOperator(ExtensionOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- throw new UnsupportedOperationException();
- }
-
- public Map<LogicalVariable, LogicalVariable> getVariableMapping() {
- return outVarMapping;
- }
-
- @Override
- public ILogicalOperator visitExternalDataLookupOperator(ExternalDataLookupOperator op, ILogicalOperator arg)
- throws AlgebricksException {
- throw new UnsupportedOperationException();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/CommitOperator.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/CommitOperator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/CommitOperator.java
deleted file mode 100644
index d65c67d..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/CommitOperator.java
+++ /dev/null
@@ -1,66 +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.asterix.algebra.operators;
-
-import java.util.Collection;
-import java.util.List;
-
-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.operators.logical.AbstractExtensibleLogicalOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorExtension;
-import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform;
-
-public class CommitOperator extends AbstractExtensibleLogicalOperator {
-
- private final List<LogicalVariable> primaryKeyLogicalVars;
-
- public CommitOperator(List<LogicalVariable> primaryKeyLogicalVars) {
- this.primaryKeyLogicalVars = primaryKeyLogicalVars;
- }
-
- @Override
- public boolean isMap() {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public IOperatorExtension newInstance() {
- return new CommitOperator(primaryKeyLogicalVars);
- }
-
- @Override
- public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform transform) throws AlgebricksException {
- // TODO Auto-generated method stub
- return false;
- }
-
- @Override
- public String toString() {
- return "commit";
- }
-
- @Override
- public void getUsedVariables(Collection<LogicalVariable> usedVars) {
- usedVars.addAll(primaryKeyLogicalVars);
- }
-
- @Override
- public void getProducedVariables(Collection<LogicalVariable> producedVars) {
- // No produced variables.
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/BTreeSearchPOperator.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/BTreeSearchPOperator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/BTreeSearchPOperator.java
deleted file mode 100644
index 5a4b52a..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/BTreeSearchPOperator.java
+++ /dev/null
@@ -1,161 +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.asterix.algebra.operators.physical;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
-import edu.uci.ics.asterix.metadata.declared.AqlSourceId;
-import edu.uci.ics.asterix.metadata.entities.Dataset;
-import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
-import edu.uci.ics.asterix.optimizer.rules.am.BTreeJobGenParams;
-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.ListSet;
-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.ILogicalExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator;
-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.base.PhysicalOperatorTag;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSourceIndex;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.OrderOperator.IOrder.OrderKind;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.UnnestMapOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
-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.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;
-import edu.uci.ics.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty;
-import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext;
-import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor;
-
-/**
- * Contributes the runtime operator for an unnest-map representing a BTree search.
- */
-public class BTreeSearchPOperator extends IndexSearchPOperator {
-
- private final List<LogicalVariable> lowKeyVarList;
- private final List<LogicalVariable> highKeyVarList;
- private final boolean isPrimaryIndex;
- private final boolean isEqCondition;
- private Object implConfig;
-
- public BTreeSearchPOperator(IDataSourceIndex<String, AqlSourceId> idx, boolean requiresBroadcast,
- boolean isPrimaryIndex, boolean isEqCondition, List<LogicalVariable> lowKeyVarList,
- List<LogicalVariable> highKeyVarList) {
- super(idx, requiresBroadcast);
- this.isPrimaryIndex = isPrimaryIndex;
- this.isEqCondition = isEqCondition;
- this.lowKeyVarList = lowKeyVarList;
- this.highKeyVarList = highKeyVarList;
- }
-
- public void setImplConfig(Object implConfig) {
- this.implConfig = implConfig;
- }
-
- public Object getImplConfig() {
- return implConfig;
- }
-
- @Override
- public PhysicalOperatorTag getOperatorTag() {
- return PhysicalOperatorTag.BTREE_SEARCH;
- }
-
- @Override
- public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op,
- IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema)
- throws AlgebricksException {
- UnnestMapOperator unnestMap = (UnnestMapOperator) op;
- ILogicalExpression unnestExpr = unnestMap.getExpressionRef().getValue();
- if (unnestExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
- throw new IllegalStateException();
- }
- AbstractFunctionCallExpression unnestFuncExpr = (AbstractFunctionCallExpression) unnestExpr;
- FunctionIdentifier funcIdent = unnestFuncExpr.getFunctionIdentifier();
- if (!funcIdent.equals(AsterixBuiltinFunctions.INDEX_SEARCH)) {
- return;
- }
- BTreeJobGenParams jobGenParams = new BTreeJobGenParams();
- jobGenParams.readFromFuncArgs(unnestFuncExpr.getArguments());
- int[] lowKeyIndexes = getKeyIndexes(jobGenParams.getLowKeyVarList(), inputSchemas);
- int[] highKeyIndexes = getKeyIndexes(jobGenParams.getHighKeyVarList(), inputSchemas);
-
- int[] minFilterFieldIndexes = getKeyIndexes(unnestMap.getMinFilterVars(), inputSchemas);
- int[] maxFilterFieldIndexes = getKeyIndexes(unnestMap.getMaxFilterVars(), inputSchemas);
-
- AqlMetadataProvider metadataProvider = (AqlMetadataProvider) context.getMetadataProvider();
- Dataset dataset = metadataProvider.findDataset(jobGenParams.getDataverseName(), jobGenParams.getDatasetName());
- IVariableTypeEnvironment typeEnv = context.getTypeEnvironment(op);
- List<LogicalVariable> outputVars = unnestMap.getVariables();
- if (jobGenParams.getRetainInput()) {
- outputVars = new ArrayList<LogicalVariable>();
- VariableUtilities.getLiveVariables(unnestMap, outputVars);
- }
- Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> btreeSearch = metadataProvider.buildBtreeRuntime(
- builder.getJobSpec(), outputVars, opSchema, typeEnv, context, jobGenParams.getRetainInput(),
- jobGenParams.getRetainNull(), dataset, jobGenParams.getIndexName(), lowKeyIndexes, highKeyIndexes,
- jobGenParams.isLowKeyInclusive(), jobGenParams.isHighKeyInclusive(), implConfig, minFilterFieldIndexes,
- maxFilterFieldIndexes);
-
- builder.contributeHyracksOperator(unnestMap, btreeSearch.first);
- builder.contributeAlgebricksPartitionConstraint(btreeSearch.first, btreeSearch.second);
-
- ILogicalOperator srcExchange = unnestMap.getInputs().get(0).getValue();
- builder.contributeGraphEdge(srcExchange, 0, unnestMap, 0);
- }
-
- @Override
- public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op,
- IPhysicalPropertiesVector reqdByParent) {
- if (requiresBroadcast) {
- // For primary indexes optimizing an equality condition we can reduce the broadcast requirement to hash partitioning.
- if (isPrimaryIndex && isEqCondition) {
- StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
- ListSet<LogicalVariable> searchKeyVars = new ListSet<LogicalVariable>();
- searchKeyVars.addAll(lowKeyVarList);
- searchKeyVars.addAll(highKeyVarList);
- // Also, add a local sorting property to enforce a sort before the primary-index operator.
- List<ILocalStructuralProperty> propsLocal = new ArrayList<ILocalStructuralProperty>();
- List<OrderColumn> orderColumns = new ArrayList<OrderColumn>();
- for (LogicalVariable orderVar : searchKeyVars) {
- orderColumns.add(new OrderColumn(orderVar, OrderKind.ASC));
- }
- propsLocal.add(new LocalOrderProperty(orderColumns));
- pv[0] = new StructuralPropertiesVector(new UnorderedPartitionedProperty(searchKeyVars, null),
- propsLocal);
- return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
- } else {
- StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
- pv[0] = new StructuralPropertiesVector(new BroadcastPartitioningProperty(null), null);
- return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
- }
- } else {
- return super.getRequiredPropertiesForChildren(op, reqdByParent);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitPOperator.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitPOperator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitPOperator.java
deleted file mode 100644
index 6722cbe..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitPOperator.java
+++ /dev/null
@@ -1,98 +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.asterix.algebra.operators.physical;
-
-import java.util.List;
-
-import edu.uci.ics.asterix.common.transactions.JobId;
-import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
-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.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.operators.logical.AbstractLogicalOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical.AbstractPhysicalOperator;
-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.api.dataflow.value.RecordDescriptor;
-
-public class CommitPOperator extends AbstractPhysicalOperator {
-
- private final List<LogicalVariable> primaryKeyLogicalVars;
- private final JobId jobId;
- private final int datasetId;
-
- public CommitPOperator(JobId jobId, int datasetId, List<LogicalVariable> primaryKeyLogicalVars) {
- this.jobId = jobId;
- this.datasetId = datasetId;
- this.primaryKeyLogicalVars = primaryKeyLogicalVars;
- }
-
- @Override
- public PhysicalOperatorTag getOperatorTag() {
- return PhysicalOperatorTag.EXTENSION_OPERATOR;
- }
-
- @Override
- public String toString() {
- return "COMMIT";
- }
-
- @Override
- public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op,
- IPhysicalPropertiesVector reqdByParent) {
- return emptyUnaryRequirements();
- }
-
- @Override
- public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context)
- throws AlgebricksException {
- AbstractLogicalOperator op2 = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
- deliveredProperties = op2.getDeliveredPhysicalProperties().clone();
- }
-
- @Override
- public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op,
- IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema)
- throws AlgebricksException {
-
- RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), propagatedSchema,
- context);
- int[] primaryKeyFields = JobGenHelper.variablesToFieldIndexes(primaryKeyLogicalVars, inputSchemas[0]);
-
- AqlMetadataProvider metadataProvider = (AqlMetadataProvider) context.getMetadataProvider();
- CommitRuntimeFactory runtime = new CommitRuntimeFactory(jobId, datasetId, primaryKeyFields,
- metadataProvider.isTemporaryDatasetWriteJob(), metadataProvider.isWriteTransaction());
- builder.contributeMicroOperator(op, runtime, recDesc);
- ILogicalOperator src = op.getInputs().get(0).getValue();
- builder.contributeGraphEdge(src, 0, op, 0);
- }
-
- @Override
- public boolean isMicroOperator() {
- return true;
- }
-
- @Override
- public boolean expensiveThanMaterialization() {
- return false;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntime.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntime.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntime.java
deleted file mode 100644
index 69c8f78..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntime.java
+++ /dev/null
@@ -1,139 +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.asterix.algebra.operators.physical;
-
-import java.nio.ByteBuffer;
-
-import edu.uci.ics.asterix.common.api.IAsterixAppRuntimeContext;
-import edu.uci.ics.asterix.common.exceptions.ACIDException;
-import edu.uci.ics.asterix.common.transactions.ILogManager;
-import edu.uci.ics.asterix.common.transactions.ITransactionContext;
-import edu.uci.ics.asterix.common.transactions.ITransactionManager;
-import edu.uci.ics.asterix.common.transactions.JobId;
-import edu.uci.ics.asterix.common.transactions.LogRecord;
-import edu.uci.ics.hyracks.algebricks.runtime.base.IPushRuntime;
-import edu.uci.ics.hyracks.api.comm.IFrameWriter;
-import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
-import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor;
-import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
-import edu.uci.ics.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
-import edu.uci.ics.hyracks.dataflow.common.data.accessors.FrameTupleReference;
-import edu.uci.ics.hyracks.dataflow.common.data.accessors.ITupleReference;
-import edu.uci.ics.hyracks.storage.am.bloomfilter.impls.MurmurHash128Bit;
-
-public class CommitRuntime implements IPushRuntime {
-
- private final static long SEED = 0L;
-
- private final IHyracksTaskContext hyracksTaskCtx;
- private final ITransactionManager transactionManager;
- private final ILogManager logMgr;
- private final JobId jobId;
- private final int datasetId;
- private final int[] primaryKeyFields;
- private final boolean isTemporaryDatasetWriteJob;
- private final boolean isWriteTransaction;
- private final long[] longHashes;
- private final LogRecord logRecord;
-
- private ITransactionContext transactionContext;
- private FrameTupleAccessor frameTupleAccessor;
- private final FrameTupleReference frameTupleReference;
-
- public CommitRuntime(IHyracksTaskContext ctx, JobId jobId, int datasetId, int[] primaryKeyFields,
- boolean isTemporaryDatasetWriteJob, boolean isWriteTransaction) {
- this.hyracksTaskCtx = ctx;
- IAsterixAppRuntimeContext runtimeCtx = (IAsterixAppRuntimeContext) ctx.getJobletContext()
- .getApplicationContext().getApplicationObject();
- this.transactionManager = runtimeCtx.getTransactionSubsystem().getTransactionManager();
- this.logMgr = runtimeCtx.getTransactionSubsystem().getLogManager();
- this.jobId = jobId;
- this.datasetId = datasetId;
- this.primaryKeyFields = primaryKeyFields;
- this.frameTupleReference = new FrameTupleReference();
- this.isTemporaryDatasetWriteJob = isTemporaryDatasetWriteJob;
- this.isWriteTransaction = isWriteTransaction;
- this.longHashes = new long[2];
- this.logRecord = new LogRecord();
- }
-
- @Override
- public void open() throws HyracksDataException {
- try {
- transactionContext = transactionManager.getTransactionContext(jobId, false);
- transactionContext.setWriteTxn(isWriteTransaction);
- } catch (ACIDException e) {
- throw new HyracksDataException(e);
- }
- }
-
- @Override
- public void nextFrame(ByteBuffer buffer) throws HyracksDataException {
- int pkHash = 0;
- frameTupleAccessor.reset(buffer);
- int nTuple = frameTupleAccessor.getTupleCount();
- for (int t = 0; t < nTuple; t++) {
- if (isTemporaryDatasetWriteJob) {
- /**
- * This "if branch" is for writes over temporary datasets.
- * A temporary dataset does not require any lock and does not generate any write-ahead
- * update and commit log but generates flush log and job commit log.
- * However, a temporary dataset still MUST guarantee no-steal policy so that this
- * notification call should be delivered to PrimaryIndexOptracker and used correctly in order
- * to decrement number of active operation count of PrimaryIndexOptracker.
- * By maintaining the count correctly and only allowing flushing when the count is 0, it can
- * guarantee the no-steal policy for temporary datasets, too.
- */
- transactionContext.notifyOptracker(false);
- } else {
- frameTupleReference.reset(frameTupleAccessor, t);
- pkHash = computePrimaryKeyHashValue(frameTupleReference, primaryKeyFields);
- logRecord.formEntityCommitLogRecord(transactionContext, datasetId, pkHash, frameTupleReference,
- primaryKeyFields);
- try {
- logMgr.log(logRecord);
- } catch (ACIDException e) {
- throw new HyracksDataException(e);
- }
- }
- }
- }
-
- private int computePrimaryKeyHashValue(ITupleReference tuple, int[] primaryKeyFields) {
- MurmurHash128Bit.hash3_x64_128(tuple, primaryKeyFields, SEED, longHashes);
- return Math.abs((int) longHashes[0]);
- }
-
- @Override
- public void fail() throws HyracksDataException {
-
- }
-
- @Override
- public void close() throws HyracksDataException {
-
- }
-
- @Override
- public void setFrameWriter(int index, IFrameWriter writer, RecordDescriptor recordDesc) {
- throw new IllegalStateException();
- }
-
- @Override
- public void setInputRecordDescriptor(int index, RecordDescriptor recordDescriptor) {
- this.frameTupleAccessor = new FrameTupleAccessor(recordDescriptor);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntimeFactory.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntimeFactory.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntimeFactory.java
deleted file mode 100644
index 768cdb6..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/CommitRuntimeFactory.java
+++ /dev/null
@@ -1,53 +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.asterix.algebra.operators.physical;
-
-import edu.uci.ics.asterix.common.transactions.JobId;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-import edu.uci.ics.hyracks.algebricks.runtime.base.IPushRuntime;
-import edu.uci.ics.hyracks.algebricks.runtime.base.IPushRuntimeFactory;
-import edu.uci.ics.hyracks.api.context.IHyracksTaskContext;
-
-public class CommitRuntimeFactory implements IPushRuntimeFactory {
-
- private static final long serialVersionUID = 1L;
-
- private final JobId jobId;
- private final int datasetId;
- private final int[] primaryKeyFields;
- private final boolean isTemporaryDatasetWriteJob;
- private final boolean isWriteTransaction;
-
- public CommitRuntimeFactory(JobId jobId, int datasetId, int[] primaryKeyFields, boolean isTemporaryDatasetWriteJob,
- boolean isWriteTransaction) {
- this.jobId = jobId;
- this.datasetId = datasetId;
- this.primaryKeyFields = primaryKeyFields;
- this.isTemporaryDatasetWriteJob = isTemporaryDatasetWriteJob;
- this.isWriteTransaction = isWriteTransaction;
- }
-
- @Override
- public String toString() {
- return "commit";
- }
-
- @Override
- public IPushRuntime createPushRuntime(IHyracksTaskContext ctx) throws AlgebricksException {
- return new CommitRuntime(ctx, jobId, datasetId, primaryKeyFields, isTemporaryDatasetWriteJob,
- isWriteTransaction);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/ExternalDataLookupPOperator.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/ExternalDataLookupPOperator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/ExternalDataLookupPOperator.java
deleted file mode 100644
index dcbc70c..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/ExternalDataLookupPOperator.java
+++ /dev/null
@@ -1,180 +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.asterix.algebra.operators.physical;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import edu.uci.ics.asterix.external.indexing.dataflow.HDFSLookupAdapterFactory;
-import edu.uci.ics.asterix.metadata.declared.AqlDataSource;
-import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
-import edu.uci.ics.asterix.metadata.declared.AqlSourceId;
-import edu.uci.ics.asterix.metadata.declared.DatasetDataSource;
-import edu.uci.ics.asterix.metadata.declared.AqlDataSource.AqlDataSourceType;
-import edu.uci.ics.asterix.metadata.entities.Dataset;
-import edu.uci.ics.asterix.metadata.entities.Index;
-import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
-import edu.uci.ics.asterix.om.types.ARecordType;
-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.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.base.PhysicalOperatorTag;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSourcePropertiesProvider;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractScanOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ExternalDataLookupOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.visitors.VariableUtilities;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical.AbstractScanPOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.properties.BroadcastPartitioningProperty;
-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.api.dataflow.IOperatorDescriptor;
-
-public class ExternalDataLookupPOperator extends AbstractScanPOperator {
-
- private final List<LogicalVariable> ridVarList;
- private AqlSourceId datasetId;
- private Dataset dataset;
- private ARecordType recordType;
- private Index secondaryIndex;
- private boolean requiresBroadcast;
- private boolean retainInput;
- private boolean retainNull;
-
- public ExternalDataLookupPOperator(AqlSourceId datasetId, Dataset dataset, ARecordType recordType,
- Index secondaryIndex, List<LogicalVariable> ridVarList, boolean requiresBroadcast, boolean retainInput, boolean retainNull) {
- this.datasetId = datasetId;
- this.dataset = dataset;
- this.recordType = recordType;
- this.secondaryIndex = secondaryIndex;
- this.ridVarList = ridVarList;
- this.requiresBroadcast = requiresBroadcast;
- this.retainInput = retainInput;
- this.retainNull = retainNull;
- }
-
- public Dataset getDataset() {
- return dataset;
- }
-
- public void setDataset(Dataset dataset) {
- this.dataset = dataset;
- }
-
- public ARecordType getRecordType() {
- return recordType;
- }
-
- public void setRecordType(ARecordType recordType) {
- this.recordType = recordType;
- }
-
- public AqlSourceId getDatasetId() {
- return datasetId;
- }
-
- public void setDatasetId(AqlSourceId datasetId) {
- this.datasetId = datasetId;
- }
-
- @Override
- public PhysicalOperatorTag getOperatorTag() {
- return PhysicalOperatorTag.EXTERNAL_LOOKUP;
- }
-
- @Override
- public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context)
- throws AlgebricksException {
- AqlDataSource ds = new DatasetDataSource(datasetId, datasetId.getDataverseName(), datasetId.getDatasourceName(),
- recordType, AqlDataSourceType.EXTERNAL_DATASET);
- IDataSourcePropertiesProvider dspp = ds.getPropertiesProvider();
- AbstractScanOperator as = (AbstractScanOperator) op;
- deliveredProperties = dspp.computePropertiesVector(as.getVariables());
- }
-
- @Override
- public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op,
- IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema)
- throws AlgebricksException {
- ExternalDataLookupOperator edabro = (ExternalDataLookupOperator) op;
- ILogicalExpression expr = edabro.getExpressionRef().getValue();
- if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
- throw new IllegalStateException();
- }
- AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
- FunctionIdentifier funcIdent = funcExpr.getFunctionIdentifier();
- if (!funcIdent.equals(AsterixBuiltinFunctions.EXTERNAL_LOOKUP)) {
- return;
- }
- int[] ridIndexes = getKeyIndexes(ridVarList, inputSchemas);
- IVariableTypeEnvironment typeEnv = context.getTypeEnvironment(op);
- List<LogicalVariable> outputVars = new ArrayList<LogicalVariable>();
- if (retainInput) {
- VariableUtilities.getLiveVariables(edabro, outputVars);
- } else {
- VariableUtilities.getProducedVariables(edabro, outputVars);
- }
-
- AqlMetadataProvider metadataProvider = (AqlMetadataProvider) context.getMetadataProvider();
- Pair<IOperatorDescriptor, AlgebricksPartitionConstraint> externalLoopup = HDFSLookupAdapterFactory
- .buildExternalDataLookupRuntime(builder.getJobSpec(), dataset, secondaryIndex, ridIndexes, retainInput,
- typeEnv, outputVars, opSchema, context, metadataProvider, retainNull);
- builder.contributeHyracksOperator(edabro, externalLoopup.first);
- builder.contributeAlgebricksPartitionConstraint(externalLoopup.first, externalLoopup.second);
- ILogicalOperator srcExchange = edabro.getInputs().get(0).getValue();
- builder.contributeGraphEdge(srcExchange, 0, edabro, 0);
- }
-
- protected int[] getKeyIndexes(List<LogicalVariable> keyVarList, IOperatorSchema[] inputSchemas) {
- if (keyVarList == null) {
- return null;
- }
- int[] keyIndexes = new int[keyVarList.size()];
- for (int i = 0; i < keyVarList.size(); i++) {
- keyIndexes[i] = inputSchemas[0].findVariable(keyVarList.get(i));
- }
- return keyIndexes;
- }
-
- public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op,
- IPhysicalPropertiesVector reqdByParent) {
- if (requiresBroadcast) {
- StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
- pv[0] = new StructuralPropertiesVector(new BroadcastPartitioningProperty(null), null);
- return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
-
- } else {
- return super.getRequiredPropertiesForChildren(op, reqdByParent);
- }
- }
-
- @Override
- public boolean isMicroOperator() {
- return false;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-asterixdb/blob/34d81630/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/IndexSearchPOperator.java
----------------------------------------------------------------------
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/IndexSearchPOperator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/IndexSearchPOperator.java
deleted file mode 100644
index 1793407..0000000
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/operators/physical/IndexSearchPOperator.java
+++ /dev/null
@@ -1,87 +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.asterix.algebra.operators.physical;
-
-import java.util.List;
-
-import edu.uci.ics.asterix.metadata.declared.AqlSourceId;
-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.metadata.IDataSource;
-import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSourceIndex;
-import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSourcePropertiesProvider;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractScanOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical.AbstractScanPOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.properties.BroadcastPartitioningProperty;
-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;
-
-/**
- * Class that embodies the commonalities between access method physical operators.
- */
-public abstract class IndexSearchPOperator extends AbstractScanPOperator {
-
- protected final IDataSourceIndex<String, AqlSourceId> idx;
- protected final boolean requiresBroadcast;
-
- public IndexSearchPOperator(IDataSourceIndex<String, AqlSourceId> idx, boolean requiresBroadcast) {
- this.idx = idx;
- this.requiresBroadcast = requiresBroadcast;
- }
-
- @Override
- public boolean isMicroOperator() {
- return false;
- }
-
- @Override
- public void computeDeliveredProperties(ILogicalOperator op, IOptimizationContext context) {
- IDataSource<?> ds = idx.getDataSource();
- IDataSourcePropertiesProvider dspp = ds.getPropertiesProvider();
- AbstractScanOperator as = (AbstractScanOperator) op;
- deliveredProperties = dspp.computePropertiesVector(as.getVariables());
- }
-
- protected int[] getKeyIndexes(List<LogicalVariable> keyVarList, IOperatorSchema[] inputSchemas) {
- if (keyVarList == null) {
- return null;
- }
- int[] keyIndexes = new int[keyVarList.size()];
- for (int i = 0; i < keyVarList.size(); i++) {
- keyIndexes[i] = inputSchemas[0].findVariable(keyVarList.get(i));
- }
- return keyIndexes;
- }
-
- public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op,
- IPhysicalPropertiesVector reqdByParent) {
- if (requiresBroadcast) {
- StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
- pv[0] = new StructuralPropertiesVector(new BroadcastPartitioningProperty(null), null);
- return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
- } else {
- return super.getRequiredPropertiesForChildren(op, reqdByParent);
- }
- }
-
- @Override
- public boolean expensiveThanMaterialization() {
- return true;
- }
-}