-
Notifications
You must be signed in to change notification settings - Fork 28k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-16941]Use concurrentHashMap instead of scala Map in SparkSQLOperationManager. #14534
Changes from 4 commits
4af58bc
a333269
2591b50
592d817
0a436a0
4f27261
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,7 @@ | |
package org.apache.spark.sql.hive.thriftserver.server | ||
|
||
import java.util.{Map => JMap} | ||
|
||
import scala.collection.mutable.Map | ||
import java.util.concurrent.ConcurrentHashMap | ||
|
||
import org.apache.hive.service.cli._ | ||
import org.apache.hive.service.cli.operation.{ExecuteStatementOperation, Operation, OperationManager} | ||
|
@@ -39,15 +38,19 @@ private[thriftserver] class SparkSQLOperationManager() | |
val handleToOperation = ReflectionUtils | ||
.getSuperField[JMap[OperationHandle, Operation]](this, "handleToOperation") | ||
|
||
val sessionToActivePool = Map[SessionHandle, String]() | ||
val sessionToContexts = Map[SessionHandle, SQLContext]() | ||
val sessionToActivePool = new ConcurrentHashMap[SessionHandle, String]() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While we're here, make them There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the whole class is private, it this necessary to make flied to be private? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's only There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah OK, leave it. It'd be nice to encapsulate access a bit more but not that important. = |
||
val sessionToContexts = new ConcurrentHashMap[SessionHandle, SQLContext]() | ||
|
||
override def newExecuteStatementOperation( | ||
parentSession: HiveSession, | ||
statement: String, | ||
confOverlay: JMap[String, String], | ||
async: Boolean): ExecuteStatementOperation = synchronized { | ||
val sqlContext = sessionToContexts(parentSession.getSessionHandle) | ||
val sqlContext = sessionToContexts.get(parentSession.getSessionHandle) | ||
if (null == sqlContext) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this have to be |
||
throw new HiveSQLException(s"Session handle: ${parentSession.getSessionHandle} has not been" + | ||
s" initialed or had already closed.") | ||
} | ||
val sessionState = sqlContext.sessionState.asInstanceOf[HiveSessionState] | ||
val runInBackground = async && sessionState.hiveThriftServerAsync | ||
val operation = new SparkExecuteStatementOperation(parentSession, statement, confOverlay, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (pool != null)