Hazelcast C++ Client
Hazelcast C++ Client Library
hazelcast::client::multi_map Class Reference

A specialized distributed map client whose keys can be associated with multiple values. More...

#include <multi_map.h>

+ Inheritance diagram for hazelcast::client::multi_map:

Public Member Functions

template<typename K , typename V >
boost::future< bool > put (const K &key, const V &value)
 Stores a key-value pair in the multimap. More...
 
template<typename K , typename V >
boost::future< std::vector< V > > get (const K &key)
 Returns the multimap of values associated with the key. More...
 
template<typename K , typename V >
boost::future< bool > remove (const K &key, const V &value)
 Removes the given key value pair from the multimap. More...
 
template<typename K , typename V >
boost::future< std::vector< V > > remove (const K &key)
 Removes all the entries with the given key. More...
 
template<typename K >
boost::future< std::vector< K > > key_set ()
 Returns the set of keys in the multimap. More...
 
template<typename V >
boost::future< std::vector< V > > values ()
 Returns the multimap of values in the multimap. More...
 
template<typename K , typename V >
boost::future< std::vector< std::pair< K, V > > > entry_set ()
 Returns the set of key-value pairs in the multimap. More...
 
template<typename K >
boost::future< bool > contains_key (const K &key)
 Returns whether the multimap contains an entry with the key. More...
 
template<typename V >
boost::future< bool > contains_value (const V &value)
 Returns whether the multimap contains an entry with the value. More...
 
template<typename K , typename V >
boost::future< bool > contains_entry (const K &key, const V &value)
 Returns whether the multimap contains the given key-value pair. More...
 
template<typename K >
boost::future< int > value_count (const K &key)
 Returns number of values matching to given key in the multimap. More...
 
boost::future< boost::uuids::uuid > add_entry_listener (entry_listener &&listener, bool include_value)
 Adds an entry listener for this multimap. More...
 
template<typename K >
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. More...
 
template<typename K >
boost::future< void > lock (const K &key)
 Acquires the lock for the specified key. More...
 
template<typename K >
boost::future< void > lock (const K &key, std::chrono::milliseconds lease_time)
 Acquires the lock for the specified key for the specified lease time. More...
 
template<typename K >
boost::future< bool > is_locked (const K &key)
 Checks the lock for the specified key. More...
 
template<typename K >
boost::future< bool > try_lock (const K &key)
 Tries to acquire the lock for the specified key. More...
 
template<typename K >
boost::future< bool > try_lock (const K &key, std::chrono::milliseconds timeout)
 Tries to acquire the lock for the specified key. More...
 
template<typename K >
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. More...
 
template<typename K >
boost::future< void > unlock (const K &key)
 Releases the lock for the specified key. More...
 
template<typename K >
boost::future< void > force_unlock (const K &key)
 Releases the lock for the specified key regardless of the lock owner. More...
 

Static Public Attributes

static constexpr const char * SERVICE_NAME = "hz:impl:multiMapService"
 

Friends

class spi::ProxyManager
 

Detailed Description

A specialized distributed map client whose keys can be associated with multiple values.

See also
IMap

Definition at line 31 of file multi_map.h.

Member Function Documentation

◆ add_entry_listener() [1/2]

boost::future<boost::uuids::uuid> hazelcast::client::multi_map::add_entry_listener ( entry_listener &&  listener,
bool  include_value 
)
inline

Adds an entry listener for this multimap.

Listener will get notified for all multimap add/remove/update/evict events.

Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.

Warning 2: Do not make a call to hazelcast. It can cause deadlock.

Parameters
listenerentry listener
includeValuetrue if EntryEvent should contain the value.
Returns
returns registration id.

Definition at line 199 of file multi_map.h.

202  {
203  return proxy::MultiMapImpl::add_entry_listener(
204  std::unique_ptr<impl::BaseEventHandler>(
205  new impl::EntryEventHandler<
206  protocol::codec::multimap_addentrylistener_handler>(
207  get_name(),
208  get_context().get_client_cluster_service(),
209  get_context().get_serialization_service(),
210  std::move(listener),
211  include_value,
212  get_context().get_logger())),
213  include_value);
214  }

◆ add_entry_listener() [2/2]

template<typename K >
boost::future<boost::uuids::uuid> hazelcast::client::multi_map::add_entry_listener ( entry_listener &&  listener,
const K &  key,
bool  include_value 
)
inline

Adds the specified entry listener for the specified key.

The listener will get notified for all add/remove/update/evict events of the specified key only.

Warning 1: If listener should do a time consuming operation, off-load the operation to another thread. otherwise it will slow down the system.

Warning 2: Do not make a call to hazelcast. It can cause deadlock.

Parameters
listenerentry listener
keythe key to listen
includeValuetrue if EntryEvent should contain the value.
Returns
returns registration id.

Definition at line 233 of file multi_map.h.

