16 #ifndef HAZELCAST_MULTI_MAP
17 #define HAZELCAST_MULTI_MAP
19 #include "hazelcast/client/proxy/MultiMapImpl.h"
20 #include "hazelcast/client/impl/EntryEventHandler.h"
21 #include "hazelcast/client/protocol/codec/MultiMapAddEntryListenerCodec.h"
31 template <
typename K,
typename V>
32 class RawPointerMultiMap;
40 template<
typename K,
typename V>
55 bool put(
const K &key,
const V &value) {
56 return proxy::MultiMapImpl::put(toData(key), toData(value));
65 std::vector<V>
get(
const K &key) {
66 return toObjectCollection<V>(proxy::MultiMapImpl::getData(toData(key)));
76 bool remove(
const K &key,
const V &value) {
77 return proxy::MultiMapImpl::remove(toData(key), toData(value));
87 std::vector<V>
remove(
const K &key) {
88 return toObjectCollection<V>(proxy::MultiMapImpl::removeData(toData(key)));
98 return toObjectCollection<K>(proxy::MultiMapImpl::keySetData());
108 return toObjectCollection<V>(proxy::MultiMapImpl::valuesData());
118 return toObjectEntrySet<K, V>(proxy::MultiMapImpl::entrySetData());
128 return proxy::MultiMapImpl::containsKey(toData(key));
138 return proxy::MultiMapImpl::containsValue(toData(value));
149 return proxy::MultiMapImpl::containsEntry(toData(key), toData(value));
158 return proxy::MultiMapImpl::size();
165 proxy::MultiMapImpl::clear();
176 return proxy::MultiMapImpl::valueCount(toData(key));
194 spi::ClusterService &clusterService = context->getClusterService();
195 serialization::pimpl::SerializationService &ss = context->getSerializationService();
196 impl::EntryEventHandler<K, V, protocol::codec::MultiMapAddEntryListenerCodec::AbstractEventHandler> *entryEventHandler =
197 new impl::EntryEventHandler<K, V, protocol::codec::MultiMapAddEntryListenerCodec::AbstractEventHandler>(
198 getName(), clusterService, ss, listener, includeValue);
199 return proxy::MultiMapImpl::addEntryListener(entryEventHandler, includeValue);
219 impl::EntryEventHandler<K, V, protocol::codec::MultiMapAddEntryListenerCodec::AbstractEventHandler> *entryEventHandler =
220 new impl::EntryEventHandler<K, V, protocol::codec::MultiMapAddEntryListenerCodec::AbstractEventHandler>(
221 getName(), context->getClusterService(), context->getSerializationService(), listener,
223 return proxy::MultiMapImpl::addEntryListener(entryEventHandler, toData(key), includeValue);
235 return proxy::MultiMapImpl::removeEntryListener(registrationId);
254 proxy::MultiMapImpl::lock(toData(key));
273 void lock(
const K &key,
long leaseTimeInMillis) {
274 proxy::MultiMapImpl::lock(toData(key), leaseTimeInMillis);
285 return proxy::MultiMapImpl::isLocked(toData(key));
298 return proxy::MultiMapImpl::tryLock(toData(key));
317 bool tryLock(
const K &key,
long timeoutInMillis) {
318 return proxy::MultiMapImpl::tryLock(toData(key), timeoutInMillis);
329 proxy::MultiMapImpl::unlock(toData(key));
339 proxy::MultiMapImpl::forceUnlock(toData(key));
343 MultiMap(
const std::string &instanceName, spi::ClientContext *context)
344 : proxy::MultiMapImpl(instanceName, context) {
std::vector< std::pair< K, V > > entrySet()
Returns the set of key-value pairs in the multimap.
Definition: MultiMap.h:117
Map Entry listener to get notified when a map entry is added, removed, updated or evicted...
Definition: EntryListener.h:45
void lock(const K &key, long leaseTimeInMillis)
Acquires the lock for the specified key for the specified lease time.
Definition: MultiMap.h:273
void lock(const K &key)
Acquires the lock for the specified key.
Definition: MultiMap.h:253
bool tryLock(const K &key, long timeoutInMillis)
Tries to acquire the lock for the specified key.
Definition: MultiMap.h:317
bool isLocked(const K &key)
Checks the lock for the specified key.
Definition: MultiMap.h:284
int size()
Returns the number of key-value pairs in the multimap.
Definition: MultiMap.h:157
std::string addEntryListener(EntryListener< K, V > &listener, bool includeValue)
Adds an entry listener for this multimap.
Definition: MultiMap.h:193
std::vector< K > keySet()
Returns the set of keys in the multimap.
Definition: MultiMap.h:97
int valueCount(const K &key)
Returns number of values matching to given key in the multimap.
Definition: MultiMap.h:175
A specialized distributed map client whose keys can be associated with multiple values.
Definition: MultiMap.h:41
bool tryLock(const K &key)
Tries to acquire the lock for the specified key.
Definition: MultiMap.h:297
bool containsValue(const V &value)
Returns whether the multimap contains an entry with the value.
Definition: MultiMap.h:137
void clear()
Clears the multimap.
Definition: MultiMap.h:164
std::string addEntryListener(EntryListener< K, V > &listener, const K &key, bool includeValue)
Adds the specified entry listener for the specified key.
Definition: MultiMap.h:218
bool put(const K &key, const V &value)
Stores a key-value pair in the multimap.
Definition: MultiMap.h:55
bool containsKey(const K &key)
Returns whether the multimap contains an entry with the key.
Definition: MultiMap.h:127
std::vector< V > values()
Returns the multimap of values in the multimap.
Definition: MultiMap.h:107
void forceUnlock(const K &key)
Releases the lock for the specified key regardless of the lock owner.
Definition: MultiMap.h:338
void unlock(const K &key)
Releases the lock for the specified key.
Definition: MultiMap.h:328
bool removeEntryListener(const std::string ®istrationId)
Removes the specified entry listener Returns silently if there is no such listener added before...
Definition: MultiMap.h:234
A specialized distributed map client whose keys can be associated with multiple values.
Definition: RawPointerMultiMap.h:32
Definition: MapEntryView.h:32
bool containsEntry(const K &key, const V &value)
Returns whether the multimap contains the given key-value pair.
Definition: MultiMap.h:148
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster...
Definition: HazelcastClient.h:459