use of com.hazelcast.nio.serialization.PortableFactory in project hazelcast by hazelcast.
the class DefaultSerializationServiceBuilder method registerPortableFactories.
private void registerPortableFactories(Map<Integer, PortableFactory> portableFactories, SerializationConfig config) {
for (Map.Entry<Integer, PortableFactory> entry : config.getPortableFactories().entrySet()) {
int factoryId = entry.getKey();
PortableFactory factory = entry.getValue();
if (factoryId <= 0) {
throw new IllegalArgumentException("PortableFactory factoryId must be positive! -> " + factory);
}
if (portableFactories.containsKey(factoryId)) {
throw new IllegalArgumentException("PortableFactory with factoryId '" + factoryId + "' is already registered!");
}
portableFactories.put(factoryId, factory);
}
}
use of com.hazelcast.nio.serialization.PortableFactory in project hazelcast by hazelcast.
the class QueryAdvancedTest method testUnknownPortableField_notCausesQueryException_withIndex.
@Test
public // see: https://github.com/hazelcast/hazelcast/issues/3927
void testUnknownPortableField_notCausesQueryException_withIndex() {
String mapName = "default";
Config config = getConfig();
config.getSerializationConfig().addPortableFactory(666, new PortableFactory() {
public Portable create(int classId) {
return new PortableEmployee();
}
});
config.getMapConfig(mapName).addMapIndexConfig(new MapIndexConfig("notExist", false)).addMapIndexConfig(new MapIndexConfig("n", false));
HazelcastInstance hazelcastInstance = createHazelcastInstance(config);
IMap<Integer, PortableEmployee> map = hazelcastInstance.getMap(mapName);
for (int i = 0; i < 5; i++) {
map.put(i, new PortableEmployee(i, "name_" + i));
}
Collection values = map.values(new SqlPredicate("n = name_2 OR notExist = name_0"));
assertEquals(1, values.size());
}
use of com.hazelcast.nio.serialization.PortableFactory in project hazelcast by hazelcast.
the class MorphingPortableReaderTest method before.
@Before
public void before() throws Exception {
service1 = (SerializationServiceV1) new DefaultSerializationServiceBuilder().addPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new MorphingBasePortable();
}
}).build();
service2 = (SerializationServiceV1) new DefaultSerializationServiceBuilder().addPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID, new PortableFactory() {
public Portable create(int classId) {
return new MorphingPortable();
}
}).build();
Data data = service1.toData(new MorphingBasePortable((byte) 1, true, (char) 2, (short) 3, 4, 5, 1f, 2d, "test"));
BufferObjectDataInput in = service2.createObjectDataInput(data);
PortableSerializer portableSerializer = service2.getPortableSerializer();
reader = portableSerializer.createMorphingReader(in);
}
Aggregations