237  {
238  return proxy::MultiMapImpl::add_entry_listener(
239  std::shared_ptr<impl::BaseEventHandler>(
240  new impl::EntryEventHandler<
241  protocol::codec::multimap_addentrylistenertokey_handler>(
242  get_name(),
243  get_context().get_client_cluster_service(),
244  get_context().get_serialization_service(),
245  std::move(listener),
246  include_value,
247  get_context().get_logger())),
248  include_value,
249  to_data(key));
250  }

◆ contains_entry()

template<typename K , typename V >
boost::future<bool> hazelcast::client::multi_map::contains_entry ( const K &  key,
const V &  value 
)
inline

Returns whether the multimap contains the given key-value pair.

Parameters
keythe key whose existence is checked.
valuethe value whose existence is checked.
Returns
true if the multimap contains the key-value pair, false otherwise.

Definition at line 166 of file multi_map.h.

167  {
168  return proxy::MultiMapImpl::contains_entry(to_data(key),
169  to_data(value));
170  }

◆ contains_key()

template<typename K >
boost::future<bool> hazelcast::client::multi_map::contains_key ( const K &  key)
inline

Returns whether the multimap contains an entry with the key.

Parameters
keythe key whose existence is checked.
Returns
true if the multimap contains an entry with the key, false otherwise.

Definition at line 139 of file multi_map.h.

140  {
141  return proxy::MultiMapImpl::contains_key(to_data(key));
142  }

◆ contains_value()

template<typename V >
boost::future<bool> hazelcast::client::multi_map::contains_value ( const V &  value)
inline

Returns whether the multimap contains an entry with the value.

Parameters
valuethe value whose existence is checked.
Returns
true if the multimap contains an entry with the value, false otherwise.

Definition at line 152 of file multi_map.h.

153  {
154  return proxy::MultiMapImpl::contains_value(to_data(value));
155  }

◆ entry_set()

template<typename K , typename V >
boost::future<std::vector<std::pair<K, V> > > hazelcast::client::multi_map::entry_set ( )
inline

Returns the set of key-value pairs in the multimap.

Returns
the set of key-value pairs in the multimap. Returned set might be modifiable but it has no effect on the multimap

Definition at line 125 of file multi_map.h.

126  {
127  return to_entry_object_vector<K, V>(
128  proxy::MultiMapImpl::entry_set_data());
129  }

◆ force_unlock()

template<typename K >
boost::future<void> hazelcast::client::multi_map::force_unlock ( const K &  key)
inline

Releases the lock for the specified key regardless of the lock owner.

It always successfully unlocks the key, never blocks and returns immediately.

Parameters
keykey to lock.

Definition at line 391 of file multi_map.h.

392  {
393  return proxy::MultiMapImpl::force_unlock(to_data(key));
394  }

◆ get()

template<typename K , typename V >
boost::future<std::vector<V> > hazelcast::client::multi_map::get ( const K &  key)
inline

Returns the multimap of values associated with the key.

Parameters
keythe key whose associated values are to be returned
Returns
the multimap of the values associated with the key.

Definition at line 60 of file multi_map.h.

61  {
62  return to_object_vector<V>(proxy::MultiMapImpl::get_data(to_data(key)));
63  }

◆ is_locked()

template<typename K >
boost::future<bool> hazelcast::client::multi_map::is_locked ( const K &  key)
inline

Checks the lock for the specified key.

If the lock is acquired then returns true, else false.

Parameters
keykey to lock to be checked.
Returns
true if lock is acquired, false otherwise.

Definition at line 303 of file multi_map.h.

304  {
305  return proxy::MultiMapImpl::is_locked(to_data(key));
306  }

◆ key_set()

template<typename K >
boost::future<std::vector<K> > hazelcast::client::multi_map::key_set ( )
inline

Returns the set of keys in the multimap.

Returns
the set of keys in the multimap. Returned set might be modifiable but it has no effect on the multimap

Definition at line 101 of file multi_map.h.

102  {
103  return to_object_vector<K>(proxy::MultiMapImpl::key_set_data());
104  }

◆ lock() [1/2]

template<typename K >
boost::future<void> hazelcast::client::multi_map::lock ( const K &  key)
inline

Acquires the lock for the specified key.

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

Scope of the lock is this multimap only. Acquired lock is only for the key in this multimap.

Locks are re-entrant so if the key is locked N times then it should be unlocked N times before another thread can acquire it.

Parameters
keykey to lock.

Definition at line 268 of file multi_map.h.

269  {
270  return proxy::MultiMapImpl::lock(to_data(key));
271  }

◆ lock() [2/2]

template<typename K >
boost::future<void> hazelcast::client::multi_map::lock ( const K &  key,
std::chrono::milliseconds  lease_time 
)
inline

Acquires the lock for the specified key for the specified lease time.

After lease time, lock will be released..

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until the lock has been acquired.

Scope of the lock is this map only. Acquired lock is only for the key in this map.

