You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by ja...@apache.org on 2013/09/04 13:09:40 UTC
[10/52] [abbrv] [partial] DRILL-165: Reorganize directories (moves
only)
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataType.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataType.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataType.java
deleted file mode 100644
index 84ff054..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataType.java
+++ /dev/null
@@ -1,145 +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.drill.common.expression.types;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.annotation.JsonSerialize;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-
-@JsonSerialize(using = DataType.Se.class)
-@JsonDeserialize(using = DataType.De.class)
-abstract class DataType {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(DataType.class);
-
- public static enum Comparability{
- UNKNOWN, NONE, EQUAL, ORDERED;
- }
-
- public abstract String getName();
- public abstract boolean isLateBind();
- public abstract boolean hasChildType();
- public abstract DataType getChildType();
- public abstract Comparability getComparability();
- public abstract boolean isNumericType();
-
-
-
- public static final DataType LATEBIND = new LateBindType();
- public static final DataType BOOLEAN = new AtomType("BOOLEAN", Comparability.EQUAL, false);
- public static final DataType BYTES = new AtomType("BYTES", Comparability.ORDERED, false);
- public static final DataType SIGNED_BYTE = new AtomType("SIGNED_BYTE", Comparability.ORDERED, true);
- public static final DataType SIGNED_INT16 = new AtomType("SIGNED_INT16", Comparability.ORDERED, true);
- public static final DataType NVARCHAR = new AtomType("VARCHAR", Comparability.ORDERED, false);
- public static final DataType FLOAT32 = new AtomType("FLOAT32", Comparability.ORDERED, true);
- public static final DataType FLOAT64 = new AtomType("FLOAT64", Comparability.ORDERED, true);
- public static final DataType INT64 = new AtomType("INT64", Comparability.ORDERED, true);
- public static final DataType INT32 = new AtomType("INT32", Comparability.ORDERED, true);
- public static final DataType INT16 = new AtomType("INT16", Comparability.ORDERED, true);
- public static final DataType UINT16 = new AtomType("UINT16", Comparability.ORDERED, true);
-// public static final DataType INT16 = new AtomType("int16", Comparability.ORDERED, true);
-// public static final DataType BIG_INTEGER = new AtomType("bigint", Comparability.ORDERED, true);
-// public static final DataType BIG_DECIMAL = new AtomType("bigdecimal", Comparability.ORDERED, true);
- public static final DataType DATE = new AtomType("DATE", Comparability.ORDERED, false);
- public static final DataType DATETIME = new AtomType("DATETIME", Comparability.ORDERED, false);
- public static final DataType MAP = new AtomType("MAP", Comparability.NONE, false);
- public static final DataType ARRAY = new AtomType("ARRAY", Comparability.NONE, false);
- public static final DataType NULL = new AtomType("NULL", Comparability.NONE, false);
-
- //TODO: Hack to get some size data, needs to be fixed so that each type reveals it's size.
- public int size(){
- if(this == BOOLEAN){
- return 1;
- }else if(this == INT32){
- return 4;
- }else if(this == INT16){
- return 4;
- }
- return 2;
- }
-
- static final Map<String, DataType> TYPES;
- static {
- Field[] fields = DataType.class.getFields();
- Map<String, DataType> types = new HashMap<String, DataType>();
- for(Field f : fields){
- //logger.debug("Reviewing {}, Field: {}", f.getClass(), f);
- if(Modifier.isStatic(f.getModifiers())){
- try {
- Object o = f.get(null);
- //logger.debug("Object {}", o);
-
- if(o instanceof DataType) types.put(((DataType) o).getName(), (DataType) o);
- } catch (IllegalArgumentException | IllegalAccessException e) {
- logger.warn("Failure while reading DataType.", e);
- }
- }
- }
- TYPES = Collections.unmodifiableMap(types);
-
- }
-
- public static DataType getDataType(String name){
- if(TYPES.containsKey(name)){
- return TYPES.get(name);
- }else{
- throw new IllegalArgumentException(String.format("Unknown type requested of [%s].", name));
- }
- }
-
- public static class De extends StdDeserializer<DataType> {
-
- public De() {
- super(DataType.class);
- }
-
- @Override
- public DataType deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
- JsonProcessingException {
- return getDataType(this._parseString(jp, ctxt));
- }
-
- }
-
- public static class Se extends StdSerializer<DataType> {
-
- public Se() {
- super(DataType.class);
- }
-
- @Override
- public void serialize(DataType value, JsonGenerator jgen, SerializerProvider provider) throws IOException,
- JsonGenerationException {
- jgen.writeString(value.getName());
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataTypeFactory.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataTypeFactory.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataTypeFactory.java
deleted file mode 100644
index 2ad03df..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/DataTypeFactory.java
+++ /dev/null
@@ -1,25 +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.drill.common.expression.types;
-
-public abstract class DataTypeFactory {
-
- public abstract DataType getArrayType(DataType containedType);
- public abstract DataType getMapType(DataType keyType, DataType valueType);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/LateBindType.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/LateBindType.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/LateBindType.java
deleted file mode 100644
index da3d87a..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/types/LateBindType.java
+++ /dev/null
@@ -1,53 +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.drill.common.expression.types;
-
-class LateBindType extends DataType {
-
- @Override
- public String getName() {
- return "LATE";
- }
-
- @Override
- public boolean isLateBind() {
- return true;
- }
-
- @Override
- public boolean hasChildType() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public DataType getChildType() {
- throw new UnsupportedOperationException();
- }
-
-
- @Override
- public boolean isNumericType() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Comparability getComparability() {
- return Comparability.UNKNOWN;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AbstractExprVisitor.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AbstractExprVisitor.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AbstractExprVisitor.java
deleted file mode 100644
index d561f7e..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AbstractExprVisitor.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.apache.drill.common.expression.visitors;
-
-import org.apache.drill.common.expression.FunctionCall;
-import org.apache.drill.common.expression.IfExpression;
-import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.expression.ValueExpressions.BooleanExpression;
-import org.apache.drill.common.expression.ValueExpressions.DoubleExpression;
-import org.apache.drill.common.expression.ValueExpressions.LongExpression;
-import org.apache.drill.common.expression.ValueExpressions.QuotedString;
-
-public abstract class AbstractExprVisitor<T, VAL, EXCEP extends Exception> implements ExprVisitor<T, VAL, EXCEP> {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AbstractExprVisitor.class);
-
- @Override
- public T visitFunctionCall(FunctionCall call, VAL value) throws EXCEP {
- return null;
- }
-
- @Override
- public T visitIfExpression(IfExpression ifExpr, VAL value) throws EXCEP {
- return visitUnknown(ifExpr, value);
- }
-
- @Override
- public T visitSchemaPath(SchemaPath path, VAL value) throws EXCEP {
- return visitUnknown(path, value);
- }
-
- @Override
- public T visitLongConstant(LongExpression intExpr, VAL value) throws EXCEP {
- return visitUnknown(intExpr, value);
- }
-
- @Override
- public T visitDoubleConstant(DoubleExpression dExpr, VAL value) throws EXCEP {
- return visitUnknown(dExpr, value);
- }
-
- @Override
- public T visitBooleanConstant(BooleanExpression e, VAL value) throws EXCEP {
- return visitUnknown(e, value);
- }
-
- @Override
- public T visitQuotedStringConstant(QuotedString e, VAL value) throws EXCEP {
- return visitUnknown(e, value);
- }
-
- @Override
- public T visitUnknown(LogicalExpression e, VAL value) throws EXCEP {
- throw new UnsupportedOperationException(String.format("Expression of type %s not handled by visitor type %s.", e.getClass().getCanonicalName(), this.getClass().getCanonicalName()));
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java
deleted file mode 100644
index aa44281..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/AggregateChecker.java
+++ /dev/null
@@ -1,94 +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.drill.common.expression.visitors;
-
-import org.apache.drill.common.expression.FunctionCall;
-import org.apache.drill.common.expression.IfExpression;
-import org.apache.drill.common.expression.IfExpression.IfCondition;
-import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.expression.ValueExpressions.BooleanExpression;
-import org.apache.drill.common.expression.ValueExpressions.DoubleExpression;
-import org.apache.drill.common.expression.ValueExpressions.LongExpression;
-import org.apache.drill.common.expression.ValueExpressions.QuotedString;
-
-public final class AggregateChecker extends SimpleExprVisitor<Boolean>{
-
- public static final AggregateChecker INSTANCE = new AggregateChecker();
-
- private AggregateChecker(){};
-
- public static boolean isAggregating(LogicalExpression e){
- return e.accept(INSTANCE, null);
- }
-
- @Override
- public Boolean visitFunctionCall(FunctionCall call) {
- if(call.getDefinition().isAggregating()){
- for(LogicalExpression e : call){
- if(e.accept(this, null)) throw new IllegalArgumentException(String.format("Your aggregating function call %s also includes arguments that contain aggregations. This isn't allowed.", call.getDefinition().toString()));
- }
- return true;
- }else{
- for(LogicalExpression e : call){
- if(e.accept(this, null)) return true;
- }
- return false;
- }
- }
-
- @Override
- public Boolean visitIfExpression(IfExpression ifExpr) {
- for(IfCondition c : ifExpr.conditions){
- if(c.condition.accept(this, null) || c.expression.accept(this, null)) return true;
- }
- return ifExpr.elseExpression.accept(this, null);
- }
-
- @Override
- public Boolean visitSchemaPath(SchemaPath path) {
- return false;
- }
-
- @Override
- public Boolean visitLongConstant(LongExpression intExpr) {
- return false;
- }
-
- @Override
- public Boolean visitDoubleConstant(DoubleExpression dExpr) {
- return false;
- }
-
- @Override
- public Boolean visitBooleanConstant(BooleanExpression e) {
- return false;
- }
-
- @Override
- public Boolean visitQuotedStringConstant(QuotedString e) {
- return false;
- }
-
- @Override
- public Boolean visitUnknown(LogicalExpression e, Void value) throws RuntimeException {
- return false;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java
deleted file mode 100644
index f8984e9..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ConstantChecker.java
+++ /dev/null
@@ -1,88 +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.drill.common.expression.visitors;
-
-import org.apache.drill.common.expression.FunctionCall;
-import org.apache.drill.common.expression.IfExpression;
-import org.apache.drill.common.expression.IfExpression.IfCondition;
-import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.expression.ValueExpressions.BooleanExpression;
-import org.apache.drill.common.expression.ValueExpressions.DoubleExpression;
-import org.apache.drill.common.expression.ValueExpressions.LongExpression;
-import org.apache.drill.common.expression.ValueExpressions.QuotedString;
-
-public final class ConstantChecker extends SimpleExprVisitor<Boolean>{
-
- private final static ConstantChecker INSTANCE = new ConstantChecker();
-
- private ConstantChecker(){}
-
- public static boolean onlyIncludesConstants(LogicalExpression e){
- return e.accept(INSTANCE, null);
- }
-
- @Override
- public Boolean visitFunctionCall(FunctionCall call) {
- for(LogicalExpression e : call){
- if(!e.accept(this, null)) return false;
- }
- return true;
- }
-
- @Override
- public Boolean visitIfExpression(IfExpression ifExpr) {
- for(IfCondition c : ifExpr.conditions){
- if(!c.condition.accept(this, null) || !c.expression.accept(this, null)) return false;
- }
- if(!ifExpr.elseExpression.accept(this, null)) return false;
- return true;
- }
-
- @Override
- public Boolean visitSchemaPath(SchemaPath path) {
- return false;
- }
-
- @Override
- public Boolean visitLongConstant(LongExpression intExpr) {
- return true;
- }
-
- @Override
- public Boolean visitDoubleConstant(DoubleExpression dExpr) {
- return true;
- }
-
- @Override
- public Boolean visitBooleanConstant(BooleanExpression e) {
- return true;
- }
-
- @Override
- public Boolean visitQuotedStringConstant(QuotedString e) {
- return true;
- }
-
- @Override
- public Boolean visitUnknown(LogicalExpression e, Void value) throws RuntimeException {
- return false;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ExprVisitor.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ExprVisitor.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ExprVisitor.java
deleted file mode 100644
index cd27157..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/ExprVisitor.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.drill.common.expression.visitors;
-
-import org.apache.drill.common.expression.FunctionCall;
-import org.apache.drill.common.expression.IfExpression;
-import org.apache.drill.common.expression.LogicalExpression;
-import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.expression.ValueExpressions.BooleanExpression;
-import org.apache.drill.common.expression.ValueExpressions.DoubleExpression;
-import org.apache.drill.common.expression.ValueExpressions.LongExpression;
-import org.apache.drill.common.expression.ValueExpressions.QuotedString;
-
-public interface ExprVisitor<T, VAL, EXCEP extends Exception> {
- public T visitFunctionCall(FunctionCall call, VAL value) throws EXCEP;
- public T visitIfExpression(IfExpression ifExpr, VAL value) throws EXCEP;
- public T visitSchemaPath(SchemaPath path, VAL value) throws EXCEP;
- public T visitLongConstant(LongExpression intExpr, VAL value) throws EXCEP;
- public T visitDoubleConstant(DoubleExpression dExpr, VAL value) throws EXCEP;
- public T visitBooleanConstant(BooleanExpression e, VAL value) throws EXCEP;
- public T visitQuotedStringConstant(QuotedString e, VAL value) throws EXCEP;
- public T visitUnknown(LogicalExpression e, VAL value) throws EXCEP;
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/OpVisitor.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/OpVisitor.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/OpVisitor.java
deleted file mode 100644
index 983a258..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/OpVisitor.java
+++ /dev/null
@@ -1,24 +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.drill.common.expression.visitors;
-
-import org.apache.drill.common.graph.GraphVisitor;
-import org.apache.drill.common.logical.data.LogicalOperator;
-
-public interface OpVisitor extends GraphVisitor<LogicalOperator> {
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/SimpleExprVisitor.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/SimpleExprVisitor.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/SimpleExprVisitor.java
deleted file mode 100644
index 434bdaf..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/expression/visitors/SimpleExprVisitor.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.apache.drill.common.expression.visitors;
-
-import org.apache.drill.common.expression.FunctionCall;
-import org.apache.drill.common.expression.IfExpression;
-import org.apache.drill.common.expression.SchemaPath;
-import org.apache.drill.common.expression.ValueExpressions.BooleanExpression;
-import org.apache.drill.common.expression.ValueExpressions.DoubleExpression;
-import org.apache.drill.common.expression.ValueExpressions.LongExpression;
-import org.apache.drill.common.expression.ValueExpressions.QuotedString;
-
-public abstract class SimpleExprVisitor<T> implements ExprVisitor<T, Void, RuntimeException>{
-
- @Override
- public T visitFunctionCall(FunctionCall call, Void value) throws RuntimeException {
- return visitFunctionCall(call);
- }
-
- @Override
- public T visitIfExpression(IfExpression ifExpr, Void value) throws RuntimeException {
- return visitIfExpression(ifExpr);
- }
-
- @Override
- public T visitSchemaPath(SchemaPath path, Void value) throws RuntimeException {
- return visitSchemaPath(path);
- }
-
- @Override
- public T visitLongConstant(LongExpression intExpr, Void value) throws RuntimeException {
- return visitLongConstant(intExpr);
- }
-
- @Override
- public T visitDoubleConstant(DoubleExpression dExpr, Void value) throws RuntimeException {
- return visitDoubleConstant(dExpr);
- }
-
- @Override
- public T visitBooleanConstant(BooleanExpression e, Void value) throws RuntimeException {
- return visitBooleanConstant(e);
- }
-
- @Override
- public T visitQuotedStringConstant(QuotedString e, Void value) throws RuntimeException {
- return visitQuotedStringConstant(e);
- }
-
-
- public abstract T visitFunctionCall(FunctionCall call);
- public abstract T visitIfExpression(IfExpression ifExpr);
- public abstract T visitSchemaPath(SchemaPath path);
- public abstract T visitLongConstant(LongExpression intExpr);
- public abstract T visitDoubleConstant(DoubleExpression dExpr);
- public abstract T visitBooleanConstant(BooleanExpression e);
- public abstract T visitQuotedStringConstant(QuotedString e);
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java
deleted file mode 100644
index f23eeca..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyList.java
+++ /dev/null
@@ -1,185 +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.drill.common.graph;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.ListMultimap;
-import com.google.common.collect.Multimaps;
-
-class AdjacencyList<V extends GraphValue<V>> {
- private Set<Node> allNodes = new HashSet<Node>();
- private ListMultimap<Node, Edge<Node>> adjacencies = ArrayListMultimap.create();
-
- void addEdge(Node source, Node target, int weight) {
- adjacencies.put(source, new Edge<Node>(source, target, weight));
- allNodes.add(source);
- allNodes.add(target);
- }
-
- void clearVisited() {
- for (Edge<Node> e : adjacencies.values()) {
- e.from.visited = false;
- e.to.visited = false;
- }
- }
-
- Node getNewNode(V value){
- return new Node(value);
- }
-
- public List<Edge<Node>> getAdjacent(AdjacencyList<V>.Node source) {
- return adjacencies.get(source);
- }
-
- public void printEdges() {
- for (Edge<Node> e : adjacencies.values()) {
- System.out.println(e.from.index + " -> " + e.to.index);
- }
- }
-
- public AdjacencyList<V> getReversedList() {
- AdjacencyList<V> newlist = new AdjacencyList<V>();
- for (Edge<Node> e : adjacencies.values()) {
- newlist.addEdge(e.to, e.from, e.weight);
- }
- return newlist;
- }
-
- public Set<Node> getNodeSet() {
- return adjacencies.keySet();
- }
-
-
- Collection<Node> getInternalLeafNodes() {
- // we have to use the allNodes list as otherwise destination only nodes won't be found.
- List<Node> nodes = new LinkedList<Node>(allNodes);
-
- for (Iterator<Node> i = nodes.iterator(); i.hasNext();) {
- final Node n = i.next();
-
- // remove any nodes that have one or more outbound edges.
- List<Edge<Node>> adjList = this.getAdjacent(n);
- if (adjList != null && !adjList.isEmpty()) i.remove();
-
- }
- return nodes;
- }
-
- /**
- * Get a list of nodes that have no outbound edges.
- *
- * @return
- */
- public Collection<V> getLeafNodes(){
- return convert(getInternalLeafNodes());
- }
-
-
- Collection<Node> getInternalRootNodes() {
- Set<Node> nodes = new HashSet<Node>(getNodeSet());
- for (Edge<Node> e : adjacencies.values()) {
- nodes.remove(e.to);
- }
- return nodes;
- }
-
- /**
- * Get a list of all nodes that have no incoming edges.
- *
- * @return
- */
- public List<V> getRootNodes(){
- return convert(getInternalRootNodes());
- }
-
- public Collection<Edge<Node>> getAllEdges() {
- return adjacencies.values();
- }
-
- public void fix(boolean requireDirected) {
- adjacencies = Multimaps.unmodifiableListMultimap(adjacencies);
- allNodes = Collections.unmodifiableSet(allNodes);
-
- if (requireDirected) {
- List<List<Node>> cyclicReferences = GraphAlgos.checkDirected(this);
- if (cyclicReferences.size() > 0) {
- throw new IllegalArgumentException(
- "A logical plan must be a valid DAG. You have cyclic references in your graph. " + cyclicReferences);
- }
- }
- }
-
- List<V> convert(Collection<Node> nodes) {
- List<V> out = new ArrayList<V>(nodes.size());
- for (Node o : nodes) {
- out.add(o.getNodeValue());
- }
- return out;
- }
-
- class Node implements Comparable<Node> {
- final V nodeValue;
- boolean visited = false; // used for Kosaraju's algorithm and Edmonds's
- // algorithm
- int lowlink = -1; // used for Tarjan's algorithm
- int index = -1; // used for Tarjan's algorithm
-
- public Node(final V operator) {
- if (operator == null) throw new IllegalArgumentException("Operator node was null.");
- this.nodeValue = operator;
- }
-
- public int compareTo(final Node argNode) {
- // just do an identity compare since elsewhere you should ensure that only one node exists for each nodeValue.
- return argNode == this ? 0 : -1;
- }
-
- @Override
- public int hashCode() {
- return nodeValue.hashCode();
- }
-
- public V getNodeValue() {
- return nodeValue;
- }
-
- @Override
- public String toString() {
- return "Node [val=" + nodeValue + "]";
- }
-
- }
-
- public static <V extends GraphValue<V>> AdjacencyList<V> newInstance(Collection<V> nodes){
- AdjacencyList<V> list = new AdjacencyList<V>();
- AdjacencyListBuilder<V> builder = new AdjacencyListBuilder<V>(list);
- for(V v : nodes){
- v.accept(builder);
- }
- return builder.getAdjacencyList();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java
deleted file mode 100644
index 4a385ce..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/AdjacencyListBuilder.java
+++ /dev/null
@@ -1,74 +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.drill.common.graph;
-
-import java.util.HashMap;
-import java.util.Map;
-
- class AdjacencyListBuilder<V extends GraphValue<V>> implements GraphVisitor<V> {
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(AdjacencyListBuilder.class);
-
- private Map<V, AdjacencyList<V>.Node> ops = new HashMap<V, AdjacencyList<V>.Node>();
- private final AdjacencyList<V> parent;
-
- public AdjacencyListBuilder(AdjacencyList<V> parent) {
- this.parent = parent;
- }
-
-
- protected boolean requireDirected() {
- return true;
- }
-
- public boolean enter(V o) {
- visit(o);
- return true;
- }
-
- @Override
- public void leave(V o) {
- }
-
- @Override
- public boolean visit(V o) {
- if (o == null) throw new IllegalArgumentException("Null operator.");
-
- if (!ops.containsKey(o)) {
- ops.put(o, parent.getNewNode(o));
- return true;
- }
-
- return true;
- }
-
- public AdjacencyList<V> getAdjacencyList() {
-// logger.debug("Values; {}", ops.values().toArray());
- AdjacencyList<V> a = new AdjacencyList<V>();
-
- for (AdjacencyList<V>.Node from : ops.values()) {
- for (V t : from.getNodeValue()) {
- AdjacencyList<V>.Node to = ops.get(t);
- a.addEdge(from, to, 0);
- }
-
- }
- a.fix(true);
- return a;
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Edge.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Edge.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Edge.java
deleted file mode 100644
index d444b9b..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Edge.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.drill.common.graph;
-
-
-class Edge<N> implements Comparable<Edge<N>> {
-
- final N from, to;
- final int weight;
-
- public Edge(final N argFrom, final N argTo, final int argWeight) {
- from = argFrom;
- to = argTo;
- weight = argWeight;
- }
-
- public int compareTo(final Edge<N> argEdge) {
- return weight - argEdge.weight;
- }
-
- @Override
- public String toString() {
- return "Edge [from=" + from + ", to=" + to + "]";
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Graph.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Graph.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Graph.java
deleted file mode 100644
index 295a81a..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Graph.java
+++ /dev/null
@@ -1,68 +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.drill.common.graph;
-
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.drill.common.logical.UnexpectedOperatorType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class Graph<G extends GraphValue<G>, R extends G, T extends G> {
-
- static final Logger logger = LoggerFactory.getLogger(Graph.class);
-
- private AdjacencyList<G> adjList;
- private final List<R> roots;
- private final List<T> leaves;
-
- public Graph(List<G> operators, Class<R> root, Class<T> leaf) {
- adjList = AdjacencyList.newInstance(operators);
- roots = checkOperatorType(adjList.getRootNodes(), root, String.format("Root nodes must be a subclass of %s.", root.getSimpleName()));
- leaves = checkOperatorType(adjList.getLeafNodes(), leaf, String.format("Leaf nodes must be a subclass of %s.", leaf.getSimpleName()));
- }
-
- @SuppressWarnings("unchecked")
- private <O extends G> List<O> checkOperatorType(Collection<G> ops, Class<O> classIdentifier, String error){
- for(G o : ops){
- if(!classIdentifier.isAssignableFrom(o.getClass())){
- throw new UnexpectedOperatorType(o, error);
- }
- }
- return (List<O>) ops;
- }
-
- public AdjacencyList<G> getAdjList() {
- return adjList;
- }
-
- public Collection<R> getRoots() {
- return roots;
- }
-
- public Collection<T> getLeaves() {
- return leaves;
- }
-
- public static <G extends GraphValue<G>, R extends G, T extends G> Graph<G, R, T> newGraph(List<G> operators, Class<R> root, Class<T> leaf){
- return new Graph<G, R, T>(operators, root, leaf);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java
deleted file mode 100644
index 692fd1b..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphAlgos.java
+++ /dev/null
@@ -1,155 +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.drill.common.graph;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GraphAlgos {
- static final Logger logger = LoggerFactory.getLogger(GraphAlgos.class);
-
- public static class TopoSorter<V extends GraphValue<V>> {
- final List<AdjacencyList<V>.Node> sorted = new LinkedList<AdjacencyList<V>.Node>();
- final AdjacencyList<V> rGraph;
-
- private TopoSorter(AdjacencyList<V> graph, boolean reverse) {
- graph.clearVisited();
-
- if (reverse){
- this.rGraph = graph.getReversedList();
- }
- else{
- this.rGraph = graph;
- }
- Collection<AdjacencyList<V>.Node> sourceNodes = rGraph.getInternalRootNodes();
-
- for (AdjacencyList<V>.Node n : sourceNodes) {
- visit(n);
- }
- }
-
- private void visit(AdjacencyList<V>.Node n) {
- if (n.visited) return;
-
- n.visited = true;
- List<Edge<AdjacencyList<V>.Node>> edges = rGraph.getAdjacent(n);
- if (edges != null) {
- for (Edge<AdjacencyList<V>.Node> e : edges) {
- visit(e.to);
- }
- }
-
- sorted.add(n);
-
- }
-
- /**
- * Execute a depth-first sort on the reversed DAG.
- *
- * @param graph
- * The adjacency list for the DAG.
- * @param sourceNodes
- * List of nodes that
- * @return
- */
- static <V extends GraphValue<V>> List<AdjacencyList<V>.Node> sortInternal(AdjacencyList<V> graph, boolean reverse) {
- TopoSorter<V> ts = new TopoSorter<V>(graph, reverse);
- return ts.sorted;
- }
-
- public static <V extends GraphValue<V>> List<V> sort(Graph<V, ?, ?> graph) {
- AdjacencyList<V> l = graph.getAdjList();
- return l.convert(sortInternal(l, true));
- }
-
- public static <V extends GraphValue<V>> List<V> sortLogical(Graph<V, ?, ?> graph) {
- AdjacencyList<V> l = graph.getAdjList();
- return l.convert(sortInternal(l, false));
- }
- }
-
- static <V extends GraphValue<V>> List<List<AdjacencyList<V>.Node>> checkDirected(AdjacencyList<V> graph) {
- Tarjan<V> t = new Tarjan<V>();
- List<List<AdjacencyList<V>.Node>> subgraphs = t.executeTarjan(graph);
- for (Iterator<List<AdjacencyList<V>.Node>> i = subgraphs.iterator(); i.hasNext();) {
- List<AdjacencyList<V>.Node> l = i.next();
- if (l.size() == 1) i.remove();
- }
- return subgraphs;
- }
-
- public static <V extends GraphValue<V>> List<List<AdjacencyList<V>.Node>> checkDirected(Graph<V, ?, ?> graph) {
- return checkDirected(graph.getAdjList());
- }
-
- public static class Tarjan<V extends GraphValue<V>> {
-
- private int index = 0;
- private List<AdjacencyList<V>.Node> stack = new LinkedList<AdjacencyList<V>.Node>();
- private List<List<AdjacencyList<V>.Node>> SCC = new LinkedList<List<AdjacencyList<V>.Node>>();
-
- public List<List<AdjacencyList<V>.Node>> executeTarjan(AdjacencyList<V> graph) {
- SCC.clear();
- index = 0;
- stack.clear();
- if (graph != null) {
- List<AdjacencyList<V>.Node> nodeList = new LinkedList<AdjacencyList<V>.Node>(graph.getNodeSet());
- for (AdjacencyList<V>.Node node : nodeList) {
- if (node.index == -1) {
- tarjan(node, graph);
- }
- }
- }
- return SCC;
- }
-
- private List<List<AdjacencyList<V>.Node>> tarjan(AdjacencyList<V>.Node v, AdjacencyList<V> list) {
- v.index = index;
- v.lowlink = index;
- index++;
- stack.add(0, v);
- List<Edge<AdjacencyList<V>.Node>> l = list.getAdjacent(v);
- if (l != null) {
- for (Edge<AdjacencyList<V>.Node> e : l) {
- AdjacencyList<V>.Node n = e.to;
- if (n.index == -1) {
- tarjan(n, list);
- v.lowlink = Math.min(v.lowlink, n.lowlink);
- } else if (stack.contains(n)) {
- v.lowlink = Math.min(v.lowlink, n.index);
- }
- }
- }
- if (v.lowlink == v.index) {
- AdjacencyList<V>.Node n;
- List<AdjacencyList<V>.Node> component = new LinkedList<AdjacencyList<V>.Node>();
- do {
- n = stack.remove(0);
- component.add(n);
- } while (n != v);
- SCC.add(component);
- }
- return SCC;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphValue.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphValue.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphValue.java
deleted file mode 100644
index b1eeede..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphValue.java
+++ /dev/null
@@ -1,26 +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.drill.common.graph;
-
-
-public interface GraphValue<T> extends Iterable<T>{
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(GraphValue.class);
-
- public void accept(GraphVisitor<T> visitor);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphVisitor.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphVisitor.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphVisitor.java
deleted file mode 100644
index 5ecdaea..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/GraphVisitor.java
+++ /dev/null
@@ -1,25 +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.drill.common.graph;
-
-
-public interface GraphVisitor<T> {
- public boolean enter(T o);
- public void leave(T o);
- public boolean visit(T o);
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Visitable.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Visitable.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Visitable.java
deleted file mode 100644
index 90ee1d1..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/graph/Visitable.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.drill.common.graph;
-
-public interface Visitable<T extends Visitable<?>> {
- public void accept(T node);
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java
deleted file mode 100644
index 6692661..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/LogicalPlan.java
+++ /dev/null
@@ -1,107 +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.drill.common.logical;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.drill.common.PlanProperties;
-import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.common.graph.Graph;
-import org.apache.drill.common.graph.GraphAlgos;
-import org.apache.drill.common.logical.data.LogicalOperator;
-import org.apache.drill.common.logical.data.SinkOperator;
-import org.apache.drill.common.logical.data.SourceOperator;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-@JsonPropertyOrder({ "head", "storage", "query" })
-public class LogicalPlan {
- static final Logger logger = LoggerFactory.getLogger(LogicalPlan.class);
-
- private final PlanProperties properties;
- private final Map<String, StorageEngineConfig> storageEngineMap;
- private final Graph<LogicalOperator, SinkOperator, SourceOperator> graph;
-
- @JsonCreator
- public LogicalPlan(@JsonProperty("head") PlanProperties head,
- @JsonProperty("storage") Map<String, StorageEngineConfig> storageEngineMap,
- @JsonProperty("query") List<LogicalOperator> operators) {
- this.storageEngineMap = storageEngineMap != null ? storageEngineMap : new HashMap<String, StorageEngineConfig>();
- this.properties = head;
- this.graph = Graph.newGraph(operators, SinkOperator.class, SourceOperator.class);
- }
-
- @JsonProperty("query")
- public List<LogicalOperator> getSortedOperators() {
- return GraphAlgos.TopoSorter.sortLogical(graph);
- }
-
- public StorageEngineConfig getStorageEngineConfig(String name) {
- return storageEngineMap.get(name);
- }
-
- @JsonIgnore
- public Graph<LogicalOperator, SinkOperator, SourceOperator> getGraph() {
- return graph;
- }
-
- @JsonProperty("head")
- public PlanProperties getProperties() {
- return properties;
- }
-
- @JsonProperty("storage")
- public Map<String, StorageEngineConfig> getStorageEngines() {
- return storageEngineMap;
- }
-
- public String toJsonString(DrillConfig config) throws JsonProcessingException {
- return config.getMapper().writeValueAsString(this);
- }
-
- /** Parses a logical plan. */
- public static LogicalPlan parse(DrillConfig config, String planString) {
- ObjectMapper mapper = config.getMapper();
- try {
- LogicalPlan plan = mapper.readValue(planString, LogicalPlan.class);
- return plan;
- } catch (IOException e) {
-
- throw new RuntimeException(String.format("Failure while parsing plan: \n %s}", planString), e);
- }
- }
-
- /** Converts a logical plan to a string. (Opposite of {@link #parse}.) */
- public String unparse(DrillConfig config) {
- try {
- return config.getMapper().writeValueAsString(this);
- } catch (JsonProcessingException e) {
- throw new RuntimeException(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfig.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfig.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfig.java
deleted file mode 100644
index b73a2c1..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfig.java
+++ /dev/null
@@ -1,28 +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.drill.common.logical;
-
-
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-
-
-@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property="type")
-public interface StorageEngineConfig{
-
- public boolean equals(Object o);
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfigBase.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfigBase.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfigBase.java
deleted file mode 100644
index 51dbef3..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/StorageEngineConfigBase.java
+++ /dev/null
@@ -1,41 +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.drill.common.logical;
-
-import java.util.List;
-
-import org.apache.drill.common.config.CommonConstants;
-import org.apache.drill.common.config.DrillConfig;
-import org.apache.drill.common.util.PathScanner;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public abstract class StorageEngineConfigBase implements StorageEngineConfig{
- static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StorageEngineConfigBase.class);
-
-
- public synchronized static Class<?>[] getSubTypes(DrillConfig config){
- List<String> packages = config.getStringList(CommonConstants.STORAGE_ENGINE_CONFIG_SCAN_PACKAGES);
- Class<?>[] sec = PathScanner.scanForImplementationsArr(StorageEngineConfig.class, packages);
- logger.debug("Adding Storage Engine Configs including {}", (Object) sec );
- return sec;
- }
-
- public abstract boolean equals(Object o);
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/UnexpectedOperatorType.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/UnexpectedOperatorType.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/UnexpectedOperatorType.java
deleted file mode 100644
index d515503..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/UnexpectedOperatorType.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.drill.common.logical;
-
-
-public class UnexpectedOperatorType extends ValidationError{
-
- public UnexpectedOperatorType(String message){
- super(message);
- }
-
- public UnexpectedOperatorType(Object operator, String message) {
- super(message + " Received node of type " + operator.getClass().getCanonicalName());
- }
-
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/ValidationError.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/ValidationError.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/ValidationError.java
deleted file mode 100644
index f5b7ad5..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/ValidationError.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.drill.common.logical;
-
-public class ValidationError extends RuntimeException{
-
- public ValidationError() {
- super();
- }
-
-
- public ValidationError(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
- super(message, cause, enableSuppression, writableStackTrace);
- }
-
- public ValidationError(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ValidationError(String message) {
- super(message);
- }
-
- public ValidationError(Throwable cause) {
- super(cause);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/CollapsingAggregate.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/CollapsingAggregate.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/CollapsingAggregate.java
deleted file mode 100644
index 49015ec..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/CollapsingAggregate.java
+++ /dev/null
@@ -1,73 +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.drill.common.logical.data;
-
-import com.google.common.collect.Iterators;
-import org.apache.drill.common.expression.FieldReference;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
-import java.util.List;
-
-@JsonTypeName("collapsingaggregate")
-public class CollapsingAggregate extends SingleInputOperator{
-
- private final FieldReference within;
- private final FieldReference target;
- private final FieldReference[] carryovers;
- private final NamedExpression[] aggregations;
-
- @JsonCreator
- public CollapsingAggregate(@JsonProperty("within") FieldReference within, @JsonProperty("target") FieldReference target, @JsonProperty("carryovers") FieldReference[] carryovers, @JsonProperty("aggregations") NamedExpression[] aggregations) {
- super();
- this.within = within;
- this.target = target;
- this.carryovers = carryovers;
- this.aggregations = aggregations;
- }
-
- public FieldReference getWithin() {
- return within;
- }
-
- public FieldReference getTarget() {
- return target;
- }
-
- public FieldReference[] getCarryovers() {
- return carryovers;
- }
-
- public NamedExpression[] getAggregations() {
- return aggregations;
- }
-
- @Override
- public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
- return logicalVisitor.visitCollapsingAggregate(this, value);
- }
-
- @Override
- public Iterator<LogicalOperator> iterator() {
- return Iterators.singletonIterator(getInput());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Constant.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Constant.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Constant.java
deleted file mode 100644
index 8a0024c..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Constant.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.drill.common.logical.data;
-
-import java.util.Iterator;
-
-import org.apache.drill.common.JSONOptions;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import com.google.common.base.Preconditions;
-
-@JsonTypeName("constant")
-public class Constant extends SourceOperator{
-
- private final JSONOptions content;
-
- @JsonCreator
- public Constant(@JsonProperty("content") JSONOptions content){
- super();
- this.content = content;
- Preconditions.checkNotNull(content, "content attribute is required for source operator 'constant'.");
- }
-
- public JSONOptions getContent() {
- return content;
- }
-
- @Override
- public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
- return logicalVisitor.visitConstant(this, value);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Filter.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Filter.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Filter.java
deleted file mode 100644
index e23f9ff..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Filter.java
+++ /dev/null
@@ -1,55 +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.drill.common.logical.data;
-
-import com.google.common.collect.Iterators;
-import org.apache.drill.common.expression.LogicalExpression;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
-
-@JsonTypeName("filter")
-public class Filter extends SingleInputOperator{
- private final LogicalExpression expr;
-
- @JsonCreator
- public Filter(@JsonProperty("expr") LogicalExpression expr) {
- this.expr = expr;
- }
-
- public LogicalExpression getExpr() {
- return expr;
- }
-
- @Override
- public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
- return logicalVisitor.visitFilter(this, value);
- }
-
- @Override
- public Iterator<LogicalOperator> iterator() {
- return Iterators.singletonIterator(getInput());
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Flatten.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Flatten.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Flatten.java
deleted file mode 100644
index 114ba0a..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Flatten.java
+++ /dev/null
@@ -1,69 +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.drill.common.logical.data;
-
-import com.google.common.collect.Iterators;
-import org.apache.drill.common.expression.FieldReference;
-import org.apache.drill.common.expression.LogicalExpression;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
-
-@JsonTypeName("flatten")
-public class Flatten extends SingleInputOperator{
- private final FieldReference name;
- private final LogicalExpression expr;
- private final boolean drop;
-
- @JsonCreator
- public Flatten(@JsonProperty("name") FieldReference name, @JsonProperty("expr") LogicalExpression expr, @JsonProperty("drop") boolean drop) {
- this.name = name;
- this.expr = expr;
- this.drop = drop;
- }
-
- public FieldReference getName() {
- return name;
- }
-
- public LogicalExpression getExpr() {
- return expr;
- }
-
- public boolean isDrop() {
- return drop;
- }
-
- @Override
- public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
- return logicalVisitor.visitFlatten(this, value);
- }
-
- @Override
- public Iterator<LogicalOperator> iterator() {
- return Iterators.singletonIterator(getInput());
- }
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
deleted file mode 100644
index f97dab1..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Join.java
+++ /dev/null
@@ -1,91 +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.drill.common.logical.data;
-
-import com.google.common.collect.Iterators;
-import org.apache.drill.common.exceptions.ExpressionParsingException;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
-
-@JsonTypeName("join")
-public class Join extends LogicalOperatorBase {
- private final LogicalOperator left;
- private final LogicalOperator right;
- private final JoinType type;
- private final JoinCondition[] conditions;
-
- public static enum JoinType{
- LEFT, INNER, OUTER, RIGHT;
-
- public static JoinType resolve(String val){
- for(JoinType jt : JoinType.values()){
- if(jt.name().equalsIgnoreCase(val)) return jt;
- }
- throw new ExpressionParsingException(String.format("Unable to determine join type for value '%s'.", val));
- }
- }
-
- @JsonCreator
- public Join(@JsonProperty("left") LogicalOperator left, @JsonProperty("right") LogicalOperator right, @JsonProperty("conditions") JoinCondition[] conditions, @JsonProperty("type") String type) {
- super();
- this.conditions = conditions;
- this.left = left;
- this.right = right;
- left.registerAsSubscriber(this);
- right.registerAsSubscriber(this);
- this.type = JoinType.resolve(type);
-
- }
-
- public LogicalOperator getLeft() {
- return left;
- }
-
- public LogicalOperator getRight() {
- return right;
- }
-
- public JoinCondition[] getConditions() {
- return conditions;
- }
-
- @JsonIgnore
- public JoinType getJointType(){
- return type;
- }
-
- public String getType(){
- return type.name();
- }
-
- @Override
- public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
- return logicalVisitor.visitJoin(this, value);
- }
-
- @Override
- public Iterator<LogicalOperator> iterator() {
- return Iterators.forArray(getLeft(), getRight());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
deleted file mode 100644
index 01c332b..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/JoinCondition.java
+++ /dev/null
@@ -1,55 +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.drill.common.logical.data;
-
-import org.apache.drill.common.expression.LogicalExpression;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-public class JoinCondition {
- private final String relationship;
- private final LogicalExpression left;
- private final LogicalExpression right;
-
- @JsonCreator
- public JoinCondition(@JsonProperty("relationship") String relationship,
- @JsonProperty("left") LogicalExpression left, @JsonProperty("right") LogicalExpression right) {
- super();
- this.relationship = relationship;
- this.left = left;
- this.right = right;
- }
-
- public String getRelationship() {
- return relationship;
- }
-
- public LogicalExpression getLeft() {
- return left;
- }
-
- public LogicalExpression getRight() {
- return right;
- }
-
- public JoinCondition flip(){
- return new JoinCondition(relationship, right, left);
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-drill/blob/a593d908/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Limit.java
----------------------------------------------------------------------
diff --git a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Limit.java b/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Limit.java
deleted file mode 100644
index 1774790..0000000
--- a/sandbox/prototype/common/src/main/java/org/apache/drill/common/logical/data/Limit.java
+++ /dev/null
@@ -1,60 +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.drill.common.logical.data;
-
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonTypeName;
-import com.google.common.collect.Iterators;
-import org.apache.drill.common.logical.data.visitors.LogicalVisitor;
-
-import java.util.Iterator;
-
-@JsonTypeName("limit")
-public class Limit extends SingleInputOperator{
-
- private final int first;
- private final int last;
-
- @JsonCreator
- public Limit(@JsonProperty("first") int first, @JsonProperty("last") int last) {
- super();
- this.first = first;
- this.last = last;
- }
-
- public int getFirst() {
- return first;
- }
-
- public int getLast() {
- return last;
- }
-
- @Override
- public <T, X, E extends Throwable> T accept(LogicalVisitor<T, X, E> logicalVisitor, X value) throws E {
- return logicalVisitor.visitLimit(this, value);
- }
-
- @Override
- public Iterator<LogicalOperator> iterator() {
- return Iterators.singletonIterator(getInput());
- }
-
-
-}