spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdpratti <>
Subject Using Java Function API with Java 8
Date Thu, 24 Dec 2015 01:13:21 GMT
I am trying to pass lambda expressions to Spark JavaRDD methods.

Having using lambda expressions in Java, in general, I was hoping for
similar behavour and coding patterns, but am finding confusing compile

The use case is a lambda expression that has a number of statements,
returning a boolean from various points in the logic. 

I have tried both inline, as well as defining a Function functional type
with no luck.

Here is an example:

Function<String, Boolean> checkHeaders2 = x -> {if
	    												return new Boolean(false);
	    												else new Boolean(true); };   

This code gets an error stating that method must return a Boolean.

I know that the lambda expression can be shortened and included as a simple
one statement return, but using non-Spark Java 8 and a Predicate functional
type this would compile and be usable.  

What am I missing and how to use the Spark Function to define lambda
exressions made up of mutliple Java statements.



View this message in context:
Sent from the Apache Spark User List mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message