Locks are re-entrant so if the key is locked N times then it should be unlocked N times before another thread can acquire it.

Parameters
keykey to lock.
leaseTimetime to wait before releasing the lock.

Definition at line 290 of file multi_map.h.

291  {
292  return proxy::MultiMapImpl::lock(to_data(key), lease_time);
293  }

◆ put()

template<typename K , typename V >
boost::future<bool> hazelcast::client::multi_map::put ( const K &  key,
const V &  value 
)
inline

Stores a key-value pair in the multimap.

Parameters
keythe key to be stored
valuethe value to be stored
Returns
true if size of the multimap is increased, false if the multimap already contains the key-value pair.

Definition at line 48 of file multi_map.h.

49  {
50  return proxy::MultiMapImpl::put(to_data(key), to_data(value));
51  }

◆ remove() [1/2]

template<typename K , typename V >
boost::future<std::vector<V> > hazelcast::client::multi_map::remove ( const K &  key)
inline

Removes all the entries with the given key.

Parameters
key
Returns
the multimap of removed values associated with the given key. Returned multimap might be modifiable but it has no effect on the multimap

Definition at line 88 of file multi_map.h.

89  {
90  return to_object_vector<V>(
91  proxy::MultiMapImpl::remove_data(to_data(key)));
92  }

◆ remove() [2/2]

template<typename K , typename V >
boost::future<bool> hazelcast::client::multi_map::remove ( const K &  key,
const V &  value 
)
inline

Removes the given key value pair from the multimap.

Parameters
key
value
Returns
true if the size of the multimap changed after the remove operation, false otherwise.

Definition at line 74 of file multi_map.h.

75  {
76  return proxy::MultiMapImpl::remove(to_data(key), to_data(value));
77  }

◆ try_lock() [1/3]

template<typename K >
boost::future<bool> hazelcast::client::multi_map::try_lock ( const K &  key)
inline

Tries to acquire the lock for the specified key.

If the lock is not available then the current thread doesn't wait and returns false immediately.

Parameters
keykey to lock.
Returns
true if lock is acquired, false otherwise.

Definition at line 318 of file multi_map.h.

319  {
320  return proxy::MultiMapImpl::try_lock(to_data(key));
321  }

◆ try_lock() [2/3]

template<typename K >
boost::future<bool> hazelcast::client::multi_map::try_lock ( const K &  key,
std::chrono::milliseconds  timeout 
)
inline

Tries to acquire the lock for the specified key.

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:

  • The lock is acquired by the current thread; or
  • The specified waiting time elapses
Parameters
keyto be locked.
timeoutthe maximum time to wait for the lock
Returns
true if the lock was acquired and false if the waiting time elapsed before the lock was acquired.

Definition at line 340 of file multi_map.h.

342  {
343  return proxy::MultiMapImpl::try_lock(to_data(key), timeout);
344  }

◆ try_lock() [3/3]

template<typename K >
boost::future<bool> hazelcast::client::multi_map::try_lock ( const K &  key,
std::chrono::milliseconds  timeout,
std::chrono::milliseconds  lease_time 
)
inline

Tries to acquire the lock for the specified key for the specified lease time.

After lease time, the lock will be released.

If the lock is not available then the current thread becomes disabled for thread scheduling purposes and lies dormant until one of two things happens:

  • The lock is acquired by the current thread; or
  • The specified waiting time elapses
Parameters
keyto be locked.
timeoutthe maximum time to wait for the lock
leaseTimetime to wait before releasing the lock.
Returns
true if the lock was acquired and false if the waiting time elapsed before the lock was acquired.

Definition at line 364 of file multi_map.h.

367  {
368  return proxy::MultiMapImpl::try_lock(to_data(key), timeout, lease_time);
369  }

◆ unlock()

template<typename K >
boost::future<void> hazelcast::client::multi_map::unlock ( const K &  key)
inline

Releases the lock for the specified key.

It never blocks and returns immediately.

Parameters
keykey to lock.

Definition at line 379 of file multi_map.h.

380  {
381  return proxy::MultiMapImpl::unlock(to_data(key));
382  }

◆ value_count()

template<typename K >
boost::future<int> hazelcast::client::multi_map::value_count ( const K &  key)
inline

Returns number of values matching to given key in the multimap.

Parameters
keythe key whose values count are to be returned
Returns
number of values matching to given key in the multimap.

Definition at line 180 of file multi_map.h.

181  {
182  return proxy::MultiMapImpl::value_count(to_data(key));
183  }

◆ values()

template<typename V >
boost::future<std::vector<V> > hazelcast::client::multi_map::values ( )
inline

Returns the multimap of values in the multimap.

Returns
the multimap of values in the multimap. Returned multimap might be modifiable but it has no effect on the multimap

Definition at line 113 of file multi_map.h.

114  {
115  return to_object_vector<V>(proxy::MultiMapImpl::values_data());
116  }

The documentation for this class was generated from the following file: