You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Humphrey <hm...@gmail.com> on 2017/05/02 18:46:12 UTC

Ignite .NET vs Java

I'm trying to do the following in .NET with C# using lambda expression and I
can't figure out how to do the same thing I can do with Java.
----
In Java I can do the following:

List<String> listOfWords = Arrays.asList("How many characters are
there?".split(" "));
Collection<Integer> res = ignite.compute().apply((String word) ->
word.length(), listOfWords);
----
Now I'm trying to do the same in .NET with C#:

ICollection<string> words = "Count characters using
closure".Split().ToList();
var res = ignite.GetCompute().Apply<string, int>((string x) => x.Length,
words);
----
It looks like it is trying to invoke the following method:
TRes Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);

Instead I want it to invoke the following method:
ICollection<TRes> Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo,
IEnumerable<TArg> args);

Both apply overloaded method have the same amount of paramters, so how do I
specify it to use the correct apply method? I don't want to create an
implementation of the IComputeFunction but want to use lambda like I can do
in Java.

I have tried different combination of the <> after Apply, for example
Apply<string, int> or without the <>.
The complete code (using implementation of the IComputeFunction) is in the
.NET examples of ignite. I'm trying to find out the equivalent lambda way in
C#.

Humphrey



--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Ignite-NET-vs-Java-tp12354.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Re: Ignite .NET vs Java

Posted by Pavel Tupitsyn <pt...@apache.org>.
You have to implement IComputeFunc.
Ignite.NET does not have overloads for anonymous functions & lambdas.
We have plans to add them in future versions.

On Tue, May 2, 2017 at 9:46 PM, Humphrey <hm...@gmail.com> wrote:

> I'm trying to do the following in .NET with C# using lambda expression and
> I
> can't figure out how to do the same thing I can do with Java.
> ----
> In Java I can do the following:
>
> List<String> listOfWords = Arrays.asList("How many characters are
> there?".split(" "));
> Collection<Integer> res = ignite.compute().apply((String word) ->
> word.length(), listOfWords);
> ----
> Now I'm trying to do the same in .NET with C#:
>
> ICollection<string> words = "Count characters using
> closure".Split().ToList();
> var res = ignite.GetCompute().Apply<string, int>((string x) => x.Length,
> words);
> ----
> It looks like it is trying to invoke the following method:
> TRes Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo, TArg arg);
>
> Instead I want it to invoke the following method:
> ICollection<TRes> Apply<TArg, TRes>(IComputeFunc<TArg, TRes> clo,
> IEnumerable<TArg> args);
>
> Both apply overloaded method have the same amount of paramters, so how do I
> specify it to use the correct apply method? I don't want to create an
> implementation of the IComputeFunction but want to use lambda like I can do
> in Java.
>
> I have tried different combination of the <> after Apply, for example
> Apply<string, int> or without the <>.
> The complete code (using implementation of the IComputeFunction) is in the
> .NET examples of ignite. I'm trying to find out the equivalent lambda way
> in
> C#.
>
> Humphrey
>
>
>
> --
> View this message in context: http://apache-ignite-users.
> 70518.x6.nabble.com/Ignite-NET-vs-Java-tp12354.html
> Sent from the Apache Ignite Users mailing list archive at Nabble.com.
>