filter dataset

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

filter dataset

Lydia Ickler
Hi all,

I have a DataSet<Tuple3<Integer, Integer, Double> and I want to apply a filter to only get back all entries with e.g. first Integer in tuple == 0.
With a normal filter I do not have the possibility to pass an an additional argument but I have to set that parameter inside the filter function.
Is there a possibility to send a parameter to make the filter more flexible?
How would be the smartest way to do so?

Best regards,
Lydia
Reply | Threaded
Open this post in threaded view
|

Re: filter dataset

stefanobaghino
Hi Lydia,

you can use a variable outside the scope of the normal filter (the one that you define inline, if I understand correctly), like this:

final int filterParameter = 0;

dataset.filter(new FilterFunction<Integer, Integer, Double> () {
    @Override
    public boolean filter(Integer value) { 
        return value == filterParameter
    }
}

The only catch is that you have to make the variable final.

Does this answer your question? Hope I've been helpful.

Best,
Stefano

On Mon, Feb 29, 2016 at 11:14 AM, Lydia Ickler <[hidden email]> wrote:
Hi all,

I have a DataSet<Tuple3<Integer, Integer, Double> and I want to apply a filter to only get back all entries with e.g. first Integer in tuple == 0.
With a normal filter I do not have the possibility to pass an an additional argument but I have to set that parameter inside the filter function.
Is there a possibility to send a parameter to make the filter more flexible?
How would be the smartest way to do so?

Best regards,
Lydia



--
BR,
Stefano Baghino

Software Engineer @ Radicalbit