tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jihoon...@apache.org
Subject git commit: TAJO-825: Datetime type refactoring. (fixed missing changes)
Date Thu, 22 May 2014 01:57:59 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 526dca28b -> 5bdfe887a


TAJO-825: Datetime type refactoring. (fixed missing changes)


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

Branch: refs/heads/master
Commit: 5bdfe887a4eeb54f830369804e82d6baec4e7a5f
Parents: 526dca2
Author: Jihoon Son <jihoonson@apache.org>
Authored: Thu May 22 10:57:26 2014 +0900
Committer: Jihoon Son <jihoonson@apache.org>
Committed: Thu May 22 10:57:26 2014 +0900

----------------------------------------------------------------------
 .../datetime/DateTimePartFromUnixTimeStamp.java | 141 -------------------
 .../datetime/DateTimePartFromUnixTimestamp.java | 141 +++++++++++++++++++
 2 files changed, 141 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tajo/blob/5bdfe887/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
deleted file mode 100644
index 8705b06..0000000
--- a/tajo-core/src/main/java/org/apache/tajo/engine/function/datetime/DateTimePartFromUnixTimeStamp.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tajo.engine.function.datetime;
-
-import org.apache.tajo.catalog.Column;
-import org.apache.tajo.common.TajoDataTypes;
-import org.apache.tajo.datum.*;
-import org.apache.tajo.engine.function.GeneralFunction;
-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 static org.apache.tajo.common.TajoDataTypes.Type.*;
-
-
-@Description(
-    functionName = "utc_usec_to",
-    description = "Extract field from time",
-    example = "> SELECT utc_usec_to('day', 1274259481071200);\n"
-        + "1274227200000000",
-    returnType = TajoDataTypes.Type.INT8,
-    paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.INT8}),
-        @ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT4})}
-)
-public class DateTimePartFromUnixTimestamp extends GeneralFunction {
-
-  private DateTimePartExtractorFromUnixTime extractor = null;
-  private WeekPartExtractorFromUnixTime weekExtractor = null;
-
-  public DateTimePartFromUnixTimestamp() {
-    super(new Column[]{
-        new Column("target", TEXT),
-        new Column("source", INT8),
-        new Column("dayOfWeek", INT4),
-
-    });
-  }
-
-  @Override
-  public Datum eval(Tuple params) {
-
-    Datum target = params.get(0);
-    DateTime dateTime;
-    Int4Datum dayOfWeek = null;
-
-    if (target instanceof NullDatum || params.get(1) instanceof NullDatum) {
-      return NullDatum.get();
-    }
-
-    if (params.get(1) instanceof Int8Datum) {
-      dateTime = DateTimeUtil.getUTCDateTime((Int8Datum) (params.get(1)));
-    } else {
-      return NullDatum.get();
-    }
-
-
-    if ( null == extractor || null == weekExtractor) {
-
-      String extractType = target.asChars().toLowerCase();
-
-      if (extractType.equals("day")) {
-        extractor = new DayExtractorFromTime();
-      } else if (extractType.equals("hour")) {
-        extractor = new HourExtractorFromTime();
-      } else if (extractType.equals("month")) {
-        extractor = new MonthExtractorFromTime();
-      } else if (extractType.equals("year")) {
-        extractor = new YearExtractorFromTime();
-      } else if (extractType.equals("week")) {
-        if (params.get(2) instanceof NullDatum) {
-          return NullDatum.get();
-        }
-        dayOfWeek = (Int4Datum) params.get(2);
-        weekExtractor = new WeekExtractorFromTime();
-      }
-    }
-
-    return null != weekExtractor ? weekExtractor.extract(dateTime, dayOfWeek.asInt4()) :
extractor.extract(dateTime);
-  }
-
-  private interface DateTimePartExtractorFromUnixTime {
-    public Datum extract(DateTime dateTime);
-  }
-
-  private interface WeekPartExtractorFromUnixTime {
-    public Datum extract(DateTime dateTime, int week);
-  }
-
-  private class DayExtractorFromTime implements DateTimePartExtractorFromUnixTime {
-    @Override
-    public Datum extract(DateTime dateTime) {
-      return DatumFactory.createInt8(DateTimeUtil.getDay(dateTime));
-    }
-  }
-
-  private class HourExtractorFromTime implements DateTimePartExtractorFromUnixTime {
-    @Override
-    public Datum extract(DateTime dateTime) {
-      return DatumFactory.createInt8(DateTimeUtil.getHour(dateTime));
-    }
-  }
-
-  private class MonthExtractorFromTime implements DateTimePartExtractorFromUnixTime {
-    @Override
-    public Datum extract(DateTime dateTime) {
-      return DatumFactory.createInt8(DateTimeUtil.getMonth(dateTime));
-    }
-  }
-
-  private class YearExtractorFromTime implements DateTimePartExtractorFromUnixTime {
-    @Override
-    public Datum extract(DateTime dateTime) {
-      return DatumFactory.createInt8(DateTimeUtil.getYear(dateTime));
-    }
-  }
-
-  private class WeekExtractorFromTime implements WeekPartExtractorFromUnixTime {
-    @Override
-    public Datum extract(DateTime dateTime , int week) {
-      return DatumFactory.createInt8(DateTimeUtil.getDayOfWeek(dateTime,week));
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/tajo/blob/5bdfe887/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
new file mode 100644
index 0000000..8705b06
--- /dev/null
+++ b/tajo-core/src/main/java/org/apache/tajo/engine/function/datetime/DateTimePartFromUnixTimestamp.java
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.tajo.engine.function.datetime;
+
+import org.apache.tajo.catalog.Column;
+import org.apache.tajo.common.TajoDataTypes;
+import org.apache.tajo.datum.*;
+import org.apache.tajo.engine.function.GeneralFunction;
+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 static org.apache.tajo.common.TajoDataTypes.Type.*;
+
+
+@Description(
+    functionName = "utc_usec_to",
+    description = "Extract field from time",
+    example = "> SELECT utc_usec_to('day', 1274259481071200);\n"
+        + "1274227200000000",
+    returnType = TajoDataTypes.Type.INT8,
+    paramTypes = {@ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.INT8}),
+        @ParamTypes(paramTypes = {TajoDataTypes.Type.TEXT, TajoDataTypes.Type.INT8, TajoDataTypes.Type.INT4})}
+)
+public class DateTimePartFromUnixTimestamp extends GeneralFunction {
+
+  private DateTimePartExtractorFromUnixTime extractor = null;
+  private WeekPartExtractorFromUnixTime weekExtractor = null;
+
+  public DateTimePartFromUnixTimestamp() {
+    super(new Column[]{
+        new Column("target", TEXT),
+        new Column("source", INT8),
+        new Column("dayOfWeek", INT4),
+
+    });
+  }
+
+  @Override
+  public Datum eval(Tuple params) {
+
+    Datum target = params.get(0);
+    DateTime dateTime;
+    Int4Datum dayOfWeek = null;
+
+    if (target instanceof NullDatum || params.get(1) instanceof NullDatum) {
+      return NullDatum.get();
+    }
+
+    if (params.get(1) instanceof Int8Datum) {
+      dateTime = DateTimeUtil.getUTCDateTime((Int8Datum) (params.get(1)));
+    } else {
+      return NullDatum.get();
+    }
+
+
+    if ( null == extractor || null == weekExtractor) {
+
+      String extractType = target.asChars().toLowerCase();
+
+      if (extractType.equals("day")) {
+        extractor = new DayExtractorFromTime();
+      } else if (extractType.equals("hour")) {
+        extractor = new HourExtractorFromTime();
+      } else if (extractType.equals("month")) {
+        extractor = new MonthExtractorFromTime();
+      } else if (extractType.equals("year")) {
+        extractor = new YearExtractorFromTime();
+      } else if (extractType.equals("week")) {
+        if (params.get(2) instanceof NullDatum) {
+          return NullDatum.get();
+        }
+        dayOfWeek = (Int4Datum) params.get(2);
+        weekExtractor = new WeekExtractorFromTime();
+      }
+    }
+
+    return null != weekExtractor ? weekExtractor.extract(dateTime, dayOfWeek.asInt4()) :
extractor.extract(dateTime);
+  }
+
+  private interface DateTimePartExtractorFromUnixTime {
+    public Datum extract(DateTime dateTime);
+  }
+
+  private interface WeekPartExtractorFromUnixTime {
+    public Datum extract(DateTime dateTime, int week);
+  }
+
+  private class DayExtractorFromTime implements DateTimePartExtractorFromUnixTime {
+    @Override
+    public Datum extract(DateTime dateTime) {
+      return DatumFactory.createInt8(DateTimeUtil.getDay(dateTime));
+    }
+  }
+
+  private class HourExtractorFromTime implements DateTimePartExtractorFromUnixTime {
+    @Override
+    public Datum extract(DateTime dateTime) {
+      return DatumFactory.createInt8(DateTimeUtil.getHour(dateTime));
+    }
+  }
+
+  private class MonthExtractorFromTime implements DateTimePartExtractorFromUnixTime {
+    @Override
+    public Datum extract(DateTime dateTime) {
+      return DatumFactory.createInt8(DateTimeUtil.getMonth(dateTime));
+    }
+  }
+
+  private class YearExtractorFromTime implements DateTimePartExtractorFromUnixTime {
+    @Override
+    public Datum extract(DateTime dateTime) {
+      return DatumFactory.createInt8(DateTimeUtil.getYear(dateTime));
+    }
+  }
+
+  private class WeekExtractorFromTime implements WeekPartExtractorFromUnixTime {
+    @Override
+    public Datum extract(DateTime dateTime , int week) {
+      return DatumFactory.createInt8(DateTimeUtil.getDayOfWeek(dateTime,week));
+    }
+  }
+}


Mime
View raw message