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:41 UTC

[47/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-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/Stat.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/Stat.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/Stat.java
new file mode 100644
index 0000000..346c99b
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/Stat.java
@@ -0,0 +1,107 @@
+/**
+ * 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.tajo.catalog.statistics;
+
+import com.google.common.base.Objects;
+import com.google.gson.annotations.Expose;
+import org.apache.tajo.catalog.proto.CatalogProtos.StatProto;
+import org.apache.tajo.catalog.proto.CatalogProtos.StatType;
+
+public class Stat implements Cloneable {
+  @Expose private long val = 0;
+  @Expose private StatType type;
+
+  public Stat(StatType type) {
+    this.type = type;
+    val = 0;
+  }
+
+  public Stat(StatProto proto) {
+    this.type = proto.getType();
+    this.val = proto.getValue();
+  }
+
+  public StatType getType() {
+    return this.type;
+  }
+
+  public long getValue() {
+    return this.val;
+  }
+
+  public void setValue(long val) {
+    this.val = val;
+  }
+
+  public void increment() {
+    this.val++;
+  }
+
+  public void incrementBy(long delta) {
+    this.val += delta;
+  }
+
+  public void subtract() {
+    this.val--;
+  }
+
+  public void subtractBy(long delta) {
+    val -= delta;
+  }
+
+  public boolean equals(Object obj) {
+    if (obj instanceof Stat) {
+      Stat other = (Stat) obj;
+      return this.type == other.type 
+          && this.val == other.val;
+    } else {
+      return false;
+    }
+  }
+
+  public int hashCode() {
+    return Objects.hashCode(type, val);
+  }
+
+  public Object clone() throws CloneNotSupportedException {
+    Stat stat = (Stat) super.clone();
+    stat.type = type;
+    stat.val = val;
+
+    return stat;
+  }
+
+  /**
+   * @return
+   */
+  public StatProto toProto() {
+    // This is not designed for a proto buffer object due to
+    // performance problem. However, it needs the method to transform
+    // itself to the proto object.
+    StatProto.Builder builder = StatProto.newBuilder();
+    builder.setType(type);
+    builder.setValue(val);
+
+    return builder.build();
+  }
+
+  public String toString() {
+    return type + ": " + val;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java
new file mode 100644
index 0000000..d3a3c3e
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatSet.java
@@ -0,0 +1,151 @@
+/**
+ * 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.tajo.catalog.statistics;
+
+import com.google.common.collect.Maps;
+import com.google.gson.annotations.Expose;
+import org.apache.tajo.catalog.json.GsonCreator;
+import org.apache.tajo.catalog.proto.CatalogProtos.StatProto;
+import org.apache.tajo.catalog.proto.CatalogProtos.StatSetProto;
+import org.apache.tajo.catalog.proto.CatalogProtos.StatSetProtoOrBuilder;
+import org.apache.tajo.catalog.proto.CatalogProtos.StatType;
+import org.apache.tajo.common.ProtoObject;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Map.Entry;
+
+public class StatSet implements ProtoObject<StatSetProto>, Cloneable {
+  private StatSetProto proto = StatSetProto.getDefaultInstance();
+  private StatSetProto.Builder builder = null;
+  boolean viaProto = false;
+
+  @Expose private Map<StatType, Stat> stats;
+
+  public StatSet() {
+    builder = StatSetProto.newBuilder();
+  }
+
+  public StatSet(StatSetProto proto) {
+    this.proto = proto;
+    this.viaProto = true;
+  }
+
+  public void putStat(Stat stat) {
+    initStats();
+    setModified();
+    stats.put(stat.getType(), stat);
+  }
+  
+  public boolean containStat(StatType type) {
+    initStats();
+    return stats.containsKey(type);
+  }
+
+  public Stat getStat(StatType type) {
+    initStats();
+    return stats.get(type);
+  }
+
+  public Collection<Stat> getAllStats() {
+    initStats();
+    return stats.values();
+  }
+  
+  public boolean equals(Object obj) {
+    if (obj instanceof StatSet) {
+      StatSet other = (StatSet) obj;
+      for (Entry<StatType, Stat> entry : stats.entrySet()) {
+        if (!other.getStat(entry.getKey()).equals(entry.getValue())) {
+          return false;
+        }
+      }      
+      return true;
+    } else {
+      return false;
+    }
+  }
+  
+  public Object clone() throws CloneNotSupportedException {
+    StatSet group = (StatSet) super.clone();
+    initFromProto();
+    group.stats = Maps.newHashMap();
+    for (Stat stat : stats.values()) {
+      group.stats.put(stat.getType(), (Stat) stat.clone());
+    }
+    
+    return group;
+  }
+
+  private void initStats() {
+    if (this.stats != null) {
+      return;
+    }
+    StatSetProtoOrBuilder p = viaProto ? proto : builder;
+    this.stats = Maps.newHashMap();
+    for (StatProto statProto : p.getStatsList()) {
+      stats.put(statProto.getType(), new Stat(statProto));
+    }
+  }
+
+  private void setModified() {
+    if (viaProto && builder == null) {
+      builder = StatSetProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  @Override
+  public void initFromProto() {
+    StatSetProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.stats == null && p.getStatsCount() > 0) {
+      this.stats = Maps.newHashMap();
+      for (StatProto statProto : p.getStatsList()) {
+        this.stats.put(statProto.getType(), new Stat(statProto));
+      }
+    }
+  }
+
+  @Override
+  public StatSetProto getProto() {
+    if (!viaProto) {
+      mergeLocalToBuilder();
+      proto = builder.build();
+      viaProto = true;
+    }
+
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (builder == null) {
+      builder = StatSetProto.newBuilder(proto);
+    }
+
+    if (this.stats != null) {
+      for (Stat stat : stats.values()) {
+        builder.addStats(stat.toProto());
+      }
+    }
+  }
+  
+  public String toString() {
+    return GsonCreator.getPrettyInstance().toJson(this);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatisticsUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatisticsUtil.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatisticsUtil.java
new file mode 100644
index 0000000..188fdcc
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/StatisticsUtil.java
@@ -0,0 +1,104 @@
+/**
+ * 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.tajo.catalog.statistics;
+
+import com.google.common.collect.Lists;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.List;
+
+public class StatisticsUtil {
+  private static final Log LOG = LogFactory.getLog(StatisticsUtil.class);
+
+  public static StatSet aggregateStatSet(List<StatSet> statSets) {
+    StatSet aggregated = new StatSet();
+
+    for (StatSet statSet : statSets) {
+      for (Stat stat : statSet.getAllStats()) {
+        if (aggregated.containStat(stat.getType())) {
+          aggregated.getStat(stat.getType()).incrementBy(stat.getValue());
+        } else {
+          aggregated.putStat(stat);
+        }
+      }
+    }
+    return aggregated;
+  }
+
+  public static TableStat aggregateTableStat(List<TableStat> tableStats) {
+    if(tableStats == null || tableStats.size() == 0 || tableStats.get(0) == null)
+      return null;
+    TableStat aggregated = new TableStat();
+
+    ColumnStat [] css = null;
+    if (tableStats.size() > 0) {
+      for (TableStat ts : tableStats) {
+        // A TableStats cannot contain any ColumnStat if there is no output.
+        // So, we should consider such a condition.
+        if (ts.getColumnStats().size() > 0) {
+          css = new ColumnStat[ts.getColumnStats().size()];
+          for (int i = 0; i < css.length; i++) {
+            css[i] = new ColumnStat(ts.getColumnStats().get(i).getColumn());
+          }
+          break;
+        }
+      }
+    }
+
+    for (TableStat ts : tableStats) {
+      // if there is empty stats
+      if (ts.getColumnStats().size() == 0) {
+        continue;
+      }
+
+      // aggregate column stats for each table
+      for (int i = 0; i < ts.getColumnStats().size(); i++) {
+        ColumnStat cs = ts.getColumnStats().get(i);
+        if (cs == null) {
+          LOG.warn("ERROR: One of column stats is NULL (expected column: " + css[i].getColumn() + ")");
+          continue;
+        }
+        css[i].setNumDistVals(css[i].getNumDistValues() + cs.getNumDistValues());
+        css[i].setNumNulls(css[i].getNumNulls() + cs.getNumNulls());
+        if (!cs.minIsNotSet() && (css[i].minIsNotSet() ||
+            css[i].getMinValue().compareTo(cs.getMinValue()) > 0)) {
+          css[i].setMinValue(cs.getMinValue());
+        }
+        if (!cs.maxIsNotSet() && (css[i].maxIsNotSet() ||
+            css[i].getMaxValue().compareTo(cs.getMaxValue()) < 0)) {
+          css[i].setMaxValue(ts.getColumnStats().get(i).getMaxValue());
+        }
+      }
+
+      // aggregate table stats for each table
+      aggregated.setNumRows(aggregated.getNumRows() + ts.getNumRows());
+      aggregated.setNumBytes(aggregated.getNumBytes() + ts.getNumBytes());
+      aggregated.setNumBlocks(aggregated.getNumBlocks() + ts.getNumBlocks());
+      aggregated.setNumPartitions(aggregated.getNumPartitions() + ts.getNumPartitions());
+    }
+
+    //aggregated.setAvgRows(aggregated.getNumRows() / tableStats.size());
+    if (css != null) {
+      aggregated.setColumnStats(Lists.newArrayList(css));
+    }
+
+    return aggregated;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TableStat.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TableStat.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TableStat.java
new file mode 100644
index 0000000..56396b1
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TableStat.java
@@ -0,0 +1,285 @@
+/**
+ * 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.tajo.catalog.statistics;
+
+import com.google.common.base.Objects;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.annotations.Expose;
+import org.apache.tajo.catalog.proto.CatalogProtos.ColumnStatProto;
+import org.apache.tajo.catalog.proto.CatalogProtos.TableStatProto;
+import org.apache.tajo.catalog.proto.CatalogProtos.TableStatProtoOrBuilder;
+import org.apache.tajo.common.ProtoObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TableStat implements ProtoObject<TableStatProto>, Cloneable {
+  private TableStatProto proto = TableStatProto.getDefaultInstance();
+  private TableStatProto.Builder builder = null;
+  private boolean viaProto = false;
+
+  @Expose private Long numRows = null;
+  @Expose private Long numBytes = null;
+  @Expose private Integer numBlocks = null;
+  @Expose private Integer numPartitions = null;
+  @Expose private Long avgRows = null;
+  @Expose private List<ColumnStat> columnStats = null;
+
+  public TableStat() {
+    builder = TableStatProto.newBuilder();
+    numRows = 0l;
+    numBytes = 0l;
+    numBlocks = 0;
+    numPartitions = 0;
+    avgRows = 0l;
+  }
+
+  public TableStat(TableStatProto proto) {
+    this.proto = proto;
+    this.viaProto = true;
+  }
+
+  public Long getNumRows() {
+    TableStatProtoOrBuilder p = viaProto ? proto : builder;
+    if(numRows != null) {
+      return this.numRows;
+    }
+    if(!p.hasNumRows()) {
+      return 0l;
+    }
+    this.numRows = p.getNumRows();
+
+    return this.numRows;
+  }
+
+  public void setNumRows(long numRows) {
+    setModified();
+    this.numRows = numRows;
+  }
+
+  public Integer getNumBlocks() {
+    TableStatProtoOrBuilder p = viaProto ? proto : builder;
+    if(numBlocks != null) {
+      return this.numBlocks;
+    }
+    if(!p.hasNumBlocks()) {
+      return 0;
+    }
+    this.numBlocks = p.getNumBlocks();
+
+    return this.numBlocks;
+  }
+
+  public void setNumBytes(long numBytes) {
+    setModified();
+    this.numBytes = numBytes;
+  }
+
+  public Long getNumBytes() {
+    TableStatProtoOrBuilder p = viaProto ? proto : builder;
+    if (numBytes != null) {
+      return this.numBytes;
+    }
+    if (!p.hasNumBytes()) {
+      return 0l;
+    }
+    this.numBytes = p.getNumBytes();
+    return this.numBytes;
+  }
+
+  public void setNumBlocks(int numBlocks) {
+    setModified();
+    this.numBlocks = numBlocks;
+  }
+
+  public Integer getNumPartitions() {
+    TableStatProtoOrBuilder p = viaProto ? proto : builder;
+    if(numPartitions != null) {
+      return this.numPartitions;
+    }
+    if(!p.hasNumPartitions()) {
+      return 0;
+    }
+    this.numPartitions = p.getNumPartitions();
+
+    return this.numPartitions;
+  }
+
+  public void setNumPartitions(int numPartitions) {
+    setModified();
+    this.numPartitions = numPartitions;
+  }
+
+  public Long getAvgRows() {
+    TableStatProtoOrBuilder p = viaProto ? proto : builder;
+    if(avgRows != null) {
+      return this.avgRows;
+    }
+    if(!p.hasAvgRows()) {
+      return 0l;
+    }
+    this.avgRows = p.getAvgRows();
+
+    return this.avgRows;
+  }
+
+  public void setAvgRows(long avgRows) {
+    setModified();
+    this.avgRows = avgRows;
+  }
+
+  public List<ColumnStat> getColumnStats() {
+    initColumnStats();
+    return this.columnStats;
+  }
+
+  public void setColumnStats(List<ColumnStat> columnStats) {
+    setModified();
+    this.columnStats = new ArrayList<ColumnStat>(columnStats);
+  }
+
+  public void addColumnStat(ColumnStat columnStat) {
+    initColumnStats();
+    this.columnStats.add(columnStat);
+  }
+
+  public boolean equals(Object obj) {
+    if (obj instanceof TableStat) {
+      TableStat other = (TableStat) obj;
+      initFromProto();
+      other.initFromProto();
+
+      return this.numRows.equals(other.numRows)
+          && this.numBytes.equals(other.numBytes)
+          && this.numBlocks.equals(other.numBlocks)
+          && this.numPartitions.equals(other.numPartitions)
+          && this.avgRows.equals(other.avgRows)
+          && columnStats.equals(other.columnStats);
+    } else {
+      return false;
+    }
+  }
+
+  public int hashCode() {
+    return Objects.hashCode(numRows, numBytes,
+        numBlocks, numPartitions, columnStats);
+  }
+
+  public Object clone() throws CloneNotSupportedException {
+    TableStat stat = (TableStat) super.clone();
+    initFromProto();
+    stat.numRows = numRows;
+    stat.numBytes = numBytes;
+    stat.numBlocks = numBlocks;
+    stat.numPartitions = numPartitions;
+    stat.columnStats = new ArrayList<ColumnStat>(this.columnStats);
+
+    return stat;
+  }
+
+  public String toString() {
+    Gson gson = new GsonBuilder().setPrettyPrinting().
+        excludeFieldsWithoutExposeAnnotation().create();
+    return gson.toJson(this);
+  }
+
+  private void initColumnStats() {
+    if (this.columnStats != null) {
+      return;
+    }
+    TableStatProtoOrBuilder p = viaProto ? proto : builder;
+    this.columnStats = new ArrayList<ColumnStat>();
+    for (ColumnStatProto colProto : p.getColStatList()) {
+      columnStats.add(new ColumnStat(colProto));
+    }
+  }
+
+  private void setModified() {
+    if (viaProto && builder == null) {
+      builder = TableStatProto.newBuilder(proto);
+    }
+    viaProto = false;
+  }
+
+  @Override
+  public void initFromProto() {
+    TableStatProtoOrBuilder p = viaProto ? proto : builder;
+    if (this.numRows == null && p.hasNumRows()) {
+      this.numRows = p.getNumRows();
+    }
+    if (this.numBytes == null && p.hasNumBytes()) {
+      this.numBytes = p.getNumBytes();
+    }
+    if (this.numBlocks == null && p.hasNumBlocks()) {
+      this.numBlocks = p.getNumBlocks();
+    }
+    if (this.numPartitions == null && p.hasNumPartitions()) {
+      this.numPartitions = p.getNumPartitions();
+    }
+    if (this.avgRows == null && p.hasAvgRows()) {
+      this.avgRows = p.getAvgRows();
+    }
+
+    initColumnStats();
+    for (ColumnStat col : columnStats) {
+      col.initFromProto();
+    }
+  }
+
+  @Override
+  public TableStatProto getProto() {
+    if (!viaProto) {
+      mergeLocalToBuilder();
+      proto = builder.build();
+      viaProto = true;
+    }
+
+    return proto;
+  }
+
+  private void mergeLocalToBuilder() {
+    if (builder == null) {
+      builder = TableStatProto.newBuilder(proto);
+    }
+    if (this.numRows != null) {
+      builder.setNumRows(this.numRows);
+    }
+    if (this.numBytes != null) {
+      builder.setNumBytes(this.numBytes);
+    }
+    if (this.numBlocks != null) {
+      builder.setNumBlocks(this.numBlocks);
+    }
+    if (this.numPartitions != null) {
+      builder.setNumPartitions(this.numPartitions);
+    }
+    if (this.avgRows != null) {
+      builder.setAvgRows(this.avgRows);
+    }
+    if (this.columnStats != null) {
+      for (ColumnStat colStat : columnStats) {
+        builder.addColStat(colStat.getProto());
+      }
+    }
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TupleUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TupleUtil.java b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TupleUtil.java
new file mode 100644
index 0000000..5ed89b6
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/java/org/apache/tajo/catalog/statistics/TupleUtil.java
@@ -0,0 +1,50 @@
+/**
+ * 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.tajo.catalog.statistics;
+
+import org.apache.tajo.common.TajoDataTypes.DataType;
+import org.apache.tajo.datum.*;
+
+public class TupleUtil {
+  public static Datum createFromBytes(DataType type, byte [] bytes) {
+    switch (type.getType()) {
+      case BOOLEAN:
+        return new BooleanDatum(bytes);
+      case BLOB:
+        return new BlobDatum(bytes);
+      case CHAR:
+        return new CharDatum(bytes);
+      case INT2:
+        return new Int2Datum(bytes);
+      case INT4:
+        return new Int4Datum(bytes);
+      case INT8:
+        return new Int8Datum(bytes);
+      case FLOAT4:
+        return new Float4Datum(bytes);
+      case FLOAT8:
+        return new Float8Datum(bytes);
+      case TEXT:
+        return new TextDatum(bytes);
+      case INET4:
+        return new Inet4Datum(bytes);
+      default: throw new UnsupportedOperationException(type + " is not supported yet");
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AlreadyRegisteredURIException.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AlreadyRegisteredURIException.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AlreadyRegisteredURIException.java
deleted file mode 100644
index 69df366..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AlreadyRegisteredURIException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package tajo.catalog;
-
-import java.net.URI;
-
-public class AlreadyRegisteredURIException extends RuntimeException {
-
-	private static final long serialVersionUID = 747390434221048348L;
-
-	public AlreadyRegisteredURIException() {
-	}
-
-	/**
-	 * @param uri
-	 */
-	public AlreadyRegisteredURIException(String uri) {
-		super("Already registered TRID: "+uri);
-	}
-	
-	public AlreadyRegisteredURIException(URI uri) {
-		this("Already registered TRID: "+uri);
-	}
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AttributeType.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AttributeType.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AttributeType.java
deleted file mode 100644
index 49e757b..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/AttributeType.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 tajo.catalog;
-
-public enum AttributeType {
-	GROUPBY,
-	AGGREGATION,
-	NORMAL
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogConstants.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogConstants.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogConstants.java
deleted file mode 100644
index 17f7bc4..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogConstants.java
+++ /dev/null
@@ -1,30 +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.catalog;
-
-public class CatalogConstants {
-  public static final String STORE_CLASS="tajo.catalog.store.class";
-  
-  public static final String JDBC_DRIVER="tajo.catalog.jdbc.driver";
-  public static final String DEFAULT_JDBC_DRIVER="org.apache.derby.jdbc.EmbeddedDriver";
-  
-  public static final String JDBC_URI="tajo.catalog.jdbc.uri";
-
-  private CatalogConstants() {}
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogUtil.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogUtil.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogUtil.java
deleted file mode 100644
index 41a72de..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/CatalogUtil.java
+++ /dev/null
@@ -1,181 +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.catalog;
-
-import org.apache.hadoop.fs.Path;
-import tajo.catalog.proto.CatalogProtos;
-import tajo.catalog.proto.CatalogProtos.ColumnProto;
-import tajo.catalog.proto.CatalogProtos.SchemaProto;
-import tajo.catalog.proto.CatalogProtos.TableDescProto;
-import tajo.catalog.statistics.TableStat;
-import tajo.common.TajoDataTypes.DataType;
-import tajo.util.FileUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-
-import static tajo.catalog.proto.CatalogProtos.StoreType;
-import static tajo.common.TajoDataTypes.Type;
-
-public class CatalogUtil {
-  public static String getCanonicalName(String signature,
-      Collection<DataType> paramTypes) {
-    DataType [] types = paramTypes.toArray(new DataType[paramTypes.size()]);
-    return getCanonicalName(signature, types);
-  }
-  public static String getCanonicalName(String signature,
-      DataType...paramTypes) {
-    StringBuilder sb = new StringBuilder(signature);
-    sb.append("(");
-    int i = 0;
-    for (DataType type : paramTypes) {
-      sb.append(type.getType());
-      if(i < paramTypes.length - 1) {
-        sb.append(",");
-      }
-      
-      i++;
-    }
-    sb.append(")");
-    return sb.toString();
-  }
-
-  public static String prettyPrint(TableMeta meta) {
-    StringBuilder sb = new StringBuilder();
-    sb.append("store type: ").append(meta.getStoreType()).append("\n");
-    sb.append("schema: \n");
-
-    for(int i = 0; i < meta.getSchema().getColumnNum(); i++) {
-      Column col = meta.getSchema().getColumn(i);
-      sb.append(col.getColumnName()).append("\t").append(col.getDataType());
-      sb.append("\n");
-    }
-    return sb.toString();
-  }
-
-  public static void printTableMeta(File file) throws IOException {
-    CatalogProtos.TableProto proto = (CatalogProtos.TableProto) FileUtil.
-        loadProto(file, CatalogProtos.TableProto.getDefaultInstance());
-    System.out.println(prettyPrint(new TableMetaImpl(proto)));
-  }
-
-  public static void main(String [] args) throws IOException {
-    if (args.length < 2) {
-      System.out.println("catalog print [filename]");
-      System.exit(-1);
-    }
-
-    File file = new File(args[1]);
-    printTableMeta(file);
-  }
-
-  public static StoreType getStoreType(final String typeStr) {
-    if (typeStr.equalsIgnoreCase(StoreType.CSV.name())) {
-      return StoreType.CSV;
-    } else if (typeStr.equalsIgnoreCase(StoreType.RAW.name())) {
-      return StoreType.RAW;
-    } else if (typeStr.equalsIgnoreCase(StoreType.CSV.name())) {
-      return StoreType.CSV;
-    } else if (typeStr.equalsIgnoreCase(StoreType.ROWFILE.name())) {
-      return StoreType.ROWFILE;
-    }else if (typeStr.equalsIgnoreCase(StoreType.RCFILE.name())) {
-      return StoreType.RCFILE;
-    } else if (typeStr.equalsIgnoreCase(StoreType.TREVNI.name())) {
-      return StoreType.TREVNI;
-    } else {
-      return null;
-    }
-  }
-
-  public static TableMeta newTableMeta(Schema schema, StoreType type) {
-    return new TableMetaImpl(schema, type, new Options());
-  }
-
-  public static TableMeta newTableMeta(Schema schema, StoreType type,
-      Options options) {
-    return new TableMetaImpl(schema, type, options);
-  }
-
-  public static TableMeta newTableMeta(Schema schema, StoreType type, Options options,
-      TableStat stat) {
-    return new TableMetaImpl(schema, type, options, stat);
-  }
-
-  public static TableDesc newTableDesc(String tableName, TableMeta meta,
-      Path path) {
-    return new TableDescImpl(tableName, meta, path);
-  }
-
-  public static TableDesc newTableDesc(TableDescProto proto) {
-    return new TableDescImpl(proto);
-  }
-
-  public static TableDesc newTableDesc(String tableName,
-      Schema schema, StoreType type, Options options, Path path) {
-    return new TableDescImpl(tableName, schema, type, options, path);
-  }
-
-  /**
-  * This method transforms the unqualified names of a given schema into
-  * the qualified names.
-  *
-  * @param tableName a table name to be prefixed
-  * @param schema a schema to be transformed
-  *
-  * @return
-  */
-  public static SchemaProto getQualfiedSchema(String tableName,
-      SchemaProto schema) {
-    SchemaProto.Builder revisedSchema = SchemaProto.newBuilder(schema);
-    revisedSchema.clearFields();
-    String[] split;
-    for (ColumnProto col : schema.getFieldsList()) {
-      split = col.getColumnName().split("\\.");
-      if (split.length == 1) { // if not qualified name
-        // rewrite the column
-        ColumnProto.Builder builder = ColumnProto.newBuilder(col);
-        builder.setColumnName(tableName + "." + col.getColumnName());
-        col = builder.build();
-      } else if (split.length == 2) {
-        ColumnProto.Builder builder = ColumnProto.newBuilder(col);
-        builder.setColumnName(tableName + "." + split[1]);
-        col = builder.build();
-      } else {
-        throw new InternalError("Unaccetable field name "
-            + col.getColumnName());
-      }
-      revisedSchema.addFields(col);
-    }
-
-    return revisedSchema.build();
-  }
-
-  public static DataType newDataTypeWithoutLen(Type type) {
-    return DataType.newBuilder().setType(type).build();
-  }
-
-  public static DataType [] newDataTypesWithoutLen(Type... types) {
-    DataType [] dataTypes = new DataType[types.length];
-    for (int i = 0; i < types.length; i++) {
-      dataTypes[i] = DataType.newBuilder().setType(types[i]).build();
-    }
-    return dataTypes;
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Column.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Column.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Column.java
deleted file mode 100644
index ecdc4c3..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Column.java
+++ /dev/null
@@ -1,187 +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.catalog;
-
-import com.google.gson.annotations.Expose;
-import tajo.catalog.json.GsonCreator;
-import tajo.catalog.proto.CatalogProtos.ColumnProto;
-import tajo.catalog.proto.CatalogProtos.ColumnProtoOrBuilder;
-import tajo.common.ProtoObject;
-import tajo.common.TajoDataTypes;
-import tajo.common.TajoDataTypes.DataType;
-
-public class Column implements ProtoObject<ColumnProto>, Cloneable {
-	private ColumnProto proto = ColumnProto.getDefaultInstance();
-	private ColumnProto.Builder builder = null;
-	private boolean viaProto = false;
-	
-	@Expose protected String name;
-	@Expose protected DataType dataType;
-	
-	public Column() {
-		this.builder = ColumnProto.newBuilder();
-	}
-	  
-	public Column(String columnName, DataType dataType) {
-	  this();
-		this.name = columnName.toLowerCase();
-		this.dataType = dataType;
-	}
-
-  public Column(String columnName, TajoDataTypes.Type type) {
-    this(columnName, CatalogUtil.newDataTypeWithoutLen(type));
-  }
-	
-	public Column(ColumnProto proto) {
-		this.proto = proto;
-		this.viaProto = true;
-	}
-	
-
-	public String getQualifiedName() {
-		ColumnProtoOrBuilder p = viaProto ? proto : builder;
-		if(name != null) {
-			return this.name;
-		}
-		if(!p.hasColumnName()) {
-			return null;			
-		}		
-		this.name = p.getColumnName();
-		
-		return this.name;
-	}
-	
-  public boolean isQualified() {
-    return getQualifiedName().split("\\.").length == 2;
-  }
-
-  public String getTableName() {
-    if (isQualified()) {
-      return getQualifiedName().split("\\.")[0];
-    } else {
-      return "";
-    }    
-  }
-
-  public String getColumnName() {
-    if (isQualified())
-      return getQualifiedName().split("\\.")[1];
-    else
-      return getQualifiedName();
-  }
-	
-	public void setName(String name) {
-	  setModified();
-		this.name = name.toLowerCase();
-	}
-	
-	public DataType getDataType() {
-		ColumnProtoOrBuilder p = viaProto ? proto : builder;
-		if(dataType != null) {
-			return this.dataType;
-		}
-		if(!p.hasDataType()) {
-			return null;
-		}
-		this.dataType = p.getDataType();
-		
-		return this.dataType;
-	}
-	
-	public void setDataType(DataType dataType) {
-		setModified();
-		this.dataType = dataType;
-	}
-	
-	@Override
-	public boolean equals(Object o) {
-		if (o instanceof Column) {
-			Column cd = (Column)o;
-			return this.getQualifiedName().equals(cd.getQualifiedName()) &&
-					this.getDataType().equals(cd.getDataType());
-		}
-		return false;
-	}
-	
-  public int hashCode() {
-    return getQualifiedName().hashCode() ^ (getDataType().hashCode() * 17);
-  }
-  
-  @Override
-  public Object clone() throws CloneNotSupportedException {
-    Column column = (Column) super.clone();
-    initFromProto();
-    column.proto = null;
-    column.viaProto = false;
-    column.builder = ColumnProto.newBuilder();
-    column.name = name;
-    column.dataType = dataType;
-    return column;
-  }
-
-	@Override
-	public ColumnProto getProto() {
-	  if(!viaProto) {
-      mergeLocalToBuilder();
-      proto = builder.build();
-      viaProto = true;
-    }
-	  
-	  return proto;
-	}
-	
-	private void setModified() {
-	  if (viaProto && builder == null) {
-	    builder = ColumnProto.newBuilder(proto);
-	  }
-	  viaProto = false;
-	}
-	
-	private void mergeLocalToBuilder() {
-	  if (builder == null) {
-	    builder = ColumnProto.newBuilder(proto);
-	  }
-		if (this.name != null) {
-			builder.setColumnName(this.name);			
-		}
-		if (this.dataType != null) {
-			builder.setDataType(this.dataType);
-		}
-	}
-	
-	public String toString() {
-	  return getQualifiedName() +" (" + getDataType().getType() +")";
-	}
-	
-	public String toJSON() {
-		initFromProto();
-		return GsonCreator.getInstance().toJson(this);
-	}
-
-	@Override
-	public void initFromProto() {
-		ColumnProtoOrBuilder p = viaProto ? proto : builder;
-		if (this.name == null && p.hasColumnName()) {
-			this.name = p.getColumnName();
-		}
-		if (this.dataType == null && p.hasDataType()) {
-			this.dataType = p.getDataType();
-		}
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/FunctionDesc.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/FunctionDesc.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/FunctionDesc.java
deleted file mode 100644
index 7fdf336..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/FunctionDesc.java
+++ /dev/null
@@ -1,274 +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.catalog;
-
-import com.google.gson.Gson;
-import com.google.gson.annotations.Expose;
-import tajo.catalog.function.Function;
-import tajo.catalog.function.GeneralFunction;
-import tajo.catalog.json.GsonCreator;
-import tajo.catalog.proto.CatalogProtos.FunctionDescProto;
-import tajo.catalog.proto.CatalogProtos.FunctionDescProtoOrBuilder;
-import tajo.catalog.proto.CatalogProtos.FunctionType;
-import tajo.common.ProtoObject;
-import tajo.common.TajoDataTypes.DataType;
-import tajo.exception.InternalException;
-
-import java.lang.reflect.Constructor;
-import java.util.Arrays;
-
-public class FunctionDesc implements ProtoObject<FunctionDescProto>, Cloneable {
-  private FunctionDescProto proto = FunctionDescProto.getDefaultInstance();
-  private FunctionDescProto.Builder builder = null;
-  private boolean viaProto = false;
-  
-  @Expose private String signature;
-  @Expose private Class<? extends Function> funcClass;
-  @Expose private FunctionType funcType;
-  @Expose private DataType [] returnType;
-  @Expose private DataType [] params;
-
-  public FunctionDesc() {
-    this.builder = FunctionDescProto.newBuilder();
-  }
-  
-  public FunctionDesc(String signature, Class<? extends Function> clazz,
-      FunctionType funcType, DataType [] retType, DataType [] params) {
-    this();
-    this.signature = signature.toLowerCase();
-    this.funcClass = clazz;
-    this.funcType = funcType;
-    this.returnType = retType;
-    this.params = params;
-  }
-  
-  public FunctionDesc(FunctionDescProto proto) {
-    this.proto = proto;
-    this.viaProto = true;
-  }
-
-  @SuppressWarnings("unchecked")
-  public FunctionDesc(String signature, String className, FunctionType type,
-                      DataType [] retType, DataType... argTypes) throws ClassNotFoundException {
-    this(signature, (Class<? extends Function>) Class.forName(className), type,
-        retType, argTypes);
-  }
-
-  /**
-   * 
-   * @return 함수 인스턴스
-   * @throws InternalException
-   */
-  public Function newInstance() throws InternalException {
-    try {
-      Constructor<? extends Function> cons = getFuncClass().getConstructor();
-      return cons.newInstance();
-    } catch (Exception ioe) {
-      throw new InternalException("Cannot initiate function " + signature);
-    }
-  }
-
-  public String getSignature() {
-    FunctionDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.signature != null) {
-      return this.signature;
-    }
-    if (!proto.hasSignature()) {
-      return null;
-    }
-    this.signature = p.getSignature();
-    return this.signature;
-  }
-
-  @SuppressWarnings("unchecked")
-  public Class<? extends Function> getFuncClass() throws InternalException {
-    FunctionDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.funcClass != null) {
-      return this.funcClass;
-    }
-    if (!p.hasClassName()) {
-      return null;
-    }
-    try {
-      this.funcClass = (Class<? extends Function>)Class.forName(p.getClassName());
-    } catch (ClassNotFoundException e) {
-      throw new InternalException("The function class ("+p.getClassName()+") cannot be loaded");
-    }
-    return this.funcClass;
-  }
-
-  public FunctionType getFuncType() {
-    FunctionDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.funcType != null) {
-      return this.funcType;
-    }
-    if (!p.hasType()) {
-      return null;
-    }
-    this.funcType = p.getType();
-    return this.funcType;
-  }
-
-  public DataType [] getParamTypes() {
-    FunctionDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.params != null) {
-      return this.params;
-    }
-    if (p.getParameterTypesCount() == 0) {
-      return null;
-    }
-    this.params = p.getParameterTypesList().toArray(
-        new DataType[p.getParameterTypesCount()]);
-    return this.params;
-  }
-
-  public DataType [] getReturnType() {
-    FunctionDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.returnType != null) {
-      return newNoNameSchema(this.returnType);
-    }
-    if (!p.hasReturnType()) {
-      return null;
-    }
-    this.returnType = newNoNameSchema(p.getReturnType());
-    return this.returnType;
-    
-  }
-
-  public static DataType [] newNoNameSchema(DataType ... types) {
-    DataType [] dataTypes = types.clone();
-    return dataTypes;
-  }
-  
-  @Override
-  public boolean equals(Object obj) {
-    if (obj instanceof FunctionDesc) {
-      FunctionDesc other = (FunctionDesc) obj;
-      if(this.getProto().equals(other.getProto()))
-        return true;
-    }
-    return false;
-  }
-  
-  @Override
-  public Object clone() throws CloneNotSupportedException{
-    FunctionDesc desc  = (FunctionDesc)super.clone();
-    desc.proto = this.proto;
-    desc.builder = this.builder == null?null:this.builder.clone();
-    
-    desc.signature = this.signature;
-    desc.params = this.params;
-    
-    desc.returnType = this.returnType;
-    desc.viaProto = this.viaProto;
-    desc.funcClass = this.funcClass;
-    
-    return desc;
-  }
-
-  @Override
-  public FunctionDescProto getProto() {
-    mergeLocalToProto();
-    proto = viaProto ? proto : builder.build();
-    viaProto = true;
-    return proto;
-  }
-  
-  private void maybeInitBuilder() {
-    if (viaProto || builder == null) {
-      builder = FunctionDescProto.newBuilder(proto);
-    }
-    viaProto = false;
-  }
-  
-  private void mergeLocalToBuilder() {
-    if (this.signature  != null) {     
-      builder.setSignature(this.signature);
-    }
-    if (this.funcClass != null) {
-      builder.setClassName(this.funcClass.getName());
-    }
-    if (this.funcType != null) {
-      builder.setType(this.funcType);
-    }
-    if (this.returnType != null) {
-      builder.setReturnType(this.returnType[0]);
-    }
-    if (this.params != null) {
-      builder.addAllParameterTypes(Arrays.asList(params));
-    }
-  }
-  
-  private void mergeLocalToProto() {
-    if(viaProto) {
-      maybeInitBuilder();
-    }
-    mergeLocalToBuilder();
-    proto = builder.build();
-    viaProto = true;
-  }
-  
-  @SuppressWarnings("unchecked")
-  private void mergeProtoToLocal() throws InternalException {
-	  FunctionDescProtoOrBuilder p = viaProto ? proto : builder;
-	  if (signature == null && p.hasSignature()) {
-		  signature = p.getSignature();
-	  }
-	  if (funcClass == null && p.hasClassName()) {
-		  try {
-			  this.funcClass = 
-			      (Class<? extends GeneralFunction>)Class.forName(p.getClassName());
-		  } catch (ClassNotFoundException e) {
-			  throw new InternalException("The function class ("+p.getClassName()+") cannot be loaded");
-		  }
-	  }
-	  if (funcType == null && p.hasType()) {
-		  funcType = p.getType();
-	  }
-	  if (returnType == null && p.hasReturnType()) {
-		  returnType = newNoNameSchema(p.getReturnType());
-	  }
-	  if (params == null && p.getParameterTypesCount() > 0) {
-		  params = new DataType[p.getParameterTypesCount()];
-		  for (int i = 0; i < p.getParameterTypesCount(); i++) {
-			  params[i] = p.getParameterTypes(i);
-		  }
-	  }
-  }
-  
-  @Override
-  public String toString() {
-	  return getProto().toString();
-  }
-
-  @Override
-  public void initFromProto() {
-    try {
-      mergeProtoToLocal();
-    } catch (InternalException e) {
-      e.printStackTrace();
-    }
-  }
-  
-  public String toJSON() {
-    initFromProto();
-    Gson gson = GsonCreator.getInstance();
-    return gson.toJson(this, FunctionDesc.class);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/IndexDesc.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/IndexDesc.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/IndexDesc.java
deleted file mode 100644
index 9e7789b..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/IndexDesc.java
+++ /dev/null
@@ -1,265 +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.catalog;
-
-import com.google.common.base.Objects;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.annotations.Expose;
-import tajo.catalog.proto.CatalogProtos.IndexDescProto;
-import tajo.catalog.proto.CatalogProtos.IndexDescProtoOrBuilder;
-import tajo.catalog.proto.CatalogProtos.IndexMethod;
-import tajo.common.ProtoObject;
-
-public class IndexDesc implements ProtoObject<IndexDescProto>, Cloneable {
-  private IndexDescProto proto;
-  private IndexDescProto.Builder builder;
-  private boolean viaProto;
-  
-  @Expose private String name;
-  @Expose private String tableId;
-  @Expose private Column column;
-  @Expose private IndexMethod indexMethod;
-  @Expose private boolean isUnique = false;
-  @Expose private boolean isClustered = false;
-  @Expose private boolean isAscending = false;
-  
-  public IndexDesc() {
-    this.builder = IndexDescProto.newBuilder();
-  }
-  
-  public IndexDesc(String name, String tableId, Column column, IndexMethod type,
-      boolean isUnique, boolean isClustered, boolean isAscending) {
-    this();
-    this.name = name.toLowerCase();
-    this.tableId = tableId.toLowerCase();
-    this.column = column;
-    this.indexMethod = type;
-    this.isUnique = isUnique;
-    this.isClustered = isClustered;
-    this.isAscending = isAscending;
-  }
-  
-  public IndexDesc(IndexDescProto proto) {
-    this.proto = proto;
-    this.viaProto = true;
-  }
-  
-  public String getName() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.name != null) {
-      return name;
-    }
-    if (!p.hasName()) {
-      return null;
-    }
-    this.name = p.getName();
-    
-    return name;
-  }
-  
-  public String getTableId() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.tableId != null) {
-      return tableId;
-    }
-    if (!p.hasTableId()) {
-      return null;
-    }
-    this.tableId = p.getTableId();
-    
-    return tableId;
-  }
-  
-  public Column getColumn() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.column != null) {
-      return column;
-    }
-    if (!p.hasColumn()) {
-      return null;
-    }
-    this.column = new Column(p.getColumn());
-    
-    return column;
-  }
-  
-  public IndexMethod getIndexMethod() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;    
-    if (this.indexMethod != null) {
-      return this.indexMethod;
-    }
-    if (!p.hasIndexMethod()) { // if isCluster == false and proto has no set
-      return null;
-    }
-    this.indexMethod = p.getIndexMethod();
-    
-    return this.indexMethod;
-  }
-  
-  public boolean isClustered() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (isClustered) {
-      return true;
-    }
-    if (!p.hasIsClustered()) { // if isCluster == false and proto has no set
-      return false;
-    }
-    this.isClustered = p.getIsClustered();
-    
-    return this.isClustered;
-  }
-  
-  public boolean isUnique() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;    
-    if (isUnique) {
-      return true;
-    }
-    if (!p.hasIsUnique()) { // if isCluster == false and proto has no set
-      return false;
-    }
-    this.isUnique = p.getIsUnique();
-    
-    return this.isUnique;
-  }
-  
-  public boolean isAscending() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;    
-    if (isAscending) {
-      return true;
-    }
-    if (!p.hasIsAscending()) { // if isCluster == false and proto has no set
-      return false;
-    }
-    this.isAscending = p.getIsAscending();
-    
-    return this.isAscending;
-  }
-
-  @Override
-  public IndexDescProto getProto() {
-    if(!viaProto) {
-      mergeLocalToBuilder();
-      proto = builder.build();
-      viaProto = true;
-    }
-    
-    return proto;
-  }
-  
-  @SuppressWarnings("unused")
-  private void setModified() {
-    if (viaProto && builder == null) {
-      builder = IndexDescProto.newBuilder(proto);
-    }
-    viaProto = false;
-  }
-  
-  private void mergeLocalToBuilder() {
-    if (builder == null) {
-      builder = IndexDescProto.newBuilder(proto);
-    }
-    if (this.name != null) {
-      builder.setName(this.name);
-    }
-    if (this.tableId != null) {
-      builder.setTableId(this.tableId);
-    }
-    if (this.column != null) {
-      builder.setColumn(this.column.getProto());
-    }
-    if (this.indexMethod != null) {
-      builder.setIndexMethod(indexMethod);
-    }
-    if (this.isUnique) {
-      builder.setIsUnique(this.isUnique);
-    }
-    if (this.isClustered) {
-      builder.setIsClustered(this.isClustered);
-    }
-    if (this.isAscending) {
-      builder.setIsAscending(this.isAscending);
-    }
-  }
-  
-  @Override
-  public void initFromProto() {
-    IndexDescProtoOrBuilder p = viaProto ? proto : builder;
-    if (this.name == null && p.hasName()) {
-      this.name = p.getName();
-    }
-    if (this.tableId == null && p.hasTableId()) {
-      this.tableId = p.getTableId();
-    }
-    if (this.column == null && p.hasColumn()) {
-      this.column = new Column(p.getColumn());
-    }
-    if (this.indexMethod == null && p.hasIndexMethod()) {
-      this.indexMethod = p.getIndexMethod();
-    }
-    if (this.isUnique == false && p.hasIsUnique()) {
-      this.isUnique = p.getIsUnique();
-    }
-    if (this.isClustered == false && p.hasIsClustered()) {
-      this.isUnique = p.getIsUnique();
-    }
-    if (this.isAscending == false && p.hasIsAscending()) {
-      this.isAscending = p.getIsAscending();
-    }
-    viaProto = false;
-  }
-  
-  public boolean equals(Object obj) {
-    if (obj instanceof IndexDesc) {
-      IndexDesc other = (IndexDesc) obj;
-      return getName().equals(other.getName())
-          && getTableId().equals(other.getTableId())
-          && getColumn().equals(other.getColumn())
-          && getIndexMethod().equals(other.getIndexMethod())
-          && isUnique() == other.isUnique()
-          && isClustered() == other.isClustered()
-          && isAscending() == other.isAscending();
-    } else {
-      return false;
-    }
-  }
-  
-  public int hashCode() {
-    return Objects.hashCode(getName(), getTableId(), getColumn(), 
-        getIndexMethod(), isUnique(), isClustered(), isAscending());
-  }
-  
-  public Object clone() throws CloneNotSupportedException {
-    IndexDesc desc = (IndexDesc) super.clone();
-    initFromProto();
-    desc.name = name;
-    desc.tableId = tableId;
-    desc.column = (Column) column.clone();
-    desc.indexMethod = indexMethod;
-    desc.isUnique = isUnique;
-    desc.isClustered = isClustered;
-    desc.isAscending = isAscending;
-    return desc; 
-  }
-  
-  public String toString() {
-    Gson gson = new GsonBuilder().setPrettyPrinting().create();
-    return gson.toJson(this);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Options.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Options.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Options.java
deleted file mode 100644
index 9422d78..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Options.java
+++ /dev/null
@@ -1,180 +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.catalog;
-
-import com.google.common.collect.Maps;
-import com.google.gson.annotations.Expose;
-import tajo.catalog.json.GsonCreator;
-import tajo.catalog.proto.CatalogProtos.KeyValueProto;
-import tajo.catalog.proto.CatalogProtos.KeyValueSetProto;
-import tajo.catalog.proto.CatalogProtos.KeyValueSetProtoOrBuilder;
-import tajo.common.ProtoObject;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-public class Options implements ProtoObject<KeyValueSetProto>, Cloneable {
-	@Expose(serialize=false,deserialize=false)
-	private KeyValueSetProto proto = KeyValueSetProto.getDefaultInstance();
-	@Expose(serialize=false,deserialize=false)
-	private KeyValueSetProto.Builder builder = null;
-	@Expose(serialize=false,deserialize=false)
-	private boolean viaProto = false;
-	
-	@Expose private Map<String,String> keyVals;
-	
-	public Options() {
-		builder = KeyValueSetProto.newBuilder();
-	}
-	
-	public Options(KeyValueSetProto proto) {
-		this.proto = proto;
-		viaProto = true;
-	}
-	
-	public Options(Options options) {
-	  this();
-	  options.initFromProto();
-	  this.keyVals = Maps.newHashMap(options.keyVals);
-	}
-	
-	public static Options create() {
-	  return new Options();
-	}
-	
-	public static Options create(Options options) {
-    return new Options(options);
-  }
-	
-	public void put(String key, String val) {
-		initOptions();
-		setModified();
-		this.keyVals.put(key, val);
-	}
-	
-	public void putAll(Options options) {
-	  initOptions();
-	  setModified();
-	  this.keyVals.putAll(options.keyVals);
-	}
-	
-	public String get(String key) {
-		initOptions();
-		return this.keyVals.get(key);
-	}
-	
-	public String get(String key, String defaultVal) {
-	  initOptions();
-	  if(keyVals.containsKey(key))
-	    return keyVals.get(key);
-	  else {
-	    return defaultVal;
-	  }
-	}
-	
-	public Iterator<Entry<String,String>> getAllKeyValus() {
-	  initOptions();
-	  return keyVals.entrySet().iterator();
-	}
-	
-	public String delete(String key) {
-		initOptions();
-		return keyVals.remove(key);
-	}
-	
-	@Override
-	public boolean equals(Object object) {
-		if(object instanceof Options) {
-			Options other = (Options)object;
-			initOptions();
-			other.initOptions();
-			for(Entry<String, String> entry : other.keyVals.entrySet()) {
-				if(!keyVals.get(entry.getKey()).equals(entry.getValue()))
-					return false;
-			}
-			return true;
-		}
-		
-		return false;
-	}
-	
-	@Override
-  public Object clone() throws CloneNotSupportedException {    
-    Options options = (Options) super.clone();
-    initFromProto();
-    options.proto = null;
-    options.viaProto = false;
-    options.builder = KeyValueSetProto.newBuilder();
-    options.keyVals = keyVals != null ? new HashMap<String, String>(keyVals) :
-      null;    
-    return options;
-	}
-	
-	@Override
-	public KeyValueSetProto getProto() {
-	  if(!viaProto) {
-      mergeLocalToBuilder();
-      proto = builder.build();
-      viaProto = true;
-    }	  
-		return proto;
-	}
-	
-	private void initOptions() {
-		if (this.keyVals != null) {
-			return;
-		}
-		KeyValueSetProtoOrBuilder p = viaProto ? proto : builder;
-		this.keyVals = Maps.newHashMap();
-		for(KeyValueProto keyval:p.getKeyvalList()) {
-			this.keyVals.put(keyval.getKey(), keyval.getValue());
-		}		
-	}
-	
-	private void setModified() {
-		if (viaProto || builder == null) {
-			builder = KeyValueSetProto.newBuilder(proto);
-		}
-		viaProto = false;
-	}
-	
-	private void mergeLocalToBuilder() {
-		KeyValueProto.Builder kvBuilder = null;
-		if(this.keyVals != null) {
-			for(Entry<String,String> kv : keyVals.entrySet()) {
-				kvBuilder = KeyValueProto.newBuilder();
-				kvBuilder.setKey(kv.getKey());
-				kvBuilder.setValue(kv.getValue());
-				builder.addKeyval(kvBuilder.build());
-			}
-		}
-	}
-
-  @Override
-  public void initFromProto() {
-    initOptions();
-  }
-  
-  public String toJSON() {
-    initFromProto();
-    return GsonCreator.getInstance().toJson(this, Options.class);
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Schema.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Schema.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Schema.java
deleted file mode 100644
index d11170d..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/Schema.java
+++ /dev/null
@@ -1,253 +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.catalog;
-
-import com.google.gson.Gson;
-import com.google.gson.annotations.Expose;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import tajo.catalog.exception.AlreadyExistsFieldException;
-import tajo.catalog.json.GsonCreator;
-import tajo.catalog.proto.CatalogProtos.ColumnProto;
-import tajo.catalog.proto.CatalogProtos.SchemaProto;
-import tajo.catalog.proto.CatalogProtos.SchemaProtoOrBuilder;
-import tajo.common.ProtoObject;
-import tajo.common.TajoDataTypes.DataType;
-import tajo.common.TajoDataTypes.Type;
-
-import java.util.*;
-
-public class Schema implements ProtoObject<SchemaProto>, Cloneable {
-  private static final Log LOG = LogFactory.getLog(Schema.class);
-  
-	private SchemaProto proto = SchemaProto.getDefaultInstance();
-	private	SchemaProto.Builder builder = null;
-	boolean viaProto = false;
-
-	@Expose
-	protected List<Column> fields = null;
-	@Expose
-	protected Map<String,Integer> fieldsByName = null;
-
-	public Schema() {
-		builder = SchemaProto.newBuilder();
-	}
-	
-	public Schema(SchemaProto proto) {
-    this.proto = proto;
-    this.viaProto = true;
-  }
-
-	public Schema(Schema schema) {
-	  this();
-		this.fields = new ArrayList<Column>(schema.fields);
-		this.fieldsByName = new HashMap<String, Integer>(schema.fieldsByName);
-	}
-	
-	public Schema(Column [] columns) {
-    this();
-    for(Column c : columns) {
-      addColumn(c);
-    }
-  }
-	
-	public int getColumnNum() {
-		initColumns();
-		return this.fields.size();
-	}
-
-	public Column getColumn(String colName) {
-		initColumns();
-		Integer cid = fieldsByName.get(colName.toLowerCase());
-		return cid != null ? fields.get(cid) : null;
-	}
-	
-	public Column getColumnByName(String colName) {
-	  initColumns();
-	  for (Column col : fields) {
-	    if (col.getColumnName().equals(colName.toLowerCase())) {
-	      return col;
-	    }
-	  }
-	  return null;
-	}
-	
-	public Column getColumn(int id) {
-	  initColumns();
-	  return fields.get(id);
-	}
-	
-	public int getColumnId(String colName) {
-	  initColumns();
-	  return fieldsByName.get(colName.toLowerCase());
-	}
-
-  public int getColumnIdByName(String colName) {
-    initColumns();
-    for (Column col : fields) {
-      if (col.getColumnName().equals(colName.toLowerCase())) {
-        return fieldsByName.get(col.getQualifiedName());
-      }
-    }
-    return -1;
-  }
-	
-	public Collection<Column> getColumns() {
-		initColumns();
-		return fields;
-	}
-	
-	public void alter(int idx, Column column) {
-	  initColumns();
-	  this.fields.set(idx, column);
-	}
-	
-	public boolean contains(String colName) {
-		initColumns();
-		return fieldsByName.containsKey(colName.toLowerCase());
-	}
-	
-	public void initFromProto() {
-		initColumns();
-		for (Column col : fields) {
-		  col.initFromProto();
-		}
-	}
-
-	private void initColumns() {
-		if (this.fields != null) {
-			return;
-		}
-		SchemaProtoOrBuilder p = viaProto ? proto : builder;
-		this.fields = new ArrayList<Column>();
-		this.fieldsByName = new HashMap<String, Integer>();
-		for(ColumnProto colProto : p.getFieldsList()) {
-			fields.add(new Column(colProto));
-			fieldsByName.put(colProto.getColumnName(), fields.size() - 1);
-		}
-	}
-
-  public synchronized Schema addColumn(String name, Type type) {
-    return addColumn(name, CatalogUtil.newDataTypeWithoutLen(type));
-  }
-
-  public synchronized Schema addColumn(String name, DataType dataType) {
-		initColumns();
-		setModified();
-		String lowcased = name.toLowerCase();
-		if(fieldsByName.containsKey(lowcased)) {
-		  LOG.error("Already exists column " + lowcased);
-			throw new AlreadyExistsFieldException(lowcased);
-		}
-			
-		Column newCol = new Column(lowcased, dataType);
-		fields.add(newCol);
-		fieldsByName.put(lowcased, fields.size() - 1);
-		
-		return this;
-	}
-	
-	public synchronized void addColumn(Column column) {
-		addColumn(column.getQualifiedName(), column.getDataType());		
-	}
-	
-	public synchronized void addColumns(Schema schema) {
-    for(Column column : schema.getColumns()) {
-      addColumn(column);
-    }
-  }
-
-	@Override
-	public boolean equals(Object o) {
-		if (o instanceof Schema) {
-		  Schema other = (Schema) o;
-		  return getProto().equals(other.getProto());
-		}
-		return false;
-	}
-	
-  @Override
-  public Object clone() throws CloneNotSupportedException {
-    Schema schema = (Schema) super.clone();
-    initFromProto();
-    schema.viaProto = false;
-    schema.builder = SchemaProto.newBuilder();
-    schema.fields = fields != null ? new ArrayList<Column>(fields) : null;
-    schema.fieldsByName = fieldsByName != null ? new HashMap<String, Integer>(fieldsByName) : null;
-
-    return schema;
-  }
-
-	@Override
-	public SchemaProto getProto() {
-	  if(!viaProto) {
-      mergeLocalToBuilder();
-      proto = builder.build();
-      viaProto = true;
-    }
-	  
-		return proto;
-	}
-
-	private void setModified() {
-		viaProto = false;
-	}
-
-	private void mergeLocalToBuilder() {
-	  if (builder == null) {
-	    builder = SchemaProto.newBuilder(proto);
-	  } else {	  
-	    builder.clearFields();
-	  }
-	  
-		if (this.fields  != null) {			
-			for(Column col : fields) {
-				builder.addFields(col.getProto());
-			}
-		}
-	}
-
-	public String toString() {
-	  initColumns();
-	  StringBuilder sb = new StringBuilder();
-	  sb.append("{");
-	  int i = 0;
-	  for(Column col : fields) {
-	    sb.append(col);
-	    if (i < fields.size() - 1) {
-	      sb.append(",");
-	    }
-	    i++;
-	  }
-	  sb.append("}");
-	  
-	  return sb.toString();
-	}
-	
-	public String toJson() {
-	  initFromProto();
-	  Gson gson = GsonCreator.getInstance();
-	  return gson.toJson(this, Schema.class);
-		
-	}
-
-  public Column [] toArray() {
-    return this.fields.toArray(new Column[this.fields.size()]);
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SchemaObject.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SchemaObject.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SchemaObject.java
deleted file mode 100644
index dbf52c1..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SchemaObject.java
+++ /dev/null
@@ -1,23 +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.catalog;
-
-public interface SchemaObject {
-	public Schema getSchema();
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SortSpec.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SortSpec.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SortSpec.java
deleted file mode 100644
index bea4e34..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/SortSpec.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.catalog;
-
-import com.google.gson.annotations.Expose;
-import tajo.catalog.json.GsonCreator;
-
-public class SortSpec implements Cloneable {
-  @Expose
-  private Column sortKey;
-  @Expose private boolean ascending = true;
-  @Expose private boolean nullFirst = false;
-
-  public SortSpec(final Column sortKey) {
-    this.sortKey = sortKey;
-  }
-
-  /**
-   *
-   * @param sortKey columns to sort
-   * @param asc true if the sort order is ascending order
-   * @param nullFirst
-   * Otherwise, it should be false.
-   */
-  public SortSpec(final Column sortKey, final boolean asc,
-                  final boolean nullFirst) {
-    this(sortKey);
-    this.ascending = asc;
-    this.nullFirst = nullFirst;
-  }
-
-  public final boolean isAscending() {
-    return this.ascending;
-  }
-
-  public final void setDescOrder() {
-    this.ascending = false;
-  }
-
-  public final boolean isNullFirst() {
-    return this.nullFirst;
-  }
-
-  public final void setNullFirst() {
-    this.nullFirst = true;
-  }
-
-  public final Column getSortKey() {
-    return this.sortKey;
-  }
-
-  @Override
-  public Object clone() throws CloneNotSupportedException {
-    SortSpec key = (SortSpec) super.clone();
-    key.sortKey = (Column) sortKey.clone();
-    key.ascending = ascending;
-
-    return key;
-  }
-
-  public String toJSON() {
-    sortKey.initFromProto();
-    return GsonCreator.getInstance().toJson(this);
-  }
-
-  public String toString() {
-    return "Sortkey (key="+sortKey
-        + " "+(ascending ? "asc" : "desc")+")";
-  }
-}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDesc.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDesc.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDesc.java
deleted file mode 100644
index 6692c21..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDesc.java
+++ /dev/null
@@ -1,44 +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.catalog;
-
-import com.google.protobuf.Message;
-import org.apache.hadoop.fs.Path;
-
-public interface TableDesc extends Cloneable {
-  void setId(String tableId);
-  
-  String getId();
-  
-  void setPath(Path path);
-  
-  Path getPath();
-  
-  void setMeta(TableMeta info);
-  
-  TableMeta getMeta();
-  
-  Message getProto();
-  
-  void initFromProto();
-  
-  String toJSON();
- 
-  Object clone() throws CloneNotSupportedException;
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDescImpl.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDescImpl.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDescImpl.java
deleted file mode 100644
index fc776e2..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableDescImpl.java
+++ /dev/null
@@ -1,214 +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.catalog;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.annotations.Expose;
-import org.apache.hadoop.fs.Path;
-import tajo.catalog.json.GsonCreator;
-import tajo.catalog.proto.CatalogProtos.StoreType;
-import tajo.catalog.proto.CatalogProtos.TableDescProto;
-import tajo.catalog.proto.CatalogProtos.TableDescProtoOrBuilder;
-import tajo.common.ProtoObject;
-
-public class TableDescImpl implements TableDesc, ProtoObject<TableDescProto>,
-    Cloneable {
-  protected TableDescProto proto = TableDescProto.getDefaultInstance();
-  protected TableDescProto.Builder builder = null;
-  protected boolean viaProto = false;
-  
-	@Expose protected String tableId;
-	@Expose protected Path uri;
-	@Expose protected TableMeta meta;
-  
-	public TableDescImpl() {
-		builder = TableDescProto.newBuilder();
-	}
-	
-	public TableDescImpl(String tableId, TableMeta info, Path path) {
-		this();
-		// tajo deems all identifiers as lowcase characters
-	  this.tableId = tableId.toLowerCase();
-	  this.meta = info;
-	  this.uri = path;	   
-	}
-	
-	public TableDescImpl(String tableId, Schema schema, StoreType type, 
-	    Options options, Path path) {
-	  this(tableId, new TableMetaImpl(schema, type, options), path);
-	}
-	
-	public TableDescImpl(TableDescProto proto) {
-	  this.proto = proto;
-	  viaProto = true;
-	}
-	
-	public void setId(String tableId) {
-	  setModified();
-	  // tajo deems all identifiers as lowcase characters
-		this.tableId = tableId.toLowerCase();
-	}
-	
-  public String getId() {
-    TableDescProtoOrBuilder p = viaProto ? proto : builder;
-    
-    if (tableId != null) {
-      return this.tableId;
-    }
-    if (!p.hasId()) {
-      return null;
-    }
-    this.tableId = p.getId();
-    
-    return this.tableId;
-  }
-	
-	public void setPath(Path uri) {
-	  setModified();
-		this.uri = uri;
-	}
-	
-  public Path getPath() {
-    TableDescProtoOrBuilder p = viaProto ? proto : builder;
-    
-    if (uri != null) {
-      return this.uri;
-    }
-    if (!proto.hasPath()) {
-      return null;
-    }
-    this.uri = new Path(p.getPath());
-    
-    return this.uri;
-  }
-  
-  @Override
-  public void setMeta(TableMeta info) {
-    setModified();
-    this.meta = info;
-  }
-	
-	public TableMeta getMeta() {
-	  TableDescProtoOrBuilder p = viaProto ? proto : builder;
-    
-    if (meta != null) {
-      return this.meta;
-    }
-    if (!p.hasMeta()) {
-      return null;
-    }
-    this.meta = new TableMetaImpl(p.getMeta());
-	  return this.meta;
-	}
-	
-  public Schema getSchema() {
-    return getMeta().getSchema();
-  }
-	
-	public boolean equals(Object object) {
-    if(object instanceof TableDescImpl) {
-      TableDescImpl other = (TableDescImpl) object;
-      
-      return this.getProto().equals(other.getProto());
-    }
-    
-    return false;   
-  }
-	
-	public Object clone() throws CloneNotSupportedException {	  
-	  TableDescImpl desc = (TableDescImpl) super.clone();
-	  initFromProto();
-	  desc.proto = null;
-	  desc.builder = TableDescProto.newBuilder();
-	  desc.viaProto = false;
-	  desc.tableId = tableId;
-	  desc.uri = uri;
-	  desc.meta = (TableMeta) meta.clone();
-	  
-	  return desc;
-	}
-	
-	public String toString() {
-	  Gson gson = new GsonBuilder().setPrettyPrinting().
-	      excludeFieldsWithoutExposeAnnotation().create();
-    return gson.toJson(this);
-	}
-	
-	public String toJSON() {
-		initFromProto();
-		Gson gson = GsonCreator.getInstance();
-		
-		return gson.toJson(this, TableDesc.class);
-	}
-
-  public TableDescProto getProto() {
-    if(!viaProto) {
-      mergeLocalToBuilder();
-      proto = builder.build();
-      viaProto = true;
-    }
-    
-    return proto;
-  }
-  
-  private void setModified() {
-    if (viaProto && builder == null) {
-      builder = TableDescProto.newBuilder(proto);
-    }
-    viaProto = false;
-  }
-  
-  protected void mergeLocalToBuilder() {
-    if (builder == null) {
-      builder = TableDescProto.newBuilder(proto);
-    }
-    
-    if (this.tableId != null) {
-      builder.setId(this.tableId);
-    }
-    
-    if (this.uri != null) {
-      builder.setPath(this.uri.toString());
-    }
-    
-    if (this.meta != null) {
-      builder.setMeta(meta.getProto());
-    }
-  }
-  
-  private void mergeProtoToLocal() {
-	  TableDescProtoOrBuilder p = viaProto ? proto : builder;
-	  if (tableId == null && p.hasId()) {
-		  tableId = p.getId();
-	  }
-	  if (uri == null && p.hasPath()) {
-		  uri = new Path(p.getPath());
-	  }
-	  if (meta == null && p.hasMeta()) {
-		  meta = new TableMetaImpl(p.getMeta());
-	  }
-  }
-
-  @Override
-  public void initFromProto() {
-	  mergeProtoToLocal();
-    meta.initFromProto();
-  }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/bc6359b8/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableMeta.java
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableMeta.java b/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableMeta.java
deleted file mode 100644
index 14938ae..0000000
--- a/tajo-catalog/tajo-catalog-common/src/main/java/tajo/catalog/TableMeta.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.catalog;
-
-import tajo.catalog.proto.CatalogProtos.StoreType;
-import tajo.catalog.proto.CatalogProtos.TableProto;
-import tajo.catalog.statistics.TableStat;
-import tajo.common.ProtoObject;
-
-import java.util.Iterator;
-import java.util.Map.Entry;
-
-public interface TableMeta extends ProtoObject<TableProto>, Cloneable {
-  
-  void setStorageType(StoreType storeType);
-  
-  StoreType getStoreType();
-  
-  void setSchema(Schema schema);
-  
-  Schema getSchema();
-  
-  void putOption(String key, String val);
-  
-  void setStat(TableStat stat);
-  
-  String getOption(String key);
-  
-  String getOption(String key, String defaultValue);
-  
-  Iterator<Entry<String,String>> getOptions();
-  
-  TableStat getStat();
-  
-  Object clone() throws CloneNotSupportedException;
-  
-  public String toJSON();
-}