You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by rx...@apache.org on 2016/01/31 00:21:04 UTC

spark git commit: [SPARK-13100][SQL] improving the performance of stringToDate method in DateTimeUtils.scala

Repository: spark
Updated Branches:
  refs/heads/master 289373b28 -> de2837199


[SPARK-13100][SQL] improving the performance of stringToDate method in DateTimeUtils.scala

 In jdk1.7 TimeZone.getTimeZone() is synchronized, so use an instance variable to hold an GMT TimeZone object instead of instantiate it every time.

Author: wangyang <wa...@haizhi.com>

Closes #10994 from wangyang1992/datetimeUtil.


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

Branch: refs/heads/master
Commit: de283719980ae78b740e507e4d70c7ebbf6c5f74
Parents: 289373b
Author: wangyang <wa...@haizhi.com>
Authored: Sat Jan 30 15:20:57 2016 -0800
Committer: Reynold Xin <rx...@databricks.com>
Committed: Sat Jan 30 15:20:57 2016 -0800

----------------------------------------------------------------------
 .../scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/de283719/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
index f18c052..a159bc6 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
@@ -55,6 +55,7 @@ object DateTimeUtils {
   // this is year -17999, calculation: 50 * daysIn400Year
   final val YearZero = -17999
   final val toYearZero = to2001 + 7304850
+  final val TimeZoneGMT = TimeZone.getTimeZone("GMT")
 
   @transient lazy val defaultTimeZone = TimeZone.getDefault
 
@@ -407,7 +408,7 @@ object DateTimeUtils {
         segments(2) < 1 || segments(2) > 31) {
       return None
     }
-    val c = Calendar.getInstance(TimeZone.getTimeZone("GMT"))
+    val c = Calendar.getInstance(TimeZoneGMT)
     c.set(segments(0), segments(1) - 1, segments(2), 0, 0, 0)
     c.set(Calendar.MILLISECOND, 0)
     Some((c.getTimeInMillis / MILLIS_PER_DAY).toInt)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org