Return-Path: X-Original-To: apmail-asterixdb-commits-archive@minotaur.apache.org Delivered-To: apmail-asterixdb-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D75AC18FF8 for ; Tue, 25 Aug 2015 17:41:38 +0000 (UTC) Received: (qmail 97178 invoked by uid 500); 25 Aug 2015 17:41:38 -0000 Delivered-To: apmail-asterixdb-commits-archive@asterixdb.apache.org Received: (qmail 97146 invoked by uid 500); 25 Aug 2015 17:41:38 -0000 Mailing-List: contact commits-help@asterixdb.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.incubator.apache.org Delivered-To: mailing list commits@asterixdb.incubator.apache.org Received: (qmail 97135 invoked by uid 99); 25 Aug 2015 17:41:38 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2015 17:41:38 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 29C66C009B for ; Tue, 25 Aug 2015 17:41:38 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.795 X-Spam-Level: * X-Spam-Status: No, score=1.795 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.006, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id nbCaDi8jnupp for ; Tue, 25 Aug 2015 17:41:15 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id 9690A21115 for ; Tue, 25 Aug 2015 17:41:15 +0000 (UTC) Received: (qmail 69538 invoked by uid 99); 25 Aug 2015 16:41:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 25 Aug 2015 16:41:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id ED920E35D5; Tue, 25 Aug 2015 16:41:14 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: imaxon@apache.org To: commits@asterixdb.incubator.apache.org Date: Tue, 25 Aug 2015 16:41:46 -0000 Message-Id: <446bc6f53c7040eab99b805dedd7b7f5@git.apache.org> In-Reply-To: <339f74e1fc5c4aabb18d5e46ecf6ba11@git.apache.org> References: <339f74e1fc5c4aabb18d5e46ecf6ba11@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [33/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/org/apache/hyracks/algebricks/core/algebra/functions/FunctionIdentifier.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/FunctionIdentifier.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/FunctionIdentifier.java new file mode 100644 index 0000000..7f812f3 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/FunctionIdentifier.java @@ -0,0 +1,70 @@ +/* + * 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.functions; + +import java.io.Serializable; + +public final class FunctionIdentifier implements Serializable { + private static final long serialVersionUID = 1L; + + private final String namespace; + private final String name; + private final int arity; + + public final static int VARARGS = -1; + + public FunctionIdentifier(String namespace, String name) { + this(namespace, name, VARARGS); + } + + public FunctionIdentifier(String namespace, String name, int arity) { + this.namespace = namespace; + this.name = name; + this.arity = arity; + } + + public String getName() { + return name; + } + + @Override + public boolean equals(Object o) { + if (super.equals(o)) { + return true; + } + if (o instanceof FunctionIdentifier) { + FunctionIdentifier ofi = (FunctionIdentifier) o; + return ofi.getNamespace().equals(getNamespace()) && ofi.name.equals(name); + } + return false; + } + + @Override + public int hashCode() { + return name.hashCode() + namespace.hashCode(); + } + + public String toString() { + return getNamespace() + ":" + name; + } + + public int getArity() { + return arity; + } + + public String getNamespace() { + return namespace; + } +} \ 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/org/apache/hyracks/algebricks/core/algebra/functions/IFunctionInfo.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/IFunctionInfo.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/IFunctionInfo.java new file mode 100644 index 0000000..02cd6de --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/IFunctionInfo.java @@ -0,0 +1,21 @@ +/* + * 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.functions; + +public interface IFunctionInfo { + FunctionIdentifier getFunctionIdentifier(); + + public boolean isFunctional(); +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSink.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSink.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSink.java new file mode 100644 index 0000000..a7b7bc5 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSink.java @@ -0,0 +1,25 @@ +/* + * 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.metadata; + +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; + +public interface IDataSink { + public Object getId(); + + public Object[] getSchemaTypes(); + + public IPartitioningProperty getPartitioningProperty(); +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSource.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSource.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSource.java new file mode 100644 index 0000000..ed5cb4b --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSource.java @@ -0,0 +1,30 @@ +/* + * 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.metadata; + +import java.util.List; + +import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.FunctionalDependency; + +public interface IDataSource { + public T getId(); + + public Object[] getSchemaTypes(); + + public IDataSourcePropertiesProvider getPropertiesProvider(); + + public void computeFDs(List scanVariables, List fdList); +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourceIndex.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourceIndex.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourceIndex.java new file mode 100644 index 0000000..20a2dcf --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourceIndex.java @@ -0,0 +1,21 @@ +/* + * 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.metadata; + +public interface IDataSourceIndex { + public I getId(); + + public IDataSource getDataSource(); +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourcePropertiesProvider.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourcePropertiesProvider.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourcePropertiesProvider.java new file mode 100644 index 0000000..3ae1e31 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IDataSourcePropertiesProvider.java @@ -0,0 +1,24 @@ +/* + * 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.metadata; + +import java.util.List; + +import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; + +public interface IDataSourcePropertiesProvider { + public IPhysicalPropertiesVector computePropertiesVector(List scanVariables); +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IMetadataProvider.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IMetadataProvider.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IMetadataProvider.java new file mode 100644 index 0000000..c71b352 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/metadata/IMetadataProvider.java @@ -0,0 +1,192 @@ +/* + * 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.metadata; + +import java.util.List; + +import edu.uci.ics.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint; +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.common.utils.Pair; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +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.functions.FunctionIdentifier; +import edu.uci.ics.hyracks.algebricks.core.algebra.functions.IFunctionInfo; +import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema; +import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; +import edu.uci.ics.hyracks.algebricks.data.IPrinterFactory; +import edu.uci.ics.hyracks.algebricks.runtime.base.IPushRuntimeFactory; +import edu.uci.ics.hyracks.api.dataflow.IOperatorDescriptor; +import edu.uci.ics.hyracks.api.dataflow.value.RecordDescriptor; +import edu.uci.ics.hyracks.api.job.JobSpecification; + +public interface IMetadataProvider { + public IDataSource findDataSource(S id) throws AlgebricksException; + + /** + * Obs: A scanner may choose to contribute a null + * AlgebricksPartitionConstraint and implement + * contributeSchedulingConstraints instead. + */ + public Pair getScannerRuntime(IDataSource dataSource, + List scanVariables, List projectVariables, boolean projectPushed, + List minFilterVars, List maxFilterVars, IOperatorSchema opSchema, + IVariableTypeEnvironment typeEnv, JobGenContext context, JobSpecification jobSpec, Object implConfig) + throws AlgebricksException; + + public boolean scannerOperatorIsLeaf(IDataSource dataSource); + + public Pair getWriteFileRuntime(IDataSink sink, + int[] printColumns, IPrinterFactory[] printerFactories, RecordDescriptor inputDesc) + throws AlgebricksException; + + public Pair getResultHandleRuntime(IDataSink sink, + int[] printColumns, IPrinterFactory[] printerFactories, RecordDescriptor inputDesc, boolean ordered, + JobSpecification spec) throws AlgebricksException; + + public Pair getWriteResultRuntime(IDataSource dataSource, + IOperatorSchema propagatedSchema, List keys, LogicalVariable payLoadVar, + List additionalNonKeyFields, JobGenContext context, JobSpecification jobSpec) + throws AlgebricksException; + + public Pair getInsertRuntime(IDataSource dataSource, + IOperatorSchema propagatedSchema, IVariableTypeEnvironment typeEnv, List keys, + LogicalVariable payLoadVar, List additionalNonKeyFields, RecordDescriptor recordDesc, + JobGenContext context, JobSpecification jobSpec, boolean bulkload) throws AlgebricksException; + + public Pair getDeleteRuntime(IDataSource dataSource, + IOperatorSchema propagatedSchema, IVariableTypeEnvironment typeEnv, List keys, + LogicalVariable payLoadVar, List additionalNonKeyFields, RecordDescriptor recordDesc, + JobGenContext context, JobSpecification jobSpec) throws AlgebricksException; + + /** + * Creates the insert runtime of IndexInsertDeletePOperator, which models + * insert/delete operations into a secondary index. + * + * @param dataSource + * Target secondary index. + * @param propagatedSchema + * Output schema of the insert/delete operator to be created. + * @param inputSchemas + * Output schemas of the insert/delete operator to be created. + * @param typeEnv + * Type environment of the original IndexInsertDeleteOperator operator. + * @param primaryKeys + * Variables for the dataset's primary keys that the dataSource secondary index belongs to. + * @param secondaryKeys + * Variables for the secondary-index keys. + * @param additionalNonKeyFields + * Additional variables that can be passed to the secondary index as payload. + * This can be useful when creating a second filter on a non-primary and non-secondary + * fields for additional pruning power. + * @param filterExpr + * Filtering expression to be pushed inside the runtime op. + * Such a filter may, e.g., exclude NULLs from being inserted/deleted. + * @param recordDesc + * Output record descriptor of the runtime op to be created. + * @param context + * Job generation context. + * @param spec + * Target job specification. + * @return + * A Hyracks IOperatorDescriptor and its partition constraint. + * @throws AlgebricksException + */ + public Pair getIndexInsertRuntime( + IDataSourceIndex dataSource, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, + IVariableTypeEnvironment typeEnv, List primaryKeys, List secondaryKeys, + List additionalNonKeyFields, ILogicalExpression filterExpr, RecordDescriptor recordDesc, + JobGenContext context, JobSpecification spec, boolean bulkload) throws AlgebricksException; + + /** + * Creates the delete runtime of IndexInsertDeletePOperator, which models + * insert/delete operations into a secondary index. + * + * @param dataSource + * Target secondary index. + * @param propagatedSchema + * Output schema of the insert/delete operator to be created. + * @param inputSchemas + * Output schemas of the insert/delete operator to be created. + * @param typeEnv + * Type environment of the original IndexInsertDeleteOperator operator. + * @param primaryKeys + * Variables for the dataset's primary keys that the dataSource secondary index belongs to. + * @param secondaryKeys + * Variables for the secondary-index keys. + * @param additionalNonKeyFields + * Additional variables that can be passed to the secondary index as payload. + * This can be useful when creating a second filter on a non-primary and non-secondary + * fields for additional pruning power. + * @param filterExpr + * Filtering expression to be pushed inside the runtime op. + * Such a filter may, e.g., exclude NULLs from being inserted/deleted. + * @param recordDesc + * Output record descriptor of the runtime op to be created. + * @param context + * Job generation context. + * @param spec + * Target job specification. + * @return + * A Hyracks IOperatorDescriptor and its partition constraint. + * @throws AlgebricksException + */ + public Pair getIndexDeleteRuntime( + IDataSourceIndex dataSource, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, + IVariableTypeEnvironment typeEnv, List primaryKeys, List secondaryKeys, + List additionalNonKeyFields, ILogicalExpression filterExpr, RecordDescriptor recordDesc, + JobGenContext context, JobSpecification spec) throws AlgebricksException; + + /** + * Creates the TokenizeOperator for IndexInsertDeletePOperator, which tokenizes + * secondary key into [token, number of token] pair in a length-partitioned index. + * In case of non length-partitioned index, it tokenizes secondary key into [token]. + * + * @param dataSource + * Target secondary index. + * @param propagatedSchema + * Output schema of the insert/delete operator to be created. + * @param inputSchemas + * Output schemas of the insert/delete operator to be created. + * @param typeEnv + * Type environment of the original IndexInsertDeleteOperator operator. + * @param primaryKeys + * Variables for the dataset's primary keys that the dataSource secondary index belongs to. + * @param secondaryKeys + * Variables for the secondary-index keys. + * @param filterExpr + * Filtering expression to be pushed inside the runtime op. + * Such a filter may, e.g., exclude NULLs from being inserted/deleted. + * @param recordDesc + * Output record descriptor of the runtime op to be created. + * @param context + * Job generation context. + * @param spec + * Target job specification. + * @return + * A Hyracks IOperatorDescriptor and its partition constraint. + * @throws AlgebricksException + */ + public Pair getTokenizerRuntime( + IDataSourceIndex dataSource, IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, + IVariableTypeEnvironment typeEnv, List primaryKeys, List secondaryKeys, + ILogicalExpression filterExpr, RecordDescriptor recordDesc, JobGenContext context, JobSpecification spec, + boolean bulkload) throws AlgebricksException; + + public IDataSourceIndex findDataSourceIndex(I indexId, S dataSourceId) throws AlgebricksException; + + public IFunctionInfo lookupFunction(FunctionIdentifier fid); + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractAssignOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractAssignOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractAssignOperator.java new file mode 100644 index 0000000..687025a --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractAssignOperator.java @@ -0,0 +1,70 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; + +/** + * @author Nicola + */ +public abstract class AbstractAssignOperator extends AbstractLogicalOperator { + protected final List variables; + protected final List> expressions; + + public AbstractAssignOperator() { + this.variables = new ArrayList(); + this.expressions = new ArrayList>(); + } + + public AbstractAssignOperator(List variables, List> expressions) { + this.variables = variables; + this.expressions = expressions; + } + + public List getVariables() { + return variables; + } + + public List> getExpressions() { + return expressions; + } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + schema.addAll(inputs.get(0).getValue().getSchema()); + schema.addAll(variables); + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) throws AlgebricksException { + boolean modif = false; + for (int i = 0; i < expressions.size(); i++) { + if (visitor.transform(expressions.get(i))) { + modif = true; + } + } + return modif; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractBinaryJoinOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractBinaryJoinOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractBinaryJoinOperator.java new file mode 100644 index 0000000..6c00412 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractBinaryJoinOperator.java @@ -0,0 +1,78 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; + +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; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; + +public abstract class AbstractBinaryJoinOperator extends AbstractLogicalOperator { + protected final Mutable condition; + protected JoinKind joinKind; + + public enum JoinKind { + INNER, + LEFT_OUTER + } + + public AbstractBinaryJoinOperator(JoinKind joinKind, Mutable condition) { + this.joinKind = joinKind; + this.condition = condition; + } + + public AbstractBinaryJoinOperator(JoinKind joinKind, Mutable condition, + Mutable input1, Mutable input2) { + this(joinKind, condition); + inputs.add(input1); + inputs.add(input2); + } + + public Mutable getCondition() { + return condition; + } + + public JoinKind getJoinKind() { + return joinKind; + } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + schema.addAll(inputs.get(0).getValue().getSchema()); + schema.addAll(inputs.get(1).getValue().getSchema()); + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return VariablePropagationPolicy.concat(VariablePropagationPolicy.ALL, VariablePropagationPolicy.ALL); + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) throws AlgebricksException { + return visitor.transform(condition); + } + + @Override + public boolean isMap() { + return false; + } +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractDataSourceOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractDataSourceOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractDataSourceOperator.java new file mode 100644 index 0000000..85660e2 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractDataSourceOperator.java @@ -0,0 +1,35 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +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.operators.logical.AbstractScanOperator; + +import java.util.List; + +public abstract class AbstractDataSourceOperator extends AbstractScanOperator { + protected IDataSource dataSource; + + public AbstractDataSourceOperator(List variables, IDataSource dataSource) { + super(variables); + this.dataSource = dataSource; + } + + public IDataSource getDataSource() { + return dataSource; + } +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractExtensibleLogicalOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractExtensibleLogicalOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractExtensibleLogicalOperator.java new file mode 100644 index 0000000..2b3c60a --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractExtensibleLogicalOperator.java @@ -0,0 +1,56 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.List; + +import edu.uci.ics.hyracks.algebricks.core.algebra.base.IPhysicalOperator; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; +import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator.ExecutionMode; + +/** + * @author rico + */ +public abstract class AbstractExtensibleLogicalOperator implements IOperatorExtension { + + private AbstractLogicalOperator.ExecutionMode mode = AbstractLogicalOperator.ExecutionMode.UNPARTITIONED; + protected List schema; + protected IPhysicalOperator physicalOperator; + + @Override + public ExecutionMode getExecutionMode() { + return mode; + } + + @Override + public void setExecutionMode(ExecutionMode mode) { + this.mode = mode; + } + + @Override + public void setSchema(List schema) { + this.schema = schema; + } + + @Override + public IPhysicalOperator getPhysicalOperator() { + return physicalOperator; + } + + @Override + public void setPhysicalOperator(IPhysicalOperator physicalOperator) { + this.physicalOperator = physicalOperator; + } +} \ 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/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java new file mode 100644 index 0000000..528ae4e --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java @@ -0,0 +1,190 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.IHyracksJobBuilder; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.IPhysicalOperator; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalOperatorTag; +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.properties.IPhysicalPropertiesVector; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.PhysicalRequirements; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.TypePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.OpRefTypeEnvPointer; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.jobgen.impl.JobGenContext; + +public abstract class AbstractLogicalOperator implements ILogicalOperator { + + /********************************************************************* + * UNPARTITIONED, the input data is not partitioned + * PARTITIONED, the input data is partitioned, the operator is executed on + * each partition and may receive input from other partitions (e.g. if it is + * a join or an aggregate) + * LOCAL, the input data is partitioned, the operator is executed on each + * partition and only processes data from that partition + */ + + public static enum ExecutionMode { + UNPARTITIONED, + PARTITIONED, + LOCAL + } + + private AbstractLogicalOperator.ExecutionMode mode = AbstractLogicalOperator.ExecutionMode.UNPARTITIONED; + protected IPhysicalOperator physicalOperator; + private final Map annotations = new HashMap(); + private boolean bJobGenEnabled = true; + + final protected List> inputs; + // protected List outputs; + protected List schema; + + public AbstractLogicalOperator() { + inputs = new ArrayList>(); + // outputs = new ArrayList(); + } + + @Override + public abstract LogicalOperatorTag getOperatorTag(); + + public ExecutionMode getExecutionMode() { + return mode; + } + + public void setExecutionMode(ExecutionMode mode) { + this.mode = mode; + } + + @Override + public List getSchema() { + return schema; + } + + public void setPhysicalOperator(IPhysicalOperator physicalOp) { + this.physicalOperator = physicalOp; + } + + public IPhysicalOperator getPhysicalOperator() { + return physicalOperator; + } + + /** + * @return for each child, one vector of required physical properties + */ + + @Override + public final PhysicalRequirements getRequiredPhysicalPropertiesForChildren( + IPhysicalPropertiesVector requiredProperties) { + return physicalOperator.getRequiredPropertiesForChildren(this, requiredProperties); + } + + /** + * @return the physical properties that this operator delivers, based on + * what its children deliver + */ + + @Override + public final IPhysicalPropertiesVector getDeliveredPhysicalProperties() { + return physicalOperator.getDeliveredProperties(); + } + + @Override + public final void computeDeliveredPhysicalProperties(IOptimizationContext context) throws AlgebricksException { + physicalOperator.computeDeliveredProperties(this, context); + } + + @Override + public final List> getInputs() { + return inputs; + } + + // @Override + // public final List getOutputs() { + // return outputs; + // } + + @Override + public final boolean hasInputs() { + return !inputs.isEmpty(); + } + + public boolean hasNestedPlans() { + return false; + } + + @Override + public Map getAnnotations() { + return annotations; + } + + @Override + public void removeAnnotation(String annotationName) { + annotations.remove(annotationName); + } + + @Override + public final void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, + IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) + throws AlgebricksException { + if (bJobGenEnabled) { + if (physicalOperator == null) { + throw new AlgebricksException("Physical operator not set for operator: " + this); + } + physicalOperator.contributeRuntimeOperator(builder, context, this, propagatedSchema, inputSchemas, + outerPlanSchema); + } + } + + public void disableJobGen() { + bJobGenEnabled = false; + } + + public boolean isJobGenEnabled() { + return bJobGenEnabled; + } + + @Override + public IVariableTypeEnvironment computeInputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { + return createPropagatingAllInputsTypeEnvironment(ctx); + } + + protected PropagatingTypeEnvironment createPropagatingAllInputsTypeEnvironment(ITypingContext ctx) { + int n = inputs.size(); + ITypeEnvPointer[] envPointers = new ITypeEnvPointer[n]; + for (int i = 0; i < n; i++) { + envPointers[i] = new OpRefTypeEnvPointer(inputs.get(i), ctx); + } + return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getNullableTypeComputer(), + ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers); + } + + @Override + public boolean requiresVariableReferenceExpressions() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractOperatorWithNestedPlans.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractOperatorWithNestedPlans.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractOperatorWithNestedPlans.java new file mode 100644 index 0000000..417c959 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractOperatorWithNestedPlans.java @@ -0,0 +1,90 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import org.apache.commons.lang3.mutable.Mutable; + +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.LogicalVariable; + +public abstract class AbstractOperatorWithNestedPlans extends AbstractLogicalOperator { + protected final List nestedPlans; + + public AbstractOperatorWithNestedPlans() { + nestedPlans = new ArrayList(); + } + + public AbstractOperatorWithNestedPlans(List nestedPlans) { + this.nestedPlans = nestedPlans; + } + + public List getNestedPlans() { + return nestedPlans; + } + + @Override + public boolean hasNestedPlans() { + return true; + } + + public LinkedList> allRootsInReverseOrder() { + LinkedList> allRoots = new LinkedList>(); + for (ILogicalPlan p : nestedPlans) { + for (Mutable r : p.getRoots()) { + allRoots.addFirst(r); + } + } + return allRoots; + } + + // + // @Override + // public void computeConstraintsAndEquivClasses() { + // for (ILogicalPlan p : nestedPlans) { + // for (LogicalOperatorReference r : p.getRoots()) { + // AbstractLogicalOperator op = (AbstractLogicalOperator) r.getOperator(); + // equivalenceClasses.putAll(op.getEquivalenceClasses()); + // functionalDependencies.addAll(op.getFDs()); + // } + // } + // } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + schema.addAll(inputs.get(0).getValue().getSchema()); + for (ILogicalPlan p : nestedPlans) { + for (Mutable r : p.getRoots()) { + schema.addAll(r.getValue().getSchema()); + } + } + } + + @Override + public boolean isMap() { + return false; + } + + public abstract void getUsedVariablesExceptNestedPlans(Collection vars); + + public abstract void getProducedVariablesExceptNestedPlans(Collection vars); + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractScanOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractScanOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractScanOperator.java new file mode 100644 index 0000000..e18fbfb --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractScanOperator.java @@ -0,0 +1,63 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +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.properties.VariablePropagationPolicy; + +public abstract class AbstractScanOperator extends AbstractLogicalOperator { + protected List variables; + + public AbstractScanOperator(List variables) { + this.variables = variables; + } + + public List getVariables() { + return variables; + } + + public void setVariables(List variables) { + this.variables = variables; + } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + schema.addAll(inputs.get(0).getValue().getSchema()); + schema.addAll(variables); + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return new VariablePropagationPolicy() { + + @Override + public void propagateVariables(IOperatorSchema target, IOperatorSchema... sources) + throws AlgebricksException { + if (sources.length > 0) { + target.addAllVariables(sources[0]); + } + for (LogicalVariable v : variables) { + target.addVariable(v); + } + } + }; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractUnnestOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractUnnestOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractUnnestOperator.java new file mode 100644 index 0000000..fdc827f --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractUnnestOperator.java @@ -0,0 +1,49 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.List; + +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalVariable; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; + +public abstract class AbstractUnnestOperator extends AbstractScanOperator { + + protected final Mutable expression; + + public AbstractUnnestOperator(List variables, Mutable expression) { + super(variables); + this.expression = expression; + } + + public Mutable getExpressionRef() { + return expression; + } + + @Override + public boolean isMap() { + return true; + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) throws AlgebricksException { + return visitor.transform(expression); + } + +} \ 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/org/apache/hyracks/algebricks/core/algebra/operators/logical/AggregateOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AggregateOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AggregateOperator.java new file mode 100644 index 0000000..371da4c --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AggregateOperator.java @@ -0,0 +1,109 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +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.IVariableTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.NonPropagatingTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; + +public class AggregateOperator extends AbstractAssignOperator { + + // private ArrayList expressions; + // TODO type safe list of expressions + private List> mergeExpressions; + private boolean global; + + public AggregateOperator(List variables, List> expressions) { + super(variables, expressions); + global = true; + } + + @Override + public LogicalOperatorTag getOperatorTag() { + return LogicalOperatorTag.AGGREGATE; + } + + @Override + public R accept(ILogicalOperatorVisitor visitor, T arg) throws AlgebricksException { + return visitor.visitAggregateOperator(this, arg); + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return new VariablePropagationPolicy() { + + @Override + public void propagateVariables(IOperatorSchema target, IOperatorSchema... sources) + throws AlgebricksException { + for (LogicalVariable v : variables) { + target.addVariable(v); + } + } + }; + } + + @Override + public boolean isMap() { + return false; + } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + schema.addAll(variables); + } + + public void setMergeExpressions(List> merges) { + mergeExpressions = merges; + } + + public List> getMergeExpressions() { + return mergeExpressions; + } + + public void setGlobal(boolean global) { + this.global = global; + } + + public boolean isGlobal() { + return global; + } + + @Override + public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { + IVariableTypeEnvironment env = new NonPropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), + ctx.getMetadataProvider()); + IVariableTypeEnvironment env2 = ctx.getOutputTypeEnvironment(inputs.get(0).getValue()); + int n = variables.size(); + for (int i = 0; i < n; i++) { + Object t = ctx.getExpressionTypeComputer().getType(expressions.get(i).getValue(), + ctx.getMetadataProvider(), env2); + env.setVarType(variables.get(i), t); + } + return env; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AssignOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AssignOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AssignOperator.java new file mode 100644 index 0000000..9a8c428 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AssignOperator.java @@ -0,0 +1,119 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.List; +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +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.IVariableTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.LocalOrderProperty; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.PropagatingTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; + +/** + * It corresponds to the Map operator in other algebras. + * + * @author Nicola + */ + +public class AssignOperator extends AbstractAssignOperator { + + private LocalOrderProperty explicitOrderingProperty; + + public AssignOperator(List vars, List> exprs) { + super(vars, exprs); + } + + public AssignOperator(LogicalVariable var, Mutable expr) { + super(); + this.variables.add(var); + this.expressions.add(expr); + } + + @Override + public LogicalOperatorTag getOperatorTag() { + return LogicalOperatorTag.ASSIGN; + } + + @Override + public R accept(ILogicalOperatorVisitor visitor, T arg) throws AlgebricksException { + return visitor.visitAssignOperator(this, arg); + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return new VariablePropagationPolicy() { + + @Override + public void propagateVariables(IOperatorSchema target, IOperatorSchema... sources) + throws AlgebricksException { + target.addAllVariables(sources[0]); + for (LogicalVariable v : variables) { + target.addVariable(v); + } + } + }; + + } + + @Override + public boolean isMap() { + return true; + } + + @Override + public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { + PropagatingTypeEnvironment env = createPropagatingAllInputsTypeEnvironment(ctx); + int n = variables.size(); + for (int i = 0; i < n; i++) { + env.setVarType( + variables.get(i), + ctx.getExpressionTypeComputer().getType(expressions.get(i).getValue(), ctx.getMetadataProvider(), + env)); + if (expressions.get(i).getValue().getExpressionTag() == LogicalExpressionTag.VARIABLE) { + LogicalVariable var = ((VariableReferenceExpression) expressions.get(i).getValue()) + .getVariableReference(); + for (List list : env.getCorrelatedNullableVariableLists()) { + if (list.contains(var)) { + list.add(variables.get(i)); + } + } + } + } + return env; + } + + @Override + public boolean requiresVariableReferenceExpressions() { + return false; + } + + public LocalOrderProperty getExplicitOrderingProperty() { + return explicitOrderingProperty; + } + + public void setExplicitOrderingProperty( + LocalOrderProperty explicitOrderingProperty) { + this.explicitOrderingProperty = explicitOrderingProperty; + } +} \ 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/org/apache/hyracks/algebricks/core/algebra/operators/logical/DataSourceScanOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DataSourceScanOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DataSourceScanOperator.java new file mode 100644 index 0000000..ff21478 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DataSourceScanOperator.java @@ -0,0 +1,133 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +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.IVariableTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSource; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; + +public class DataSourceScanOperator extends AbstractDataSourceOperator { + private List projectVars; + + private boolean projectPushed = false; + + private List> additionalFilteringExpressions; + private List minFilterVars; + private List maxFilterVars; + + public DataSourceScanOperator(List variables, IDataSource dataSource) { + super(variables, dataSource); + projectVars = new ArrayList(); + } + + @Override + public LogicalOperatorTag getOperatorTag() { + return LogicalOperatorTag.DATASOURCESCAN; + } + + @Override + public R accept(ILogicalOperatorVisitor visitor, S arg) throws AlgebricksException { + return visitor.visitDataScanOperator(this, arg); + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) throws AlgebricksException { + return false; + } + + @Override + public boolean isMap() { + return false; + } + + public void addProjectVariables(Collection vars) { + projectVars.addAll(vars); + projectPushed = true; + } + + public List getProjectVariables() { + return projectVars; + } + + public boolean isProjectPushed() { + return projectPushed; + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return new VariablePropagationPolicy() { + @Override + public void propagateVariables(IOperatorSchema target, IOperatorSchema... sources) + throws AlgebricksException { + if (sources.length > 0) { + target.addAllVariables(sources[0]); + } + List outputVariables = projectPushed ? projectVars : variables; + for (LogicalVariable v : outputVariables) { + target.addVariable(v); + } + } + }; + } + + @Override + public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { + IVariableTypeEnvironment env = createPropagatingAllInputsTypeEnvironment(ctx); + Object[] types = dataSource.getSchemaTypes(); + int i = 0; + for (LogicalVariable v : variables) { + env.setVarType(v, types[i]); + ++i; + } + return env; + } + + public List getMinFilterVars() { + return minFilterVars; + } + + public void setMinFilterVars(List minFilterVars) { + this.minFilterVars = minFilterVars; + } + + public List getMaxFilterVars() { + return maxFilterVars; + } + + public void setMaxFilterVars(List maxFilterVars) { + this.maxFilterVars = maxFilterVars; + } + + public void setAdditionalFilteringExpressions(List> additionalFilteringExpressions) { + this.additionalFilteringExpressions = additionalFilteringExpressions; + } + + public List> getAdditionalFilteringExpressions() { + return additionalFilteringExpressions; + } +} \ 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/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistinctOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistinctOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistinctOperator.java new file mode 100644 index 0000000..3d8c4b6 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistinctOperator.java @@ -0,0 +1,134 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +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.IVariableTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; + +public class DistinctOperator extends AbstractLogicalOperator { + private final List> expressions; + + public DistinctOperator(List> expressions) { + this.expressions = expressions; + } + + @Override + public LogicalOperatorTag getOperatorTag() { + return LogicalOperatorTag.DISTINCT; + } + + public List> getExpressions() { + return expressions; + } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + schema.addAll(this.getDistinctByVarList()); + List inputSchema = inputs.get(0).getValue().getSchema(); + for (LogicalVariable var : inputSchema) { + if (!schema.contains(var)) { + schema.add(var); + } + } + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return new VariablePropagationPolicy() { + @Override + public void propagateVariables(IOperatorSchema target, IOperatorSchema... sources) + throws AlgebricksException { + /** make sure distinct key vars laid-out first */ + for (LogicalVariable keyVar : getDistinctByVarList()) { + target.addVariable(keyVar); + } + /** add other source vars */ + for (IOperatorSchema srcSchema : sources) { + for (LogicalVariable srcVar : srcSchema) + if (target.findVariable(srcVar) < 0) { + target.addVariable(srcVar); + } + } + } + }; + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) throws AlgebricksException { + boolean changed = false; + for (Mutable e : expressions) { + if (visitor.transform(e)) { + changed = true; + } + } + return changed; + } + + @Override + public R accept(ILogicalOperatorVisitor visitor, T arg) throws AlgebricksException { + return visitor.visitDistinctOperator(this, arg); + } + + @Override + public boolean isMap() { + return false; + } + + public List getDistinctByVarList() { + List varList = new ArrayList(expressions.size()); + for (Mutable eRef : expressions) { + ILogicalExpression e = eRef.getValue(); + if (e.getExpressionTag() == LogicalExpressionTag.VARIABLE) { + VariableReferenceExpression v = (VariableReferenceExpression) e; + varList.add(v.getVariableReference()); + } + } + return varList; + } + + public boolean isDistinctByVar(LogicalVariable var) { + for (Mutable eRef : expressions) { + ILogicalExpression e = eRef.getValue(); + if (e.getExpressionTag() == LogicalExpressionTag.VARIABLE) { + VariableReferenceExpression v = (VariableReferenceExpression) e; + if (v.getVariableReference() == var) { + return true; + } + } + } + return false; + } + + @Override + public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { + return createPropagatingAllInputsTypeEnvironment(ctx); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistributeResultOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistributeResultOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistributeResultOperator.java new file mode 100644 index 0000000..3e28d73 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/DistributeResultOperator.java @@ -0,0 +1,93 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.lang3.mutable.Mutable; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; +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.IVariableTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.metadata.IDataSink; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; + +public class DistributeResultOperator extends AbstractLogicalOperator { + private List> expressions; + private IDataSink dataSink; + + public DistributeResultOperator(List> expressions, IDataSink dataSink) { + this.expressions = expressions; + this.dataSink = dataSink; + } + + public List> getExpressions() { + return expressions; + } + + public IDataSink getDataSink() { + return dataSink; + } + + @Override + public LogicalOperatorTag getOperatorTag() { + return LogicalOperatorTag.DISTRIBUTE_RESULT; + } + + @Override + public R accept(ILogicalOperatorVisitor visitor, T arg) throws AlgebricksException { + return visitor.visitDistributeResultOperator(this, arg); + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) throws AlgebricksException { + boolean modif = false; + for (int i = 0; i < expressions.size(); i++) { + boolean b = visitor.transform(expressions.get(i)); + if (b) { + modif = true; + } + } + return modif; + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return VariablePropagationPolicy.ALL; + } + + @Override + public boolean isMap() { + return false; // actually depends on the physical op. + } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + schema.addAll(inputs.get(0).getValue().getSchema()); + } + + @Override + public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { + return createPropagatingAllInputsTypeEnvironment(ctx); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-asterixdb-hyracks/blob/9939b48e/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/EmptyTupleSourceOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/EmptyTupleSourceOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/EmptyTupleSourceOperator.java new file mode 100644 index 0000000..7d16ed1 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/EmptyTupleSourceOperator.java @@ -0,0 +1,96 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.List; + +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.LogicalOperatorTag; +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.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; + +public class EmptyTupleSourceOperator extends AbstractLogicalOperator { + + @Override + public LogicalOperatorTag getOperatorTag() { + return LogicalOperatorTag.EMPTYTUPLESOURCE; + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return VariablePropagationPolicy.NONE; + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) { + // do nothing + return false; + } + + @Override + public R accept(ILogicalOperatorVisitor visitor, T arg) throws AlgebricksException { + return visitor.visitEmptyTupleSourceOperator(this, arg); + } + + @Override + public void recomputeSchema() { + schema = new ArrayList(); + } + + @Override + public boolean isMap() { + return false; + } + + @Override + public IVariableTypeEnvironment computeOutputTypeEnvironment(final ITypingContext ctx) throws AlgebricksException { + return new IVariableTypeEnvironment() { + + @Override + public void setVarType(LogicalVariable var, Object type) { + throw new IllegalStateException(); + } + + @Override + public Object getVarType(LogicalVariable var) throws AlgebricksException { + return null; + } + + @Override + public Object getType(ILogicalExpression expr) throws AlgebricksException { + return ctx.getExpressionTypeComputer().getType(expr, ctx.getMetadataProvider(), this); + } + + @Override + public Object getVarType(LogicalVariable var, List nonNullVariables, + List> correlatedNullableVariableLists) throws AlgebricksException { + return null; + } + + @Override + public boolean substituteProducedVariable(LogicalVariable v1, LogicalVariable v2) + throws AlgebricksException { + return false; + } + }; + } + +} \ 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/org/apache/hyracks/algebricks/core/algebra/operators/logical/ExchangeOperator.java ---------------------------------------------------------------------- diff --git a/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/ExchangeOperator.java b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/ExchangeOperator.java new file mode 100644 index 0000000..a3c2650 --- /dev/null +++ b/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/ExchangeOperator.java @@ -0,0 +1,76 @@ +/* + * Copyright 2009-2013 by The Regents of the University of California + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * you may obtain a copy of the License from + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical; + +import java.util.ArrayList; +import java.util.List; + +import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; +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.IVariableTypeEnvironment; +import edu.uci.ics.hyracks.algebricks.core.algebra.properties.VariablePropagationPolicy; +import edu.uci.ics.hyracks.algebricks.core.algebra.typing.ITypingContext; +import edu.uci.ics.hyracks.algebricks.core.algebra.util.OperatorPropertiesUtil; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalExpressionReferenceTransform; +import edu.uci.ics.hyracks.algebricks.core.algebra.visitors.ILogicalOperatorVisitor; + +public class ExchangeOperator extends AbstractLogicalOperator { + + public ExchangeOperator() { + super(); + setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED); + } + + @Override + public R accept(ILogicalOperatorVisitor visitor, T arg) throws AlgebricksException { + return visitor.visitExchangeOperator(this, arg); + } + + @Override + public boolean acceptExpressionTransform(ILogicalExpressionReferenceTransform visitor) { + // do nothing + return false; + } + + @Override + public LogicalOperatorTag getOperatorTag() { + return LogicalOperatorTag.EXCHANGE; + } + + @Override + public void recomputeSchema() throws AlgebricksException { + AbstractLogicalOperator cld = (AbstractLogicalOperator) inputs.get(0).getValue(); + OperatorPropertiesUtil.computeSchemaRecIfNull(cld); + List inputSchema = inputs.get(0).getValue().getSchema(); + schema = new ArrayList(inputSchema); + } + + @Override + public VariablePropagationPolicy getVariablePropagationPolicy() { + return VariablePropagationPolicy.ALL; + } + + @Override + public boolean isMap() { + return true; + } + + @Override + public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException { + return createPropagatingAllInputsTypeEnvironment(ctx); + } + +}