You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tajo.apache.org by hy...@apache.org on 2013/07/02 16:16:09 UTC
[15/51] [partial] TAJO-22: The package prefix should be
org.apache.tajo. (DaeMyung Kang via hyunsik)
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/PlanningContextImpl.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/PlanningContextImpl.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/PlanningContextImpl.java
deleted file mode 100644
index 494a28d..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/PlanningContextImpl.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 tajo.engine.planner;
-
-import org.antlr.runtime.tree.Tree;
-import tajo.engine.parser.ParseTree;
-
-public class PlanningContextImpl implements PlanningContext {
- private String rawQuery;
- // private TableMap tableMap = new TableMap();
- private ParseTree parseTree;
- private Tree ast;
- private String outputTableName;
-
- private static final String DEFAULT_TABLE_GEN_PREFIX = "table";
- private static final String DEFAULT_COLUMN_GEN_PREFIX = "column";
- private static final String SEPARATOR = "_";
-
- private int generatedTableId = 1;
- private int generatedColumnId = 1;
-
-
- public PlanningContextImpl(String rawQuery) {
- this.rawQuery = rawQuery;
- }
-
- @Override
- public String getRawQuery() {
- return rawQuery;
- }
-
- @Override
- public Tree getAST() {
- return ast;
- }
-
- public void setAST(Tree ast) {
- this.ast = ast;
- }
-
- @Override
- public ParseTree getParseTree() {
- return parseTree;
- }
-
-// @Override
-// public TableMap getTableMap() {
-// return tableMap;
-// }
-
- @Override
- public String getGeneratedColumnName() {
- return DEFAULT_COLUMN_GEN_PREFIX + SEPARATOR + (generatedColumnId++);
- }
-
- @Override
- public synchronized String getGeneratedColumnName(String prefix) {
- return prefix + SEPARATOR + (generatedColumnId++);
- }
-
- @Override
- public String getExplicitOutputTable() {
- return outputTableName;
- }
-
- @Override
- public boolean hasExplicitOutputTable() {
- return outputTableName != null;
- }
-
- public void setOutputTableName(String outputTableName) {
- this.outputTableName = outputTableName;
- }
-
- public void setParseTree(ParseTree parseTree) {
- this.parseTree = parseTree;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/Projector.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/Projector.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/Projector.java
deleted file mode 100644
index c49ef29..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/Projector.java
+++ /dev/null
@@ -1,114 +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 tajo.engine.planner;
-
-import tajo.catalog.Column;
-import tajo.catalog.Schema;
-import tajo.engine.eval.EvalContext;
-import tajo.engine.eval.EvalNode;
-import tajo.engine.parser.QueryBlock.Target;
-import tajo.storage.Tuple;
-
-public class Projector {
- private final Schema inSchema;
- private final Schema outSchema;
-
- // for projection
- private final int targetNum;
- private final int [] inMap;
- private final int [] outMap;
- private int [] evalOutMap; // target list?
- private EvalNode[] evals;
- private Tuple prevTuple;
-
- public Projector(Schema inSchema, Schema outSchema, Target [] targets) {
- this.inSchema = inSchema;
- this.outSchema = outSchema;
-
- this.targetNum = targets != null ? targets.length : 0;
-
- inMap = new int[outSchema.getColumnNum() - targetNum];
- outMap = new int[outSchema.getColumnNum() - targetNum];
- int mapId = 0;
- Column col;
-
- if (targetNum > 0) {
- evalOutMap = new int[targetNum];
- evals = new EvalNode[targetNum];
- for (int i = 0; i < targetNum; i++) {
- // TODO - is it always correct?
- if (targets[i].hasAlias()) {
- evalOutMap[i] = outSchema.getColumnId(targets[i].getAlias());
- } else {
- evalOutMap[i] = outSchema.getColumnId(targets[i].getEvalTree().getName());
- }
- evals[i] = targets[i].getEvalTree();
- }
-
- outer:
- for (int targetId = 0; targetId < outSchema.getColumnNum(); targetId ++) {
- for (int j = 0; j < evalOutMap.length; j++) {
- if (evalOutMap[j] == targetId)
- continue outer;
- }
-
- col = inSchema.getColumn(outSchema.getColumn(targetId).getQualifiedName());
- outMap[mapId] = targetId;
- inMap[mapId] = inSchema.getColumnId(col.getQualifiedName());
- mapId++;
- }
- } else {
- for (int targetId = 0; targetId < outSchema.getColumnNum(); targetId ++) {
- col = inSchema.getColumn(outSchema.getColumn(targetId).getQualifiedName());
- outMap[mapId] = targetId;
- inMap[mapId] = inSchema.getColumnId(col.getQualifiedName());
- mapId++;
- }
- }
- }
-
- public void eval(EvalContext[] evalContexts, Tuple in) {
- this.prevTuple = in;
- if (targetNum > 0) {
- for (int i = 0; i < evals.length; i++) {
- evals[i].eval(evalContexts[i], inSchema, in);
- }
- }
- }
-
- public void terminate(EvalContext [] evalContexts, Tuple out) {
- for (int i = 0; i < inMap.length; i++) {
- out.put(outMap[i], prevTuple.get(inMap[i]));
- }
- if (targetNum > 0) {
- for (int i = 0; i < evals.length; i++) {
- out.put(evalOutMap[i], evals[i].terminate(evalContexts[i]));
- }
- }
- }
-
- public EvalContext [] renew() {
- EvalContext [] evalContexts = new EvalContext[targetNum];
- for (int i = 0; i < targetNum; i++) {
- evalContexts[i] = evals[i].newContext();
- }
-
- return evalContexts;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangeOverflowException.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangeOverflowException.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangeOverflowException.java
deleted file mode 100644
index 1b67bbc..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangeOverflowException.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 tajo.engine.planner;
-
-import tajo.storage.Tuple;
-import tajo.storage.TupleRange;
-
-public class RangeOverflowException extends RuntimeException {
- public RangeOverflowException(TupleRange range, Tuple overflowValue, long inc) {
- super("Overflow Error: tried to increase " + inc + " to " + overflowValue + ", but the range " + range);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangePartitionAlgorithm.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangePartitionAlgorithm.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangePartitionAlgorithm.java
deleted file mode 100644
index 7d4ce4a..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/RangePartitionAlgorithm.java
+++ /dev/null
@@ -1,127 +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 tajo.engine.planner;
-
-import tajo.catalog.Column;
-import tajo.catalog.Schema;
-import tajo.common.TajoDataTypes.DataType;
-import tajo.datum.Datum;
-import tajo.storage.Tuple;
-import tajo.storage.TupleRange;
-
-import java.math.BigDecimal;
-
-public abstract class RangePartitionAlgorithm {
- protected Schema schema;
- protected TupleRange range;
- protected final BigDecimal totalCard;
- /** true if the end of the range is inclusive. Otherwise, it should be false. */
- protected final boolean inclusive;
-
- /**
- *
- * @param schema the schema of the range tuples
- * @param range range to be partition
- * @param inclusive true if the end of the range is inclusive. Otherwise, false.
- */
- public RangePartitionAlgorithm(Schema schema, TupleRange range, boolean inclusive) {
- this.schema = schema;
- this.range = range;
- this.inclusive = inclusive;
- this.totalCard = computeCardinalityForAllColumns(schema, range, inclusive);
- }
-
- /**
- * It computes the value cardinality of a tuple range.
- *
- * @param dataType
- * @param start
- * @param end
- * @return
- */
- public static BigDecimal computeCardinality(DataType dataType, Datum start, Datum end,
- boolean inclusive) {
- BigDecimal columnCard;
-
- switch (dataType.getType()) {
- case CHAR:
- columnCard = new BigDecimal(end.asChar() - start.asChar());
- break;
- case BIT:
- columnCard = new BigDecimal(end.asByte() - start.asByte());
- break;
- case INT2:
- columnCard = new BigDecimal(end.asInt2() - start.asInt2());
- break;
- case INT4:
- columnCard = new BigDecimal(end.asInt4() - start.asInt4());
- break;
- case INT8:
- columnCard = new BigDecimal(end.asInt8() - start.asInt8());
- break;
- case FLOAT4:
- columnCard = new BigDecimal(end.asInt4() - start.asInt4());
- break;
- case FLOAT8:
- columnCard = new BigDecimal(end.asInt8() - start.asInt8());
- break;
- case TEXT:
- columnCard = new BigDecimal(end.asChars().charAt(0) - start.asChars().charAt(0));
- break;
- default:
- throw new UnsupportedOperationException(dataType + " is not supported yet");
- }
-
- return inclusive ? columnCard.add(new BigDecimal(1)) : columnCard;
- }
-
- /**
- * It computes the value cardinality of a tuple range.
- * @return
- */
- public static BigDecimal computeCardinalityForAllColumns(Schema schema, TupleRange range, boolean inclusive) {
- Tuple start = range.getStart();
- Tuple end = range.getEnd();
- Column col;
-
- BigDecimal cardinality = new BigDecimal(1);
- BigDecimal columnCard;
- for (int i = 0; i < schema.getColumnNum(); i++) {
- col = schema.getColumn(i);
- columnCard = computeCardinality(col.getDataType(), start.get(i), end.get(i), inclusive);
-
- if (new BigDecimal(0).compareTo(columnCard) < 0) {
- cardinality = cardinality.multiply(columnCard);
- }
- }
-
- return cardinality;
- }
-
- public BigDecimal getTotalCardinality() {
- return totalCard;
- }
-
- /**
- *
- * @param partNum the number of desired partitions, but it may return the less partitions.
- * @return the end of intermediate ranges are exclusive, and the end of final range is inclusive.
- */
- public abstract TupleRange[] partition(int partNum);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/UniformRangePartition.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/UniformRangePartition.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/UniformRangePartition.java
deleted file mode 100644
index 87dac08..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/UniformRangePartition.java
+++ /dev/null
@@ -1,331 +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 tajo.engine.planner;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import tajo.catalog.Column;
-import tajo.catalog.Schema;
-import tajo.datum.Datum;
-import tajo.datum.DatumFactory;
-import tajo.storage.Tuple;
-import tajo.storage.TupleRange;
-import tajo.storage.VTuple;
-
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.util.List;
-
-public class UniformRangePartition extends RangePartitionAlgorithm {
- private int variableId;
- private BigDecimal[] cardForEachDigit;
- private BigDecimal[] colCards;
-
- /**
- *
- * @param schema
- * @param range
- * @param inclusive true if the end of the range is inclusive
- */
- public UniformRangePartition(Schema schema, TupleRange range, boolean inclusive) {
- super(schema, range, inclusive);
- colCards = new BigDecimal[schema.getColumnNum()];
- for (int i = 0; i < schema.getColumnNum(); i++) {
- colCards[i] = computeCardinality(schema.getColumn(i).getDataType(), range.getStart().get(i),
- range.getEnd().get(i), inclusive);
- }
-
- cardForEachDigit = new BigDecimal[colCards.length];
- for (int i = 0; i < colCards.length ; i++) {
- if (i == 0) {
- cardForEachDigit[i] = colCards[i];
- } else {
- cardForEachDigit[i] = cardForEachDigit[i - 1].multiply(colCards[i]);
- }
- }
- }
-
- public UniformRangePartition(Schema schema, TupleRange range) {
- this(schema, range, true);
- }
-
- @Override
- public TupleRange[] partition(int partNum) {
- Preconditions.checkArgument(partNum > 0,
- "The number of partitions must be positive, but the given number: "
- + partNum);
- Preconditions.checkArgument(totalCard.compareTo(new BigDecimal(partNum)) >= 0,
- "the number of partition cannot exceed total cardinality (" + totalCard + ")");
-
- int varId;
- for (varId = 0; varId < cardForEachDigit.length; varId++) {
- if (cardForEachDigit[varId].compareTo(new BigDecimal(partNum)) >= 0)
- break;
- }
- this.variableId = varId;
-
- BigDecimal [] reverseCardsForDigit = new BigDecimal[variableId+1];
- for (int i = variableId; i >= 0; i--) {
- if (i == variableId) {
- reverseCardsForDigit[i] = colCards[i];
- } else {
- reverseCardsForDigit[i] = reverseCardsForDigit[i+1].multiply(colCards[i]);
- }
- }
-
- List<TupleRange> ranges = Lists.newArrayList();
- BigDecimal term = reverseCardsForDigit[0].divide(
- new BigDecimal(partNum), RoundingMode.CEILING);
- BigDecimal reminder = reverseCardsForDigit[0];
- Tuple last = range.getStart();
- while(reminder.compareTo(new BigDecimal(0)) > 0) {
- if (reminder.compareTo(term) <= 0) { // final one is inclusive
- ranges.add(new TupleRange(schema, last, range.getEnd()));
- } else {
- Tuple next = increment(last, term.longValue(), variableId);
- ranges.add(new TupleRange(schema, last, next));
- }
- last = ranges.get(ranges.size() - 1).getEnd();
- reminder = reminder.subtract(term);
- }
-
- return ranges.toArray(new TupleRange[ranges.size()]);
- }
-
- public boolean isOverflow(int colId, Datum last, BigDecimal inc) {
- Column column = schema.getColumn(colId);
- BigDecimal candidate;
- boolean overflow = false;
- switch (column.getDataType().getType()) {
- case BIT: {
- candidate = inc.add(new BigDecimal(last.asByte()));
- return new BigDecimal(range.getEnd().get(colId).asByte()).compareTo(candidate) < 0;
- }
- case CHAR: {
- candidate = inc.add(new BigDecimal((int)last.asChar()));
- return new BigDecimal((int)range.getEnd().get(colId).asChar()).compareTo(candidate) < 0;
- }
- case INT2: {
- candidate = inc.add(new BigDecimal(last.asInt2()));
- return new BigDecimal(range.getEnd().get(colId).asInt2()).compareTo(candidate) < 0;
- }
- case INT4: {
- candidate = inc.add(new BigDecimal(last.asInt4()));
- return new BigDecimal(range.getEnd().get(colId).asInt4()).compareTo(candidate) < 0;
- }
- case INT8: {
- candidate = inc.add(new BigDecimal(last.asInt8()));
- return new BigDecimal(range.getEnd().get(colId).asInt8()).compareTo(candidate) < 0;
- }
- case FLOAT4: {
- candidate = inc.add(new BigDecimal(last.asFloat4()));
- return new BigDecimal(range.getEnd().get(colId).asFloat4()).compareTo(candidate) < 0;
- }
- case FLOAT8: {
- candidate = inc.add(new BigDecimal(last.asFloat8()));
- return new BigDecimal(range.getEnd().get(colId).asFloat8()).compareTo(candidate) < 0;
- }
- case TEXT: {
- candidate = inc.add(new BigDecimal((int)(last.asChars().charAt(0))));
- return new BigDecimal(range.getEnd().get(colId).asChars().charAt(0)).compareTo(candidate) < 0;
- }
- }
- return overflow;
- }
-
- public long incrementAndGetReminder(int colId, Datum last, long inc) {
- Column column = schema.getColumn(colId);
- long reminder = 0;
- switch (column.getDataType().getType()) {
- case BIT: {
- long candidate = last.asByte() + inc;
- byte end = range.getEnd().get(colId).asByte();
- reminder = candidate - end;
- break;
- }
- case CHAR: {
- long candidate = last.asChar() + inc;
- char end = range.getEnd().get(colId).asChar();
- reminder = candidate - end;
- break;
- }
- case INT4: {
- int candidate = (int) (last.asInt4() + inc);
- int end = range.getEnd().get(colId).asInt4();
- reminder = candidate - end;
- break;
- }
- case INT8: {
- long candidate = last.asInt8() + inc;
- long end = range.getEnd().get(colId).asInt8();
- reminder = candidate - end;
- break;
- }
- case FLOAT4: {
- float candidate = last.asFloat4() + inc;
- float end = range.getEnd().get(colId).asFloat4();
- reminder = (long) (candidate - end);
- break;
- }
- case FLOAT8: {
- double candidate = last.asFloat8() + inc;
- double end = range.getEnd().get(colId).asFloat8();
- reminder = (long) Math.ceil(candidate - end);
- break;
- }
- case TEXT: {
- char candidate = ((char)(last.asChars().charAt(0) + inc));
- char end = range.getEnd().get(colId).asChars().charAt(0);
- reminder = (char) (candidate - end);
- break;
- }
- }
-
- // including zero
- return reminder - 1;
- }
-
- /**
- *
- * @param last
- * @param inc
- * @return
- */
- public Tuple increment(final Tuple last, final long inc, final int baseDigit) {
- BigDecimal [] incs = new BigDecimal[last.size()];
- boolean [] overflowFlag = new boolean[last.size()];
- BigDecimal [] result;
- BigDecimal value = new BigDecimal(inc);
-
- BigDecimal [] reverseCardsForDigit = new BigDecimal[baseDigit + 1];
- for (int i = baseDigit; i >= 0; i--) {
- if (i == baseDigit) {
- reverseCardsForDigit[i] = colCards[i];
- } else {
- reverseCardsForDigit[i] = reverseCardsForDigit[i+1].multiply(colCards[i]);
- }
- }
-
- for (int i = 0; i < baseDigit; i++) {
- result = value.divideAndRemainder(reverseCardsForDigit[i + 1]);
- incs[i] = result[0];
- value = result[1];
- }
- int finalId = baseDigit;
- incs[finalId] = value;
- for (int i = finalId; i >= 0; i--) {
- if (isOverflow(i, last.get(i), incs[i])) {
- if (i == 0) {
- throw new RangeOverflowException(range, last, incs[i].longValue());
- }
- long rem = incrementAndGetReminder(i, last.get(i), value.longValue());
- incs[i] = new BigDecimal(rem);
- incs[i - 1] = incs[i-1].add(new BigDecimal(1));
- overflowFlag[i] = true;
- } else {
- if (i > 0) {
- incs[i] = value;
- break;
- }
- }
- }
-
- for (int i = 0; i < incs.length; i++) {
- if (incs[i] == null) {
- incs[i] = new BigDecimal(0);
- }
- }
-
- Tuple end = new VTuple(schema.getColumnNum());
- Column column;
- for (int i = 0; i < last.size(); i++) {
- column = schema.getColumn(i);
- switch (column.getDataType().getType()) {
- case CHAR:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createChar((char) (range.getStart().get(i).asChar() + incs[i].longValue())));
- } else {
- end.put(i, DatumFactory.createChar((char) (last.get(i).asChar() + incs[i].longValue())));
- }
- break;
- case BIT:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createBit(
- (byte) (range.getStart().get(i).asByte() + incs[i].longValue())));
- } else {
- end.put(i, DatumFactory.createBit((byte) (last.get(i).asByte() + incs[i].longValue())));
- }
- break;
- case INT2:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createInt2(
- (short) (range.getStart().get(i).asInt2() + incs[i].longValue())));
- } else {
- end.put(i, DatumFactory.createInt2((short) (last.get(i).asInt2() + incs[i].longValue())));
- }
- break;
- case INT4:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createInt4(
- (int) (range.getStart().get(i).asInt4() + incs[i].longValue())));
- } else {
- end.put(i, DatumFactory.createInt4((int) (last.get(i).asInt4() + incs[i].longValue())));
- }
- break;
- case INT8:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createInt8(
- range.getStart().get(i).asInt4() + incs[i].longValue()));
- } else {
- end.put(i, DatumFactory.createInt8(last.get(i).asInt8() + incs[i].longValue()));
- }
- break;
- case FLOAT4:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createFloat4(
- range.getStart().get(i).asFloat4() + incs[i].longValue()));
- } else {
- end.put(i, DatumFactory.createFloat4(last.get(i).asFloat4() + incs[i].longValue()));
- }
- break;
- case FLOAT8:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createFloat8(
- range.getStart().get(i).asFloat8() + incs[i].longValue()));
- } else {
- end.put(i, DatumFactory.createFloat8(last.get(i).asFloat8() + incs[i].longValue()));
- }
- break;
- case TEXT:
- if (overflowFlag[i]) {
- end.put(i, DatumFactory.createText(((char) (range.getStart().get(i).asChars().charAt(0)
- + incs[i].longValue())) + ""));
- } else {
- end.put(i, DatumFactory.createText(
- ((char) (last.get(i).asChars().charAt(0) + incs[i].longValue())) + ""));
- }
- break;
- default:
- throw new UnsupportedOperationException(column.getDataType() + " is not supported yet");
- }
- }
-
- return end;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/GlobalOptimizer.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/GlobalOptimizer.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/GlobalOptimizer.java
deleted file mode 100644
index 4c50669..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/GlobalOptimizer.java
+++ /dev/null
@@ -1,80 +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 tajo.engine.planner.global;
-
-import com.google.common.annotations.VisibleForTesting;
-import tajo.engine.planner.PlannerUtil;
-import tajo.engine.planner.logical.ExprType;
-import tajo.engine.planner.logical.LogicalNode;
-import tajo.engine.planner.logical.ScanNode;
-import tajo.engine.planner.logical.UnaryNode;
-import tajo.master.ExecutionBlock;
-import tajo.master.ExecutionBlock.PartitionType;
-
-public class GlobalOptimizer {
-
- public GlobalOptimizer() {
-
- }
-
- public MasterPlan optimize(MasterPlan plan) {
- ExecutionBlock reducedStep = reduceSchedules(plan.getRoot());
-
- MasterPlan optimized = new MasterPlan(reducedStep);
- optimized.setOutputTableName(plan.getOutputTable());
-
- return optimized;
- }
-
- @VisibleForTesting
- private ExecutionBlock reduceSchedules(ExecutionBlock logicalUnit) {
- reduceLogicalQueryUnitStep_(logicalUnit);
- return logicalUnit;
- }
-
- private void reduceLogicalQueryUnitStep_(ExecutionBlock cur) {
- if (cur.hasChildBlock()) {
- for (ExecutionBlock childBlock: cur.getChildBlocks())
- reduceLogicalQueryUnitStep_(childBlock);
- }
-
- for (ExecutionBlock childBlock: cur.getChildBlocks()) {
- if (childBlock.getStoreTableNode().getSubNode().getType() != ExprType.UNION &&
- childBlock.getPartitionType() == PartitionType.LIST) {
- mergeLogicalUnits(cur, childBlock);
- }
- }
- }
-
- private ExecutionBlock mergeLogicalUnits(ExecutionBlock parent, ExecutionBlock child) {
- LogicalNode p = PlannerUtil.findTopParentNode(parent.getPlan(), ExprType.SCAN);
-
- if (p instanceof UnaryNode) {
- UnaryNode u = (UnaryNode) p;
- ScanNode scan = (ScanNode) u.getSubNode();
- LogicalNode c = child.getStoreTableNode().getSubNode();
-
- parent.removeChildBlock(scan);
- u.setSubNode(c);
- parent.setPlan(parent.getPlan());
- parent.addChildBlocks(child.getChildBlockMap());
- }
- return parent;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/MasterPlan.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/MasterPlan.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/MasterPlan.java
deleted file mode 100644
index 5ae4faf..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/global/MasterPlan.java
+++ /dev/null
@@ -1,49 +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 tajo.engine.planner.global;
-
-import tajo.master.ExecutionBlock;
-
-public class MasterPlan {
- private ExecutionBlock root;
- private String outputTableName;
-
- public MasterPlan(ExecutionBlock root) {
- setRoot(root);
- }
-
- public void setRoot(ExecutionBlock root) {
- this.root = root;
- }
-
- public ExecutionBlock getRoot() {
- return this.root;
- }
-
- public void setOutputTableName(String tableName) {
- this.outputTableName = tableName;
- }
-
- public String getOutputTable() {
- return outputTableName;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/BinaryNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/BinaryNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/BinaryNode.java
deleted file mode 100644
index b53259b..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/BinaryNode.java
+++ /dev/null
@@ -1,86 +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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import tajo.engine.json.GsonCreator;
-
-public abstract class BinaryNode extends LogicalNode implements Cloneable {
- @Expose
- LogicalNode outer = null;
- @Expose
- LogicalNode inner = null;
-
- public BinaryNode() {
- super();
- }
-
- /**
- * @param opType
- */
- public BinaryNode(ExprType opType) {
- super(opType);
- }
-
- public LogicalNode getOuterNode() {
- return this.outer;
- }
-
- public void setOuter(LogicalNode op) {
- this.outer = op;
- }
-
- public LogicalNode getInnerNode() {
- return this.inner;
- }
-
- public void setInner(LogicalNode op) {
- this.inner = op;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- BinaryNode binNode = (BinaryNode) super.clone();
- binNode.outer = (LogicalNode) outer.clone();
- binNode.inner = (LogicalNode) inner.clone();
-
- return binNode;
- }
-
- public void preOrder(LogicalNodeVisitor visitor) {
- visitor.visit(this);
- outer.postOrder(visitor);
- inner.postOrder(visitor);
- }
-
- public void postOrder(LogicalNodeVisitor visitor) {
- outer.postOrder(visitor);
- inner.postOrder(visitor);
- visitor.visit(this);
- }
-
- public String toJSON() {
- outer.toJSON();
- inner.toJSON();
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/CreateTableNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/CreateTableNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/CreateTableNode.java
deleted file mode 100644
index b95db6b..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/CreateTableNode.java
+++ /dev/null
@@ -1,148 +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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import org.apache.hadoop.fs.Path;
-import tajo.catalog.Column;
-import tajo.catalog.Options;
-import tajo.catalog.Schema;
-import tajo.catalog.proto.CatalogProtos.StoreType;
-import tajo.engine.json.GsonCreator;
-import tajo.util.TUtil;
-
-public class CreateTableNode extends LogicalNode implements Cloneable {
- @Expose private String tableName;
- @Expose private Column[] partitionKeys;
- @Expose private StoreType storageType;
- @Expose private Schema schema;
- @Expose private Path path;
- @Expose private Options options;
-
- public CreateTableNode(String tableName, Schema schema) {
- super(ExprType.CREATE_TABLE);
- this.tableName = tableName;
- this.schema = schema;
- }
-
- public final String getTableName() {
- return this.tableName;
- }
-
- public Schema getSchema() {
- return this.schema;
- }
-
- public void setStorageType(StoreType storageType) {
- this.storageType = storageType;
- }
-
- public StoreType getStorageType() {
- return this.storageType;
- }
-
- public boolean hasPath() {
- return this.path != null;
- }
-
- public void setPath(Path path) {
- this.path = path;
- }
-
- public Path getPath() {
- return this.path;
- }
-
- public boolean hasOptions() {
- return this.options != null;
- }
-
- public void setOptions(Options opt) {
- this.options = opt;
- }
-
- public Options getOptions() {
- return this.options;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof CreateTableNode) {
- CreateTableNode other = (CreateTableNode) obj;
- return super.equals(other)
- && this.tableName.equals(other.tableName)
- && this.schema.equals(other.schema)
- && this.storageType == other.storageType
- && this.path.equals(other.path)
- && TUtil.checkEquals(options, other.options)
- && TUtil.checkEquals(partitionKeys, other.partitionKeys);
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- CreateTableNode store = (CreateTableNode) super.clone();
- store.tableName = tableName;
- store.schema = (Schema) schema.clone();
- store.storageType = storageType;
- store.path = new Path(path.toString());
- store.partitionKeys = partitionKeys != null ? partitionKeys.clone() : null;
- store.options = (Options) (options != null ? options.clone() : null);
- return store;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("\"Store\": {\"table\": \""+tableName+"\",");
- if (partitionKeys != null) {
- sb.append("\"partition keys: [");
- for (int i = 0; i < partitionKeys.length; i++) {
- sb.append(partitionKeys[i]);
- if (i < partitionKeys.length - 1)
- sb.append(",");
- }
- sb.append("],");
- }
- sb.append("\"schema: \"{" + this.schema).append("}");
- sb.append(",\"storeType\": \"" + this.storageType);
- sb.append(",\"path\" : \"" + this.path).append("\",");
-
- sb.append("\n \"out schema\": ").append(getOutSchema()).append(",")
- .append("\n \"in schema\": ").append(getInSchema())
- .append("}");
-
- return sb.toString();
- }
-
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-
- @Override
- public void preOrder(LogicalNodeVisitor visitor) {
- visitor.visit(this);
- }
-
- @Override
- public void postOrder(LogicalNodeVisitor visitor) {
- visitor.visit(this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/EvalExprNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/EvalExprNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/EvalExprNode.java
deleted file mode 100644
index 6934eaa..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/EvalExprNode.java
+++ /dev/null
@@ -1,75 +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 tajo.engine.planner.logical;
-
-import com.google.gson.Gson;
-import com.google.gson.annotations.Expose;
-import tajo.engine.json.GsonCreator;
-import tajo.engine.parser.QueryBlock;
-
-public class EvalExprNode extends LogicalNode {
- @Expose private QueryBlock.Target[] exprs;
-
- public EvalExprNode(QueryBlock.Target[] exprs) {
- super(ExprType.EXPRS);
- this.exprs = exprs;
- }
-
- @Override
- public String toJSON() {
- Gson gson = GsonCreator.getInstance();
- return gson.toJson(this);
- }
-
- public QueryBlock.Target[] getExprs() {
- return this.exprs;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("\"EvalExpr\": {");
- sb.append("\"targets\": [");
-
- for (int i = 0; i < exprs.length; i++) {
- sb.append("\"").append(exprs[i]).append("\"");
- if( i < exprs.length - 1) {
- sb.append(",");
- }
- }
- sb.append("],");
- sb.append("\n \"out schema\": ").append(getOutSchema()).append(",");
- sb.append("\n \"in schema\": ").append(getInSchema());
- sb.append("}");
- return sb.toString();
- }
-
- @Override
- public void preOrder(LogicalNodeVisitor visitor) {
- // nothing
- }
-
- @Override
- public void postOrder(LogicalNodeVisitor visitor) {
- // nothing
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExceptNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExceptNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExceptNode.java
deleted file mode 100644
index 71d51e0..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExceptNode.java
+++ /dev/null
@@ -1,46 +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 tajo.engine.planner.logical;
-
-import tajo.engine.json.GsonCreator;
-
-public class ExceptNode extends BinaryNode {
-
- public ExceptNode() {
- super(ExprType.EXCEPT);
- }
-
- public ExceptNode(LogicalNode outer, LogicalNode inner) {
- this();
- setOuter(outer);
- setInner(inner);
- }
-
- public String toString() {
- return getOuterNode().toString() + "\n EXCEPT \n" + getInnerNode().toString();
- }
-
- @Override
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExprType.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExprType.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExprType.java
deleted file mode 100644
index 7caae3f..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ExprType.java
+++ /dev/null
@@ -1,51 +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 tajo.engine.planner.logical;
-
-public enum ExprType {
- BST_INDEX_SCAN,
- CREATE_INDEX,
- CREATE_TABLE,
- DESC_TABLE,
- EXCEPT,
- EXPRS,
- GROUP_BY,
- INSERT_INTO,
- INTERSECT,
- LIMIT,
- JOIN,
- PROJECTION,
- RECEIVE,
- RENAME,
- ROOT,
- SCAN,
- SELECTION,
- SEND,
- SET_DIFF,
- SET_UNION,
- SET_INTERSECT,
- SHOW_TABLE,
- SHOW_FUNCTION,
- SORT,
- STORE,
- UNION
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/GroupbyNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/GroupbyNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/GroupbyNode.java
deleted file mode 100644
index d037e3d..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/GroupbyNode.java
+++ /dev/null
@@ -1,152 +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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import tajo.catalog.Column;
-import tajo.engine.eval.EvalNode;
-import tajo.engine.json.GsonCreator;
-import tajo.engine.parser.QueryBlock;
-import tajo.util.TUtil;
-
-import java.util.Arrays;
-
-public class GroupbyNode extends UnaryNode implements Cloneable {
- @Expose
- private Column[] columns;
- @Expose
- private EvalNode havingCondition = null;
- @Expose
- private QueryBlock.Target[] targets;
-
- public GroupbyNode() {
- super();
- }
-
- public GroupbyNode(final Column [] columns) {
- super(ExprType.GROUP_BY);
- this.columns = columns;
- }
-
- public GroupbyNode(final Column [] columns,
- final EvalNode havingCondition) {
- this(columns);
- this.havingCondition = havingCondition;
- }
-
- public final Column [] getGroupingColumns() {
- return this.columns;
- }
-
- public final boolean hasHavingCondition() {
- return this.havingCondition != null;
- }
-
- public final EvalNode getHavingCondition() {
- return this.havingCondition;
- }
-
- public final void setHavingCondition(final EvalNode evalTree) {
- this.havingCondition = evalTree;
- }
-
- public boolean hasTargetList() {
- return this.targets != null;
- }
-
- public QueryBlock.Target[] getTargets() {
- return this.targets;
- }
-
- public void setTargetList(QueryBlock.Target[] targets) {
- this.targets = targets;
- }
-
- public void setSubNode(LogicalNode subNode) {
- super.setSubNode(subNode);
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder("\"GroupBy\": {\"fields\":[");
- for (int i=0; i < columns.length; i++) {
- sb.append("\"").append(columns[i]).append("\"");
- if(i < columns.length - 1)
- sb.append(",");
- }
-
- if(hasHavingCondition()) {
- sb.append("], \"having qual\": \""+havingCondition+"\"");
- }
- if(hasTargetList()) {
- sb.append(", \"target\": [");
- for (int i = 0; i < targets.length; i++) {
- sb.append("\"").append(targets[i]).append("\"");
- if( i < targets.length - 1) {
- sb.append(",");
- }
- }
- sb.append("],");
- }
- sb.append("\n \"out schema\": ").append(getOutSchema()).append(",");
- sb.append("\n \"in schema\": ").append(getInSchema());
- sb.append("}");
-
- return sb.toString() + "\n"
- + getSubNode().toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof GroupbyNode) {
- GroupbyNode other = (GroupbyNode) obj;
- return super.equals(other)
- && Arrays.equals(columns, other.columns)
- && TUtil.checkEquals(havingCondition, other.havingCondition)
- && TUtil.checkEquals(targets, other.targets)
- && getSubNode().equals(other.getSubNode());
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- GroupbyNode grp = (GroupbyNode) super.clone();
- if (columns != null) {
- grp.columns = new Column[columns.length];
- for (int i = 0; i < columns.length; i++) {
- grp.columns[i] = (Column) columns[i].clone();
- }
- }
- grp.havingCondition = (EvalNode) (havingCondition != null
- ? havingCondition.clone() : null);
- if (targets != null) {
- grp.targets = new QueryBlock.Target[targets.length];
- for (int i = 0; i < targets.length; i++) {
- grp.targets[i] = (QueryBlock.Target) targets[i].clone();
- }
- }
-
- return grp;
- }
-
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexScanNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexScanNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexScanNode.java
deleted file mode 100644
index 899d4e3..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexScanNode.java
+++ /dev/null
@@ -1,131 +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 tajo.engine.planner.logical;
-
-import com.google.gson.Gson;
-import com.google.gson.annotations.Expose;
-import tajo.catalog.Schema;
-import tajo.catalog.SortSpec;
-import tajo.datum.Datum;
-import tajo.engine.json.GsonCreator;
-
-public class IndexScanNode extends ScanNode {
-
- @Expose private SortSpec[]sortKeys;
- @Expose private Schema keySchema = null;
- @Expose private Datum[] datum = null;
- //TODO- @Expose private IndexType type;
-
- public IndexScanNode(ScanNode scanNode ,
- Schema keySchema , Datum[] datum, SortSpec[] sortKeys ) {
- super();
- setQual(scanNode.getQual());
- setFromTable(scanNode.getFromTable());
- setInSchema(scanNode.getInSchema());
- setOutSchema(scanNode.getOutSchema());
- setLocal(scanNode.isLocal());
- setTargets(scanNode.getTargets());
- setType(ExprType.BST_INDEX_SCAN);
- this.sortKeys = sortKeys;
- this.keySchema = keySchema;
- this.datum = datum;
- }
-
- public SortSpec[] getSortKeys() {
- return this.sortKeys;
- }
-
- public Schema getKeySchema() {
- return this.keySchema;
- }
-
- public Datum[] getDatum() {
- return this.datum;
- }
-
- public void setSortKeys(SortSpec[] sortKeys) {
- this.sortKeys = sortKeys;
- }
-
- public void setKeySchema( Schema keySchema ) {
- this.keySchema = keySchema;
- }
-
- @Override
- public String toJSON() {
- GsonCreator.getInstance().toJson(this, LogicalNode.class);
- return null;
- }
- @Override
- public String toString() {
- Gson gson = GsonCreator.getInstance();
- StringBuilder builder = new StringBuilder();
- builder.append("IndexScanNode : {\n");
- builder.append(" \"keySchema\" : \"" + gson.toJson(this.keySchema) + "\"\n");
- builder.append(" \"sortKeys\" : \"" + gson.toJson(this.sortKeys) + " \"\n");
- builder.append(" \"datums\" : \"" + gson.toJson(this.datum) + "\"\n");
- builder.append(" <<\"superClass\" : " + super.toString());
- builder.append(">>}");
- builder.append("}");
- return builder.toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof IndexScanNode) {
- IndexScanNode other = (IndexScanNode) obj;
-
- boolean eq = super.equals(other);
- eq = eq && this.sortKeys.length == other.sortKeys.length;
- if(eq) {
- for(int i = 0 ; i < this.sortKeys.length ; i ++) {
- eq = eq && this.sortKeys[i].getSortKey().equals(
- other.sortKeys[i].getSortKey());
- eq = eq && this.sortKeys[i].isAscending()
- == other.sortKeys[i].isAscending();
- eq = eq && this.sortKeys[i].isNullFirst()
- == other.sortKeys[i].isNullFirst();
- }
- }
- if(eq) {
- for(int i = 0 ; i < this.datum.length ; i ++ ) {
- eq = eq && this.datum[i].equals(other.datum[i]);
- }
- }
- return eq;
- }
- return false;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- IndexScanNode indexNode = (IndexScanNode) super.clone();
- indexNode.keySchema = (Schema) this.keySchema.clone();
- indexNode.sortKeys = new SortSpec[this.sortKeys.length];
- for(int i = 0 ; i < sortKeys.length ; i ++ )
- indexNode.sortKeys[i] = (SortSpec) this.sortKeys[i].clone();
- indexNode.datum = new Datum[this.datum.length];
- for(int i = 0 ; i < datum.length ; i ++ ) {
- indexNode.datum[i] = this.datum[i];
- }
- return indexNode;
- }
-}
-
-
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexWriteNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexWriteNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexWriteNode.java
deleted file mode 100644
index d049789..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IndexWriteNode.java
+++ /dev/null
@@ -1,95 +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 tajo.engine.planner.logical;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.annotations.Expose;
-import tajo.catalog.Options;
-import tajo.catalog.SortSpec;
-import tajo.catalog.proto.CatalogProtos.IndexMethod;
-import tajo.engine.json.GsonCreator;
-import tajo.engine.parser.CreateIndexStmt;
-
-public class IndexWriteNode extends UnaryNode {
- @Expose private String indexName;
- @Expose private boolean unique = false;
- @Expose private String tableName;
- @Expose private IndexMethod method = IndexMethod.TWO_LEVEL_BIN_TREE;
- @Expose private SortSpec[] sortSpecs;
- @Expose private Options params = null;
-
- public IndexWriteNode(CreateIndexStmt stmt) {
- super(ExprType.CREATE_INDEX);
- this.indexName = stmt.getIndexName();
- this.unique = stmt.isUnique();
- this.tableName = stmt.getTableName();
- this.method = stmt.getMethod();
- this.sortSpecs = stmt.getSortSpecs();
- this.params = stmt.hasParams() ? stmt.getParams() : null;
- }
-
- public String getIndexName() {
- return this.indexName;
- }
-
- public boolean isUnique() {
- return this.unique;
- }
-
- public void setUnique() {
- this.unique = true;
- }
-
- public String getTableName() {
- return this.tableName;
- }
-
- public IndexMethod getMethod() {
- return this.method;
- }
-
- public SortSpec[] getSortSpecs() {
- return this.sortSpecs;
- }
-
- public boolean hasParams() {
- return this.params != null;
- }
-
- public Options getParams() {
- return this.params;
- }
-
- public String toJSON() {
- for( int i = 0 ; i < this.sortSpecs.length ; i ++ ) {
- sortSpecs[i].getSortKey().initFromProto();
- }
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-
- @Override
- public String toString() {
- Gson gson = new GsonBuilder().setPrettyPrinting().create();
- return gson.toJson(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IntersectNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IntersectNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IntersectNode.java
deleted file mode 100644
index a3f1a7c..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/IntersectNode.java
+++ /dev/null
@@ -1,46 +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 tajo.engine.planner.logical;
-
-import tajo.engine.json.GsonCreator;
-
-public class IntersectNode extends BinaryNode {
-
- public IntersectNode() {
- super(ExprType.INTERSECT);
- }
-
- public IntersectNode(LogicalNode outer, LogicalNode inner) {
- this();
- setOuter(outer);
- setInner(inner);
- }
-
- public String toString() {
- return getOuterNode().toString() + "\n INTERSECT \n" + getInnerNode().toString();
- }
-
- @Override
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/JoinNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/JoinNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/JoinNode.java
deleted file mode 100644
index 4ecd011..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/JoinNode.java
+++ /dev/null
@@ -1,110 +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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import tajo.engine.eval.EvalNode;
-import tajo.engine.json.GsonCreator;
-import tajo.engine.parser.QueryBlock;
-import tajo.engine.planner.JoinType;
-
-public class JoinNode extends BinaryNode implements Cloneable {
- @Expose private JoinType joinType;
- @Expose private EvalNode joinQual;
- @Expose private QueryBlock.Target[] targets;
-
- public JoinNode(JoinType joinType, LogicalNode left) {
- super(ExprType.JOIN);
- this.joinType = joinType;
- setOuter(left);
- }
-
- public JoinNode(JoinType joinType, LogicalNode left, LogicalNode right) {
- super(ExprType.JOIN);
- this.joinType = joinType;
- setOuter(left);
- setInner(right);
- }
-
- public JoinType getJoinType() {
- return this.joinType;
- }
-
- public void setJoinType(JoinType joinType) {
- this.joinType = joinType;
- }
-
- public void setJoinQual(EvalNode joinQual) {
- this.joinQual = joinQual;
- }
-
- public boolean hasJoinQual() {
- return this.joinQual != null;
- }
-
- public EvalNode getJoinQual() {
- return this.joinQual;
- }
-
- public boolean hasTargetList() {
- return this.targets != null;
- }
-
- public QueryBlock.Target[] getTargets() {
- return this.targets;
- }
-
- public void setTargetList(QueryBlock.Target[] targets) {
- this.targets = targets;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof JoinNode) {
- JoinNode other = (JoinNode) obj;
- return super.equals(other) && outer.equals(other.outer)
- && inner.equals(other.inner);
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- JoinNode join = (JoinNode) super.clone();
- join.joinType = this.joinType;
- join.joinQual = this.joinQual == null ? null : (EvalNode) this.joinQual.clone();
- return join;
- }
-
- public String toString() {
- return "\"Join\": \"joinType\": \"" + joinType +"\""
- + (joinQual != null ? ", \"qual\": " + joinQual : "")
- + "\n\"out schema: " + getOutSchema()
- + "\n\"in schema: " + getInSchema()
- + "\n" + getOuterNode().toString() + " and " + getInnerNode();
- }
-
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LimitNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LimitNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LimitNode.java
deleted file mode 100644
index 2e36daf..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LimitNode.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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import tajo.engine.json.GsonCreator;
-import tajo.engine.parser.QueryBlock.LimitClause;
-import tajo.util.TUtil;
-
-public final class LimitNode extends UnaryNode implements Cloneable {
- @Expose
- private LimitClause limitClause;
-
- public LimitNode() {
- super();
- }
-
- public LimitNode(LimitClause limitClause) {
- super(ExprType.LIMIT);
- this.limitClause = limitClause;
- }
-
- public long getFetchFirstNum() {
- return this.limitClause.getLimitRow();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LimitNode) {
- LimitNode other = (LimitNode) obj;
- return super.equals(other)
- && TUtil.checkEquals(limitClause, other.limitClause)
- && subExpr.equals(other.subExpr);
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- LimitNode newLimitNode = (LimitNode) super.clone();
- newLimitNode.limitClause = (LimitClause) limitClause.clone();
- return newLimitNode;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder(limitClause.toString());
-
- sb.append("\n\"out schema: " + getOutSchema()
- + "\n\"in schema: " + getInSchema());
- return sb.toString()+"\n"
- + getSubNode().toString();
- }
-
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNode.java
deleted file mode 100644
index d18fc77..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNode.java
+++ /dev/null
@@ -1,110 +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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import tajo.catalog.Schema;
-
-public abstract class LogicalNode implements Cloneable {
- @Expose
- private ExprType type;
- @Expose
- private Schema inputSchema;
- @Expose
- private Schema outputSchema;
-
- @Expose
- private double cost = 0;
-
- public LogicalNode() {
-
- }
-
- public LogicalNode(ExprType type) {
- this.type = type;
- }
-
- public ExprType getType() {
- return this.type;
- }
-
- public void setType(ExprType type) {
- this.type = type;
- }
-
- public double getCost() {
- return this.cost;
- }
-
- public void setCost(double cost) {
- this.cost = cost;
- }
-
- public void setInSchema(Schema inSchema) {
- this.inputSchema = inSchema;
- }
-
- public Schema getInSchema() {
- return this.inputSchema;
- }
-
- public void setOutSchema(Schema outSchema) {
- this.outputSchema = outSchema;
- }
-
- public Schema getOutSchema() {
- return this.outputSchema;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LogicalNode) {
- LogicalNode other = (LogicalNode) obj;
-
- boolean b1 = this.type == other.type;
- boolean b2 = this.inputSchema.equals(other.inputSchema);
- boolean b3 = this.outputSchema.equals(other.outputSchema);
- boolean b4 = this.cost == other.cost;
-
- return b1 && b2 && b3 && b4;
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- LogicalNode node = (LogicalNode)super.clone();
- node.type = type;
- node.inputSchema =
- (Schema) (inputSchema != null ? inputSchema.clone() : null);
- node.outputSchema =
- (Schema) (outputSchema != null ? outputSchema.clone() : null);
-
- return node;
- }
-
- public abstract String toJSON();
-
- public abstract void preOrder(LogicalNodeVisitor visitor);
- public abstract void postOrder(LogicalNodeVisitor visitor);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNodeVisitor.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNodeVisitor.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNodeVisitor.java
deleted file mode 100644
index 0ee74c6..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalNodeVisitor.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 tajo.engine.planner.logical;
-
-
-public interface LogicalNodeVisitor {
- void visit(LogicalNode node);
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalRootNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalRootNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalRootNode.java
deleted file mode 100644
index fdb7981..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/LogicalRootNode.java
+++ /dev/null
@@ -1,54 +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 tajo.engine.planner.logical;
-
-import tajo.engine.json.GsonCreator;
-
-public class LogicalRootNode extends UnaryNode implements Cloneable {
- public LogicalRootNode() {
- super(ExprType.ROOT);
- }
-
- public String toString() {
- return "Logical Plan Root\n\n" + getSubNode().toString();
- }
-
- @Override
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof LogicalRootNode) {
- LogicalRootNode other = (LogicalRootNode) obj;
- boolean b1 = super.equals(other);
- boolean b2 = subExpr.equals(other.subExpr);
-
- return b1 && b2;
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ProjectionNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ProjectionNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ProjectionNode.java
deleted file mode 100644
index 5683fe5..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ProjectionNode.java
+++ /dev/null
@@ -1,106 +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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import tajo.engine.json.GsonCreator;
-import tajo.engine.parser.QueryBlock.Target;
-
-import java.util.Arrays;
-
-public class ProjectionNode extends UnaryNode {
- /**
- * the targets are always filled even if the query is 'select *'
- */
- @Expose private Target [] targets;
- @Expose private boolean distinct = false;
-
- /**
- * This method is for gson.
- */
- private ProjectionNode() {
- super();
- }
-
- public ProjectionNode(Target [] targets) {
- super(ExprType.PROJECTION);
- this.targets = targets;
- }
-
- public Target [] getTargets() {
- return this.targets;
- }
-
- public void setTargetList(Target [] targets) {
- this.targets = targets;
- }
-
- public void setSubNode(LogicalNode subNode) {
- super.setSubNode(subNode);
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("\"Projection\": {");
- if (distinct) {
- sb.append("\"distinct\": true, ");
- }
- sb.append("\"targets\": [");
-
- for (int i = 0; i < targets.length; i++) {
- sb.append("\"").append(targets[i]).append("\"");
- if( i < targets.length - 1) {
- sb.append(",");
- }
- }
- sb.append("],");
- sb.append("\n \"out schema\": ").append(getOutSchema()).append(",");
- sb.append("\n \"in schema\": ").append(getInSchema());
- sb.append("}");
- return sb.toString()+"\n"
- + getSubNode().toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ProjectionNode) {
- ProjectionNode other = (ProjectionNode) obj;
-
- boolean b1 = super.equals(other);
- boolean b2 = Arrays.equals(targets, other.targets);
- boolean b3 = subExpr.equals(other.subExpr);
-
- return b1 && b2 && b3;
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- ProjectionNode projNode = (ProjectionNode) super.clone();
- projNode.targets = targets.clone();
-
- return projNode;
- }
-
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ScanNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ScanNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ScanNode.java
deleted file mode 100644
index 41fbb86..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/ScanNode.java
+++ /dev/null
@@ -1,193 +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 tajo.engine.planner.logical;
-
-import com.google.common.base.Objects;
-import com.google.gson.annotations.Expose;
-import tajo.engine.eval.EvalNode;
-import tajo.engine.json.GsonCreator;
-import tajo.engine.parser.QueryBlock;
-import tajo.engine.parser.QueryBlock.FromTable;
-import tajo.engine.parser.QueryBlock.Target;
-import tajo.util.TUtil;
-
-public class ScanNode extends LogicalNode {
- @Expose private FromTable table;
- @Expose private EvalNode qual;
- @Expose private QueryBlock.Target[] targets;
- @Expose private boolean local;
- @Expose private boolean broadcast;
-
- public ScanNode() {
- super();
- local = false;
- }
-
- public ScanNode(FromTable table) {
- super(ExprType.SCAN);
- this.table = table;
- this.setInSchema(table.getSchema());
- this.setOutSchema(table.getSchema());
- local = false;
- }
-
- public String getTableId() {
- return table.getTableName();
- }
-
- public boolean hasAlias() {
- return table.hasAlias();
- }
-
- public boolean hasQual() {
- return qual != null;
- }
-
- public EvalNode getQual() {
- return this.qual;
- }
-
- public boolean isLocal() {
- return this.local;
- }
-
- public void setLocal(boolean local) {
- this.local = local;
- }
-
- public void setQual(EvalNode evalTree) {
- this.qual = evalTree;
- }
-
- public boolean hasTargetList() {
- return this.targets != null;
- }
-
- public void setTargets(Target [] targets) {
- this.targets = targets;
- }
-
- public Target [] getTargets() {
- return this.targets;
- }
-
- public boolean isBroadcast() {
- return broadcast;
- }
-
- public void setBroadcast() {
- broadcast = true;
- }
-
- public FromTable getFromTable() {
- return this.table;
- }
-
- public void setFromTable(FromTable from) {
- this.table = from;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("\"Scan\" : {\"table\":\"")
- .append(table.getTableName()).append("\"");
- if (hasAlias()) {
- sb.append(",\"alias\": \"").append(table.getAlias());
- }
-
- if (isBroadcast()) {
- sb.append(",\"broadcast\": true\"");
- }
-
- if (hasQual()) {
- sb.append(", \"qual\": \"").append(this.qual).append("\"");
- }
-
- if (hasTargetList()) {
- sb.append(", \"target list\": ");
- boolean first = true;
- for (Target target : targets) {
- if (!first) {
- sb.append(", ");
- }
- sb.append(target);
- first = false;
- }
- }
-
- sb.append(",");
- sb.append("\n \"out schema\": ").append(getOutSchema());
- sb.append("\n \"in schema\": ").append(getInSchema());
- return sb.toString();
- }
-
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-
- @Override
- public int hashCode() {
- return Objects.hashCode(this.table, this.qual, this.targets);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ScanNode) {
- ScanNode other = (ScanNode) obj;
-
- boolean eq = super.equals(other);
- eq = eq && TUtil.checkEquals(this.table, other.table);
- eq = eq && TUtil.checkEquals(this.qual, other.qual);
- eq = eq && TUtil.checkEquals(this.targets, other.targets);
-
- return eq;
- }
-
- return false;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- ScanNode scanNode = (ScanNode) super.clone();
-
- scanNode.table = (FromTable) this.table.clone();
-
- if (hasQual()) {
- scanNode.qual = (EvalNode) this.qual.clone();
- }
-
- if (hasTargetList()) {
- scanNode.targets = new Target[targets.length];
- for (int i = 0; i < targets.length; i++) {
- scanNode.targets[i] = (Target) targets[i].clone();
- }
- }
-
- return scanNode;
- }
-
- @Override
- public void preOrder(LogicalNodeVisitor visitor) {
- visitor.visit(this);
- }
-
- public void postOrder(LogicalNodeVisitor visitor) {
- visitor.visit(this);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/SelectionNode.java
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/SelectionNode.java b/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/SelectionNode.java
deleted file mode 100644
index f115a20..0000000
--- a/tajo-core/tajo-core-backend/src/main/java/tajo/engine/planner/logical/SelectionNode.java
+++ /dev/null
@@ -1,80 +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 tajo.engine.planner.logical;
-
-import com.google.gson.annotations.Expose;
-import tajo.engine.eval.EvalNode;
-import tajo.engine.json.GsonCreator;
-
-public class SelectionNode extends UnaryNode implements Cloneable {
-
- @Expose
- private EvalNode qual;
-
- public SelectionNode() {
- super();
- }
-
- public SelectionNode(EvalNode qual) {
- super(ExprType.SELECTION);
- setQual(qual);
- }
-
- public EvalNode getQual() {
- return this.qual;
- }
-
- public void setQual(EvalNode qual) {
- this.qual = qual;
- }
-
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("\"Selection\": {\"qual\": \"").append(qual.toString()).append("\",");
- sb.append("\n \"out schema\": ").append(getOutSchema()).append(",");
- sb.append("\n \"in schema\": ").append(getInSchema()).append("}");
-
- return sb.toString()+"\n"
- + getSubNode().toString();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof SelectionNode) {
- SelectionNode other = (SelectionNode) obj;
- return super.equals(other)
- && this.qual.equals(other.qual)
- && subExpr.equals(other.subExpr);
- } else {
- return false;
- }
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- SelectionNode selNode = (SelectionNode) super.clone();
- selNode.qual = (EvalNode) this.qual.clone();
-
- return selNode;
- }
-
- public String toJSON() {
- return GsonCreator.getInstance().toJson(this, LogicalNode.class);
- }
-}