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

GenericRecord when InMemoryFormat.OBJECT can not be queried #18336

Closed
sancar opened this issue Mar 3, 2021 · 0 comments · Fixed by #18349
Closed

GenericRecord when InMemoryFormat.OBJECT can not be queried #18336

sancar opened this issue Mar 3, 2021 · 0 comments · Fixed by #18349
Assignees
Milestone

Comments

@sancar
Copy link
Contributor

sancar commented Mar 3, 2021

  public static class M implements Portable {

        @Override
        public int getFactoryId() {
            return 1;
        }

        @Override
        public int getClassId() {
            return 1;
        }

        @Override
        public void writePortable(PortableWriter writer) throws IOException {
            writer.writeInt("a", 4);
        }

        @Override
        public void readPortable(PortableReader reader) throws IOException {
            reader.readInt("a");
        }
    }
        Config config = new YamlConfigBuilder().build();
        config.addMapConfig(new MapConfig("map").setInMemoryFormat(InMemoryFormat.OBJECT));
        Hazelcast.newHazelcastInstance(config);
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.getSerializationConfig().addPortableFactory(1, new PortableFactory() {
            @Override
            public Portable create(int classId) {
                return new M();
            }
        });
        HazelcastInstance client = HazelcastClient.newHazelcastClient(clientConfig);
        IMap<Object, Object> map = client.getMap("map");
        map.put(1, new M());
        map.values(Predicates.sql("a == 4"));

If cluster is missing addPortableFactory, the queries against cluster fails with following expcetion

com.hazelcast.query.QueryException: java.lang.IllegalArgumentException: There is no suitable accessor for 'a' on class 'com.hazelcast.internal.serialization.impl.portable.PortableGenericRecord'
	at com.hazelcast.query.impl.getters.ReflectionHelper.createGetter(ReflectionHelper.java:175)
	at com.hazelcast.query.impl.getters.Extractors.instantiateGetter(Extractors.java:156)
	at com.hazelcast.query.impl.getters.Extractors.getGetter(Extractors.java:122)
	at com.hazelcast.query.impl.getters.Extractors.extract(Extractors.java:77)

We can make this work easily fixing the query system.
This was also not working before 3.12 but the fail point was map.put, not the query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants