Skip to content

Conversation

@iRakson
Copy link
Contributor

@iRakson iRakson commented May 12, 2020

What changes were proposed in this pull request?

Currently while implementing pagination using the existing pagination framework, a lot of code is being copied as pointed out here.

I introduced some changes in PagedTable which is the main trait for implementing the pagination.

  • Added function for getting table parameters.
  • Added a function for table header row. This will help in maintaining consistency across the tables. All the header rows across tables will be consistent now.

Why are the changes needed?

  • A lot of code is copied every time pagination is implemented for any table.
  • Code readability is not great as lot of HTML is embedded.
  • Paginating other tables will be a lot easier now.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Manually. This is mainly refactoring work, no new functionality introduced. Existing test cases should pass.

@iRakson
Copy link
Contributor Author

iRakson commented May 12, 2020

cc @srowen @uncleGen @sarutak @HyukjinKwon Kindly review.

@sarutak
Copy link
Member

sarutak commented May 12, 2020

ok to test.

@SparkQA
Copy link

SparkQA commented May 12, 2020

Test build #122565 has finished for PR 28512 at commit 7775dd1.

  • This patch fails build dependency tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@uncleGen
Copy link
Contributor

retest this please.

Comment on lines 309 to 310
def getTableParameters(request: HttpServletRequest, tableTag: String,
defaultSortColumn: String): (String, Boolean, Int) = {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: all arguments in one line or each one in separate line.

@SparkQA
Copy link

SparkQA commented May 13, 2020

Test build #122570 has finished for PR 28512 at commit 7775dd1.

  • This patch fails build dependency tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 13, 2020

Test build #122591 has finished for PR 28512 at commit 89194d3.

  • This patch fails build dependency tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented May 13, 2020

Test build #122594 has finished for PR 28512 at commit 0f886d6.

  • This patch fails build dependency tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@iRakson
Copy link
Contributor Author

iRakson commented May 14, 2020

retest this please

@iRakson
Copy link
Contributor Author

iRakson commented May 16, 2020

@srowen @sarutak @uncleGen If Jenkins is fine, can we test this ?

@srowen
Copy link
Member

srowen commented May 16, 2020

Jenkins test this please

@SparkQA
Copy link

SparkQA commented May 17, 2020

Test build #122736 has finished for PR 28512 at commit 0f886d6.

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

@iRakson
Copy link
Contributor Author

iRakson commented May 18, 2020

@srowen @sarutak @uncleGen Can you take a look at this PR.
#28485 and #28439 are pending due to this one.

@srowen
Copy link
Member

srowen commented May 18, 2020

I don't know enough to have a strong opinion, but it looks plausible and I think you know this code well. If it doesn't introduce any behavior change, just a cleanup, I think it's OK.

@sarutak
Copy link
Member

sarutak commented May 20, 2020

Now I'm checking and will leave comment.

Copy link
Member

@sarutak sarutak left a comment

Choose a reason for hiding this comment

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

Thanks @iRakson for the refactoring!
It almost LGTM.
I've left some minor comments.

}

override def headers: Seq[Node] = {
// Information for each header: title, cssClass, and sortable
Copy link
Member

Choose a reason for hiding this comment

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

Could you update the comment?

*/
def isSortColumnValid(
headerInfo: Seq[(String, Boolean, Option[String])],
sortColumn: String): Any = {
Copy link
Member

Choose a reason for hiding this comment

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

The return type is better to be Unit rather than Any isn't it?

isFairScheduler: Boolean,
killEnabled: Boolean,
isFailedStage: Boolean) {
val parameterOtherTable = request.getParameterMap().asScala
Copy link
Member

Choose a reason for hiding this comment

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

JavaConverters._ is imported but it may be no longer used after this change.

jobTag: String,
jobs: Seq[v1.JobData],
killEnabled: Boolean): Seq[Node] = {
val parameterOtherTable = request.getParameterMap().asScala
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as here.

val headerRow: Seq[Node] = {
jobHeadersAndCssClasses.map { case (header, cssClass, sortable, tooltip) =>
if (header == sortColumn) {
val headerLink = Unparsed(
Copy link
Member

Choose a reason for hiding this comment

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

Unparsed is imported but it's no longer used after this change.

}

override def headers: Seq[Node] = {
// Information for each header: title, sortable
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as here.

val headerRow: Seq[Node] = {
sqlTableHeaders.zip(tooltips).map { case (header, tooltip) =>
if (header == sortColumn) {
val headerLink = Unparsed(
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as here.


val sqlTableTag = "sqlsessionstat"

val parameterOtherTable = request.getParameterMap().asScala
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as here.

s"&$sessionStatsTableTag.pageSize=$pageSize" +
s"#$sessionStatsTableTag")
val arrow = if (desc) "▾" else "▴" // UP or DOWN
<th width={colWidthAttr}>
Copy link
Member

Choose a reason for hiding this comment

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

PagedTable#headerRow you added doesn't support the width of th.
Did you confirm it doesn't matter for ThriftServerPage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, its working fine.
Screenshot 2020-05-20 at 7 26 03 PM

}
}
<thead>
{row}
Copy link
Member

Choose a reason for hiding this comment

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

{row} should be enclosed by <tr>.

@iRakson
Copy link
Contributor Author

iRakson commented May 20, 2020

@sarutak Thank You for reviewing. Code is updated as per suggestions.

@iRakson iRakson requested a review from sarutak May 20, 2020 13:26
@SparkQA
Copy link

SparkQA commented May 20, 2020

Test build #122899 has finished for PR 28512 at commit 50065ff.

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

@srowen
Copy link
Member

srowen commented May 21, 2020

Merged to master

@srowen srowen closed this in f1495c5 May 21, 2020
@iRakson
Copy link
Contributor Author

iRakson commented May 21, 2020

Thank You. 😊 @srowen @sarutak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants