tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [01/13] tajo git commit: TAJO-1450: Encapsulate Datum in Tuple.
Date Mon, 15 Jun 2015 22:42:23 GMT
Repository: tajo
Updated Branches:
  refs/heads/index_support 8ec099c8d -> f674fa8f0


http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/CSVLineSerializer.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/CSVLineSerializer.java
b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/CSVLineSerializer.java
index 9a2fe37..21984f2 100644
--- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/CSVLineSerializer.java
+++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/CSVLineSerializer.java
@@ -20,7 +20,6 @@ package org.apache.tajo.storage.text;
 
 import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.catalog.TableMeta;
-import org.apache.tajo.datum.Datum;
 import org.apache.tajo.storage.FieldSerializerDeserializer;
 import org.apache.tajo.storage.Tuple;
 
@@ -45,6 +44,7 @@ public class CSVLineSerializer extends TextLineSerializer {
     columnNum = schema.size();
 
     serde = new TextFieldSerializerDeserializer(meta);
+    serde.init(schema);
   }
 
   @Override
@@ -52,8 +52,7 @@ public class CSVLineSerializer extends TextLineSerializer {
     int writtenBytes = 0;
 
     for (int i = 0; i < columnNum; i++) {
-      Datum datum = input.get(i);
-      writtenBytes += serde.serialize(out, datum, schema.getColumn(i), i, nullChars);
+      writtenBytes += serde.serialize(i, input, out, nullChars);
 
       if (columnNum - 1 > i) {
         out.write(delimiter);

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
index d2eee9f..d7a43e1 100644
--- a/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
+++ b/tajo-storage/tajo-storage-hdfs/src/main/java/org/apache/tajo/storage/text/TextFieldSerializerDeserializer.java
@@ -24,6 +24,7 @@ import io.netty.util.CharsetUtil;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.tajo.TajoConstants;
 import org.apache.tajo.catalog.Column;
+import org.apache.tajo.catalog.Schema;
 import org.apache.tajo.catalog.TableMeta;
 import org.apache.tajo.common.TajoDataTypes;
 import org.apache.tajo.datum.*;
@@ -31,6 +32,7 @@ import org.apache.tajo.datum.protobuf.ProtobufJsonFormat;
 import org.apache.tajo.exception.ValueTooLongForTypeCharactersException;
 import org.apache.tajo.storage.FieldSerializerDeserializer;
 import org.apache.tajo.storage.StorageConstants;
+import org.apache.tajo.storage.Tuple;
 import org.apache.tajo.util.Bytes;
 import org.apache.tajo.util.NumberUtil;
 
@@ -48,6 +50,8 @@ public class TextFieldSerializerDeserializer implements FieldSerializerDeseriali
   private final boolean hasTimezone;
   private final TimeZone timezone;
 
+  private Schema schema;
+
   public TextFieldSerializerDeserializer(TableMeta meta) {
     hasTimezone = meta.containsOption(StorageConstants.TIMEZONE);
     timezone = TimeZone.getTimeZone(meta.getOption(StorageConstants.TIMEZONE, TajoConstants.DEFAULT_SYSTEM_TIMEZONE));
@@ -62,13 +66,19 @@ public class TextFieldSerializerDeserializer implements FieldSerializerDeseriali
   }
 
   @Override
-  public int serialize(OutputStream out, Datum datum, Column col, int columnIndex, byte[]
nullChars)
+  public void init(Schema schema) {
+    this.schema = schema;
+  }
+
+  @Override
+  public int serialize(int columnIndex, Tuple tuple, OutputStream out, byte[] nullChars)
       throws IOException {
     byte[] bytes;
     int length = 0;
+    Column col = schema.getColumn(columnIndex);
     TajoDataTypes.DataType dataType = col.getDataType();
 
-    if (datum == null || datum instanceof NullDatum) {
+    if (tuple.isBlankOrNull(columnIndex)) {
       switch (dataType.getType()) {
         case CHAR:
         case TEXT:
@@ -83,17 +93,17 @@ public class TextFieldSerializerDeserializer implements FieldSerializerDeseriali
 
     switch (dataType.getType()) {
       case BOOLEAN:
-        out.write(datum.asBool() ? trueBytes : falseBytes);
+        out.write(tuple.getBool(columnIndex) ? trueBytes : falseBytes);
         length = trueBytes.length;
         break;
       case CHAR:
-        int size = dataType.getLength() - datum.size();
+        int size = dataType.getLength() - tuple.size(columnIndex);
         if (size < 0){
           throw new ValueTooLongForTypeCharactersException(dataType.getLength());
         }
 
         byte[] pad = new byte[size];
-        bytes = datum.asTextBytes();
+        bytes = tuple.getBytes(columnIndex);
         out.write(bytes);
         out.write(pad);
         length = bytes.length + pad.length;
@@ -108,36 +118,36 @@ public class TextFieldSerializerDeserializer implements FieldSerializerDeseriali
       case INET4:
       case DATE:
       case INTERVAL:
-        bytes = datum.asTextBytes();
+        bytes = tuple.getTextBytes(columnIndex);
         length = bytes.length;
         out.write(bytes);
         break;
       case TIME:
         if (hasTimezone) {
-          bytes = ((TimeDatum) datum).asChars(timezone, true).getBytes(Bytes.UTF8_CHARSET);
+          bytes = TimeDatum.asChars(tuple.getTimeDate(columnIndex), timezone, true).getBytes(Bytes.UTF8_CHARSET);
         } else {
-          bytes = datum.asTextBytes();
+          bytes = tuple.getTextBytes(columnIndex);
         }
         length = bytes.length;
         out.write(bytes);
         break;
       case TIMESTAMP:
         if (hasTimezone) {
-          bytes = ((TimestampDatum) datum).asChars(timezone, true).getBytes(Bytes.UTF8_CHARSET);
+          bytes = TimestampDatum.asChars(tuple.getTimeDate(columnIndex), timezone, true).getBytes(Bytes.UTF8_CHARSET);
         } else {
-          bytes = datum.asTextBytes();
+          bytes = tuple.getTextBytes(columnIndex);
         }
         length = bytes.length;
         out.write(bytes);
         break;
       case INET6:
       case BLOB:
-        bytes = Base64.encodeBase64(datum.asByteArray(), false);
+        bytes = Base64.encodeBase64(tuple.getBytes(columnIndex), false);
         length = bytes.length;
         out.write(bytes, 0, length);
         break;
       case PROTOBUF:
-        ProtobufDatum protobuf = (ProtobufDatum) datum;
+        ProtobufDatum protobuf = (ProtobufDatum) tuple.getProtobufDatum(columnIndex);
         byte[] protoBytes = protobufJsonFormat.printToString(protobuf.get()).getBytes(Bytes.UTF8_CHARSET);
         length = protoBytes.length;
         out.write(protoBytes, 0, protoBytes.length);
@@ -150,8 +160,10 @@ public class TextFieldSerializerDeserializer implements FieldSerializerDeseriali
   }
 
   @Override
-  public Datum deserialize(ByteBuf buf, Column col, int columnIndex, ByteBuf nullChars) throws
IOException {
+  public Datum deserialize(int columnIndex, ByteBuf buf, ByteBuf nullChars) throws IOException
{
     Datum datum;
+
+    Column col = schema.getColumn(columnIndex);
     TajoDataTypes.Type type = col.getDataType().getType();
     boolean nullField;
     if (type == TajoDataTypes.Type.TEXT || type == TajoDataTypes.Type.CHAR) {

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestDelimitedTextFile.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestDelimitedTextFile.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestDelimitedTextFile.java
index 2260d2a..9726ecc 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestDelimitedTextFile.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestDelimitedTextFile.java
@@ -44,7 +44,7 @@ public class TestDelimitedTextFile {
 
   private static Schema schema = new Schema();
 
-  private static Tuple baseTuple = new VTuple(10);
+  private static Tuple baseTuple;
 
   static {
     schema.addColumn("col1", Type.BOOLEAN);
@@ -58,7 +58,7 @@ public class TestDelimitedTextFile {
     schema.addColumn("col9", Type.BLOB);
     schema.addColumn("col10", Type.INET4);
 
-    baseTuple.put(new Datum[] {
+    baseTuple = new VTuple(new Datum[] {
         DatumFactory.createBool(true),                // 0
         DatumFactory.createChar("hyunsik"),           // 1
         DatumFactory.createInt2((short) 17),          // 2

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileStorageManager.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileStorageManager.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileStorageManager.java
index 76b5c2f..a6d6077 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileStorageManager.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileStorageManager.java
@@ -69,10 +69,9 @@ public class TestFileStorageManager {
 
 		TableMeta meta = CatalogUtil.newTableMeta("CSV");
 		
-		Tuple[] tuples = new Tuple[4];
+		VTuple[] tuples = new VTuple[4];
 		for(int i=0; i < tuples.length; i++) {
-		  tuples[i] = new VTuple(3);
-		  tuples[i].put(new Datum[] {
+		  tuples[i] = new VTuple(new Datum[] {
           DatumFactory.createInt4(i),
 		      DatumFactory.createInt4(i + 32),
 		      DatumFactory.createText("name" + i)});

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileSystems.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileSystems.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileSystems.java
index 235bfaa..a6c238b 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileSystems.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestFileSystems.java
@@ -106,11 +106,10 @@ public class TestFileSystems {
 
     Tuple[] tuples = new Tuple[4];
     for (int i = 0; i < tuples.length; i++) {
-      tuples[i] = new VTuple(3);
-      tuples[i]
-          .put(new Datum[]{DatumFactory.createInt4(i),
-              DatumFactory.createInt4(i + 32),
-              DatumFactory.createText("name" + i)});
+      tuples[i] = new VTuple(new Datum[]{
+          DatumFactory.createInt4(i),
+          DatumFactory.createInt4(i + 32),
+          DatumFactory.createText("name" + i)});
     }
 
     Path path = StorageUtil.concatPath(testDir, "testGetScannerAndAppender",

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestMergeScanner.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestMergeScanner.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestMergeScanner.java
index 04f8a90..03a601d 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestMergeScanner.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestMergeScanner.java
@@ -177,20 +177,20 @@ public class TestMergeScanner {
 
       if (storeType.equalsIgnoreCase("RAW")) {
         assertEquals(4, tuple.size());
-        assertNotNull(tuple.get(0));
-        assertNotNull(tuple.get(1));
-        assertNotNull(tuple.get(2));
-        assertNotNull(tuple.get(3));
+        assertFalse(tuple.isBlankOrNull(0));
+        assertFalse(tuple.isBlankOrNull(1));
+        assertFalse(tuple.isBlankOrNull(2));
+        assertFalse(tuple.isBlankOrNull(3));
       } else if (scanner.isProjectable()) {
         assertEquals(2, tuple.size());
-        assertNotNull(tuple.get(0));
-        assertNotNull(tuple.get(1));
+        assertFalse(tuple.isBlankOrNull(0));
+        assertFalse(tuple.isBlankOrNull(1));
       } else {
         assertEquals(4, tuple.size());
-        assertNotNull(tuple.get(0));
-        assertNull(tuple.get(1));
-        assertNotNull(tuple.get(2));
-        assertNull(tuple.get(3));
+        assertFalse(tuple.isBlankOrNull(0));
+        assertTrue(tuple.isBlankOrNull(1));
+        assertFalse(tuple.isBlankOrNull(2));
+        assertTrue(tuple.isBlankOrNull(3));
       }
     }
     scanner.close();

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestStorages.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestStorages.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestStorages.java
index 4ca61e4..80d0fff 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestStorages.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/TestStorages.java
@@ -307,15 +307,15 @@ public class TestStorages {
 
   private void verifyProjectedFields(boolean projectable, Tuple tuple, int tupleCnt) {
     if (projectable) {
-      assertTrue(tupleCnt + 2 == tuple.get(0).asInt8());
-      assertTrue(tupleCnt + 3 == tuple.get(1).asFloat4());
+      assertTrue(tupleCnt + 2 == tuple.getInt8(0));
+      assertTrue(tupleCnt + 3 == tuple.getFloat4(1));
     } else {
       // RAW and ROW always project all fields.
       if (!storeType.equalsIgnoreCase("RAW") && !storeType.equalsIgnoreCase("ROWFILE"))
{
-        assertTrue(tuple.get(0) == null);
+        assertTrue(tuple.isBlankOrNull(0));
       }
-      assertTrue(tupleCnt + 2 == tuple.get(1).asInt8());
-      assertTrue(tupleCnt + 3 == tuple.get(2).asFloat4());
+      assertTrue(tupleCnt + 2 == tuple.getInt8(1));
+      assertTrue(tupleCnt + 3 == tuple.getFloat4(2));
     }
   }
 
@@ -355,7 +355,7 @@ public class TestStorages {
     QueryId queryid = new QueryId("12345", 5);
     ProtobufDatumFactory factory = ProtobufDatumFactory.get(TajoIdProtos.QueryIdProto.class.getName());
 
-    Tuple tuple = new VTuple(11 + (handleProtobuf ? 1 : 0));
+    VTuple tuple = new VTuple(11 + (handleProtobuf ? 1 : 0));
     tuple.put(new Datum[] {
         DatumFactory.createBool(true),
         DatumFactory.createChar("hyunsik"),
@@ -385,7 +385,7 @@ public class TestStorages {
     Tuple retrieved;
     while ((retrieved = scanner.next()) != null) {
       for (int i = 0; i < tuple.size(); i++) {
-        assertEquals(tuple.get(i), retrieved.get(i));
+        assertEquals(tuple.get(i), retrieved.asDatum(i));
       }
     }
     scanner.close();
@@ -432,7 +432,7 @@ public class TestStorages {
     QueryId queryid = new QueryId("12345", 5);
     ProtobufDatumFactory factory = ProtobufDatumFactory.get(TajoIdProtos.QueryIdProto.class.getName());
     int columnNum = 11 + (handleProtobuf ? 1 : 0);
-    Tuple seedTuple = new VTuple(columnNum);
+    VTuple seedTuple = new VTuple(columnNum);
     seedTuple.put(new Datum[]{
         DatumFactory.createBool(true),                // 0
         DatumFactory.createChar("hyunsik"),           // 2
@@ -478,9 +478,9 @@ public class TestStorages {
       assertEquals(columnNum, retrieved.size());
       for (int j = 0; j < columnNum; j++) {
         if (i == j) {
-          assertEquals(NullDatum.get(), retrieved.get(j));
+          assertEquals(NullDatum.get(), retrieved.asDatum(j));
         } else {
-          assertEquals(seedTuple.get(j), retrieved.get(j));
+          assertEquals(seedTuple.get(j), retrieved.asDatum(j));
         }
       }
 
@@ -521,8 +521,7 @@ public class TestStorages {
     QueryId queryid = new QueryId("12345", 5);
     ProtobufDatumFactory factory = ProtobufDatumFactory.get(TajoIdProtos.QueryIdProto.class.getName());
 
-    Tuple tuple = new VTuple(13);
-    tuple.put(new Datum[] {
+    VTuple tuple = new VTuple(new Datum[] {
         DatumFactory.createBool(true),
         DatumFactory.createBit((byte) 0x99),
         DatumFactory.createChar("jinho"),
@@ -551,7 +550,7 @@ public class TestStorages {
     Tuple retrieved;
     while ((retrieved=scanner.next()) != null) {
       for (int i = 0; i < tuple.size(); i++) {
-        assertEquals(tuple.get(i), retrieved.get(i));
+        assertEquals(tuple.get(i), retrieved.asDatum(i));
       }
     }
     scanner.close();
@@ -591,8 +590,7 @@ public class TestStorages {
     QueryId queryid = new QueryId("12345", 5);
     ProtobufDatumFactory factory = ProtobufDatumFactory.get(TajoIdProtos.QueryIdProto.class.getName());
 
-    Tuple tuple = new VTuple(13);
-    tuple.put(new Datum[] {
+    VTuple tuple = new VTuple(new Datum[] {
         DatumFactory.createBool(true),
         DatumFactory.createBit((byte) 0x99),
         DatumFactory.createChar("jinho"),
@@ -621,7 +619,7 @@ public class TestStorages {
     Tuple retrieved;
     while ((retrieved=scanner.next()) != null) {
       for (int i = 0; i < tuple.size(); i++) {
-        assertEquals(tuple.get(i), retrieved.get(i));
+        assertEquals(tuple.get(i), retrieved.asDatum(i));
       }
     }
     scanner.close();
@@ -661,8 +659,7 @@ public class TestStorages {
     QueryId queryid = new QueryId("12345", 5);
     ProtobufDatumFactory factory = ProtobufDatumFactory.get(TajoIdProtos.QueryIdProto.class.getName());
 
-    Tuple tuple = new VTuple(13);
-    tuple.put(new Datum[] {
+    VTuple tuple = new VTuple(new Datum[] {
         DatumFactory.createBool(true),
         DatumFactory.createBit((byte) 0x99),
         DatumFactory.createChar("jinho"),
@@ -695,7 +692,7 @@ public class TestStorages {
     Tuple retrieved;
     while ((retrieved=scanner.next()) != null) {
       for (int i = 0; i < tuple.size(); i++) {
-        assertEquals(tuple.get(i), retrieved.get(i));
+        assertEquals(tuple.get(i), retrieved.asDatum(i));
       }
     }
     scanner.close();
@@ -735,7 +732,7 @@ public class TestStorages {
     QueryId queryid = new QueryId("12345", 5);
     ProtobufDatumFactory factory = ProtobufDatumFactory.get(TajoIdProtos.QueryIdProto.class.getName());
 
-    Tuple tuple = new VTuple(13);
+    VTuple tuple = new VTuple(13);
     tuple.put(new Datum[] {
         DatumFactory.createBool(true),
         DatumFactory.createBit((byte) 0x99),
@@ -769,7 +766,7 @@ public class TestStorages {
     Tuple retrieved;
     while ((retrieved=scanner.next()) != null) {
       for (int i = 0; i < tuple.size(); i++) {
-        assertEquals(tuple.get(i), retrieved.get(i));
+        assertEquals(tuple.get(i), retrieved.asDatum(i));
       }
     }
     scanner.close();
@@ -793,8 +790,7 @@ public class TestStorages {
       Appender appender = sm.getAppender(meta, schema, tablePath);
       appender.init();
 
-      Tuple tuple = new VTuple(3);
-      tuple.put(new Datum[]{
+      VTuple tuple = new VTuple(new Datum[]{
           DatumFactory.createDate("1980-04-01"),
           DatumFactory.createTime("12:34:56"),
           DatumFactory.createTimestmpDatumWithUnixTime((int)(System.currentTimeMillis() /
1000))
@@ -811,7 +807,7 @@ public class TestStorages {
       Tuple retrieved;
       while ((retrieved = scanner.next()) != null) {
         for (int i = 0; i < tuple.size(); i++) {
-          assertEquals(tuple.get(i), retrieved.get(i));
+          assertEquals(tuple.get(i), retrieved.asDatum(i));
         }
       }
       scanner.close();
@@ -927,8 +923,7 @@ public class TestStorages {
 
     appender.init();
 
-    Tuple tuple = new VTuple(5);
-    tuple.put(new Datum[]{
+    VTuple tuple = new VTuple(new Datum[]{
         DatumFactory.createFloat4(Float.MAX_VALUE),
         DatumFactory.createFloat8(Double.MAX_VALUE),
         DatumFactory.createInt2(Short.MAX_VALUE),
@@ -948,7 +943,7 @@ public class TestStorages {
     Tuple retrieved;
     while ((retrieved = scanner.next()) != null) {
       for (int i = 0; i < tuple.size(); i++) {
-        assertEquals(tuple.get(i), retrieved.get(i));
+        assertEquals(tuple.get(i), retrieved.asDatum(i));
       }
     }
     scanner.close();
@@ -1016,11 +1011,11 @@ public class TestStorages {
     scanner.close();
 
     if (scanner.isProjectable()) {
-      assertEquals(expect.get(1), tuple.get(0));
-      assertEquals(NullDatum.get(), tuple.get(1));
+      assertEquals(expect.asDatum(1), tuple.asDatum(0));
+      assertEquals(NullDatum.get(), tuple.asDatum(1));
     } else {
-      assertEquals(expect.get(1), tuple.get(1));
-      assertEquals(NullDatum.get(), tuple.get(4));
+      assertEquals(expect.asDatum(1), tuple.asDatum(1));
+      assertEquals(NullDatum.get(), tuple.asDatum(4));
     }
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestBSTIndex.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestBSTIndex.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestBSTIndex.java
index e15c474..bcfca0f 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestBSTIndex.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestBSTIndex.java
@@ -135,8 +135,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(1));
-      keyTuple.put(1, tuple.get(2));
+      keyTuple.put(0, tuple.asDatum(1));
+      keyTuple.put(1, tuple.asDatum(2));
       creater.write(keyTuple, offset);
     }
 
@@ -156,8 +156,8 @@ public class TestBSTIndex {
       long offsets = reader.find(tuple);
       scanner.seek(offsets);
       tuple = scanner.next();
-      assertTrue("seek check [" + (i) + " ," + (tuple.get(1).asInt8()) + "]", (i) == (tuple.get(1).asInt8()));
-      assertTrue("seek check [" + (i) + " ," + (tuple.get(2).asFloat8()) + "]", (i) == (tuple.get(2).asFloat8()));
+      assertTrue("seek check [" + (i) + " ," + (tuple.getInt8(1)) + "]", (i) == (tuple.getInt8(1)));
+      assertTrue("seek check [" + (i) + " ," + (tuple.getFloat8(2)) + "]", (i) == (tuple.getFloat8(2)));
 
       offsets = reader.next();
       if (offsets == -1) {
@@ -165,8 +165,8 @@ public class TestBSTIndex {
       }
       scanner.seek(offsets);
       tuple = scanner.next();
-      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.get(0).asInt4()));
-      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.get(1).asInt8()));
+      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.getInt4(0)));
+      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.getInt8(1)));
     }
     reader.close();
     scanner.close();
@@ -235,8 +235,8 @@ public class TestBSTIndex {
       long offsets = reader.find(tuple);
       scanner.seek(offsets);
       tuple = scanner.next();
-      assertTrue("[seek check " + (i) + " ]", (i) == (tuple.get(1).asInt8()));
-      assertTrue("[seek check " + (i) + " ]", (i) == (tuple.get(2).asFloat8()));
+      assertTrue("[seek check " + (i) + " ]", (i) == (tuple.getInt8(1)));
+      assertTrue("[seek check " + (i) + " ]", (i) == (tuple.getFloat8(2)));
 
       offsets = reader.next();
       if (offsets == -1) {
@@ -244,8 +244,8 @@ public class TestBSTIndex {
       }
       scanner.seek(offsets);
       tuple = scanner.next();
-      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.get(0).asInt4()));
-      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.get(1).asInt8()));
+      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.getInt4(0)));
+      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (tuple.getInt8(1)));
     }
     reader.close();
     scanner.close();
@@ -300,8 +300,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(1));
-      keyTuple.put(1, tuple.get(2));
+      keyTuple.put(0, tuple.asDatum(1));
+      keyTuple.put(1, tuple.asDatum(2));
       creater.write(keyTuple, offset);
     }
 
@@ -371,8 +371,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(0));
-      keyTuple.put(1, tuple.get(1));
+      keyTuple.put(0, tuple.asDatum(0));
+      keyTuple.put(1, tuple.asDatum(1));
       creater.write(keyTuple, offset);
     }
 
@@ -395,8 +395,8 @@ public class TestBSTIndex {
       scanner.seek(offsets);
       result = scanner.next();
       assertTrue("[seek check " + (i + 1) + " ]",
-          (i + 1) == (result.get(0).asInt4()));
-      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (result.get(1).asInt8()));
+          (i + 1) == (result.getInt4(0)));
+      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (result.getInt8(1)));
 
       offsets = reader.next();
       if (offsets == -1) {
@@ -404,8 +404,8 @@ public class TestBSTIndex {
       }
       scanner.seek(offsets);
       result = scanner.next();
-      assertTrue("[seek check " + (i + 2) + " ]", (i + 2) == (result.get(0).asInt8()));
-      assertTrue("[seek check " + (i + 2) + " ]", (i + 2) == (result.get(1).asFloat8()));
+      assertTrue("[seek check " + (i + 2) + " ]", (i + 2) == (result.getInt8(0)));
+      assertTrue("[seek check " + (i + 2) + " ]", (i + 2) == (result.getFloat8(1)));
     }
     reader.close();
     scanner.close();
@@ -462,8 +462,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(0));
-      keyTuple.put(1, tuple.get(1));
+      keyTuple.put(0, tuple.asDatum(0));
+      keyTuple.put(1, tuple.asDatum(1));
       creater.write(keyTuple, offset);
     }
 
@@ -485,8 +485,8 @@ public class TestBSTIndex {
       long offsets = reader.find(keyTuple, true);
       scanner.seek(offsets);
       result = scanner.next();
-      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (result.get(0).asInt4()));
-      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (result.get(1).asInt8()));
+      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (result.getInt4(0)));
+      assertTrue("[seek check " + (i + 1) + " ]", (i + 1) == (result.getInt8(1)));
     }
     scanner.close();
   }
@@ -541,8 +541,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(1));
-      keyTuple.put(1, tuple.get(2));
+      keyTuple.put(0, tuple.asDatum(1));
+      keyTuple.put(1, tuple.asDatum(2));
       creater.write(keyTuple, offset);
     }
 
@@ -568,8 +568,8 @@ public class TestBSTIndex {
     assertTrue(offset >= 0);
     scanner.seek(offset);
     tuple = scanner.next();
-    assertEquals(5, tuple.get(1).asInt4());
-    assertEquals(5l, tuple.get(2).asInt8());
+    assertEquals(5, tuple.getInt4(1));
+    assertEquals(5l, tuple.getInt8(2));
     reader.close();
     scanner.close();
   }
@@ -624,8 +624,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(0));
-      keyTuple.put(1, tuple.get(1));
+      keyTuple.put(0, tuple.asDatum(0));
+      keyTuple.put(1, tuple.asDatum(1));
       creater.write(keyTuple, offset);
     }
 
@@ -638,12 +638,12 @@ public class TestBSTIndex {
     reader.open();
 
     Tuple min = reader.getFirstKey();
-    assertEquals(5, min.get(0).asInt4());
-    assertEquals(5l, min.get(0).asInt8());
+    assertEquals(5, min.getInt4(0));
+    assertEquals(5l, min.getInt8(0));
 
     Tuple max = reader.getLastKey();
-    assertEquals(TUPLE_NUM - 1, max.get(0).asInt4());
-    assertEquals(TUPLE_NUM - 1, max.get(0).asInt8());
+    assertEquals(TUPLE_NUM - 1, max.getInt4(0));
+    assertEquals(TUPLE_NUM - 1, max.getInt8(0));
     reader.close();
   }
 
@@ -729,8 +729,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(0));
-      keyTuple.put(1, tuple.get(1));
+      keyTuple.put(0, tuple.asDatum(0));
+      keyTuple.put(1, tuple.asDatum(1));
       creater.write(keyTuple, offset);
     }
 
@@ -810,8 +810,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(1));
-      keyTuple.put(1, tuple.get(2));
+      keyTuple.put(0, tuple.asDatum(1));
+      keyTuple.put(1, tuple.asDatum(2));
       creater.write(keyTuple, offset);
     }
 
@@ -833,8 +833,8 @@ public class TestBSTIndex {
       long offsets = reader.find(tuple);
       scanner.seek(offsets);
       tuple = scanner.next();
-      assertTrue("seek check [" + (i) + " ," + (tuple.get(1).asInt8()) + "]", (i) == (tuple.get(1).asInt8()));
-      assertTrue("seek check [" + (i) + " ," + (tuple.get(2).asFloat8()) + "]", (i) == (tuple.get(2).asFloat8()));
+      assertTrue("seek check [" + (i) + " ," + (tuple.getInt8(1)) + "]", (i) == (tuple.getInt8(1)));
+      assertTrue("seek check [" + (i) + " ," + (tuple.getFloat8(2)) + "]", (i) == (tuple.getFloat8(2)));
 
       offsets = reader.next();
       if (offsets == -1) {
@@ -842,8 +842,8 @@ public class TestBSTIndex {
       }
       scanner.seek(offsets);
       tuple = scanner.next();
-      assertTrue("[seek check " + (i - 1) + " ]", (i - 1) == (tuple.get(0).asInt4()));
-      assertTrue("[seek check " + (i - 1) + " ]", (i - 1) == (tuple.get(1).asInt8()));
+      assertTrue("[seek check " + (i - 1) + " ]", (i - 1) == (tuple.getInt4(0)));
+      assertTrue("[seek check " + (i - 1) + " ]", (i - 1) == (tuple.getInt8(1)));
     }
     reader.close();
     scanner.close();
@@ -900,8 +900,8 @@ public class TestBSTIndex {
       tuple = scanner.next();
       if (tuple == null) break;
 
-      keyTuple.put(0, tuple.get(0));
-      keyTuple.put(1, tuple.get(1));
+      keyTuple.put(0, tuple.asDatum(0));
+      keyTuple.put(1, tuple.asDatum(1));
       creater.write(keyTuple, offset);
     }
 
@@ -929,8 +929,8 @@ public class TestBSTIndex {
       scanner.seek(offsets);
       result = scanner.next();
       assertTrue("[seek check " + (i - 1) + " ]",
-          (i - 1) == (result.get(0).asInt4()));
-      assertTrue("[seek check " + (i - 1) + " ]", (i - 1) == (result.get(1).asInt8()));
+          (i - 1) == (result.getInt4(0)));
+      assertTrue("[seek check " + (i - 1) + " ]", (i - 1) == (result.getInt8(1)));
 
       offsets = reader.next();
       if (offsets == -1) {
@@ -938,8 +938,8 @@ public class TestBSTIndex {
       }
       scanner.seek(offsets);
       result = scanner.next();
-      assertTrue("[seek check " + (i - 2) + " ]", (i - 2) == (result.get(0).asInt8()));
-      assertTrue("[seek check " + (i - 2) + " ]", (i - 2) == (result.get(1).asFloat8()));
+      assertTrue("[seek check " + (i - 2) + " ]", (i - 2) == (result.getInt8(0)));
+      assertTrue("[seek check " + (i - 2) + " ]", (i - 2) == (result.getFloat8(1)));
     }
     reader.close();
     scanner.close();

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestSingleCSVFileBSTIndex.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestSingleCSVFileBSTIndex.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestSingleCSVFileBSTIndex.java
index 09191f4..49da04b 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestSingleCSVFileBSTIndex.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/index/TestSingleCSVFileBSTIndex.java
@@ -122,8 +122,8 @@ public class TestSingleCSVFileBSTIndex {
       if (tuple == null)
         break;
 
-      keyTuple.put(0, tuple.get(1));
-      keyTuple.put(1, tuple.get(2));
+      keyTuple.put(0, tuple.asDatum(1));
+      keyTuple.put(1, tuple.asDatum(2));
       creater.write(keyTuple, offset);
     }
 
@@ -143,8 +143,8 @@ public class TestSingleCSVFileBSTIndex {
       long offsets = reader.find(tuple);
       fileScanner.seek(offsets);
       tuple = fileScanner.next();
-      assertEquals(i,  (tuple.get(1).asInt8()));
-      assertEquals(i, (tuple.get(2).asFloat8()) , 0.01);
+      assertEquals(i,  (tuple.getInt8(1)));
+      assertEquals(i, (tuple.getFloat8(2)) , 0.01);
 
       offsets = reader.next();
       if (offsets == -1) {
@@ -153,9 +153,9 @@ public class TestSingleCSVFileBSTIndex {
       fileScanner.seek(offsets);
       tuple = fileScanner.next();
       assertTrue("[seek check " + (i + 1) + " ]",
-          (i + 1) == (tuple.get(0).asInt4()));
+          (i + 1) == (tuple.getInt4(0)));
       assertTrue("[seek check " + (i + 1) + " ]",
-          (i + 1) == (tuple.get(1).asInt8()));
+          (i + 1) == (tuple.getInt8(1)));
     }
   }
 
@@ -210,8 +210,8 @@ public class TestSingleCSVFileBSTIndex {
       tuple = fileScanner.next();
       if (tuple == null) break;
       
-      keyTuple.put(0, tuple.get(0));
-      keyTuple.put(1, tuple.get(1));
+      keyTuple.put(0, tuple.asDatum(0));
+      keyTuple.put(1, tuple.asDatum(1));
       creater.write(keyTuple, offset);
     }
     
@@ -231,8 +231,8 @@ public class TestSingleCSVFileBSTIndex {
       long offsets = reader.find(keyTuple, true);
       fileScanner.seek(offsets);
       result = fileScanner.next();
-      assertTrue("[seek check " + (i + 1) + " ]" , (i + 1) == (result.get(0).asInt4()));
-      assertTrue("[seek check " + (i + 1) + " ]" , (i + 1) == (result.get(1).asInt8()));
+      assertTrue("[seek check " + (i + 1) + " ]" , (i + 1) == (result.getInt4(0)));
+      assertTrue("[seek check " + (i + 1) + " ]" , (i + 1) == (result.getInt8(1)));
       
       offsets = reader.next();
       if (offsets == -1) {
@@ -240,8 +240,8 @@ public class TestSingleCSVFileBSTIndex {
       }
       fileScanner.seek(offsets);
       result = fileScanner.next();
-      assertTrue("[seek check " + (i + 2) + " ]" , (i + 2) == (result.get(0).asInt8()));
-      assertTrue("[seek check " + (i + 2) + " ]" , (i + 2) == (result.get(1).asFloat8()));
+      assertTrue("[seek check " + (i + 2) + " ]" , (i + 2) == (result.getInt8(0)));
+      assertTrue("[seek check " + (i + 2) + " ]" , (i + 2) == (result.getFloat8(1)));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/json/TestJsonSerDe.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/json/TestJsonSerDe.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/json/TestJsonSerDe.java
index 48e2db9..adc7a05 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/json/TestJsonSerDe.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/json/TestJsonSerDe.java
@@ -77,8 +77,7 @@ public class TestJsonSerDe {
     assertNull(scanner.next());
     scanner.close();
 
-    Tuple baseTuple = new VTuple(11);
-    baseTuple.put(new Datum[] {
+    Tuple baseTuple = new VTuple(new Datum[] {
         DatumFactory.createBool(true),                  // 0
         DatumFactory.createChar("hyunsik"),             // 1
         DatumFactory.createInt2((short) 17),            // 2

http://git-wip-us.apache.org/repos/asf/tajo/blob/5c2aee23/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/parquet/TestReadWrite.java
----------------------------------------------------------------------
diff --git a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/parquet/TestReadWrite.java
b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/parquet/TestReadWrite.java
index 109fed9..e63230d 100644
--- a/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/parquet/TestReadWrite.java
+++ b/tajo-storage/tajo-storage-hdfs/src/test/java/org/apache/tajo/storage/parquet/TestReadWrite.java
@@ -104,6 +104,6 @@ public class TestReadWrite {
     assertEquals(new Double(4.1), new Double(tuple.getFloat8(7)));
     assertTrue(HELLO.equals(tuple.getText(8)));
     assertArrayEquals(HELLO.getBytes(Charsets.UTF_8), tuple.getBytes(9));
-    assertEquals(NullDatum.get(), tuple.get(10));
+    assertTrue(tuple.isBlankOrNull(10));
   }
 }


Mime
View raw message