Sorry I messed up the ScanQueryWithTransform.java a little bit.
This is the clean version.
Thank you.
On 7/3/20 2:19 PM, Rafael Troilo wrote:
> Hi Ilya, hey Denis,
>
> thank you both of you for taking a look into this problem.
>
> How would you like get the reproducing stand-alone runnable?
>
> I attached a single file which reproduces the problem.
>
> Do you like to have it in any other way?
>
>
> Some comments:
> In this issue, it does not matter if the Transformer Class is a static member
> class or a separate class it self. Both produce the exception.
>
> The Transformer (IgniteClosure) class works fine in a broadcast.
>
> // simple IgniteClosure broadcast
> ignite.compute().broadcast(new Transformer<>(),
> "broadcast").forEach(System.out::println);
>
> and for a scanquery with transform from within remote job (like this
> broadcast)
>
> // broadcast which return the result the scanquery transform
> ignite.compute().broadcast(() -> {
> return cache.query(new ScanQuery<>(), new Transformer<>()).getAll();
> }).stream().flatMap(List::stream).forEach(System.out::println);
>
> but does not work on the client side directly
>
> // does throw a ClassNotFound Exception about the Transformer Class.
> cache.query(new ScanQuery<>(), new
> Transformer<>()).getAll().forEach(System.out::println);
>
>
> Thank you.
>
> Let me know if I can do more to help you to find the problem.
>
> Best,
> Rafael
>
>
>
>
> On 7/2/20 5:39 PM, Ilya Kasnacheev wrote:
>> Hello!
>>
>> I would like to start with a reproducer. Rafael, can you please throw
>> together a runnable stand-alone reproducer of this issue?
>>
>> Thanks,
>>
>
--
Rafael Troilo, Dipl.-Inform. (FH)
GIScience Research Group
Heidelberg Institute for Geoinformation Technology
[email protected]
http://giscience.uni-hd.de
http://www.geog.uni-heidelberg.de/gis/heigit.html
Berliner Str. 45 (Mathematikon), D-69120 Heidelberg, Germany
fon: +49(0)6221 / 54 / 19704
import java.util.Collections;
import java.util.List;
import javax.cache.Cache.Entry;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.Ignition;
import org.apache.ignite.cache.query.QueryCursor;
import org.apache.ignite.cache.query.ScanQuery;
import org.apache.ignite.lang.IgniteClosure;
public class ScanQueryWithTransform {
private static final String cacheName = "ScanQueryTransformerIssue";
public static void main(String[] args) {
if (args.length == 0) {
System.out.println("missing config file argument!");
System.exit(1);
}
String cfg = args[0];
Ignition.setClientMode(true);
try (Ignite ignite = Ignition.start(cfg)) {
IgniteCache<Integer, String> cache = ignite.createCache(cacheName);
for (int i = 0; i < 5; i++) {
// fill cache with some data
cache.put(i, Integer.toBinaryString(i));
}
try (QueryCursor<Entry<Integer, String>> cursor = cache.query(new ScanQuery<>(), new Transformer<>())) {
// throws exception about ClassNotFound Transformer
cursor.getAll();
} catch (Exception e) {
e.printStackTrace();
}
//clean up!
ignite.destroyCache(cacheName);
}
}
private static class Transformer<T> implements IgniteClosure<T, T> {
private static final long serialVersionUID = 1L;
@Override
public T apply(T e) {
return e;
}
}
}