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/05/09 07:46:45 UTC

[2/2] git commit: TAJO-57: Recognize Parser and Catalog Standard SQL data types. (adding missed files)

TAJO-57: Recognize Parser and Catalog Standard SQL data types. (adding missed files)


Project: http://git-wip-us.apache.org/repos/asf/incubator-tajo/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tajo/commit/0652815f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tajo/tree/0652815f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tajo/diff/0652815f

Branch: refs/heads/master
Commit: 0652815f5e8d1f0e0b571539c5f20de545c2e03d
Parents: c1c6f83
Author: Hyunsik Choi <hy...@apache.org>
Authored: Thu May 9 14:45:46 2013 +0900
Committer: Hyunsik Choi <hy...@apache.org>
Committed: Thu May 9 14:45:46 2013 +0900

----------------------------------------------------------------------
 .../src/main/proto/DataTypes.proto                 |   74 ++++
 .../src/main/proto/DataTypes.proto                 |   74 ++++
 tajo-common/src/main/java/tajo/datum/BitDatum.java |  134 +++++++
 .../src/main/java/tajo/datum/BlobDatum.java        |  163 +++++++++
 .../src/main/java/tajo/datum/BooleanDatum.java     |  173 +++++++++
 .../src/main/java/tajo/datum/Float4Datum.java      |  279 ++++++++++++++
 .../src/main/java/tajo/datum/Float8Datum.java      |  271 ++++++++++++++
 .../src/main/java/tajo/datum/Inet4Datum.java       |  138 +++++++
 .../src/main/java/tajo/datum/Int2Datum.java        |  269 ++++++++++++++
 .../src/main/java/tajo/datum/Int4Datum.java        |  274 ++++++++++++++
 .../src/main/java/tajo/datum/Int8Datum.java        |  280 +++++++++++++++
 .../src/main/java/tajo/datum/TextDatum.java        |  146 ++++++++
 .../src/main/java/tajo/gson/DataTypeAdapter.java   |   64 ++++
 tajo-common/src/main/proto/DataTypes.proto         |   74 ++++
 .../src/test/java/tajo/datum/TestBitDatum.java     |   76 ++++
 .../src/test/java/tajo/datum/TestFloat8Datum.java  |   70 ++++
 .../src/test/java/tajo/datum/TestInet4Datum.java   |   75 ++++
 .../src/test/java/tajo/datum/TestInt2Datum.java    |   70 ++++
 .../src/test/java/tajo/datum/TestInt4Datum.java    |   70 ++++
 .../src/test/java/tajo/datum/TestInt8Datum.java    |   70 ++++
 .../src/test/java/tajo/datum/TestTextDatum.java    |   70 ++++
 .../src/main/proto/DataTypes.proto                 |   74 ++++
 .../src/main/proto/DataTypes.proto                 |   74 ++++
 23 files changed, 3062 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-catalog/tajo-catalog-client/src/main/proto/DataTypes.proto
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-client/src/main/proto/DataTypes.proto b/tajo-catalog/tajo-catalog-client/src/main/proto/DataTypes.proto
new file mode 100644
index 0000000..c8b18cb
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-client/src/main/proto/DataTypes.proto
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+option java_package = "tajo.common";
+option java_outer_classname = "TajoDataTypes";
+option optimize_for = SPEED;
+option java_generic_services = false;
+option java_generate_equals_and_hash = true;
+
+enum Type {
+  // SQL Standard Data Type
+  BOOLEAN = 0; // state of true of false [1 byte]
+
+  INT1 = 1; // tinyint [1 byte] [0-255]
+  INT2 = 2; // smallint [2 bytes] [-2^15(-32,768) ~ 2^15-1(32,767)]
+  INT4 = 3; // int [4 bytes] [-2^31(-2,147,483,648) ~ 2^31-1(2,147,483,647)]
+  INT8 = 4; // bigint [8 bytes] [-2^63(-9,223,372,036,854,775,808) ~ 2^63-1(9,223,372,036,854,775,807)]
+
+  FLOAT4 = 10; // variable-precision, inexact [4 bytes]
+  FLOAT8 = 11; // variable-precision, inexact [8 bytes]
+
+  NUMERIC = 15; // variable length
+  DECIMAL = 16; // variable length  
+
+  CHAR = 20; // fixed-width n-character string
+  NCHAR = 21; // fixed width string supporting an international character set
+  VARCHAR = 22; // variable-width string
+  NVARCHAR = 23; // variable-width NCHAR string
+  TEXT = 24; // variable unlimited length
+
+  DATE = 30;
+  TIME = 31;
+  TIMEZ = 32;
+  TIMESTAMP = 33;
+  TIMESTAMPZ = 34;
+  INTERVAL = 35;
+
+  BIT = 40; // fixed-width bits. BIT without the length L means a single bit. It can be used for boolean type.
+  VARBIT = 41; // variable-width bits
+
+  BINARY = 45; // fixed-width binary strings. BINARY without the length L means a single byte.
+  VARBINARY = 46; // variable-width binary strings
+  BLOB = 47;
+
+  UDT = 51; // user-defined function
+
+  ANY = 61;
+  ARRAY = 62;
+  INET4 = 100;
+  INET6 = 101;
+
+  // Extended Data Type (Reserved 128 ~ 255)
+}
+
+message DataType {
+  required Type type = 1;
+  optional int32 length = 2;
+  optional string code = 3;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-catalog/tajo-catalog-common/src/main/proto/DataTypes.proto
----------------------------------------------------------------------
diff --git a/tajo-catalog/tajo-catalog-common/src/main/proto/DataTypes.proto b/tajo-catalog/tajo-catalog-common/src/main/proto/DataTypes.proto
new file mode 100644
index 0000000..c8b18cb
--- /dev/null
+++ b/tajo-catalog/tajo-catalog-common/src/main/proto/DataTypes.proto
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+option java_package = "tajo.common";
+option java_outer_classname = "TajoDataTypes";
+option optimize_for = SPEED;
+option java_generic_services = false;
+option java_generate_equals_and_hash = true;
+
+enum Type {
+  // SQL Standard Data Type
+  BOOLEAN = 0; // state of true of false [1 byte]
+
+  INT1 = 1; // tinyint [1 byte] [0-255]
+  INT2 = 2; // smallint [2 bytes] [-2^15(-32,768) ~ 2^15-1(32,767)]
+  INT4 = 3; // int [4 bytes] [-2^31(-2,147,483,648) ~ 2^31-1(2,147,483,647)]
+  INT8 = 4; // bigint [8 bytes] [-2^63(-9,223,372,036,854,775,808) ~ 2^63-1(9,223,372,036,854,775,807)]
+
+  FLOAT4 = 10; // variable-precision, inexact [4 bytes]
+  FLOAT8 = 11; // variable-precision, inexact [8 bytes]
+
+  NUMERIC = 15; // variable length
+  DECIMAL = 16; // variable length  
+
+  CHAR = 20; // fixed-width n-character string
+  NCHAR = 21; // fixed width string supporting an international character set
+  VARCHAR = 22; // variable-width string
+  NVARCHAR = 23; // variable-width NCHAR string
+  TEXT = 24; // variable unlimited length
+
+  DATE = 30;
+  TIME = 31;
+  TIMEZ = 32;
+  TIMESTAMP = 33;
+  TIMESTAMPZ = 34;
+  INTERVAL = 35;
+
+  BIT = 40; // fixed-width bits. BIT without the length L means a single bit. It can be used for boolean type.
+  VARBIT = 41; // variable-width bits
+
+  BINARY = 45; // fixed-width binary strings. BINARY without the length L means a single byte.
+  VARBINARY = 46; // variable-width binary strings
+  BLOB = 47;
+
+  UDT = 51; // user-defined function
+
+  ANY = 61;
+  ARRAY = 62;
+  INET4 = 100;
+  INET6 = 101;
+
+  // Extended Data Type (Reserved 128 ~ 255)
+}
+
+message DataType {
+  required Type type = 1;
+  optional int32 length = 2;
+  optional string code = 3;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/BitDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/BitDatum.java b/tajo-common/src/main/java/tajo/datum/BitDatum.java
new file mode 100644
index 0000000..5fd9ecd
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/BitDatum.java
@@ -0,0 +1,134 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.common.TajoDataTypes;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+public class BitDatum extends Datum {
+  private static final int size = 1;
+  @Expose	byte val;
+	
+	public BitDatum() {
+		super(TajoDataTypes.Type.BIT);
+	}
+	
+	public BitDatum(byte val) {
+		this();
+		this.val = val;
+	}
+
+  public BitDatum(byte[] bytes) {
+    this(bytes[0]);
+  }
+
+  @Override
+  public char asChar() {
+    return (char)val;
+  }
+
+	@Override
+	public int asInt4() {
+		return val;
+	}
+
+  @Override
+	public long asInt8() {
+		return val;
+	}
+
+  @Override
+	public byte asByte() {
+		return val;
+	}
+
+  @Override
+	public byte[] asByteArray() {
+    byte [] bytes = new byte[1];
+    bytes[0] = this.val;
+		return bytes;
+	}
+
+  @Override
+	public float asFloat4() {
+		return val;
+	}
+
+  @Override
+	public double asFloat8() {
+		return val;
+	}
+
+  @Override
+	public String asChars() {
+		return "0x"+val;
+	}
+	
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+    return size;
+  }
+  
+  @Override
+  public int hashCode() {
+    return val;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof BitDatum) {
+      BitDatum other = (BitDatum) obj;
+      return val == other.val;
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+    case BIT:
+      return DatumFactory.createBool(this.val == (((BitDatum) datum).val));
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+  
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+    case BIT:
+      if (val < datum.asByte() ) {
+        return -1;
+      } else if (val > datum.asByte()) {
+        return 1;
+      } else {
+        return 0;
+      }
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/BlobDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/BlobDatum.java b/tajo-common/src/main/java/tajo/datum/BlobDatum.java
new file mode 100644
index 0000000..5f3ad2d
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/BlobDatum.java
@@ -0,0 +1,163 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.util.Arrays;
+
+import static tajo.common.TajoDataTypes.Type.BLOB;
+
+public class BlobDatum extends Datum {
+	@Expose private byte [] val;
+	private ByteBuffer bb = null;
+
+	public BlobDatum() {
+		super(BLOB);
+	}
+	
+	public BlobDatum(byte[] val) {
+		this();
+		this.val = val;
+		this.bb = ByteBuffer.wrap(val);	
+		bb.flip();
+	}
+	
+	public BlobDatum(ByteBuffer val) {
+		this();
+		this.val = val.array();
+		this.bb = val.duplicate();
+		bb.flip();
+	}
+	
+	public void initFromBytes() {
+		if (bb == null) {
+			bb = ByteBuffer.wrap(val);
+		}
+	}
+
+  @Override
+	public int asInt4() {
+		initFromBytes();
+		bb.rewind();
+		return bb.getInt();
+	}
+
+  @Override
+	public long asInt8() {
+		initFromBytes();
+		bb.rewind();
+		return bb.getLong();
+	}
+
+  @Override
+	public byte asByte() {
+		initFromBytes();
+		bb.rewind();
+		return bb.get();
+	}
+
+  @Override
+	public byte[] asByteArray() {
+		initFromBytes();
+		bb.rewind();
+		return bb.array();
+	}
+
+  @Override
+	public float asFloat4() {
+		initFromBytes();
+		bb.rewind();
+		return bb.getFloat();
+	}
+
+  @Override
+	public double asFloat8() {
+		initFromBytes();
+		bb.rewind();
+		return bb.getDouble();
+	}
+
+  @Override
+	public String asChars() {
+		initFromBytes();
+		bb.rewind();
+		return new String(bb.array(), Charset.defaultCharset());
+	}
+
+  @Override
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+	  return this.val.length;
+  }
+  
+  @Override
+  public int hashCode() {
+	  initFromBytes();
+	  bb.rewind();
+    return bb.hashCode();
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof BlobDatum) {
+      BlobDatum other = (BlobDatum) obj;
+      initFromBytes();
+      other.initFromBytes();
+      return bb.equals(other.bb);
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+    case BLOB:
+    	initFromBytes();
+    	((BlobDatum)datum).initFromBytes();
+      return DatumFactory.createBool(Arrays.equals(this.val, ((BlobDatum)datum).val));
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+    case BLOB:
+    	initFromBytes();
+    	((BlobDatum)datum).initFromBytes();
+      return bb.compareTo(((BlobDatum) datum).bb);
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/BooleanDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/BooleanDatum.java b/tajo-common/src/main/java/tajo/datum/BooleanDatum.java
new file mode 100644
index 0000000..f936d05
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/BooleanDatum.java
@@ -0,0 +1,173 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.common.TajoDataTypes;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+public class BooleanDatum extends Datum {
+	@Expose private boolean val;
+
+  public BooleanDatum() {
+    super(TajoDataTypes.Type.BOOLEAN);
+  }
+
+	public BooleanDatum(boolean val) {
+		this();
+		this.val = val;
+	}
+
+  public BooleanDatum(byte byteVal) {
+    this();
+    this.val = byteVal == 1;
+  }
+
+  public BooleanDatum(int byteVal) {
+    this();
+    this.val = byteVal == 1;
+  }
+
+
+  public BooleanDatum(byte[] bytes) {
+    this(bytes[0]);
+  }
+	
+	public boolean asBool() {
+		return val;
+	}
+
+  public void setValue(boolean val) {
+    this.val = val;
+  }
+	
+	@Override
+	public short asInt2() {
+		return (short) (val ? 1 : 0);
+	}
+
+	/* (non-Javadoc)
+	 * @see nta.common.datum.Datum#asInt()
+	 */
+	@Override
+	public int asInt4() {
+		return val ? 1 : 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see nta.common.datum.Datum#asLong()
+	 */
+	@Override
+	public long asInt8() {
+		return val ? 1 : 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see nta.common.datum.Datum#asByte()
+	 */
+	@Override
+	public byte asByte() {
+		return (byte) (val ? 0x01 : 0x00);
+	}
+
+	/* (non-Javadoc)
+	 * @see nta.common.datum.Datum#asByteArray()
+	 */
+	@Override
+	public byte[] asByteArray() {
+	  byte [] bytes = new byte[1];
+    bytes[0] = asByte();
+	  return bytes;
+	}
+
+	/* (non-Javadoc)
+	 * @see nta.common.datum.Datum#asFloat()
+	 */
+	@Override
+	public float asFloat4() {
+		return val ? 1 : 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see nta.common.datum.Datum#asDouble()
+	 */
+	@Override
+	public double asFloat8() {
+		return val ? 1 : 0;
+	}
+
+	/* (non-Javadoc)
+	 * @see nta.common.datum.Datum#asChars()
+	 */
+	@Override
+	public String asChars() {
+		return val ? "true" : "false";
+	}
+	
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+    return 1;
+  }
+  
+  @Override
+  public int hashCode() {
+    return val ? 7907 : 0; // 7907 is one of the prime numbers
+  }
+  
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof BooleanDatum) {
+      BooleanDatum other = (BooleanDatum) obj;
+      return val == other.val;
+    }
+    
+    return false;
+  }
+  
+  // Datum Comparator
+  public BooleanDatum equalsTo(Datum datum) {
+    switch(datum.type()) {
+      case BOOLEAN: return DatumFactory.createBool(this.val == 
+          ((BooleanDatum)datum).val);
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+    case BOOLEAN:
+      if (val && !datum.asBool()) {
+        return -1;
+      } else if (val && datum.asBool()) {
+        return 1;
+      } else {
+        return 0;
+      }
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/Float4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/Float4Datum.java b/tajo-common/src/main/java/tajo/datum/Float4Datum.java
new file mode 100644
index 0000000..f3d2eb4
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/Float4Datum.java
@@ -0,0 +1,279 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.common.TajoDataTypes;
+import tajo.datum.exception.InvalidCastException;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import java.nio.ByteBuffer;
+
+public class Float4Datum extends NumericDatum {
+  private static final int size = 4;
+  @Expose float val;
+
+	public Float4Datum() {
+		super(TajoDataTypes.Type.FLOAT4);
+	}
+	
+	public Float4Datum(float val) {
+		this();
+		this.val = val;
+	}
+
+  public Float4Datum(byte[] bytes) {
+    this();
+    ByteBuffer bb = ByteBuffer.wrap(bytes);
+    this.val = bb.getFloat();
+  }
+	
+	public boolean asBool() {
+		throw new InvalidCastException();
+	}
+	
+	@Override
+	public short asInt2() {
+		return (short) val;
+	}
+
+  @Override
+	public int asInt4() {
+		return (int) val;
+	}
+
+  @Override
+	public long asInt8() {
+		return (long) val;
+	}
+
+  @Override
+	public byte asByte() {
+		throw new InvalidCastException();
+	}
+
+  @Override
+	public byte[] asByteArray() {
+		ByteBuffer bb = ByteBuffer.allocate(4);
+		bb.putFloat(val);
+		return bb.array();
+	}
+
+  @Override
+	public float asFloat4() {
+		return val;
+	}
+
+  @Override
+	public double asFloat8() {
+		return val;
+	}
+
+  @Override
+	public String asChars() {
+		return ""+val;
+	}
+
+  @Override
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+    return size;
+  }
+  
+  @Override
+  public int hashCode() {
+    return (int) val;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof Float4Datum) {
+      Float4Datum other = (Float4Datum) obj;
+      return val == other.val;
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createBool(val == datum.asInt2());
+    case INT4:
+      return DatumFactory.createBool(val == datum.asInt4());
+    case INT8:
+      return DatumFactory.createBool(val == datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createBool(val == datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createBool(val == datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        if (val < datum.asInt2()) {
+          return -1;
+        } else if (datum.asInt2() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT4:
+        if (val < datum.asInt4()) {
+          return -1;
+        } else if (datum.asInt4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT8:
+        if (val < datum.asInt8()) {
+          return -1;
+        } else if (datum.asInt8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT4:
+        if (val < datum.asFloat4()) {
+          return -1;
+        } else if (datum.asFloat4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT8:
+        if (val < datum.asFloat8()) {
+          return -1;
+        } else if (datum.asFloat8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum plus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat4(val + datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat4(val + datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val + datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val + datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val + datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum minus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat4(val - datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat4(val - datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val - datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val - datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val - datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum multiply(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat4(val * datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat4(val * datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val * datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val * datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val * datum.asFloat8());
+    default:
+      throw new InvalidOperationException();
+    }
+  }
+
+  @Override
+  public Datum divide(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat4(val / datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat4(val / datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val / datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val / datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val / datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum modular(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        return DatumFactory.createFloat4(val / datum.asInt2());
+      case INT4:
+        return DatumFactory.createFloat4(val / datum.asInt4());
+      case INT8:
+        return DatumFactory.createFloat4(val / datum.asInt8());
+      case FLOAT4:
+        return DatumFactory.createFloat4(val / datum.asFloat4());
+      case FLOAT8:
+        return DatumFactory.createFloat8(val / datum.asFloat8());
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public void inverseSign() {
+    this.val = - val;    
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/Float8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/Float8Datum.java b/tajo-common/src/main/java/tajo/datum/Float8Datum.java
new file mode 100644
index 0000000..67a0fe8
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/Float8Datum.java
@@ -0,0 +1,271 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.common.TajoDataTypes;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import java.nio.ByteBuffer;
+
+public class Float8Datum extends NumericDatum {
+  private static final int size = 8;
+  @Expose private double val;
+
+	public Float8Datum() {
+		super(TajoDataTypes.Type.FLOAT8);
+	}
+	
+	public Float8Datum(double val) {
+		this();
+		this.val = val;
+	}
+
+  public Float8Datum(byte[] bytes) {
+    this();
+    ByteBuffer bb = ByteBuffer.wrap(bytes);
+    this.val = bb.getDouble();
+  }
+	
+	@Override
+	public short asInt2() {
+		return (short) val;
+	}
+
+	@Override
+	public int asInt4() {
+		return (int) val;
+	}
+
+  @Override
+	public long asInt8() {
+		return (long) val;
+	}
+
+  @Override
+	public byte[] asByteArray() {
+		ByteBuffer bb = ByteBuffer.allocate(8);
+		bb.putDouble(val);
+		return bb.array();
+	}
+
+  @Override
+	public float asFloat4() {
+		return (float) val;
+	}
+
+  @Override
+	public double asFloat8() {
+		return val;
+	}
+
+  @Override
+	public String asChars() {
+		return ""+val;
+	}
+
+  @Override
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+    return size;
+  }
+  
+  @Override
+  public int hashCode() {
+    return (int) val;
+  }
+  
+  public boolean equals(Object obj) {
+    if (obj instanceof Float8Datum) {
+      Float8Datum other = (Float8Datum) obj;
+      return val == other.val;
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createBool(val == datum.asInt2());
+    case INT4:
+      return DatumFactory.createBool(val == datum.asInt4());
+    case INT8:
+      return DatumFactory.createBool(val == datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createBool(val == datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createBool(val == datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        if (val < datum.asInt2()) {
+          return -1;
+        } else if (datum.asInt2() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT4:
+        if (val < datum.asInt4()) {
+          return -1;
+        } else if (datum.asInt4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT8:
+        if (val < datum.asInt8()) {
+          return -1;
+        } else if (datum.asInt8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT4:
+        if (val < datum.asFloat4()) {
+          return -1;
+        } else if (datum.asFloat4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT8:
+        if (val < datum.asFloat8()) {
+          return -1;
+        } else if (datum.asFloat8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum plus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat8(val + datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat8(val + datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val + datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val + datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val + datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum minus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat8(val - datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat8(val - datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val - datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val - datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val - datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum multiply(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat8(val * datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat8(val * datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val * datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val * datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val * datum.asFloat8());
+    default:
+      throw new InvalidOperationException();
+    }
+  }
+
+  @Override
+  public Datum divide(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createFloat8(val / datum.asInt2());
+    case INT4:
+      return DatumFactory.createFloat8(val / datum.asInt4());
+    case INT8:
+      return DatumFactory.createFloat8(val / datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val / datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val / datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum modular(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        return DatumFactory.createFloat8(val % datum.asInt2());
+      case INT4:
+        return DatumFactory.createFloat8(val % datum.asInt4());
+      case INT8:
+        return DatumFactory.createFloat8(val % datum.asInt8());
+      case FLOAT4:
+        return DatumFactory.createFloat8(val % datum.asFloat4());
+      case FLOAT8:
+        return DatumFactory.createFloat8(val % datum.asFloat8());
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+  
+  @Override
+  public void inverseSign() {   
+    this.val = -val;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/Inet4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/Inet4Datum.java b/tajo-common/src/main/java/tajo/datum/Inet4Datum.java
new file mode 100644
index 0000000..ce43494
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/Inet4Datum.java
@@ -0,0 +1,138 @@
+/**
+ * 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.datum;
+
+import com.google.common.base.Preconditions;
+import com.google.gson.annotations.Expose;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import static tajo.common.TajoDataTypes.Type;
+
+public class Inet4Datum extends Datum {
+  private static final int size = 4;
+  @Expose private int address;
+
+	public Inet4Datum() {
+		super(Type.INET4);
+	}
+	
+	public Inet4Datum(String addr) {
+		this();
+		String [] elems = addr.split("\\.");
+		address  = Integer.valueOf(elems[3]) & 0xFF;
+    address |= ((Integer.valueOf(elems[2]) << 8) & 0xFF00);
+    address |= ((Integer.valueOf(elems[1]) << 16) & 0xFF0000);
+    address |= ((Integer.valueOf(elems[0]) << 24) & 0xFF000000);
+	}
+	
+	public Inet4Datum(byte[] addr) {
+		this();
+		Preconditions.checkArgument(addr.length == size);
+		address  = addr[3] & 0xFF;
+    address |= ((addr[2] << 8) & 0xFF00);
+    address |= ((addr[1] << 16) & 0xFF0000);
+    address |= ((addr[0] << 24) & 0xFF000000);
+	}
+
+	@Override
+	public int asInt4() {
+		return this.address;
+	}
+
+	@Override
+	public long asInt8() {
+	  return this.address;
+	}
+
+	@Override
+	public byte[] asByteArray() {
+	  byte[] addr = new byte[size];
+	  addr[0] = (byte) ((address >>> 24) & 0xFF);
+	  addr[1] = (byte) ((address >>> 16) & 0xFF);
+	  addr[2] = (byte) ((address >>> 8) & 0xFF);
+	  addr[3] = (byte) (address & 0xFF);
+	  return addr;
+	}
+
+	@Override
+	public String asChars() {
+		return numericToTextFormat(asByteArray());
+	}
+
+  @Override
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+    return size;
+  }
+  
+  @Override
+  public int hashCode() {
+    return address;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof Inet4Datum) {
+      Inet4Datum other = (Inet4Datum) obj;
+      return this.address == other.address;
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+    case INET4:
+    	return DatumFactory.createBool(this.address == ((Inet4Datum)datum).address);
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+  
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+    case INET4:
+      byte [] bytes = asByteArray();
+      byte [] other = datum.asByteArray();
+      
+      for (int i = 0; i < 4; i++) {
+        if (bytes[i] > other[i]) {
+          return 1;
+        } else if (bytes[i] < other[i]) {
+          return -1;
+        }
+      }
+      
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+  
+  static String numericToTextFormat(byte[] src) {
+    return (src[0] & 0xff) + "." + (src[1] & 0xff) + "." + (src[2] & 0xff)
+        + "." + (src[3] & 0xff);
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/Int2Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/Int2Datum.java b/tajo-common/src/main/java/tajo/datum/Int2Datum.java
new file mode 100644
index 0000000..bc4ec86
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/Int2Datum.java
@@ -0,0 +1,269 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.common.TajoDataTypes;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import java.nio.ByteBuffer;
+
+public class Int2Datum extends NumericDatum {
+  private static final int size = 2;  
+  @Expose private short val;
+
+  public Int2Datum() {
+    super(TajoDataTypes.Type.INT2);
+  }
+
+	public Int2Datum(short val) {
+		this();
+		this.val = val;		
+	}
+
+  public Int2Datum(byte[] bytes) {
+    this();
+    ByteBuffer bb = ByteBuffer.wrap(bytes);
+    this.val = bb.getShort();
+  }
+	
+	@Override
+	public short asInt2() {
+		return val;
+	}
+
+	@Override
+	public int asInt4() {
+		return val;
+	}
+
+	@Override
+	public long asInt8() {
+		return val;
+	}
+
+	@Override
+	public byte [] asByteArray() {
+		ByteBuffer bb = ByteBuffer.allocate(2);
+		bb.putShort(val);
+		return bb.array();
+	}
+
+	@Override
+	public float asFloat4() {
+		return val;
+	}
+
+	@Override
+	public double asFloat8() {
+		return val;
+	}
+
+	@Override
+	public String asChars() {
+		return ""+val;
+	}
+
+  @Override
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+    return size;
+  }
+
+  @Override
+  public int hashCode() {
+    return val;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof Int2Datum) {
+      Int2Datum other = (Int2Datum) obj;
+      return val == other.val;
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createBool(val == datum.asInt2());
+    case INT4:
+      return DatumFactory.createBool(val == datum.asInt4());
+    case INT8:
+      return DatumFactory.createBool(val == datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createBool(val == datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createBool(val == datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        if (val < datum.asInt2()) {
+          return -1;
+        } else if (datum.asInt2() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT4:
+        if (val < datum.asInt4()) {
+          return -1;
+        } else if (datum.asInt4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT8:
+        if (val < datum.asInt8()) {
+          return -1;
+        } else if (datum.asInt8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT4:
+        if (val < datum.asFloat4()) {
+          return -1;
+        } else if (datum.asFloat4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT8:
+        if (val < datum.asFloat8()) {
+          return -1;
+        } else if (datum.asFloat8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum plus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt2((short) (val + datum.asInt2()));
+    case INT4:
+      return DatumFactory.createInt4(val + datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val + datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val + datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val + datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum minus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt2((short) (val - datum.asInt2()));
+    case INT4:
+      return DatumFactory.createInt4(val - datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val - datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val - datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val - datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum multiply(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt4(val * datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt4(val * datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val * datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val * datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val * datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum divide(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt2((short) (val / datum.asInt2()));
+    case INT4:
+      return DatumFactory.createInt4(val / datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val / datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val / datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val / datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum modular(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        return DatumFactory.createInt2((short) (val % datum.asInt2()));
+      case INT4:
+        return DatumFactory.createInt4(val % datum.asInt4());
+      case INT8:
+        return DatumFactory.createInt8(val % datum.asInt8());
+      case FLOAT4:
+        return DatumFactory.createFloat4(val % datum.asFloat4());
+      case FLOAT8:
+        return DatumFactory.createFloat8(val % datum.asFloat8());
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public void inverseSign() {
+    this.val = (short) -val;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/Int4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/Int4Datum.java b/tajo-common/src/main/java/tajo/datum/Int4Datum.java
new file mode 100644
index 0000000..10673b5
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/Int4Datum.java
@@ -0,0 +1,274 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.common.TajoDataTypes.Type;
+import tajo.datum.exception.InvalidCastException;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import java.nio.ByteBuffer;
+
+public class Int4Datum extends NumericDatum {
+  private static final int size = 4;
+  @Expose private int val;
+	
+	public Int4Datum() {
+		super(Type.INT4);
+	}
+	
+	public Int4Datum(int val) {
+		this();
+		this.val = val;
+	}
+
+  public Int4Datum(byte[] bytes) {
+    this();
+    ByteBuffer bb = ByteBuffer.wrap(bytes);
+    this.val = bb.getInt();
+  }
+
+	@Override
+	public short asInt2() {
+		return (short) val;
+	}
+
+  @Override
+	public int asInt4() {
+		return val;
+	}
+
+  @Override
+	public long asInt8() {
+		return val;
+	}
+
+  @Override
+	public byte asByte() {
+		throw new InvalidCastException();
+	}
+
+  @Override
+	public byte[] asByteArray() {
+		ByteBuffer bb = ByteBuffer.allocate(4);
+		bb.putInt(val);
+		return bb.array();
+	}
+
+  @Override
+	public float asFloat4() {
+		return val;
+	}
+
+  @Override
+	public double asFloat8() {
+		return val;
+	}
+
+  @Override
+	public String asChars() {
+		return ""+val;
+	}
+
+  @Override
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+
+  @Override
+  public int size() {
+    return size;
+  }
+  
+  @Override
+  public int hashCode() {
+    return val;
+  }
+  
+  public boolean equals(Object obj) {
+    if (obj instanceof Int4Datum) {
+      Int4Datum other = (Int4Datum) obj;
+      return val == other.val;
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createBool(val == datum.asInt2());
+    case INT4:
+      return DatumFactory.createBool(val == datum.asInt4());
+    case INT8:
+      return DatumFactory.createBool(val == datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createBool(val == datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createBool(val == datum.asFloat8());
+    default:
+      throw new InvalidOperationException();
+    }
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        if (val < datum.asInt2()) {
+          return -1;
+        } else if (datum.asInt2() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT4:
+        if (val < datum.asInt4()) {
+          return -1;
+        } else if (datum.asInt4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT8:
+        if (val < datum.asInt8()) {
+          return -1;
+        } else if (datum.asInt8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT4:
+        if (val < datum.asFloat4()) {
+          return -1;
+        } else if (datum.asFloat4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT8:
+        if (val < datum.asFloat8()) {
+          return -1;
+        } else if (datum.asFloat8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum plus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt4(val + datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt4(val + datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val + datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val + datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val + datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum minus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt4(val - datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt4(val - datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val - datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val - datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val - datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum multiply(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt4(val * datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt4(val * datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val * datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val * datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val * datum.asFloat8());
+    default:
+      throw new InvalidOperationException();
+    }
+  }
+
+  @Override
+  public Datum divide(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt4(val / datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt4(val / datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val / datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat4(val / datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val / datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum modular(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        return DatumFactory.createInt4(val % datum.asInt2());
+      case INT4:
+        return DatumFactory.createInt4(val % datum.asInt4());
+      case INT8:
+        return DatumFactory.createInt8(val % datum.asInt8());
+      case FLOAT4:
+        return DatumFactory.createFloat4(val % datum.asFloat4());
+      case FLOAT8:
+        return DatumFactory.createFloat8(val % datum.asFloat8());
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public void inverseSign() {
+    this.val = - val;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/Int8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/Int8Datum.java b/tajo-common/src/main/java/tajo/datum/Int8Datum.java
new file mode 100644
index 0000000..8238f06
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/Int8Datum.java
@@ -0,0 +1,280 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import tajo.common.TajoDataTypes;
+import tajo.datum.exception.InvalidCastException;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import java.nio.ByteBuffer;
+
+public class Int8Datum extends NumericDatum {
+  private static final int size = 8;
+  @Expose private long val;
+
+	public Int8Datum() {
+		super(TajoDataTypes.Type.INT8);
+	}
+	
+	public Int8Datum(long val) {
+		this();
+		this.val = val;
+	}
+
+  public Int8Datum(byte[] bytes) {
+    this();
+    ByteBuffer bb = ByteBuffer.wrap(bytes);
+    val = bb.getLong();
+  }
+
+  @Override
+	public boolean asBool() {
+		throw new InvalidCastException();
+	}
+	
+	@Override
+	public short asInt2() {
+		return (short) val;
+	}
+
+  @Override
+	public int asInt4() {
+		return (int) val;
+	}
+
+  @Override
+	public long asInt8() {
+		return val;
+	}
+
+  @Override
+	public byte asByte() {
+		throw new InvalidCastException();
+	}
+
+  @Override
+	public byte[] asByteArray() {
+		ByteBuffer bb = ByteBuffer.allocate(8);
+		bb.putLong(val);
+		return bb.array();
+	}
+
+  @Override
+	public float asFloat4() {
+		return val;
+	}
+
+  @Override
+	public double asFloat8() {
+		return val;
+	}
+
+  @Override
+	public String asChars() {
+		return ""+val;
+	}
+
+  @Override
+	public String toJSON() {
+		return GsonCreator.getInstance().toJson(this, Datum.class);
+	}
+	
+  @Override
+  public int size() {
+    return size;
+  }
+  
+  @Override
+  public int hashCode() {
+    return (int) val;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof Int8Datum) {
+      Int8Datum other = (Int8Datum) obj;
+      return val == other.val;
+    }
+    
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        return DatumFactory.createBool(val == datum.asInt2());
+      case INT4:
+        return DatumFactory.createBool(val == datum.asInt4());
+      case INT8:
+        return DatumFactory.createBool(val == datum.asInt8());
+      case FLOAT4:
+        return DatumFactory.createBool(val == datum.asFloat4());
+      case FLOAT8:
+        return DatumFactory.createBool(val == datum.asFloat8());
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        if (val < datum.asInt2()) {
+          return -1;
+        } else if (datum.asInt2() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT4:
+        if (val < datum.asInt4()) {
+          return -1;
+        } else if (datum.asInt4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case INT8:
+        if (val < datum.asInt8()) {
+          return -1;
+        } else if (datum.asInt8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT4:
+        if (val < datum.asFloat4()) {
+          return -1;
+        } else if (datum.asFloat4() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      case FLOAT8:
+        if (val < datum.asFloat8()) {
+          return -1;
+        } else if (datum.asFloat8() < val) {
+          return 1;
+        } else {
+          return 0;
+        }
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum plus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt8(val + datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt8(val + datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val + datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val + datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val + datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum minus(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt8(val - datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt8(val - datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val - datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val - datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val - datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum multiply(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt8(val * datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt8(val * datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val * datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val * datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val * datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum divide(Datum datum) {
+    switch (datum.type()) {
+    case INT2:
+      return DatumFactory.createInt8(val / datum.asInt2());
+    case INT4:
+      return DatumFactory.createInt8(val / datum.asInt4());
+    case INT8:
+      return DatumFactory.createInt8(val / datum.asInt8());
+    case FLOAT4:
+      return DatumFactory.createFloat8(val / datum.asFloat4());
+    case FLOAT8:
+      return DatumFactory.createFloat8(val / datum.asFloat8());
+    default:
+      throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public Datum modular(Datum datum) {
+    switch (datum.type()) {
+      case INT2:
+        return DatumFactory.createInt8(val % datum.asInt2());
+      case INT4:
+        return DatumFactory.createInt8(val % datum.asInt4());
+      case INT8:
+        return DatumFactory.createInt8(val % datum.asInt8());
+      case FLOAT4:
+        return DatumFactory.createFloat8(val % datum.asFloat4());
+      case FLOAT8:
+        return DatumFactory.createFloat8(val % datum.asFloat8());
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public void inverseSign() {
+    this.val = -val;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/datum/TextDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/datum/TextDatum.java b/tajo-common/src/main/java/tajo/datum/TextDatum.java
new file mode 100644
index 0000000..d04533f
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/datum/TextDatum.java
@@ -0,0 +1,146 @@
+/**
+ * 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.datum;
+
+import com.google.gson.annotations.Expose;
+import org.apache.hadoop.io.WritableComparator;
+import tajo.common.TajoDataTypes;
+import tajo.datum.exception.InvalidCastException;
+import tajo.datum.exception.InvalidOperationException;
+import tajo.datum.json.GsonCreator;
+
+import java.util.Arrays;
+
+public class TextDatum extends Datum {
+  @Expose
+  private int size;
+  @Expose
+  private byte[] bytes;
+
+  public TextDatum() {
+    super(TajoDataTypes.Type.TEXT);
+  }
+
+  public TextDatum(byte[] bytes) {
+    this();
+    this.bytes = bytes;
+    this.size = bytes.length;
+  }
+
+  public TextDatum(String string) {
+    this(string.getBytes());
+  }
+
+  @Override
+  public boolean asBool() {
+    throw new InvalidCastException();
+  }
+
+  @Override
+  public byte asByte() {
+    throw new InvalidCastException();
+  }
+
+  @Override
+  public short asInt2() {
+    return Short.valueOf(new String(bytes));
+  }
+
+  @Override
+  public int asInt4() {
+    return Integer.valueOf(new String(bytes));
+  }
+
+  @Override
+  public long asInt8() {
+    return Long.valueOf(new String(bytes));
+  }
+
+  @Override
+  public float asFloat4() {
+    return Float.valueOf(new String(bytes));
+  }
+
+  @Override
+  public double asFloat8() {
+    return Double.valueOf(new String(bytes));
+  }
+
+  @Override
+  public byte[] asByteArray() {
+    return this.bytes;
+  }
+
+  public String asChars() {
+    return new String(this.bytes);
+  }
+
+  @Override
+  public int size() {
+    return size;
+  }
+
+  @Override
+  public int compareTo(Datum datum) {
+    switch (datum.type()) {
+      case TEXT:
+        byte[] o = datum.asByteArray();
+        return WritableComparator.compareBytes(this.bytes, 0, this.bytes.length,
+            o, 0, o.length);
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (obj instanceof TextDatum) {
+      TextDatum o = (TextDatum) obj;
+      return Arrays.equals(this.bytes, o.bytes);
+    }
+
+    return false;
+  }
+
+  @Override
+  public BooleanDatum equalsTo(Datum datum) {
+    switch (datum.type()) {
+      case TEXT:
+        return DatumFactory.createBool(
+            Arrays.equals(this.bytes, datum.asByteArray()));
+      default:
+        throw new InvalidOperationException(datum.type());
+    }
+  }
+
+  @Override
+  public String toJSON() {
+    return GsonCreator.getInstance().toJson(this, Datum.class);
+  }
+
+  @Override
+  public int hashCode() {
+    return Arrays.hashCode(bytes);
+  }
+
+  @Override
+  public String toString() {
+    return asChars();
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/java/tajo/gson/DataTypeAdapter.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/tajo/gson/DataTypeAdapter.java b/tajo-common/src/main/java/tajo/gson/DataTypeAdapter.java
new file mode 100644
index 0000000..e3c53c1
--- /dev/null
+++ b/tajo-common/src/main/java/tajo/gson/DataTypeAdapter.java
@@ -0,0 +1,64 @@
+/**
+ * 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.gson;
+
+import com.google.gson.*;
+import tajo.common.TajoDataTypes;
+import tajo.common.TajoDataTypes.DataType;
+
+import java.lang.reflect.Type;
+
+
+public class DataTypeAdapter implements JsonSerializer<DataType>, JsonDeserializer<DataType> {
+
+  @Override
+  public DataType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+      throws JsonParseException {
+
+
+    JsonObject obj = (JsonObject) json;
+    DataType.Builder builder = DataType.newBuilder();
+    TajoDataTypes.Type type = Enum.valueOf(TajoDataTypes.Type.class, obj.get("type").getAsString());
+    builder.setType(type);
+
+    JsonElement len = obj.get("len");
+    if (len != null) {
+      builder.setLength(len.getAsInt());
+    }
+    JsonElement code = obj.get("code");
+    if (code != null) {
+      builder.setCode(code.getAsString());
+    }
+    return builder.build();
+  }
+
+  @Override
+  public JsonElement serialize(DataType src, Type typeOfSrc, JsonSerializationContext context) {
+    JsonObject json = new JsonObject();
+    json.addProperty("type", src.getType().name());
+    if (src.hasLength()) {
+      json.addProperty("len", src.getLength());
+    }
+    if (src.hasCode()) {
+      json.addProperty("code", src.getCode());
+    }
+
+    return json;
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/main/proto/DataTypes.proto
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/proto/DataTypes.proto b/tajo-common/src/main/proto/DataTypes.proto
new file mode 100644
index 0000000..c8b18cb
--- /dev/null
+++ b/tajo-common/src/main/proto/DataTypes.proto
@@ -0,0 +1,74 @@
+/**
+ * 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.
+ */
+
+option java_package = "tajo.common";
+option java_outer_classname = "TajoDataTypes";
+option optimize_for = SPEED;
+option java_generic_services = false;
+option java_generate_equals_and_hash = true;
+
+enum Type {
+  // SQL Standard Data Type
+  BOOLEAN = 0; // state of true of false [1 byte]
+
+  INT1 = 1; // tinyint [1 byte] [0-255]
+  INT2 = 2; // smallint [2 bytes] [-2^15(-32,768) ~ 2^15-1(32,767)]
+  INT4 = 3; // int [4 bytes] [-2^31(-2,147,483,648) ~ 2^31-1(2,147,483,647)]
+  INT8 = 4; // bigint [8 bytes] [-2^63(-9,223,372,036,854,775,808) ~ 2^63-1(9,223,372,036,854,775,807)]
+
+  FLOAT4 = 10; // variable-precision, inexact [4 bytes]
+  FLOAT8 = 11; // variable-precision, inexact [8 bytes]
+
+  NUMERIC = 15; // variable length
+  DECIMAL = 16; // variable length  
+
+  CHAR = 20; // fixed-width n-character string
+  NCHAR = 21; // fixed width string supporting an international character set
+  VARCHAR = 22; // variable-width string
+  NVARCHAR = 23; // variable-width NCHAR string
+  TEXT = 24; // variable unlimited length
+
+  DATE = 30;
+  TIME = 31;
+  TIMEZ = 32;
+  TIMESTAMP = 33;
+  TIMESTAMPZ = 34;
+  INTERVAL = 35;
+
+  BIT = 40; // fixed-width bits. BIT without the length L means a single bit. It can be used for boolean type.
+  VARBIT = 41; // variable-width bits
+
+  BINARY = 45; // fixed-width binary strings. BINARY without the length L means a single byte.
+  VARBINARY = 46; // variable-width binary strings
+  BLOB = 47;
+
+  UDT = 51; // user-defined function
+
+  ANY = 61;
+  ARRAY = 62;
+  INET4 = 100;
+  INET6 = 101;
+
+  // Extended Data Type (Reserved 128 ~ 255)
+}
+
+message DataType {
+  required Type type = 1;
+  optional int32 length = 2;
+  optional string code = 3;
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/test/java/tajo/datum/TestBitDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestBitDatum.java b/tajo-common/src/test/java/tajo/datum/TestBitDatum.java
new file mode 100644
index 0000000..9225a0d
--- /dev/null
+++ b/tajo-common/src/test/java/tajo/datum/TestBitDatum.java
@@ -0,0 +1,76 @@
+/**
+ * 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.datum;
+
+import org.junit.Test;
+import tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestBitDatum {
+
+	@Test
+	public final void testType() {
+		Datum d = DatumFactory.createBit((byte) 1);
+		assertEquals(Type.BIT, d.type());
+	}
+
+	@Test
+	public final void testAsInt() {
+		Datum d = DatumFactory.createBit((byte) 5);
+		assertEquals(5,d.asInt4());
+	}
+	
+	@Test
+	public final void testAsLong() {
+		Datum d = DatumFactory.createBit((byte) 5);
+		assertEquals(5l,d.asInt8());
+	}
+	
+	@Test
+	public final void testAsByte() {
+		Datum d = DatumFactory.createBit((byte) 5);
+		assertEquals(5,d.asInt8());
+	}
+
+	@Test
+	public final void testAsFloat() {
+		Datum d = DatumFactory.createBit((byte) 5);
+		assertTrue(5.0f == d.asFloat4());
+	}
+
+	@Test
+	public final void testAsDouble() {
+		Datum d = DatumFactory.createBit((byte) 5);
+		assertTrue(5.0d == d.asFloat8());
+	}
+	
+	@Test
+	public final void testAsChars() {
+		Datum d = DatumFactory.createBit((byte) 5);
+		System.out.println(d.asChars());
+	}
+	
+	@Test
+  public final void testSize() {
+    Datum d = DatumFactory.createBit((byte) 1);
+    assertEquals(1, d.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java b/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java
new file mode 100644
index 0000000..6558fd2
--- /dev/null
+++ b/tajo-common/src/test/java/tajo/datum/TestFloat8Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.datum;
+
+import org.junit.Test;
+import tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestFloat8Datum {
+
+	@Test
+	public final void testType() {
+		Datum d = DatumFactory.createFloat8(1d);
+		assertEquals(Type.FLOAT8, d.type());
+	}
+
+	@Test
+	public final void testAsInt4() {
+		Datum d = DatumFactory.createFloat8(5d);
+		assertEquals(5,d.asInt4());
+	}
+
+	@Test
+	public final void testAsInt8() {
+		Datum d = DatumFactory.createFloat8(5d);
+		assertEquals(5l,d.asInt8());
+	}
+
+	@Test
+	public final void testAsFloat4() {
+		Datum d = DatumFactory.createFloat8(5d);
+		assertTrue(5.0f == d.asFloat4());
+	}
+
+	@Test
+	public final void testAsFloat8() {
+		Datum d = DatumFactory.createFloat8(5d);
+		assertTrue(5.0d == d.asFloat8());
+	}
+
+	@Test
+	public final void testAsText() {
+		Datum d = DatumFactory.createFloat8(5d);
+		assertEquals("5.0", d.asChars());
+	}
+	
+	@Test
+  public final void testSize() {
+	  Datum d = DatumFactory.createFloat8(5d);
+	  assertEquals(8, d.size());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java b/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java
new file mode 100644
index 0000000..8df9506
--- /dev/null
+++ b/tajo-common/src/test/java/tajo/datum/TestInet4Datum.java
@@ -0,0 +1,75 @@
+/**
+ * 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.datum;
+
+import org.junit.Before;
+import org.junit.Test;
+import tajo.datum.json.GsonCreator;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInet4Datum {
+
+	@Before
+	public void setUp() throws Exception {
+	}
+	
+	@Test
+	public final void testEquals() {
+	  Inet4Datum ip1 = new Inet4Datum("192.168.0.1");
+	  Inet4Datum ip2 = new Inet4Datum("192.168.0.1");
+	  
+	  assertEquals(ip1, ip2);
+	  
+	  Inet4Datum ip3 = new Inet4Datum(ip1.asByteArray());
+	  assertEquals(ip1, ip3);
+	  Inet4Datum ip4 = DatumFactory.createInet4(ip1.asByteArray());
+	  assertEquals(ip1, ip4);
+	}
+
+	@Test
+	public final void testAsByteArray() {
+		byte[] bytes = {(byte) 0xA3, (byte) 0x98, 0x17, (byte) 0xDE};
+		Inet4Datum ip = new Inet4Datum(bytes);
+		assertTrue(Arrays.equals(bytes, ip.asByteArray()));
+	}
+
+	@Test
+	public final void testAsChars() {
+		Inet4Datum ip = new Inet4Datum("163.152.23.222");
+		assertEquals("163.152.23.222", ip.asChars());
+	}
+	
+	@Test
+  public final void testSize() {
+    Datum d = DatumFactory.createInet4("163.152.23.222");
+    assertEquals(4, d.size());
+  }
+	
+	@Test
+	public final void testJson() {
+		Datum d = DatumFactory.createInet4("163.152.163.152");
+		String json = d.toJSON();
+		Datum fromJson = GsonCreator.getInstance().fromJson(json, Datum.class);
+		assertTrue(d.equalsTo(fromJson).asBool());
+	}
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java b/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java
new file mode 100644
index 0000000..cef991b
--- /dev/null
+++ b/tajo-common/src/test/java/tajo/datum/TestInt2Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.datum;
+
+import org.junit.Test;
+import tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInt2Datum {
+
+	@Test
+	public final void testType() {
+		Datum d = DatumFactory.createInt2((short) 1);
+		assertEquals(d.type(), Type.INT2);
+	}
+
+	@Test
+	public final void testAsInt4() {
+		Datum d = DatumFactory.createInt2((short) 5);
+		assertEquals(5,d.asInt4());
+	}
+
+	@Test
+	public final void testAsInt8() {
+		Datum d = DatumFactory.createInt2((short) 5);
+		assertEquals(5,d.asInt8());
+	}
+
+	@Test
+	public final void testAsFloat4() {
+		Datum d = DatumFactory.createInt2((short) 5);
+		assertTrue(5.0f == d.asFloat4());
+	}
+
+	@Test
+	public final void testAsFloat8() {
+		Datum d = DatumFactory.createInt2((short) 5);
+		assertTrue(5.0d == d.asFloat8());
+	}
+
+	@Test
+	public final void testAsText() {
+		Datum d = DatumFactory.createInt2((short) 5);
+		assertEquals("5", d.asChars());
+	}
+	
+	@Test
+  public final void testSize() {
+    Datum d = DatumFactory.createInt2((short) 5);
+    assertEquals(2, d.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java b/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java
new file mode 100644
index 0000000..5fc9e2d
--- /dev/null
+++ b/tajo-common/src/test/java/tajo/datum/TestInt4Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.datum;
+
+import org.junit.Test;
+import tajo.common.TajoDataTypes;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInt4Datum {
+
+  @Test
+  public final void testType() {
+    Datum d = DatumFactory.createInt4(1);
+    assertEquals(TajoDataTypes.Type.INT4, d.type());
+  }
+
+  @Test
+  public final void testAsInt() {
+    Datum d = DatumFactory.createInt4(5);
+    assertEquals(5, d.asInt4());
+  }
+
+  @Test
+  public final void testAsLong() {
+    Datum d = DatumFactory.createInt4(5);
+    assertEquals(5, d.asInt8());
+  }
+
+  @Test
+  public final void testAsFloat() {
+    Datum d = DatumFactory.createInt4(5);
+    assertTrue(5.0f == d.asFloat4());
+  }
+
+  @Test
+  public final void testAsDouble() {
+    Datum d = DatumFactory.createInt4(5);
+    assertTrue(5.0d == d.asFloat8());
+  }
+
+  @Test
+  public final void testAsChars() {
+    Datum d = DatumFactory.createInt4(5);
+    assertEquals("5", d.asChars());
+  }
+
+  @Test
+  public final void testSize() {
+    Datum d = DatumFactory.createInt4(5);
+    assertEquals(4, d.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java b/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java
new file mode 100644
index 0000000..6e8042b
--- /dev/null
+++ b/tajo-common/src/test/java/tajo/datum/TestInt8Datum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.datum;
+
+import org.junit.Test;
+import tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestInt8Datum {
+
+	@Test
+	public final void testType() {
+		Datum d = DatumFactory.createInt8(1l);
+		assertEquals(d.type(), Type.INT8);
+	}
+
+	@Test
+	public final void testAsInt() {
+		Datum d = DatumFactory.createInt8(5l);
+		assertEquals(5,d.asInt4());
+	}
+
+	@Test
+	public final void testAsLong() {
+		Datum d = DatumFactory.createInt8(5l);
+		assertEquals(5l,d.asInt8());
+	}
+
+	@Test
+	public final void testAsFloat() {
+		Datum d = DatumFactory.createInt8(5l);
+		assertTrue(5.0f == d.asFloat4());
+	}
+
+	@Test
+	public final void testAsDouble() {
+		Datum d = DatumFactory.createInt8(5l);
+		assertTrue(5.0d == d.asFloat8());
+	}
+
+	@Test
+	public final void testAsChars() {
+		Datum d = DatumFactory.createInt8(5l);
+		assertEquals("5", d.asChars());
+	}
+	
+	@Test
+  public final void testSize() {
+    Datum d = DatumFactory.createInt8(5l);
+    assertEquals(8, d.size());
+  }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tajo/blob/0652815f/tajo-common/src/test/java/tajo/datum/TestTextDatum.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/tajo/datum/TestTextDatum.java b/tajo-common/src/test/java/tajo/datum/TestTextDatum.java
new file mode 100644
index 0000000..af87bde
--- /dev/null
+++ b/tajo-common/src/test/java/tajo/datum/TestTextDatum.java
@@ -0,0 +1,70 @@
+/**
+ * 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.datum;
+
+import org.junit.Test;
+import tajo.common.TajoDataTypes.Type;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class TestTextDatum {
+	
+	@Test
+	public final void testType() {
+		Datum d = DatumFactory.createText("12345");
+		assertEquals(d.type(), Type.TEXT);
+	}
+	
+	@Test
+	public final void testAsInt4() {
+		Datum d = DatumFactory.createText("12345");
+		assertEquals(12345,d.asInt4());
+	}
+
+	@Test
+	public final void testAsInt8() {
+		Datum d = DatumFactory.createText("12345");
+		assertEquals(12345l,d.asInt8());
+	}
+
+	@Test
+	public final void testAsFloat4() {
+		Datum d = DatumFactory.createText("12345");
+		assertTrue(12345.0f == d.asFloat4());
+	}
+
+	@Test
+	public final void testAsFloat8() {
+		Datum d = DatumFactory.createText("12345");
+		assertTrue(12345.0d == d.asFloat8());
+	}
+
+	@Test
+	public final void testAsText() {
+		Datum d = DatumFactory.createText("12345");
+		assertEquals("12345", d.asChars());
+	}
+	
+	@Test
+  public final void testSize() {
+	  Datum d = DatumFactory.createText("12345");
+    assertEquals(5, d.size());
+  }
+}