[NO ISSUE] Remove Algebricks examples Change-Id: I9465405d9e929161bcc6292c5f65c7f3f385c886 Reviewed-on: https://asterix-gerrit.ics.uci.edu/2180 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Contrib: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Murtadha Hubail <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/35b6c131 Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/35b6c131 Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/35b6c131 Branch: refs/heads/master Commit: 35b6c13177ff7bd1cc367b1b0e04083ac0c181e5 Parents: dc7e68a Author: Till Westmann <[email protected]> Authored: Wed Nov 22 17:32:45 2017 -0800 Committer: Till Westmann <[email protected]> Committed: Wed Nov 29 09:25:50 2017 -0800 ---------------------------------------------------------------------- .../algebricks-examples/piglet-example/pom.xml | 169 -------- .../algebricks/examples/piglet/ast/ASTNode.java | 34 -- .../examples/piglet/ast/AssignmentNode.java | 43 -- .../examples/piglet/ast/DumpNode.java | 42 -- .../examples/piglet/ast/ExpressionNode.java | 22 -- .../piglet/ast/FieldAccessExpressionNode.java | 43 -- .../examples/piglet/ast/FilterNode.java | 43 -- .../examples/piglet/ast/FunctionTag.java | 38 -- .../piglet/ast/LiteralExpressionNode.java | 45 --- .../examples/piglet/ast/LoadNode.java | 45 --- .../examples/piglet/ast/RelationNode.java | 22 -- .../ast/ScalarFunctionExpressionNode.java | 52 --- .../examples/piglet/compiler/ConstantValue.java | 61 --- .../piglet/compiler/PigletCompiler.java | 383 ------------------ .../compiler/PigletPrinterFactoryProvider.java | 109 ----- .../piglet/exceptions/PigletException.java | 27 -- .../piglet/metadata/FileSplitUtils.java | 40 -- .../piglet/metadata/PigletFileDataSink.java | 58 --- .../piglet/metadata/PigletFileDataSource.java | 92 ----- .../piglet/metadata/PigletFunction.java | 35 -- .../piglet/metadata/PigletMetadataProvider.java | 261 ------------ .../piglet/rewriter/PigletRewriteRuleset.java | 135 ------- .../piglet/runtime/PigletExpressionJobGen.java | 146 ------- .../IPigletFunctionEvaluatorFactoryBuilder.java | 26 -- .../IntegerEqFunctionEvaluatorFactory.java | 63 --- .../functions/PigletFunctionRegistry.java | 54 --- .../examples/piglet/types/BagType.java | 26 -- .../examples/piglet/types/CharArrayType.java | 31 -- .../examples/piglet/types/DoubleType.java | 31 -- .../examples/piglet/types/FloatType.java | 31 -- .../examples/piglet/types/IntegerType.java | 31 -- .../examples/piglet/types/LongType.java | 31 -- .../examples/piglet/types/MapType.java | 26 -- .../examples/piglet/types/Schema.java | 35 -- .../examples/piglet/types/TupleType.java | 26 -- .../algebricks/examples/piglet/types/Type.java | 34 -- .../src/main/javacc/PigletParser.jj | 395 ------------------- .../examples/piglet/test/PigletTest.java | 47 --- .../examples/piglet/test/PigletTestCase.java | 60 --- .../piglet-example/testcases/q1.piglet | 19 - .../piglet-example/testcases/q2.piglet | 20 - .../algebricks/algebricks-examples/pom.xml | 55 --- hyracks-fullstack/algebricks/pom.xml | 1 - 43 files changed, 2987 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/pom.xml ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/pom.xml b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/pom.xml deleted file mode 100644 index 4827455..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/pom.xml +++ /dev/null @@ -1,169 +0,0 @@ -<!-- - ! Licensed to the Apache Software Foundation (ASF) under one - ! or more contributor license agreements. See the NOTICE file - ! distributed with this work for additional information - ! regarding copyright ownership. The ASF licenses this file - ! to you under the Apache License, Version 2.0 (the - ! "License"); you may not use this file except in compliance - ! with the License. You may obtain a copy of the License at - ! - ! http://www.apache.org/licenses/LICENSE-2.0 - ! - ! Unless required by applicable law or agreed to in writing, - ! software distributed under the License is distributed on an - ! "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ! KIND, either express or implied. See the License for the - ! specific language governing permissions and limitations - ! under the License. - !--> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <artifactId>piglet-example</artifactId> - <name>piglet-example</name> - <parent> - <groupId>org.apache.hyracks</groupId> - <artifactId>algebricks-examples</artifactId> - <version>0.3.3-SNAPSHOT</version> - </parent> - - <properties> - <root.dir>${basedir}/../../..</root.dir> - </properties> - - <build> - <plugins> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>javacc-maven-plugin</artifactId> - <version>2.6</version> - <executions> - <execution> - <id>javacc</id> - <goals> - <goal>javacc</goal> - </goals> - <configuration> - <isStatic>false</isStatic> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-source</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${project.build.directory}/generated-sources/javacc/</source> - </sources> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId> - org.codehaus.mojo - </groupId> - <artifactId> - javacc-maven-plugin - </artifactId> - <versionRange> - [2.6,) - </versionRange> - <goals> - <goal>javacc</goal> - </goals> - </pluginExecutionFilter> - <action> - <ignore /> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - <dependencies> - <dependency> - <!-- Dependency management inherited from top-level hyracks --> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>algebricks-compiler</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>hyracks-util</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>algebricks-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>hyracks-dataflow-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>algebricks-rewriter</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>algebricks-runtime</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>algebricks-data</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>hyracks-api</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>hyracks-dataflow-std</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.hyracks</groupId> - <artifactId>hyracks-data-std</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>org.apache.commons</groupId> - <artifactId>commons-lang3</artifactId> - </dependency> - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ASTNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ASTNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ASTNode.java deleted file mode 100644 index c303e99..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ASTNode.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public abstract class ASTNode { - public enum Tag { - ASSIGNMENT, - DUMP, - LOAD, - FILTER, - - SCALAR_FUNCTION, - LITERAL, - FIELD_ACCESS, - } - - public abstract Tag getTag(); -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/AssignmentNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/AssignmentNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/AssignmentNode.java deleted file mode 100644 index 8a99cb8..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/AssignmentNode.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public class AssignmentNode extends ASTNode { - private String alias; - - private RelationNode relation; - - public AssignmentNode(String alias, RelationNode relation) { - this.alias = alias; - this.relation = relation; - } - - @Override - public Tag getTag() { - return Tag.ASSIGNMENT; - } - - public String getAlias() { - return alias; - } - - public RelationNode getRelation() { - return relation; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/DumpNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/DumpNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/DumpNode.java deleted file mode 100644 index 66a229c..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/DumpNode.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public class DumpNode extends RelationNode { - private final String file; - private final String alias; - - public DumpNode(String file, String alias) { - this.file = file; - this.alias = alias; - } - - @Override - public Tag getTag() { - return Tag.DUMP; - } - - public String getFile() { - return file; - } - - public String getAlias() { - return alias; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ExpressionNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ExpressionNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ExpressionNode.java deleted file mode 100644 index 4470cd9..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ExpressionNode.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public abstract class ExpressionNode extends ASTNode { -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FieldAccessExpressionNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FieldAccessExpressionNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FieldAccessExpressionNode.java deleted file mode 100644 index cfd9bdd..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FieldAccessExpressionNode.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public class FieldAccessExpressionNode extends ExpressionNode { - private String relationName; - - private String fieldName; - - public FieldAccessExpressionNode(String relationName, String fieldName) { - this.relationName = relationName; - this.fieldName = fieldName; - } - - @Override - public Tag getTag() { - return Tag.FIELD_ACCESS; - } - - public String getRelationName() { - return relationName; - } - - public String getFieldName() { - return fieldName; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FilterNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FilterNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FilterNode.java deleted file mode 100644 index b77a6a9..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FilterNode.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public class FilterNode extends RelationNode { - private String alias; - - private ExpressionNode expression; - - public FilterNode(String alias, ExpressionNode expression) { - this.alias = alias; - this.expression = expression; - } - - @Override - public Tag getTag() { - return Tag.FILTER; - } - - public String getAlias() { - return alias; - } - - public ExpressionNode getExpression() { - return expression; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FunctionTag.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FunctionTag.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FunctionTag.java deleted file mode 100644 index b63af9c..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/FunctionTag.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public enum FunctionTag { - BOOLEAN_AND, - BOOLEAN_OR, - BOOLEAN_NOT, - - EQ, - NEQ, - LT, - LTE, - GT, - GTE, - - ADD, - SUBTRACT, - MULTIPLY, - DIVIDE, - MOD, -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LiteralExpressionNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LiteralExpressionNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LiteralExpressionNode.java deleted file mode 100644 index d039145..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LiteralExpressionNode.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -import org.apache.hyracks.algebricks.examples.piglet.types.Type; - -public class LiteralExpressionNode extends ExpressionNode { - private String image; - - private Type type; - - public LiteralExpressionNode(String image, Type type) { - this.image = image; - this.type = type; - } - - @Override - public Tag getTag() { - return Tag.LITERAL; - } - - public String getImage() { - return image; - } - - public Type getType() { - return type; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LoadNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LoadNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LoadNode.java deleted file mode 100644 index 6be1d9f..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/LoadNode.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -import org.apache.hyracks.algebricks.examples.piglet.types.Schema; - -public class LoadNode extends RelationNode { - private String dataFile; - - private Schema schema; - - public LoadNode(String dataFile, Schema schema) { - this.dataFile = dataFile; - this.schema = schema; - } - - @Override - public Tag getTag() { - return Tag.LOAD; - } - - public String getDataFile() { - return dataFile; - } - - public Schema getSchema() { - return schema; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/RelationNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/RelationNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/RelationNode.java deleted file mode 100644 index f36da51..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/RelationNode.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -public abstract class RelationNode extends ASTNode { -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ScalarFunctionExpressionNode.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ScalarFunctionExpressionNode.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ScalarFunctionExpressionNode.java deleted file mode 100644 index e1dea89..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/ast/ScalarFunctionExpressionNode.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.ast; - -import java.util.List; - -public class ScalarFunctionExpressionNode extends ExpressionNode { - private FunctionTag fTag; - - private String fName; - - private List<ASTNode> arguments; - - public ScalarFunctionExpressionNode(FunctionTag fTag, String fName, List<ASTNode> arguments) { - this.fTag = fTag; - this.fName = fName; - this.arguments = arguments; - } - - @Override - public Tag getTag() { - return Tag.SCALAR_FUNCTION; - } - - public FunctionTag getFunctionTag() { - return fTag; - } - - public String getFunctionName() { - return fName; - } - - public List<ASTNode> getArguments() { - return arguments; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java deleted file mode 100644 index 90d5b83..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.compiler; - -import org.apache.hyracks.algebricks.core.algebra.expressions.IAlgebricksConstantValue; -import org.apache.hyracks.algebricks.examples.piglet.types.Type; - -public final class ConstantValue implements IAlgebricksConstantValue { - private final Type type; - - private final String image; - - public ConstantValue(Type type, String image) { - this.type = type; - this.image = image; - } - - public Type getType() { - return type; - } - - public String getImage() { - return image; - } - - @Override - public boolean isFalse() { - return false; - } - - @Override - public boolean isMissing() { - return false; - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public boolean isTrue() { - return false; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletCompiler.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletCompiler.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletCompiler.java deleted file mode 100644 index c8b6e59..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletCompiler.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.compiler; - -import java.io.Reader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.commons.lang3.mutable.Mutable; -import org.apache.commons.lang3.mutable.MutableObject; -import org.apache.hyracks.algebricks.common.constraints.AlgebricksAbsolutePartitionConstraint; -import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; -import org.apache.hyracks.algebricks.common.utils.Pair; -import org.apache.hyracks.algebricks.compiler.api.HeuristicCompilerFactoryBuilder; -import org.apache.hyracks.algebricks.compiler.api.ICompiler; -import org.apache.hyracks.algebricks.compiler.api.ICompilerFactory; -import org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialFixpointRuleController; -import org.apache.hyracks.algebricks.compiler.rewriter.rulecontrollers.SequentialOnceRuleController; -import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression; -import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator; -import org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan; -import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable; -import org.apache.hyracks.algebricks.core.algebra.expressions.ConstantExpression; -import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer; -import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; -import org.apache.hyracks.algebricks.core.algebra.expressions.ExpressionRuntimeProvider; -import org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression; -import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression; -import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions; -import org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo; -import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider; -import org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator; -import org.apache.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator; -import org.apache.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator; -import org.apache.hyracks.algebricks.core.algebra.operators.logical.SelectOperator; -import org.apache.hyracks.algebricks.core.algebra.operators.logical.WriteOperator; -import org.apache.hyracks.algebricks.core.algebra.plan.ALogicalPlanImpl; -import org.apache.hyracks.algebricks.core.algebra.prettyprint.AlgebricksAppendable; -import org.apache.hyracks.algebricks.core.algebra.prettyprint.LogicalOperatorPrettyPrintVisitor; -import org.apache.hyracks.algebricks.core.algebra.prettyprint.PlanPrettyPrinter; -import org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController; -import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule; -import org.apache.hyracks.algebricks.data.ISerializerDeserializerProvider; -import org.apache.hyracks.algebricks.data.ITypeTraitProvider; -import org.apache.hyracks.algebricks.examples.piglet.ast.ASTNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.AssignmentNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.DumpNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.ExpressionNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.FieldAccessExpressionNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.FilterNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.FunctionTag; -import org.apache.hyracks.algebricks.examples.piglet.ast.LiteralExpressionNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.LoadNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.RelationNode; -import org.apache.hyracks.algebricks.examples.piglet.ast.ScalarFunctionExpressionNode; -import org.apache.hyracks.algebricks.examples.piglet.exceptions.PigletException; -import org.apache.hyracks.algebricks.examples.piglet.metadata.PigletFileDataSink; -import org.apache.hyracks.algebricks.examples.piglet.metadata.PigletFileDataSource; -import org.apache.hyracks.algebricks.examples.piglet.metadata.PigletMetadataProvider; -import org.apache.hyracks.algebricks.examples.piglet.parser.ParseException; -import org.apache.hyracks.algebricks.examples.piglet.parser.PigletParser; -import org.apache.hyracks.algebricks.examples.piglet.rewriter.PigletRewriteRuleset; -import org.apache.hyracks.algebricks.examples.piglet.runtime.PigletExpressionJobGen; -import org.apache.hyracks.algebricks.examples.piglet.types.Schema; -import org.apache.hyracks.algebricks.examples.piglet.types.Type; -import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer; -import org.apache.hyracks.api.dataflow.value.ITypeTraits; -import org.apache.hyracks.api.job.JobSpecification; - -public class PigletCompiler { - private static final Logger LOGGER = Logger.getLogger(PigletCompiler.class.getName()); - - private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> buildDefaultLogicalRewrites() { - List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> defaultLogicalRewrites = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>(); - SequentialFixpointRuleController seqCtrlNoDfs = new SequentialFixpointRuleController(false); - SequentialFixpointRuleController seqCtrlFullDfs = new SequentialFixpointRuleController(true); - SequentialOnceRuleController seqOnceCtrl = new SequentialOnceRuleController(true); - defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl, - PigletRewriteRuleset.buildTypeInferenceRuleCollection())); - defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlFullDfs, - PigletRewriteRuleset.buildNormalizationRuleCollection())); - defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs, - PigletRewriteRuleset.buildCondPushDownRuleCollection())); - defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs, - PigletRewriteRuleset.buildJoinInferenceRuleCollection())); - defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs, - PigletRewriteRuleset.buildOpPushDownRuleCollection())); - defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrl, - PigletRewriteRuleset.buildDataExchangeRuleCollection())); - defaultLogicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqCtrlNoDfs, - PigletRewriteRuleset.buildConsolidationRuleCollection())); - return defaultLogicalRewrites; - } - - private static List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> buildDefaultPhysicalRewrites() { - List<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>> defaultPhysicalRewrites = new ArrayList<Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>>(); - SequentialOnceRuleController seqOnceCtrlAllLevels = new SequentialOnceRuleController(true); - SequentialOnceRuleController seqOnceCtrlTopLevel = new SequentialOnceRuleController(false); - defaultPhysicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrlAllLevels, - PigletRewriteRuleset.buildPhysicalRewritesAllLevelsRuleCollection())); - defaultPhysicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrlTopLevel, - PigletRewriteRuleset.buildPhysicalRewritesTopLevelRuleCollection())); - defaultPhysicalRewrites.add(new Pair<AbstractRuleController, List<IAlgebraicRewriteRule>>(seqOnceCtrlAllLevels, - PigletRewriteRuleset.prepareForJobGenRuleCollection())); - return defaultPhysicalRewrites; - } - - private final ICompilerFactory cFactory; - - private final PigletMetadataProvider metadataProvider; - - private int varCounter; - - private ILogicalOperator previousOp; - - public PigletCompiler() { - HeuristicCompilerFactoryBuilder builder = new HeuristicCompilerFactoryBuilder(); - builder.setLogicalRewrites(buildDefaultLogicalRewrites()); - builder.setPhysicalRewrites(buildDefaultPhysicalRewrites()); - builder.setSerializerDeserializerProvider(new ISerializerDeserializerProvider() { - @SuppressWarnings("unchecked") - @Override - public ISerializerDeserializer getSerializerDeserializer(Object type) throws AlgebricksException { - return null; - } - }); - builder.setTypeTraitProvider(new ITypeTraitProvider() { - @Override - public ITypeTraits getTypeTrait(Object type) { - return null; - } - }); - builder.setPrinterProvider(PigletPrinterFactoryProvider.INSTANCE); - builder.setExpressionRuntimeProvider( - new ExpressionRuntimeProvider(new PigletExpressionJobGen())); - builder.setExpressionTypeComputer(new IExpressionTypeComputer() { - @Override - public Object getType(ILogicalExpression expr, IMetadataProvider<?, ?> metadataProvider, - IVariableTypeEnvironment env) throws AlgebricksException { - return null; - } - }); - builder.setClusterLocations(new AlgebricksAbsolutePartitionConstraint(new String[] { "nc1", "nc2" })); - cFactory = builder.create(); - metadataProvider = new PigletMetadataProvider(); - } - - public List<ASTNode> parse(Reader in) throws ParseException { - PigletParser parser = new PigletParser(in); - List<ASTNode> statements = parser.Statements(); - return statements; - } - - public JobSpecification compile(List<ASTNode> ast) throws AlgebricksException, PigletException { - ILogicalPlan plan = translate(ast); - if (LOGGER.isLoggable(Level.INFO)) { - LOGGER.info("Translated Plan:"); - LOGGER.info(getPrettyPrintedPlan(plan)); - } - ICompiler compiler = cFactory.createCompiler(plan, metadataProvider, varCounter); - compiler.optimize(); - if (LOGGER.isLoggable(Level.INFO)) { - LOGGER.info("Optimized Plan:"); - LOGGER.info(getPrettyPrintedPlan(plan)); - } - return compiler.createJob(null, null); - } - - private ILogicalPlan translate(List<ASTNode> ast) throws PigletException { - Map<String, Relation> symMap = new HashMap<String, Relation>(); - List<Mutable<ILogicalOperator>> roots = new ArrayList<Mutable<ILogicalOperator>>(); - previousOp = null; - for (ASTNode an : ast) { - switch (an.getTag()) { - case DUMP: { - DumpNode dn = (DumpNode) an; - Relation input = symMap.get(dn.getAlias()); - List<Mutable<ILogicalExpression>> expressions = new ArrayList<Mutable<ILogicalExpression>>(); - for (LogicalVariable v : input.schema.values()) { - expressions.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(v))); - } - PigletFileDataSink dataSink = new PigletFileDataSink(dn.getFile()); - ILogicalOperator op = new WriteOperator(expressions, dataSink); - op.getInputs().add(new MutableObject<ILogicalOperator>(input.op)); - roots.add(new MutableObject<ILogicalOperator>(op)); - } - break; - - case ASSIGNMENT: { - AssignmentNode asn = (AssignmentNode) an; - String alias = asn.getAlias(); - RelationNode rn = asn.getRelation(); - Relation rel = translate(rn, symMap); - previousOp = rel.op; - rel.alias = alias; - symMap.put(alias, rel); - } - break; - } - } - return new ALogicalPlanImpl(roots); - } - - private Relation translate(RelationNode rn, Map<String, Relation> symMap) throws PigletException { - switch (rn.getTag()) { - case LOAD: { - LoadNode ln = (LoadNode) rn; - String file = ln.getDataFile(); - Schema schema = ln.getSchema(); - List<Pair<String, Type>> fieldsSchema = schema.getSchema(); - List<LogicalVariable> variables = new ArrayList<LogicalVariable>(); - List<Object> types = new ArrayList<Object>(); - Relation rel = new Relation(); - for (Pair<String, Type> p : fieldsSchema) { - LogicalVariable v = newVariable(); - rel.schema.put(p.first, v); - variables.add(v); - types.add(p.second); - } - PigletFileDataSource ds = new PigletFileDataSource(file, types.toArray()); - rel.op = new DataSourceScanOperator(variables, ds); - rel.op.getInputs().add(new MutableObject<ILogicalOperator>( - previousOp == null ? new EmptyTupleSourceOperator() : previousOp)); - return rel; - } - - case FILTER: { - FilterNode fn = (FilterNode) rn; - String alias = fn.getAlias(); - ExpressionNode conditionNode = fn.getExpression(); - Relation inputRel = findInputRelation(alias, symMap); - Pair<Relation, LogicalVariable> tempInput = translateScalarExpression(inputRel, conditionNode); - Relation rel = new Relation(); - rel.op = new SelectOperator( - new MutableObject<ILogicalExpression>(new VariableReferenceExpression(tempInput.second)), false, - null); - rel.op.getInputs().add(new MutableObject<ILogicalOperator>(tempInput.first.op)); - rel.schema.putAll(tempInput.first.schema); - return rel; - } - } - throw new IllegalArgumentException("Unknown node: " + rn.getTag() + " encountered"); - } - - private Pair<Relation, LogicalVariable> translateScalarExpression(Relation inputRel, ExpressionNode expressionNode) - throws PigletException { - switch (expressionNode.getTag()) { - case FIELD_ACCESS: { - FieldAccessExpressionNode faen = (FieldAccessExpressionNode) expressionNode; - String fieldName = faen.getFieldName(); - LogicalVariable lVar = findField(fieldName, inputRel.schema); - return new Pair<Relation, LogicalVariable>(inputRel, lVar); - } - - case LITERAL: { - LiteralExpressionNode len = (LiteralExpressionNode) expressionNode; - String image = len.getImage(); - Type type = len.getType(); - ConstantExpression ce = new ConstantExpression(new ConstantValue(type, image)); - Relation rel = new Relation(); - LogicalVariable var = newVariable(); - List<LogicalVariable> vars = new ArrayList<LogicalVariable>(); - vars.add(var); - - List<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>(); - exprs.add(new MutableObject<ILogicalExpression>(ce)); - - rel.op = new AssignOperator(vars, exprs); - rel.op.getInputs().add(new MutableObject<ILogicalOperator>(inputRel.op)); - rel.schema.putAll(inputRel.schema); - - return new Pair<Relation, LogicalVariable>(rel, var); - } - - case SCALAR_FUNCTION: { - ScalarFunctionExpressionNode sfen = (ScalarFunctionExpressionNode) expressionNode; - List<Mutable<ILogicalExpression>> argExprs = new ArrayList<Mutable<ILogicalExpression>>(); - List<ASTNode> arguments = sfen.getArguments(); - Relation rel = inputRel; - for (ASTNode a : arguments) { - Pair<Relation, LogicalVariable> argPair = translateScalarExpression(rel, (ExpressionNode) a); - rel = argPair.first; - argExprs.add( - new MutableObject<ILogicalExpression>(new VariableReferenceExpression(argPair.second))); - } - Relation outRel = new Relation(); - outRel.schema.putAll(rel.schema); - LogicalVariable var = newVariable(); - List<LogicalVariable> vars = new ArrayList<LogicalVariable>(); - vars.add(var); - - IFunctionInfo fInfo = lookupFunction(sfen.getFunctionTag(), sfen.getFunctionName()); - - List<Mutable<ILogicalExpression>> exprs = new ArrayList<Mutable<ILogicalExpression>>(); - exprs.add(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(fInfo, argExprs))); - outRel.op = new AssignOperator(vars, exprs); - outRel.op.getInputs().add(new MutableObject<ILogicalOperator>(rel.op)); - return new Pair<Relation, LogicalVariable>(outRel, var); - } - } - return null; - } - - private IFunctionInfo lookupFunction(FunctionTag functionTag, String functionName) throws PigletException { - switch (functionTag) { - case EQ: - return metadataProvider.lookupFunction(AlgebricksBuiltinFunctions.EQ); - - case NEQ: - return metadataProvider.lookupFunction(AlgebricksBuiltinFunctions.NEQ); - - case LT: - return metadataProvider.lookupFunction(AlgebricksBuiltinFunctions.LT); - - case LTE: - return metadataProvider.lookupFunction(AlgebricksBuiltinFunctions.LE); - - case GT: - return metadataProvider.lookupFunction(AlgebricksBuiltinFunctions.GT); - - case GTE: - return metadataProvider.lookupFunction(AlgebricksBuiltinFunctions.GE); - } - throw new PigletException("Unsupported function: " + functionTag); - } - - private LogicalVariable newVariable() { - return new LogicalVariable(varCounter++); - } - - private LogicalVariable findField(String fieldName, Map<String, LogicalVariable> schema) throws PigletException { - LogicalVariable var = schema.get(fieldName); - if (var == null) { - throw new PigletException("Unable to find field named: " + fieldName); - } - return var; - } - - private Relation findInputRelation(String alias, Map<String, Relation> symMap) throws PigletException { - Relation rel = symMap.get(alias); - if (rel == null) { - throw new PigletException("Unknown alias " + alias + "referenced"); - } - return rel; - } - - private static class Relation { - String alias; - ILogicalOperator op; - final Map<String, LogicalVariable> schema; - - public Relation() { - schema = new LinkedHashMap<String, LogicalVariable>(); - } - } - - private String getPrettyPrintedPlan(ILogicalPlan plan) throws AlgebricksException { - LogicalOperatorPrettyPrintVisitor v = new LogicalOperatorPrettyPrintVisitor(); - PlanPrettyPrinter.printPlan(plan, v, 0); - return v.get().toString(); - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java deleted file mode 100644 index 135a9a7..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/PigletPrinterFactoryProvider.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.compiler; - -import java.io.IOException; -import java.io.PrintStream; - -import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException; -import org.apache.hyracks.algebricks.data.IPrinter; -import org.apache.hyracks.algebricks.data.IPrinterFactory; -import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider; -import org.apache.hyracks.algebricks.data.impl.IntegerPrinterFactory; -import org.apache.hyracks.algebricks.examples.piglet.types.Type; -import org.apache.hyracks.api.exceptions.HyracksDataException; -import org.apache.hyracks.data.std.primitive.FloatPointable; -import org.apache.hyracks.util.string.UTF8StringUtil; - -public class PigletPrinterFactoryProvider implements IPrinterFactoryProvider { - - public static final PigletPrinterFactoryProvider INSTANCE = new PigletPrinterFactoryProvider(); - - private PigletPrinterFactoryProvider() { - } - - @Override - public IPrinterFactory getPrinterFactory(Object type) { - Type t = (Type) type; - switch (t.getTag()) { - case INTEGER: - return IntegerPrinterFactory.INSTANCE; - case CHAR_ARRAY: - return CharArrayPrinterFactory.INSTANCE; - case FLOAT: - return FloatPrinterFactory.INSTANCE; - default: - throw new UnsupportedOperationException(); - - } - } - - public static class CharArrayPrinterFactory implements IPrinterFactory { - - private static final long serialVersionUID = 1L; - - public static final CharArrayPrinterFactory INSTANCE = new CharArrayPrinterFactory(); - - private CharArrayPrinterFactory() { - } - - @Override - public IPrinter createPrinter() { - return new IPrinter() { - @Override - public void init() { - } - - @Override - public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException { - try { - UTF8StringUtil.printUTF8StringWithQuotes(b, s, l, ps); - } catch (IOException e) { - throw new HyracksDataException(e); - } - } - }; - } - } - - public static class FloatPrinterFactory implements IPrinterFactory { - - private static final long serialVersionUID = 1L; - - public static final FloatPrinterFactory INSTANCE = new FloatPrinterFactory(); - - private FloatPrinterFactory() { - } - - @Override - public IPrinter createPrinter() { - return new IPrinter() { - @Override - public void init() throws HyracksDataException { - } - - @Override - public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException { - ps.print(FloatPointable.getFloat(b, s)); - } - }; - } - } - -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/exceptions/PigletException.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/exceptions/PigletException.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/exceptions/PigletException.java deleted file mode 100644 index 67f9d5b..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/exceptions/PigletException.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.exceptions; - -public class PigletException extends Exception { - private static final long serialVersionUID = 1L; - - public PigletException(String message) { - super(message); - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/FileSplitUtils.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/FileSplitUtils.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/FileSplitUtils.java deleted file mode 100644 index 5d9576f..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/FileSplitUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.metadata; - -import java.io.File; - -import org.apache.hyracks.api.io.FileSplit; -import org.apache.hyracks.api.io.UnmanagedFileSplit; - -public class FileSplitUtils { - public static FileSplit[] parseFileSplits(String fileSplits) { - String[] splits = fileSplits.split(","); - FileSplit[] fSplits = new FileSplit[splits.length]; - for (int i = 0; i < splits.length; ++i) { - String s = splits[i].trim(); - int idx = s.indexOf(':'); - if (idx < 0) { - throw new IllegalArgumentException("File split " + s + " not well formed"); - } - fSplits[i] = new UnmanagedFileSplit(s.substring(0, idx), new File(s.substring(idx + 1)).getAbsolutePath()); - } - return fSplits; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSink.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSink.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSink.java deleted file mode 100644 index d0d94ac..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSink.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.metadata; - -import org.apache.hyracks.algebricks.core.algebra.metadata.IDataSink; -import org.apache.hyracks.algebricks.core.algebra.properties.FileSplitDomain; -import org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty; -import org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty; -import org.apache.hyracks.api.io.FileSplit; - -public class PigletFileDataSink implements IDataSink { - private String file; - - private FileSplit[] fileSplits; - - private IPartitioningProperty partProp; - - public PigletFileDataSink(String file) { - this.file = file; - fileSplits = FileSplitUtils.parseFileSplits(file); - partProp = new RandomPartitioningProperty(new FileSplitDomain(fileSplits)); - } - - @Override - public Object getId() { - return file; - } - - public FileSplit[] getFileSplits() { - return fileSplits; - } - - @Override - public Object[] getSchemaTypes() { - return null; - } - - @Override - public IPartitioningProperty getPartitioningProperty() { - return partProp; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSource.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSource.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSource.java deleted file mode 100644 index 6a675fc..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFileDataSource.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.metadata; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable; -import org.apache.hyracks.algebricks.core.algebra.metadata.IDataSource; -import org.apache.hyracks.algebricks.core.algebra.metadata.IDataSourcePropertiesProvider; -import org.apache.hyracks.algebricks.core.algebra.properties.FileSplitDomain; -import org.apache.hyracks.algebricks.core.algebra.properties.FunctionalDependency; -import org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty; -import org.apache.hyracks.algebricks.core.algebra.properties.INodeDomain; -import org.apache.hyracks.algebricks.core.algebra.properties.IPhysicalPropertiesVector; -import org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty; -import org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector; -import org.apache.hyracks.api.io.FileSplit; - -public class PigletFileDataSource implements IDataSource<String> { - private final String file; - - private final Object[] types; - - private final FileSplit[] fileSplits; - - private IDataSourcePropertiesProvider propProvider; - - public PigletFileDataSource(String file, Object[] types) { - this.file = file; - this.types = types; - fileSplits = FileSplitUtils.parseFileSplits(file); - final IPhysicalPropertiesVector vec = new StructuralPropertiesVector(new RandomPartitioningProperty( - new FileSplitDomain(fileSplits)), new ArrayList<ILocalStructuralProperty>()); - propProvider = new IDataSourcePropertiesProvider() { - @Override - public IPhysicalPropertiesVector computePropertiesVector(List<LogicalVariable> scanVariables) { - return vec; - } - }; - - } - - @Override - public INodeDomain getDomain() { - return new FileSplitDomain(fileSplits); - } - - @Override - public String getId() { - return file; - } - - @Override - public Object[] getSchemaTypes() { - return types; - } - - public FileSplit[] getFileSplits() { - return fileSplits; - } - - @Override - public IDataSourcePropertiesProvider getPropertiesProvider() { - return propProvider; - } - - @Override - public void computeFDs(List<LogicalVariable> scanVariables, List<FunctionalDependency> fdList) { - } - - @Override - public boolean isScanAccessPathALeaf() { - return true; - } -} http://git-wip-us.apache.org/repos/asf/asterixdb/blob/35b6c131/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFunction.java ---------------------------------------------------------------------- diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFunction.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFunction.java deleted file mode 100644 index 06d9b25..0000000 --- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/metadata/PigletFunction.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.apache.hyracks.algebricks.examples.piglet.metadata; - -import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier; -import org.apache.hyracks.algebricks.core.algebra.functions.IFunctionInfo; - -public class PigletFunction implements IFunctionInfo { - private final FunctionIdentifier fid; - - public PigletFunction(FunctionIdentifier fid) { - this.fid = fid; - } - - @Override - public FunctionIdentifier getFunctionIdentifier() { - return fid; - } -}
