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-19533][EXAMPLES] Convert Java tests to use lambdas, Java 8 features #16961

Closed
wants to merge 1 commit into from

Conversation

srowen
Copy link
Member

@srowen srowen commented Feb 16, 2017

What changes were proposed in this pull request?

Convert Java tests to use lambdas, Java 8 features.

How was this patch tested?

Jenkins tests.

@@ -40,7 +38,7 @@
*/
public final class JavaLogQuery {

public static final List<String> exampleApacheLogs = Lists.newArrayList(
public static final List<String> exampleApacheLogs = Arrays.asList(
Copy link
Member Author

Choose a reason for hiding this comment

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

Although this isn't specific to Java 8, the existence of Arrays.asList should mean we don't need Guava's Lists.newArrayList, and, we should prefer examples that don't involve third party libraries.

@@ -32,9 +32,6 @@
/**
* Java example demonstrating model selection using TrainValidationSplit.
*
* The example is based on {@link org.apache.spark.examples.ml.JavaSimpleParamsExample}
Copy link
Member Author

Choose a reason for hiding this comment

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

(This was a javadoc error, and inaccurate anyway)

}
}, Encoders.STRING());
Dataset<String> namesDS = namesDF.map(
(MapFunction<Row, String>) row -> "Name: " + row.getString(0),
Copy link
Member Author

Choose a reason for hiding this comment

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

For those wondering why this lambda has to be cast, it's because it is otherwise ambiguous, as there are two methods with an eligible function interface as arg.

@dongjoon-hyun
Copy link
Member

Retest this please

@dongjoon-hyun
Copy link
Member

+1 LGTM!

@SparkQA
Copy link

SparkQA commented Feb 16, 2017

Test build #73013 has finished for PR 16961 at commit 0f8232f.

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

@felixcheung
Copy link
Member

whoa, nice/

@srowen srowen changed the title [SPARK-19534][EXAMPLES] Convert Java tests to use lambdas, Java 8 features [SPARK-19533][EXAMPLES] Convert Java tests to use lambdas, Java 8 features Feb 17, 2017
@srowen
Copy link
Member Author

srowen commented Feb 19, 2017

Merged to master

srowen added a commit to srowen/spark that referenced this pull request Feb 19, 2017
…tures

## What changes were proposed in this pull request?

Convert Java tests to use lambdas, Java 8 features.

## How was this patch tested?

Jenkins tests.

Author: Sean Owen <sowen@cloudera.com>

Closes apache#16961 from srowen/SPARK-19533.
@srowen srowen closed this Feb 19, 2017
@srowen srowen deleted the SPARK-19533 branch February 19, 2017 17:39
Yunni pushed a commit to Yunni/spark that referenced this pull request Feb 27, 2017
…tures

## What changes were proposed in this pull request?

Convert Java tests to use lambdas, Java 8 features.

## How was this patch tested?

Jenkins tests.

Author: Sean Owen <sowen@cloudera.com>

Closes apache#16961 from srowen/SPARK-19533.
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.

4 participants