Skip to content

Commit

Permalink
[SQL] add note of use synchronizedMap in SQLConf
Browse files Browse the repository at this point in the history
Refer to:
http://stackoverflow.com/questions/510632/whats-the-difference-between-concurrenthashmap-and-collections-synchronizedmap
Collections.synchronizedMap(map) creates a blocking Map which will degrade performance, albeit ensure consistency. So use ConcurrentHashMap(a more effective thread-safe hashmap) instead.

also update HiveQuerySuite to fix test error when changed to ConcurrentHashMap.

Author: wangfei <[email protected]>
Author: scwf <[email protected]>

Closes apache#1996 from scwf/sqlconf and squashes the following commits:

93bc0c5 [wangfei] revert change of HiveQuerySuite
0cc05dd [wangfei] add note for use synchronizedMap
3c224d3 [scwf] fix formate
a7bcb98 [scwf] use ConcurrentHashMap in sql conf, intead synchronizedMap
  • Loading branch information
scwf authored and conviva-zz committed Sep 4, 2014
1 parent ff165eb commit 674c9ab
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions sql/core/src/main/scala/org/apache/spark/sql/SQLConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ private[spark] object SQLConf {
trait SQLConf {
import SQLConf._

/** Only low degree of contention is expected for conf, thus NOT using ConcurrentHashMap. */
@transient protected[spark] val settings = java.util.Collections.synchronizedMap(
new java.util.HashMap[String, String]())

Expand Down

0 comments on commit 674c9ab

Please sign in to comment.