Github user ssonker commented on a diff in the pull request:

    https://github.com/apache/spark/pull/21505#discussion_r193679978
  
    --- 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)
    +      })
    +    c.clear()
    +    c.setTimeInMillis(timeInMillis)
    --- End diff --
    
    @kiszk Thanks, I'm updating that. BTW, can you please help me understand a 
scenario where that is absolutely needed.


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to