Skip to content

Conversation

@Fokko
Copy link
Contributor

@Fokko Fokko commented Oct 5, 2018

While working on another PR, I noticed that there is quite some legacy Java in there that can be beautified. For example the use of features from Java8, such as:

  • Collection libraries
  • Try-with-resource blocks

No logic has been changed. I think it is important to have a solid codebase with examples that will inspire next PR's to follow up on the best practices.

What are your thoughts on this?

This makes code easier to read, and using try-with-resource makes is less likely to forget to close something.

What changes were proposed in this pull request?

No changes in the logic of Spark, but more in the aesthetics of the code.

How was this patch tested?

Using the existing unit tests. Since no logic is changed, the existing unit tests should pass.

Please review http://spark.apache.org/contributing.html before opening a pull request.

@Fokko Fokko changed the title Spark 25408 [SPARK-25408] Move to mode ideomatic Java8 Oct 5, 2018
@HyukjinKwon
Copy link
Member

ok to test

1 similar comment
@cloud-fan
Copy link
Contributor

ok to test

@HyukjinKwon
Copy link
Member

mind filling PR description please?

Copy link
Member

Choose a reason for hiding this comment

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

Nit: move this onto the previous line

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

Copy link
Member

Choose a reason for hiding this comment

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

I wouldn't bother with this. This is a copy of some Hive code anyway

Copy link
Member

Choose a reason for hiding this comment

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

this should still be reverted

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!

@srowen
Copy link
Member

srowen commented Oct 5, 2018

Jenkins test this please

@SparkQA
Copy link

SparkQA commented Oct 5, 2018

Test build #96969 has finished for PR 22637 at commit 5d3d0c7.

  • This patch fails Java style tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 5, 2018

Test build #96970 has finished for PR 22637 at commit 0155b7a.

  • This patch fails Java style tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

@Fokko
Copy link
Contributor Author

Fokko commented Oct 5, 2018

Valid points. Personally I'm a fan of explicit final, instead of implicit. But that's a matter of taste :-)

@SparkQA
Copy link

SparkQA commented Oct 5, 2018

Test build #96972 has finished for PR 22637 at commit 14d9d1f.

  • This patch fails Java style tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

@SparkQA
Copy link

SparkQA commented Oct 5, 2018

Test build #96974 has finished for PR 22637 at commit 004ee44.

  • This patch fails Java style tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

@SparkQA
Copy link

SparkQA commented Oct 5, 2018

Test build #96967 has finished for PR 22637 at commit 5d3d0c7.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds no public classes.

@SparkQA
Copy link

SparkQA commented Oct 5, 2018

Test build #96975 has finished for PR 22637 at commit 58de6a3.

  • This patch fails due to an unknown error code, -9.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

@cloud-fan
Copy link
Contributor

retest this please

@SparkQA
Copy link

SparkQA commented Oct 5, 2018

Test build #96979 has finished for PR 22637 at commit 58de6a3.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

Copy link
Member

Choose a reason for hiding this comment

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

Indentation?

Copy link
Member

@dongjoon-hyun dongjoon-hyun Oct 5, 2018

Choose a reason for hiding this comment

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

Indentation? It seems to follow 4-space indentation for Java style, but it seems to be too outstanding in this file. For the rest of the patch, could you adjust a little bit more to be consistent in a single file?

@vanzin
Copy link
Contributor

vanzin commented Oct 5, 2018

While we're at it, it would be great to fix the typo in the PR title.

@Fokko Fokko changed the title [SPARK-25408] Move to mode ideomatic Java8 [SPARK-25408] Move to more ideomatic Java8 Oct 6, 2018
@Fokko
Copy link
Contributor Author

Fokko commented Oct 6, 2018

Thanks @dongjoon-hyun. I've fixed the indentation issues.

@SparkQA
Copy link

SparkQA commented Oct 6, 2018

Test build #97031 has finished for PR 22637 at commit db061b8.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

Copy link
Member

Choose a reason for hiding this comment

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

There's a compile error here. But note you can have multiple Closeables declared in one try block anyway, so these can be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mistake. thanks!

Copy link
Member

Choose a reason for hiding this comment

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

It's hard to know the best way to wrap these things, but here you have the continuation line indented less than the one that starts the statement. I think we can't do that. I'd indent both continuations 2 spaces from their preceding line ideally. Here and elsewhere where the try statement has to wrap.

Copy link
Member

Choose a reason for hiding this comment

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

this should still be reverted

@SparkQA
Copy link

SparkQA commented Oct 6, 2018

Test build #97063 has finished for PR 22637 at commit 4c084f9.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

Use features from Java8 such as:
- Try-with-resource blocks
@SparkQA
Copy link

SparkQA commented Oct 7, 2018

Test build #97072 has finished for PR 22637 at commit 9c9f065.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds the following public classes (experimental):
  • public abstract class RowBasedKeyValueBatch extends MemoryConsumer implements Closeable

@srowen
Copy link
Member

srowen commented Oct 8, 2018

OK, trying this again. Tests have definitely run this time and we've had another good pass at small review changes.

@asfgit asfgit closed this in 1a28625 Oct 8, 2018
jackylee-ch pushed a commit to jackylee-ch/spark that referenced this pull request Feb 18, 2019
While working on another PR, I noticed that there is quite some legacy Java in there that can be beautified. For example the use of features from Java8, such as:
- Collection libraries
- Try-with-resource blocks

No logic has been changed. I think it is important to have a solid codebase with examples that will inspire next PR's to follow up on the best practices.

What are your thoughts on this?

This makes code easier to read, and using try-with-resource makes is less likely to forget to close something.

## What changes were proposed in this pull request?

No changes in the logic of Spark, but more in the aesthetics of the code.

## How was this patch tested?

Using the existing unit tests. Since no logic is changed, the existing unit tests should pass.

Please review http://spark.apache.org/contributing.html before opening a pull request.

Closes apache#22637 from Fokko/SPARK-25408.

Authored-by: Fokko Driesprong <[email protected]>
Signed-off-by: Sean Owen <[email protected]>
@Fokko Fokko deleted the SPARK-25408 branch July 14, 2020 19:20
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.

7 participants