rico
rico

Reputation: 1935

Hazelcast Jet IMap remove entry

I've read the documentation of Hazelcast Jet.

I've seen it is possible to add/update entries in an IMap sink. But I've seen nowhere how it is possible to remove entries from the IMap.

Is there a way for this ?

Upvotes: 1

Views: 256

Answers (1)

ali
ali

Reputation: 886

See Sinks.mapWithMerging, from JavaDoc :

    /**
     * Returns a sink that uses the supplied functions to extract the key
     * and value with which to update a Hazelcast {@code IMap}. If the map
     * already contains the key, it applies the given {@code mergeFn} to
     * resolve the existing and the proposed value into the value to use. If
     * the value comes out as {@code null}, it removes the key from the map.
     * Expressed as code, the sink performs the equivalent of the following for
     * each item:
     * <pre>
     * K key = toKeyFn.apply(item);
     * V oldValue = map.get(key);
     * V newValue = toValueFn.apply(item);
     * V resolved = (oldValue == null)
     *            ? newValue
                  : mergeFn.apply(oldValue, newValue);
     * if (value == null)
     *     map.remove(key);
     * else
     *     map.put(key, value);
     * </pre>
...

Upvotes: 2

Related Questions