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

Introduce functional and serializable interfaces #14993

Merged
merged 5 commits into from Jul 18, 2019

Conversation

@mmedenjak
Copy link
Contributor

mmedenjak commented May 7, 2019

Introduces interfaces with single abstract method which declares a
checked exception. The interfaces are also Serializable and can be
readily used in IMDG API when providing a lambda which is then
serialized.

cc @cangencer

@mmedenjak mmedenjak added this to the 4.0 milestone May 7, 2019
@mmedenjak mmedenjak self-assigned this May 7, 2019
* @param objectName object description for the exception
* @throws IllegalArgumentException if {@code object} is not serializable
*/
public static void checkSerializable(Object object, String objectName) {

This comment has been minimized.

Copy link
@pveentjer

pveentjer May 8, 2019

Member

I'm pretty worried about this because AFAIK on the happy path we can end up with an extra serialization of the slowest kind.

This comment has been minimized.

Copy link
@mmedenjak

mmedenjak Jun 14, 2019

Author Contributor

You mean the part where we actually serialise - os.writeObject(object);? I guess we can remove it but it's not that bad. The method is called only once, when creating a comparator and it's only used for creating comparators and no other objects. For example:

static <T, U extends Comparable<? super U>> ComparatorEx<T> comparing(Function<? super T, ? extends U> toKeyFn) {
        checkNotNull(toKeyFn, "toKeyFn");
        checkSerializable(toKeyFn, "toKeyFn");
        return (left, right) -> toKeyFn.apply(left).compareTo(toKeyFn.apply(right));
    }
@mmedenjak mmedenjak force-pushed the mmedenjak:4.0-jet-functional-interfaces branch from 8733cdd to 45d3657 Jun 14, 2019
@mmedenjak

This comment has been minimized.

Copy link
Contributor Author

mmedenjak commented Jun 19, 2019

@mdogan @pveentjer addressed review comments, can you take a second look?

* which declares checked exception.
*/
@FunctionalInterface
public interface FunctionEx<T, R> extends Function<T, R>, Serializable {

This comment has been minimized.

Copy link
@mdogan

mdogan Jun 19, 2019

Member

When this gets merged, we can remove c.h.core.IFunction and use FunctionEx.

This comment has been minimized.

Copy link
@mmedenjak

mmedenjak Jun 19, 2019

Author Contributor

Ok, I'll trim the PR and keep the ones we actually would need, possibly substituting IFunction in the process.

Matko Medenjak added 3 commits May 7, 2019
Introduces interfaces with single abstract method which declares a
checked exception. The interfaces are also Serializable and can be
readily used in IMDG API when providing a lambda which is then
serialized.
@mmedenjak mmedenjak force-pushed the mmedenjak:4.0-jet-functional-interfaces branch from 45d3657 to 602d053 Jun 19, 2019
Matko Medenjak added 2 commits Jun 19, 2019
Matko Medenjak
Matko Medenjak
@mdogan
mdogan approved these changes Jun 20, 2019
@mmedenjak mmedenjak merged commit 4ec9756 into hazelcast:master Jul 18, 2019
1 check passed
1 check passed
default Test PASSed.
Details
@mmedenjak mmedenjak deleted the mmedenjak:4.0-jet-functional-interfaces branch Jul 18, 2019
@mmedenjak

This comment has been minimized.

Copy link
Contributor Author

mmedenjak commented Jul 18, 2019

Thanks for the reviews, guys!

petrpleshachkov pushed a commit to petrpleshachkov/hazelcast that referenced this pull request Jul 18, 2019
Introduce functional and serializable interfaces

Introduces interfaces with single abstract method which declares a
checked exception. The interfaces are also Serializable and can be
readily used in IMDG API when providing a lambda which is then
serialized.
petrpleshachkov pushed a commit to petrpleshachkov/hazelcast that referenced this pull request Jul 19, 2019
Introduce functional and serializable interfaces

Introduces interfaces with single abstract method which declares a
checked exception. The interfaces are also Serializable and can be
readily used in IMDG API when providing a lambda which is then
serialized.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.