18 #include "hazelcast/client/proxy/MultiMapImpl.h"
19 #include "hazelcast/client/impl/EntryEventHandler.h"
20 #include "hazelcast/client/protocol/codec/codecs.h"
21 #include "hazelcast/client/spi/ClientContext.h"
30 class HAZELCAST_API
multi_map :
public proxy::MultiMapImpl {
31 friend class spi::ProxyManager;
33 static constexpr
const char *SERVICE_NAME =
"hz:impl:multiMapService";
44 template<
typename K,
typename V>
45 boost::future<bool>
put(
const K &key,
const V &value) {
46 return proxy::MultiMapImpl::put(to_data(key), to_data(value));
55 template<
typename K,
typename V>
56 boost::future<std::vector<V>>
get(
const K &key) {
57 return to_object_vector<V>(proxy::MultiMapImpl::get_data(to_data(key)));
67 template<
typename K,
typename V>
68 boost::future<bool>
remove(
const K &key,
const V &value) {
69 return proxy::MultiMapImpl::remove(to_data(key), to_data(value));
79 template<
typename K,
typename V>
80 boost::future<std::vector<V>>
remove(
const K &key) {
81 return to_object_vector<V>(proxy::MultiMapImpl::remove_data(to_data(key)));
92 return to_object_vector<K>(proxy::MultiMapImpl::key_set_data());
103 return to_object_vector<V>(proxy::MultiMapImpl::values_data());
112 template<
typename K,
typename V>
113 boost::future<std::vector<std::pair<K, V>>>
entry_set() {
114 return to_entry_object_vector<K, V>(proxy::MultiMapImpl::entry_set_data());
125 return proxy::MultiMapImpl::contains_key(to_data(key));
136 return proxy::MultiMapImpl::contains_value(to_data(value));
146 template<
typename K,
typename V>
148 return proxy::MultiMapImpl::contains_entry(to_data(key), to_data(value));
160 return proxy::MultiMapImpl::value_count(to_data(key));
178 return proxy::MultiMapImpl::add_entry_listener(
179 std::unique_ptr<impl::BaseEventHandler>(
180 new impl::EntryEventHandler<protocol::codec::multimap_addentrylistener_handler>(
181 get_name(), get_context().get_client_cluster_service(),
182 get_context().get_serialization_service(), std::move(listener), include_value, get_context().get_logger())), include_value);
203 return proxy::MultiMapImpl::add_entry_listener(
204 std::shared_ptr<impl::BaseEventHandler>(
205 new impl::EntryEventHandler<protocol::codec::multimap_addentrylistenertokey_handler>(
206 get_name(), get_context().get_client_cluster_service(),
207 get_context().get_serialization_service(), std::move(listener), include_value, get_context().get_logger())), include_value,
227 boost::future<void>
lock(
const K &key) {
228 return proxy::MultiMapImpl::lock(to_data(key));
248 boost::future<void>
lock(
const K &key, std::chrono::milliseconds lease_time) {
249 return proxy::MultiMapImpl::lock(to_data(key), lease_time);
261 return proxy::MultiMapImpl::is_locked(to_data(key));
275 return proxy::MultiMapImpl::try_lock(to_data(key));
295 boost::future<bool>
try_lock(
const K &key, std::chrono::milliseconds timeout) {
296 return proxy::MultiMapImpl::try_lock(to_data(key), timeout);
317 template <
typename K>
318 boost::future<bool>
try_lock(
const K &key, std::chrono::milliseconds timeout, std::chrono::milliseconds lease_time) {
319 return proxy::MultiMapImpl::try_lock(to_data(key), timeout, lease_time);
330 boost::future<void>
unlock(
const K &key) {
331 return proxy::MultiMapImpl::unlock(to_data(key));
342 return proxy::MultiMapImpl::force_unlock(to_data(key));
345 multi_map(
const std::string &instance_name, spi::ClientContext *context)
346 : proxy::MultiMapImpl(instance_name, context) {}
Map entry listener to get notified when a map entry is added, removed, updated, evicted,...
A specialized distributed map client whose keys can be associated with multiple values.
boost::future< bool > try_lock(const K &key)
Tries to acquire the lock for the specified key.
boost::future< bool > remove(const K &key, const V &value)
Removes the given key value pair from the multimap.
boost::future< bool > contains_entry(const K &key, const V &value)
Returns whether the multimap contains the given key-value pair.
boost::future< bool > contains_key(const K &key)
Returns whether the multimap contains an entry with the key.
boost::future< std::vector< std::pair< K, V > > > entry_set()
Returns the set of key-value pairs in the multimap.
boost::future< std::vector< V > > values()
Returns the multimap of values in the multimap.
boost::future< bool > is_locked(const K &key)
Checks the lock for the specified key.
boost::future< boost::uuids::uuid > add_entry_listener(entry_listener &&listener, bool include_value)
Adds an entry listener for this multimap.
boost::future< void > force_unlock(const K &key)
Releases the lock for the specified key regardless of the lock owner.
boost::future< bool > try_lock(const K &key, std::chrono::milliseconds timeout)
Tries to acquire the lock for the specified key.
boost::future< void > unlock(const K &key)
Releases the lock for the specified key.
boost::future< std::vector< K > > key_set()
Returns the set of keys in the multimap.
boost::future< std::vector< V > > remove(const K &key)
Removes all the entries with the given key.
boost::future< bool > contains_value(const V &value)
Returns whether the multimap contains an entry with the value.
boost::future< void > lock(const K &key, std::chrono::milliseconds lease_time)
Acquires the lock for the specified key for the specified lease time.
boost::future< bool > put(const K &key, const V &value)
Stores a key-value pair in the multimap.
boost::future< void > lock(const K &key)
Acquires the lock for the specified key.
boost::future< int > value_count(const K &key)
Returns number of values matching to given key in the multimap.
boost::future< boost::uuids::uuid > add_entry_listener(entry_listener &&listener, const K &key, bool include_value)
Adds the specified entry listener for the specified key.
boost::future< bool > try_lock(const K &key, std::chrono::milliseconds timeout, std::chrono::milliseconds lease_time)
Tries to acquire the lock for the specified key for the specified lease time.
boost::future< std::vector< V > > get(const K &key)
Returns the multimap of values associated with the key.