use of com.hazelcast.jet.impl.serialization.DelegatingSerializationService in project hazelcast by hazelcast.
the class WriteMapP method init.
@Override
public void init(@Nonnull Outbox outbox, @Nonnull Context context) {
map = instance().getMap(mapName);
boolean hasCustomSerializers = serializationService instanceof DelegatingSerializationService && ((DelegatingSerializationService) serializationService).hasAddedSerializers();
boolean hasNearCache = map instanceof NearCachedMapProxyImpl;
if (hasNearCache && hasCustomSerializers) {
// See https://github.com/hazelcast/hazelcast-jet/issues/3046
throw new JetException("Writing into IMap with both near cache and custom serializers not supported");
}
if (!hasCustomSerializers) {
addToBuffer = item -> buffer.add(new SimpleEntry<>(key(item), value(item)));
} else if (map instanceof MapProxyImpl) {
PartitioningStrategy<?> partitionStrategy = ((MapProxyImpl<K, V>) map).getPartitionStrategy();
addToBuffer = item -> {
Data key = serializationService.toData(key(item), partitionStrategy);
Data value = serializationService.toData(value(item));
buffer.add(new SimpleEntry<>(key, value));
};
} else if (map instanceof ClientMapProxy) {
// TODO: add strategy/unify after https://github.com/hazelcast/hazelcast/issues/13950 is fixed
addToBuffer = item -> {
Data key = serializationService.toData(key(item));
Data value = serializationService.toData(value(item));
buffer.add(new SimpleEntry<>(key, value));
};
} else {
throw new RuntimeException("Unexpected map class: " + map.getClass().getName());
}
}
Aggregations