Skip to content

Hive: Improve code style#2641

Merged
rymurr merged 2 commits intoapache:masterfrom
StefanXiepj:improve-code-style
May 27, 2021
Merged

Hive: Improve code style#2641
rymurr merged 2 commits intoapache:masterfrom
StefanXiepj:improve-code-style

Conversation

@StefanXiepj
Copy link
Contributor

This pr improved some code style.

@southernriver
Copy link
Contributor

Good catch!

@StefanXiepj
Copy link
Contributor Author

@rymurr would you mind reviewing this?

Copy link
Contributor

@kbendick kbendick left a comment

Choose a reason for hiding this comment

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

A small cleanup suggestion to make the log more legible, plus one more place that it looks like we're missing argument placeholders in the logging string.

.onFailure((output, exc) -> LOG.warn("Failed cleanup table {} on abort job", output, exc))
.run(output -> {
LOG.info("Cleaning job for table {}", jobContext.getJobID(), output);
LOG.info("Cleaning job for table {} {}", jobContext.getJobID(), output);
Copy link
Contributor

@kbendick kbendick May 27, 2021

Choose a reason for hiding this comment

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

Good catch 👍.

I seem to remember there being some sort of analyzer annotation or something to ensure the correct number of arguments, but for the life of me I can't recall right now. Probably wouldn't be related to this case.

EDIT: You don't need to use it, but for your reference this is what I was thinking of. It and some other annotations in the same package provides compile time checking on format strings: https://errorprone.info/api/latest/com/google/errorprone/annotations/FormatMethod.html

Copy link
Contributor

@kbendick kbendick May 27, 2021

Choose a reason for hiding this comment

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

Actually, small nit:

Could you make this LOG.info("Cleaning table {} with job id {}", output, jobContext.getJobID());? I personally think having both arguments one after another will be somewhat unclear, and the emphasis should be on the table being cleaned in my opinion.

The way you have it now, for a table foo for a MapReduce job job_201112212038_0004, the output would be Cleaning job for table foo job_201112212038_0004. To me, that personally isn't super clear.

I think Cleaning table foo with job id job_201112212038_0004 would be much more clear to users, and would provide a simpler / potentially more intuitive string to search for in the logs (aka looking through cabana for "Cleaning table foo").

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, i'll do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

.onFailure((output, exc) -> LOG.warn("Failed cleanup table {} on abort job", output, exc))
.run(output -> {
LOG.info("Cleaning job for table {}", jobContext.getJobID(), output);
LOG.info("Cleaning job for table {} {}", jobContext.getJobID(), output);
Copy link
Contributor

@kbendick kbendick May 27, 2021

Choose a reason for hiding this comment

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

Actually, small nit:

Could you make this LOG.info("Cleaning table {} with job id {}", output, jobContext.getJobID());? I personally think having both arguments one after another will be somewhat unclear, and the emphasis should be on the table being cleaned in my opinion.

The way you have it now, for a table foo for a MapReduce job job_201112212038_0004, the output would be Cleaning job for table foo job_201112212038_0004. To me, that personally isn't super clear.

I think Cleaning table foo with job id job_201112212038_0004 would be much more clear to users, and would provide a simpler / potentially more intuitive string to search for in the logs (aka looking through cabana for "Cleaning table foo").

@@ -232,7 +232,7 @@ public void abortJob(JobContext originalContext, int status) throws IOException
.executeWith(tableExecutor)
.onFailure((output, exc) -> LOG.warn("Failed cleanup table {} on abort job", output, exc))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this log also missing a placeholder? Seems like it has two arguments, but only one placeholder.

My IDE doesn't seem to complain, but it looks like the same situation you're fixing. Possibly it's not complaining because it's in a lambda? If you could look into that it would be great 👍.

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 warning, the second arguments of exc is an Exception, so it is correct.

Copy link
Contributor

@kbendick kbendick left a comment

Choose a reason for hiding this comment

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

EDIT: Cat on a keyboard :)

Copy link
Contributor

@kbendick kbendick left a comment

Choose a reason for hiding this comment

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

Some small changes suggested, but overall looks safe to me. Reapproving to revert the accidental "request change". :)

Copy link
Collaborator

@marton-bod marton-bod left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@rymurr rymurr left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @StefanXiepj

@rymurr rymurr merged commit 1561694 into apache:master May 27, 2021
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