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 <[email protected]>

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 <[email protected]>
Authored: Sat Jan 30 15:20:57 2016 -0800
Committer: Reynold Xin <[email protected]>
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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to