Skip to content

Commit c68778c

Browse files
committed
Added a comment for getOrCreateFormatter
1 parent 545a710 commit c68778c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/util/DateTimeFormatterHelper.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ trait DateTimeFormatterHelper {
4040
Instant.from(zonedDateTime)
4141
}
4242

43+
// Gets a formatter from the cache or creates new one. The buildFormatter method can be called
44+
// a few times with the same parameters in parallel if the cache does not contain values
45+
// associated to those parameters. Since the formatter is immutable, it does not matter.
46+
// In this way, synchronised is intentionally omitted in this method to make parallel calls
47+
// less synchronised.
48+
// The Cache.get method is not used here to avoid creation of additional instances of Callable.
4349
protected def getOrCreateFormatter(pattern: String, locale: Locale): DateTimeFormatter = {
4450
val key = (pattern, locale)
4551
var formatter = cache.getIfPresent(key)

0 commit comments

Comments
 (0)