Skip to content
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-20127][CORE] few warning have been fixed which Intellij IDEA reported Intellij IDEA #17458

Closed
wants to merge 11 commits into from

Conversation

dbolshak
Copy link
Contributor

What changes were proposed in this pull request?

Few changes related to Intellij IDEA inspection.

How was this patch tested?

Changes were tested by existing unit tests

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I brought forward some comments but everything else looks OK. I'd be OK accepting the other changes.

@@ -56,7 +56,7 @@ private[spark] class SparkUI private (
with Logging
with UIRoot {

val killEnabled = sc.map(_.conf.getBoolean("spark.ui.killEnabled", true)).getOrElse(false)
val killEnabled = sc.exists(_.conf.getBoolean("spark.ui.killEnabled", true))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bringing forward some of my comments: I would probably not change this

def getTimeZoneOffset() : Int =
TimeZone.getDefault().getOffset(System.currentTimeMillis()) / 1000 / 60
def getTimeZoneOffset(): Int =
TimeZone.getDefault.getOffset(System.currentTimeMillis()) / 1000 / 60
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wouldn't remove the parens here (though the convention was always to use parens when calling no-arg Java methods?) or elsewhere. That really isn't done consistently at all anyway.

@@ -31,7 +31,7 @@ private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") {
val operationGraphListener = parent.operationGraphListener

def isFairScheduler: Boolean =
jobProgresslistener.schedulingMode == Some(SchedulingMode.FAIR)
jobProgresslistener.schedulingMode.contains(SchedulingMode.FAIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise not sure about this change

@@ -290,7 +290,7 @@ private[ui] class StagePage(parent: StagesTab) extends WebUIPage("stage") {
val _taskTable = new TaskPagedTable(
parent.conf,
UIUtils.prependBaseUri(parent.basePath) +
s"/stages/stage?id=${stageId}&attempt=${stageAttemptId}",
s"/stages/stage?id=$stageId&attempt=$stageAttemptId",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree they can be omitted but not sure it helps

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change was reverted.

@@ -317,7 +317,7 @@ private[spark] object UIUtils extends Logging {
def getHeaderContent(header: String): Seq[Node] = {
if (newlinesInHeader) {
<ul class="unstyled">
{ header.split("\n").map { case t => <li> {t} </li> } }
{ header.split("\n").map(t => <li> {t} </li>)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we normally use {} in this code, like map { t => xxx }.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That also works and gets rid of case. I personally prefer not opening a scope if it's not needed, and it isn't here, but it's minor as it's just a question of () vs {} and would rarely have any other impact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed almost changes related to UI.

@jerryshao
Copy link
Contributor

There're many changes related to UI part, actually we don't have many unit tests covered in this part, so I'm afraid these change may potentially introduce regression.

@@ -35,7 +35,7 @@ private[ui] class StagesTab(parent: SparkUI) extends SparkUITab(parent, "stages"
attachPage(new StagePage(this))
attachPage(new PoolPage(this))

def isFairScheduler: Boolean = progressListener.schedulingMode == Some(SchedulingMode.FAIR)
def isFairScheduler: Boolean = progressListener.schedulingMode.contains(SchedulingMode.FAIR)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to my knowledge, contains on Option breaks Scala 2.10 build (see #15393). I guess we are going to drop the support but not yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for that comment. I did not know that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, this was reverted.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems not reverted yet..

val executorOverhead = (metrics.executorDeserializeTime +
metrics.resultSerializationTime)
val executorOverhead = metrics.executorDeserializeTime +
metrics.resultSerializationTime
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can make this inlined if more commits should be pushed.

@HyukjinKwon
Copy link
Member

HyukjinKwon commented Mar 28, 2017

Probably, I guess this might be fine. Just in my experience, IntelliJ's inspection was quite okay except the case of breaking Scala 2.10. It might be better if they can be manually tested via UI though.

Copy link
Contributor Author

@dbolshak dbolshak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Folks, could you please go back to review? Looks like I reverted all my changes related to your comments.

@HyukjinKwon
Copy link
Member

They are suggestions in my point of view. it doesn't necessarily mean you should follow if there are some reasons.

@dbolshak
Copy link
Contributor Author

@HyukjinKwon could you please explain how to request to merge the PR?

@@ -34,9 +34,9 @@ private[ui] class AllStagesPage(parent: StagesTab) extends WebUIPage("") {
listener.synchronized {
val activeStages = listener.activeStages.values.toSeq
val pendingStages = listener.pendingStages.values.toSeq
val completedStages = listener.completedStages.reverse.toSeq
val completedStages = listener.completedStages.reverse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm neutral on this because Seq.toSeq is a no-op anyway and, theoretically, the type of completedStages could change and then this isn't a Seq, but, in practice, wont' matter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's really matter, it's better to add type to val completedStages, it describes your point much better then trying call no-op method. But it won't be consistent, so I would prefer to leave it as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me not clear, do you request this change back or we can leave my changes.

@@ -103,7 +103,7 @@ private[ui] class StagePage(parent: StagesTab) extends WebUIPage("stage") {
val taskSortColumn = Option(parameterTaskSortColumn).map { sortColumn =>
UIUtils.decodeURLParameter(sortColumn)
}.getOrElse("Index")
val taskSortDesc = Option(parameterTaskSortDesc).map(_.toBoolean).getOrElse(false)
val taskSortDesc = Option(parameterTaskSortDesc).exists(_.toBoolean)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not sure about whether this is clearer. I'm neutral. @HyukjinKwon is right about .contains I think so I'd double check this existed in 2.10?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no Option.contains call any more, it was in another place.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I meant the question is whether .exists is in 2.10, but I am back at a desktop now and found it is, so no problem. That's not the issue, just, whether it's clearer

Copy link
Member

@HyukjinKwon HyukjinKwon Mar 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If my opinion can be helpful.. personally I prefer the previous one to explicitly show the default like the ones below. Actually, I intendedly use this pattern in several places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've reverted this back.

@@ -69,7 +69,7 @@ private[ui] class RDDPage(parent: StorageTab) extends WebUIPage("rdd") {
}
val blockTableHTML = try {
val _blockTable = new BlockPagedTable(
UIUtils.prependBaseUri(parent.basePath) + s"/storage/rdd/?id=${rddId}",
UIUtils.prependBaseUri(parent.basePath) + s"/storage/rdd/?id=$rddId",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't this it's worth unbracing. The braces aren't hard to read and maybe prevent some misinterpretation one day after a refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one I've just reverted back.

Denis Bolshakov added 3 commits March 28, 2017 23:26
@dbolshak
Copy link
Contributor Author

Looks like all comments have been addressed.

@dbolshak
Copy link
Contributor Author

@srowen, @HyukjinKwon could you please merge the PR if it's ok of course?

newTaskInfo.setAccumulables(taskInfo.accumulables.filter {
accum => !accum.internal && accum.metadata != Some(AccumulatorContext.SQL_ACCUM_IDENTIFIER)
newTaskInfo.setAccumulables(taskInfo.accumulables.filter { acc =>
!acc.internal && !acc.metadata.contains(AccumulatorContext.SQL_ACCUM_IDENTIFIER)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should revert this one too for the same reason in https://github.com/apache/spark/pull/17458/files#r108432518

@@ -42,7 +42,7 @@ private[ui] class RDDPage(parent: StorageTab) extends WebUIPage("rdd") {

val blockPage = Option(parameterBlockPage).map(_.toInt).getOrElse(1)
val blockSortColumn = Option(parameterBlockSortColumn).getOrElse("Block Name")
val blockSortDesc = Option(parameterBlockSortDesc).map(_.toBoolean).getOrElse(false)
val blockSortDesc = Option(parameterBlockSortDesc).exists(_.toBoolean)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also looks the same instance. Let's revert this change too.

@@ -116,15 +116,15 @@ private[spark] abstract class WebUI(
* @param path Path in UI to unmount.
*/
def removeStaticHandler(path: String): Unit = {
handlers.find(_.getContextPath() == path).foreach(detachHandler)
handlers.find(_.getContextPath == path).foreach(detachHandler)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbolshak this still isn't addressing comments that have been made several times. You can appreciate why I don't think it's worth the time to make changes like this given how much discussion it takes. Here's another example. Please read all previous comments and address all of them or close this.

@dbolshak
Copy link
Contributor Author

Corrected.
Please take a look.
There is only one change (in 2 places) related to calling toSeq which has comment, but it's not clear can I leave my change or not.

@HyukjinKwon
Copy link
Member

It looks good to me too.

@SparkQA
Copy link

SparkQA commented Mar 30, 2017

Test build #3619 has finished for PR 17458 at commit 4788bbe.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@srowen
Copy link
Member

srowen commented Mar 30, 2017

Merged to master

@asfgit asfgit closed this in 5e00a5d Mar 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants