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

No results are written into sink when projected field is nullable #669

Closed
ncherkas opened this issue Jan 9, 2018 · 1 comment
Closed
Assignees
Milestone

Comments

@ncherkas
Copy link

ncherkas commented Jan 9, 2018

Consider the following example, Hazelcast Member:

        Config config = new Config();
        config.getSerializationConfig().addPortableFactory(1, new PortableFactoryImpl());
        HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);

        IMap<String, User> mapTest1 = hazelcastInstance.getMap("test1");
        mapTest1.put("k0", new User("k0", "n0", LocalDate.now()));
        mapTest1.put("k1", new User("k1", "n1", LocalDate.now()));
        mapTest1.put("k2", new User("k2", null, LocalDate.now()));
        mapTest1.put("k3", new User("k3", null, LocalDate.now()));
        mapTest1.put("k4", new User("k4", "n4", LocalDate.now()));
        mapTest1.put("k5", new User("k5", "n5", LocalDate.now()));

        System.out.println("Users count: " + mapTest1.size());

and Jet Member:

        JetInstance jet = Jet.newJetInstance();
        Pipeline p1 = Pipeline.create();

        p1.drawFrom(Sources.<String, ImdgMember.User, String>remoteMap("test1", new ClientConfig(),
// Workaround is to filter out NULLs
//                Predicates.and(Predicates.in("id", "k1", "k2", "k3", "k4"), Predicates.not(Predicates.equal("name", null))),
                Predicates.in("id", "k1", "k2", "k3", "k4"),
                Projections.singleAttribute("name"))).drainTo(Sinks.list("test1"));

        jet.newJob(p1).join();

        IList<String> sink = jet.getList("test1");
        System.out.println("Fetched (count=" + sink.size() + "): " + sink.subList(0, sink.size()));

No items are written to the sink List when some of the matching entries have null as the value of field name.

@viliam-durina
Copy link
Contributor

viliam-durina commented Jan 9, 2018

Problem is that the projectionFn returns null, which might cause the traverser to stop before iterating all items. It should be fixed.

However, jet doesn't allow null items to be emitted, so we'll make it consistent with Processors.mapP, which documents that items mapped to null are filtered out. After this change, the above example should add "n1" and "n4" to the sink.

Also these should be fixed (code and documentation):

  • kafka source
  • mapJournal source
  • Traverser.map()

@cangencer cangencer added this to the 0.6 milestone Jan 9, 2018
@cangencer cangencer added the kafka label Jan 9, 2018
@viliam-durina viliam-durina self-assigned this Jan 10, 2018
viliam-durina added a commit to viliam-durina/hazelcast-jet that referenced this issue Jan 12, 2018
Links in javadoc will work when hazelcast/hazelcast#12142 is merged and
pom.xml references imdg 3.10. Fixes hazelcast#669.
viliam-durina added a commit to viliam-durina/hazelcast-jet that referenced this issue Jan 12, 2018
Links in javadoc will work when hazelcast/hazelcast#12142 is merged and
pom.xml references imdg 3.10. Fixes hazelcast#669.
viliam-durina added a commit that referenced this issue Jan 15, 2018
Links in javadoc will work when hazelcast/hazelcast#12142 is merged and
pom.xml references imdg 3.10. Fixes #669.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants