tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject [5/6] tajo git commit: TAJO-1161: Remove joda time dependency from tajo-core. (Jihun Kang via hyunsik)
Date Tue, 11 Nov 2014 14:24:50 GMT
TAJO-1161: Remove joda time dependency from tajo-core. (Jihun Kang via hyunsik)

Closes #233


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

Branch: refs/heads/index_support
Commit: 2b8d30ca2ca4fbf1dfda58f482c952441178390d
Parents: f45e74f
Author: Hyunsik Choi <hyunsik@apache.org>
Authored: Tue Nov 11 00:55:08 2014 -0800
Committer: Hyunsik Choi <hyunsik@apache.org>
Committed: Tue Nov 11 00:55:08 2014 -0800

----------------------------------------------------------------------
 CHANGES                                         |  3 +
 tajo-common/pom.xml                             |  4 -
 .../tajo/util/datetime/DateTimeConstants.java   | 22 +++++
 .../apache/tajo/util/datetime/DateTimeUtil.java | 96 +++++++++++++-------
 .../apache/tajo/util/TestDateTimeFormat.java    | 12 +--
 .../org/apache/tajo/util/TestDateTimeUtil.java  | 79 ++++++++++------
 .../datetime/DateTimePartFromUnixTimestamp.java | 18 ++--
 .../engine/function/TestDateTimeFunctions.java  |  9 +-
 tajo-project/pom.xml                            |  5 -
 tajo-rpc/pom.xml                                |  4 -
 10 files changed, 157 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 950a108..d71905b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,9 @@ Release 0.9.1 - unreleased
 
   IMPROVEMENT
    
+    TAJO-1161: Remove joda time dependency from tajo-core. 
+    (Jihun Kang via hyunsik)
+
     TAJO-1133: Add 'bin/tajo version' command. (Jihun Kang via hyunsik)
 
     TAJO-1145: Add 'bin/tajo --help' command. (Jihun Kang via hyunsik)

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-common/pom.xml
----------------------------------------------------------------------
diff --git a/tajo-common/pom.xml b/tajo-common/pom.xml
index 820220c..9bbd5a7 100644
--- a/tajo-common/pom.xml
+++ b/tajo-common/pom.xml
@@ -216,10 +216,6 @@
       <artifactId>gson</artifactId>
     </dependency>
     <dependency>
