Github user ssonker commented on a diff in the pull request:
https://github.com/apache/spark/pull/21505#discussion_r193675674
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeUtils.scala
---
@@ -111,6 +113,24 @@ object DateTimeUtils {
computedTimeZones.computeIfAbsent(timeZoneId, computeTimeZone)
}
+ private val threadLocalComputedCalendarsMap =
+ new ThreadLocal[mutable.Map[TimeZone, (Calendar, Long)]] {
+ override def initialValue(): mutable.Map[TimeZone, (Calendar, Long)]
= {
+ mutable.Map[TimeZone, (Calendar, Long)]()
+ }
+ }
+
+ def getCalendar(timeZone: TimeZone): Calendar = {
+ val (c, timeInMillis) = threadLocalComputedCalendarsMap.get()
+ .getOrElseUpdate(timeZone, {
+ val c = Calendar.getInstance(timeZone)
+ (c, c.getTimeInMillis)
--- End diff --
@viirya ^ Does that answer you question, or you mean something else?
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]