-      <groupId>joda-time</groupId>
-      <artifactId>joda-time</artifactId>
-    </dependency>
-    <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeConstants.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeConstants.java
b/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeConstants.java
index 353a500..e5a51ef 100644
--- a/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeConstants.java
+++ b/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeConstants.java
@@ -67,6 +67,7 @@ public class DateTimeConstants {
   public static final long USECS_PER_HOUR	= 3600000000L;
   public static final long USECS_PER_MINUTE = 60000000L;
   public static final long USECS_PER_SEC = 1000000L;
+  public static final long USECS_PER_MSEC = 1000L;
 
   public static final int JULIAN_MINYEAR = -4713;
   public static final int JULIAN_MINMONTH = 11;
@@ -75,6 +76,27 @@ public class DateTimeConstants {
 
   /** == DateTimeUtil.toJulianDate(JULIAN_MAXYEAR, 1, 1) */
   public static final int JULIAN_MAX = 2147483494;
+  
+  /** the first ISO day of week */
+  public static final int MONDAY = 1;
+  
+  /** the second ISO day of week */
+  public static final int TUESDAY = 2;
+
+  /** the third ISO day of week */
+  public static final int WEDNESDAY = 3;
+
+  /** the fourth ISO day of week */
+  public static final int THURSDAY = 4;
+
+  /** the fifth ISO day of week */
+  public static final int FRIDAY = 5;
+
+  /** the sixth ISO day of week */
+  public static final int SATURDAY = 6;
+
+  /** the seventh ISO day of week */
+  public static final int SUNDAY = 7;
 
   // Julian-date equivalents of Day 0 in Unix and Postgres reckoning
   /** == DateTimeUtil.toJulianDate(1970, 1, 1) */

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeUtil.java b/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeUtil.java
index 9198f5b..a9dc4e8 100644
--- a/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeUtil.java
+++ b/tajo-common/src/main/java/org/apache/tajo/util/datetime/DateTimeUtil.java
@@ -24,8 +24,6 @@ import org.apache.tajo.exception.ValueOutOfRangeException;
 import org.apache.tajo.util.datetime.DateTimeConstants.DateStyle;
 import org.apache.tajo.util.datetime.DateTimeConstants.DateToken;
 import org.apache.tajo.util.datetime.DateTimeConstants.TokenField;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
 
 import java.util.TimeZone;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -2088,54 +2086,88 @@ public class DateTimeUtil {
     minutes = minutes - hours * DateTimeConstants.MINS_PER_HOUR;
 
     StringBuilder sb = new StringBuilder();
-    String prefix = "";
-
     sb.append(totalSecs > 0 ? "+" : "-").append(String.format("%02d", hours));
 
     if (minutes > 0) {
       sb.append(":").append(String.format("%02d", minutes));
-      prefix = ":";
     }
 
     return sb.toString();
   }
 
-  public static long getDay(DateTime dateTime) {
-    return convertToMicroSeconds(dateTime.withTimeAtStartOfDay());
-  }
-
-  public static long getHour(DateTime dateTime) {
-    return convertToMicroSeconds(dateTime.withTime(dateTime.get(org.joda.time.DateTimeFieldType.hourOfDay()),
0, 0, 0));
-  }
-
-  public static long getMinute(DateTime dateTime) {
-    return convertToMicroSeconds(dateTime.withTime(dateTime.get(org.joda.time.DateTimeFieldType.hourOfDay()),
-        dateTime.get(org.joda.time.DateTimeFieldType.minuteOfHour()), 0, 0));
+  public static long getDay(TimeMeta dateTime) {
+    long usecs = 0;
+    
+    usecs = julianTimeToJavaTime(toJulianTimestamp(dateTime.years, dateTime.monthOfYear,
dateTime.dayOfMonth, 
+        0, 0, 0, 0)) * DateTimeConstants.USECS_PER_MSEC;
+    return usecs;
   }
 
-  public static long getSecond(DateTime dateTime) {
-    return convertToMicroSeconds(dateTime.withTime(dateTime.get(org.joda.time.DateTimeFieldType.hourOfDay()),
-        dateTime.get(org.joda.time.DateTimeFieldType.minuteOfHour()), dateTime.get(org.joda.time.DateTimeFieldType.secondOfMinute()),
0));
+  public static long getHour(TimeMeta dateTime) {
+    long usecs = 0;
+    
+    usecs = julianTimeToJavaTime(toJulianTimestamp(dateTime.years, dateTime.monthOfYear,
dateTime.dayOfMonth, 
+        dateTime.hours, 0, 0, 0)) * DateTimeConstants.USECS_PER_MSEC;
+    return usecs;
   }
 
-  public static long getMonth(DateTime dateTime) {
-    return convertToMicroSeconds(dateTime.withTimeAtStartOfDay().withDate(dateTime.getYear(),
-        dateTime.getMonthOfYear(),1));
+  public static long getMinute(TimeMeta dateTime) {
+    long usecs = 0;
+    
+    usecs = julianTimeToJavaTime(toJulianTimestamp(dateTime.years, dateTime.monthOfYear,
dateTime.dayOfMonth, 
+        dateTime.hours, dateTime.minutes, 0, 0)) * DateTimeConstants.USECS_PER_MSEC;
+    return usecs;
   }
 
-  public static long getDayOfWeek(DateTime dateTime,int week) {
-    return convertToMicroSeconds(dateTime.withTimeAtStartOfDay().withDayOfWeek(week));
+  public static long getSecond(TimeMeta dateTime) {
+    long usecs = 0;
+    
+    usecs = julianTimeToJavaTime(toJulianTimestamp(dateTime.years, dateTime.monthOfYear,
dateTime.dayOfMonth, 
+        dateTime.hours, dateTime.minutes, dateTime.secs, 0)) * DateTimeConstants.USECS_PER_MSEC;
+    return usecs;
   }
 
-  public static long getYear (DateTime dateTime) {
-    return convertToMicroSeconds(dateTime.withTimeAtStartOfDay().withDate(dateTime.getYear(),
1, 1));
+  public static long getMonth(TimeMeta dateTime) {
+    long usecs = 0;
+    
+    usecs = julianTimeToJavaTime(toJulianTimestamp(dateTime.years, dateTime.monthOfYear,
1, 0, 0, 0, 0)) *
+        DateTimeConstants.USECS_PER_MSEC;
+    return usecs;
   }
 
-  public static DateTime getUTCDateTime(Int8Datum int8Datum){
-    return new DateTime(int8Datum.asInt8()/1000, DateTimeZone.UTC);
-  }
-
-  public static long convertToMicroSeconds(DateTime dateTime) {
-    return  dateTime.getMillis() * 1000;
+  public static long getDayOfWeek(TimeMeta dateTime, int weekday) {    
+    if (weekday < 1 || weekday > 7) {
+      throw new RuntimeException("Weekday is out of range. Actual : " + weekday);
+    }
+    
+    int week = date2isoweek(dateTime.years, dateTime.monthOfYear, dateTime.dayOfMonth);
+    int jday = isoweek2j(dateTime.years, week);
+    long usecs = 0;
+    
+    jday += (weekday - 1);
+    
+    jday -=  DateTimeConstants.POSTGRES_EPOCH_JDATE;
+    usecs = julianTimeToJavaTime(toJulianTimestamp(jday, 0, 0, 0, 0)) *
+        DateTimeConstants.USECS_PER_MSEC;
+    return usecs;
+  }
+
+  public static long getYear(TimeMeta dateTime) {
+    long usecs = 0;
+    
+    usecs = julianTimeToJavaTime(toJulianTimestamp(dateTime.years, 1, 1, 0, 0, 0, 0)) *
+        DateTimeConstants.USECS_PER_MSEC;
+    return usecs;
+  }
+
+  public static TimeMeta getUTCDateTime(Int8Datum int8Datum){
+    long usecs = int8Datum.asInt8()%DateTimeConstants.USECS_PER_MSEC;
+    long julianTimestamp = javaTimeToJulianTime(int8Datum.asInt8()/DateTimeConstants.USECS_PER_MSEC);
+    TimeMeta tm = new TimeMeta();
+    
+    julianTimestamp += usecs;
+    toJulianTimeMeta(julianTimestamp, tm);
+    return tm;
   }
+  
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeFormat.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeFormat.java b/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeFormat.java
index 0bfe708..2b5dba0 100644
--- a/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeFormat.java
+++ b/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeFormat.java
@@ -21,8 +21,6 @@ package org.apache.tajo.util;
 import org.apache.tajo.datum.TimestampDatum;
 import org.apache.tajo.util.datetime.DateTimeFormat;
 import org.apache.tajo.util.datetime.TimeMeta;
-import org.joda.time.DateTime;
-import org.joda.time.format.DateTimeFormatter;
 import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
@@ -117,19 +115,11 @@ public class TestDateTimeFormat {
 
   @Test
   public void testPerformance() {
-    DateTimeFormatter jodaFormat = org.joda.time.format.DateTimeFormat.forPattern("YYYY-MM-DD
HH:mm:ss.SSS");
     long startTime = System.currentTimeMillis();
     for (int i = 0; i < 10000000; i++) {
-      DateTime dateTime = jodaFormat.parseDateTime("1997-12-30 11:40:50.345");
+      DateTimeFormat.toTimestamp("1997-12-30 11:40:50.345", "YYYY-MM-DD HH24:MI:SS.MS");
     }
     long endTime = System.currentTimeMillis();
-    System.out.println("total parse time with JodaTime:" + (endTime - startTime) + " ms");
-
-    startTime = System.currentTimeMillis();
-    for (int i = 0; i < 10000000; i++) {
-      TimestampDatum datum = DateTimeFormat.toTimestamp("1997-12-30 11:40:50.345", "YYYY-MM-DD
HH24:MI:SS.MS");
-    }
-    endTime = System.currentTimeMillis();
     System.out.println("total parse time with TajoDateTimeFormat:" + (endTime - startTime)
+ " ms");
   }
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeUtil.java
----------------------------------------------------------------------
diff --git a/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeUtil.java b/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeUtil.java
index e953d44..a54fb94 100644
--- a/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeUtil.java
+++ b/tajo-common/src/test/java/org/apache/tajo/util/TestDateTimeUtil.java
@@ -19,30 +19,21 @@
 package org.apache.tajo.util;
 
 import org.apache.tajo.conf.TajoConf;
+import org.apache.tajo.datum.DatumFactory;
+import org.apache.tajo.datum.Int8Datum;
 import org.apache.tajo.util.datetime.DateTimeConstants;
 import org.apache.tajo.util.datetime.DateTimeUtil;
 import org.apache.tajo.util.datetime.TimeMeta;
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.joda.time.format.DateTimeFormat;
-import org.joda.time.format.DateTimeFormatter;
 import org.junit.Test;
 
 import java.util.Calendar;
+import java.util.Date;
 import java.util.TimeZone;
 
 import static org.junit.Assert.*;
 
 public class TestDateTimeUtil {
-  private static final int TEST_YEAR = 2014;
-  private static final int TEST_MONTH_OF_YEAR = 4;
-  private static final int TEST_DAY_OF_MONTH = 18;
-  private static final int TEST_HOUR_OF_DAY = 0;
-  private static final int TEST_MINUTE_OF_HOUR = 15;
-  private static final int TEST_SECOND_OF_MINUTE = 25;
-  private static final DateTime TEST_DATETIME = new DateTime(TEST_YEAR, TEST_MONTH_OF_YEAR,
TEST_DAY_OF_MONTH,
-      TEST_HOUR_OF_DAY, TEST_MINUTE_OF_HOUR, TEST_SECOND_OF_MINUTE, DateTimeZone.UTC);
-  private static final DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
+  private static final TimeMeta TEST_DATETIME = DateTimeUtil.decodeDateTime("2014-04-18 01:15:25.69148");
 
   @Test
   public void testDecodeDateTime() {
@@ -400,40 +391,76 @@ public class TestDateTimeUtil {
     assertEquals("-09", DateTimeUtil.getTimeZoneDisplayTime(TimeZone.getTimeZone("GMT-9")));
     assertEquals("-09:10", DateTimeUtil.getTimeZoneDisplayTime(TimeZone.getTimeZone("GMT-9:10")));
   }
-
+  
   @Test
   public void testGetYear() {
-    assertEquals(DateTime.parse("2014-01-01 00:00:00", fmt.withZoneUTC()).getMillis() * 1000,
-        DateTimeUtil.getYear(TEST_DATETIME));
+    long javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-01-01 00:00:00"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getYear(TEST_DATETIME));
   }
 
   @Test
   public void testGetMonth() {
-    assertEquals(DateTime.parse("2014-04-01 00:00:00", fmt.withZoneUTC()).getMillis() * 1000,
-        DateTimeUtil.getMonth(TEST_DATETIME));
+    long javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-04-01 00:00:00"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getMonth(TEST_DATETIME));
   }
 
   @Test
   public void testGetDay() {
-    assertEquals(DateTime.parse("2014-04-18 00:00:00", fmt.withZoneUTC()).getMillis() * 1000,
-        DateTimeUtil.getDay(TEST_DATETIME));
+    long javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-04-18 00:00:00"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getDay(TEST_DATETIME));
+  }
+  
+  @Test
+  public void testGetDayOfWeek() {
+    long javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-04-14 00:00:00"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getDayOfWeek(TEST_DATETIME, DateTimeConstants.MONDAY));
+    
+    javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-04-15 00:00:00"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getDayOfWeek(TEST_DATETIME, DateTimeConstants.TUESDAY));
   }
 
   @Test
   public void testGetHour() {
-    assertEquals(DateTime.parse("2014-04-18 00:00:00",fmt.withZoneUTC()).getMillis() * 1000,
-        DateTimeUtil.getHour(TEST_DATETIME));
+    long javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-04-18 01:00:00"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getHour(TEST_DATETIME));
   }
 
   @Test
   public void testGetMinute() {
-    assertEquals(DateTime.parse("2014-04-18 00:15:00",fmt.withZoneUTC()).getMillis() * 1000,
-        DateTimeUtil.getMinute(TEST_DATETIME));
+    long javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-04-18 01:15:00"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getMinute(TEST_DATETIME));
   }
 
   @Test
   public void testGetSecond() {
-    assertEquals(DateTime.parse("2014-04-18 00:15:25",fmt.withZoneUTC()).getMillis() * 1000,
-        DateTimeUtil.getSecond(TEST_DATETIME));
+    long javaTimestamp = 
+        DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp("2014-04-18 01:15:25"))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    assertEquals(javaTimestamp, DateTimeUtil.getSecond(TEST_DATETIME));
+  }
+  
+  @Test
+  public void testGetUTCDateTime() {
+    long javaTimestamp = DateTimeUtil.julianTimeToJavaTime(DateTimeUtil.toJulianTimestamp(TEST_DATETIME))
*
+        DateTimeConstants.USECS_PER_MSEC;
+    javaTimestamp += (TEST_DATETIME.fsecs%DateTimeConstants.USECS_PER_MSEC);
+    Int8Datum datum = DatumFactory.createInt8(javaTimestamp);
+    
+    assertTrue(TEST_DATETIME.equals(DateTimeUtil.getUTCDateTime(datum)));
   }
+  
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-core/src/main/java/org/apache/tajo/engine/function/datetime/DateTimePartFromUnixTimestamp.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/function/datetime/DateTimePartFromUnixTimestamp.java
b/tajo-core/src/main/java/org/apache/tajo/engine/function/datetime/DateTimePartFromUnixTimestamp.java
index 97b5b88..4e0449d 100644
--- a/tajo-core/src/main/java/org/apache/tajo/engine/function/datetime/DateTimePartFromUnixTimestamp.java
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/datetime/DateTimePartFromUnixTimestamp.java
@@ -26,7 +26,7 @@ import org.apache.tajo.engine.function.annotation.Description;
 import org.apache.tajo.engine.function.annotation.ParamTypes;
 import org.apache.tajo.storage.Tuple;
 import org.apache.tajo.util.datetime.DateTimeUtil;
-import org.joda.time.DateTime;
+import org.apache.tajo.util.datetime.TimeMeta;
 
 import static org.apache.tajo.common.TajoDataTypes.Type.*;
 
@@ -58,7 +58,7 @@ public class DateTimePartFromUnixTimestamp extends GeneralFunction {
   public Datum eval(Tuple params) {
 
     Datum target = params.get(0);
-    DateTime dateTime;
+    TimeMeta dateTime;
     Int4Datum dayOfWeek = null;
 
     if (target instanceof NullDatum || params.get(1) instanceof NullDatum) {
@@ -97,44 +97,44 @@ public class DateTimePartFromUnixTimestamp extends GeneralFunction {
   }
 
   private interface DateTimePartExtractorFromUnixTime {
-    public Datum extract(DateTime dateTime);
+    public Datum extract(TimeMeta dateTime);
   }
 
   private interface WeekPartExtractorFromUnixTime {
-    public Datum extract(DateTime dateTime, int week);
+    public Datum extract(TimeMeta dateTime, int week);
   }
 
   private class DayExtractorFromTime implements DateTimePartExtractorFromUnixTime {
     @Override
-    public Datum extract(DateTime dateTime) {
+    public Datum extract(TimeMeta dateTime) {
       return DatumFactory.createInt8(DateTimeUtil.getDay(dateTime));
     }
   }
 
   private class HourExtractorFromTime implements DateTimePartExtractorFromUnixTime {
     @Override
-    public Datum extract(DateTime dateTime) {
+    public Datum extract(TimeMeta dateTime) {
       return DatumFactory.createInt8(DateTimeUtil.getHour(dateTime));
     }
   }
 
   private class MonthExtractorFromTime implements DateTimePartExtractorFromUnixTime {
     @Override
-    public Datum extract(DateTime dateTime) {
+    public Datum extract(TimeMeta dateTime) {
       return DatumFactory.createInt8(DateTimeUtil.getMonth(dateTime));
     }
   }
 
   private class YearExtractorFromTime implements DateTimePartExtractorFromUnixTime {
     @Override
-    public Datum extract(DateTime dateTime) {
+    public Datum extract(TimeMeta dateTime) {
       return DatumFactory.createInt8(DateTimeUtil.getYear(dateTime));
     }
   }
 
   private class WeekExtractorFromTime implements WeekPartExtractorFromUnixTime {
     @Override
-    public Datum extract(DateTime dateTime , int week) {
+    public Datum extract(TimeMeta dateTime , int week) {
       return DatumFactory.createInt8(DateTimeUtil.getDayOfWeek(dateTime,week));
     }
   }

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
----------------------------------------------------------------------
diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
index 619bc5b..7cca13d 100644
--- a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
+++ b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java
@@ -24,7 +24,8 @@ import org.apache.tajo.conf.TajoConf;
 import org.apache.tajo.datum.DatumFactory;
 import org.apache.tajo.datum.TimestampDatum;
 import org.apache.tajo.engine.eval.ExprTestBase;
-import org.joda.time.DateTime;
+import org.apache.tajo.util.datetime.DateTimeUtil;
+import org.apache.tajo.util.datetime.TimeMeta;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -99,11 +100,11 @@ public class TestDateTimeFunctions extends ExprTestBase {
   @Test
   public void testToChar() throws IOException {
     long expectedTimestamp = System.currentTimeMillis();
-    DateTime expectedDateTime = new DateTime(expectedTimestamp);
-    String dateFormatStr = "yyyy-MM";
+    TimeMeta tm = new TimeMeta();
+    DateTimeUtil.toJulianTimeMeta(DateTimeUtil.javaTimeToJulianTime(expectedTimestamp), tm);
     // (expectedTimestamp / 1000) means the translation from millis seconds to unix timestamp
     String q = String.format("select to_char(to_timestamp(%d), 'yyyy-MM');", (expectedTimestamp
/ 1000));
-    testSimpleEval(q, new String[]{expectedDateTime.toString(dateFormatStr)});
+    testSimpleEval(q, new String[]{String.format("%04d-%02d", tm.years, tm.monthOfYear)});
 
     q = "select to_char(to_timestamp('1997-12-30 11:40:00', 'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD
HH24:MI:SS')";
     testSimpleEval(q, new String[]{"1997-12-30 11:40:00"});

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-project/pom.xml
----------------------------------------------------------------------
diff --git a/tajo-project/pom.xml b/tajo-project/pom.xml
index aa8110f..5493095 100644
--- a/tajo-project/pom.xml
+++ b/tajo-project/pom.xml
@@ -1011,11 +1011,6 @@
         <version>4.0.23.Final</version>
       </dependency>
       <dependency>
-        <groupId>joda-time</groupId>
-        <artifactId>joda-time</artifactId>
-        <version>2.3</version>
-      </dependency>
-      <dependency>
         <groupId>org.apache.derby</groupId>
         <artifactId>derby</artifactId>
         <version>10.8.2.2</version>

http://git-wip-us.apache.org/repos/asf/tajo/blob/2b8d30ca/tajo-rpc/pom.xml
----------------------------------------------------------------------
diff --git a/tajo-rpc/pom.xml b/tajo-rpc/pom.xml
index 9079ecd..6a7f379 100644
--- a/tajo-rpc/pom.xml
+++ b/tajo-rpc/pom.xml
@@ -141,10 +141,6 @@
       <artifactId>tajo-common</artifactId>
       <exclusions>
         <exclusion>
-          <groupId>joda-time</groupId>
-          <artifactId>joda-time</artifactId>
-        </exclusion>
-        <exclusion>
           <groupId>com.google.code.gson</groupId>
           <artifactId>gson</artifactId>
         </exclusion>


Mime
View raw message