Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
hazelcast::client::imap Class Reference

Concurrent, distributed, observable and queryable map client. More...

#include <imap.h>

Inheritance diagram for hazelcast::client::imap:

Public Member Functions

 imap (const std::string &instance_name, spi::ClientContext *context)
template<typename K>
boost::future< bool > contains_key (const K &key)
 check if this map contains key.
template<typename V>
boost::future< bool > contains_value (const V &value)
 check if this map contains value.
template<typename K, typename V>
boost::future< boost::optional< V > > get (const K &key)
 get the value.
template<typename K, typename V, typename R = V>
boost::future< boost::optional< R > > put (const K &key, const V &value)
 put new entry into map.
template<typename K, typename V, typename R = V>
boost::future< boost::optional< R > > put (const K &key, const V &value, std::chrono::milliseconds ttl)
 Puts an entry into this map with a given ttl (time to live) value.
template<typename K, typename V>
boost::future< boost::optional< V > > remove (const K &key)
 remove entry form map
template<typename K, typename V>
boost::future< bool > remove (const K &key, const V &value)
 removes entry from map if there is an entry with same key and value.
template<typename P>
boost::future< void > remove_all (const P &predicate)
 Removes all entries which match with the supplied predicate.
template<typename K>
boost::future< void > delete_entry (const K &key)
 removes entry from map.
template<typename K>
boost::future< bool > try_remove (const K &key, std::chrono::milliseconds timeout)
 Tries to remove the entry with the given key from this map within specified timeout value.
template<typename K, typename V>
boost::future< bool > try_put (const K &key, const V &value, std::chrono::milliseconds timeout)
 Tries to put the given key, value into this map within specified timeout value.
template<typename K, typename V>
boost::future< void > put_transient (const K &key, const V &value, std::chrono::milliseconds ttl)
 Same as put(K, V, int64_t, TimeUnit) but MapStore, if defined, will not be called to store/persist the entry.
template<typename K, typename V, typename R = V>
boost::future< boost::optional< V > > put_if_absent (const K &key, const V &value)
 Puts an entry into this map, if the specified key is not already associated with a value.
template<typename K, typename V, typename R = V>
boost::future< boost::optional< V > > put_if_absent (const K &key, const V &value, std::chrono::milliseconds ttl)
 Puts an entry into this map with a given ttl (time to live) value if the specified key is not already associated with a value.
template<typename K, typename V, typename N = V>
boost::future< bool > replace (const K &key, const V &old_value, const N &new_value)
 Replaces the entry for a key only if currently mapped to a given value.
template<typename K, typename V, typename R = V>
boost::future< boost::optional< R > > replace (const K &key, const V &value)
 Replaces the entry for a key only if currently mapped to some value.
template<typename K, typename V, typename R = V>
boost::future< void > set (const K &key, const V &value)
 Puts an entry into this map.
template<typename K, typename V>
boost::future< void > set (const K &key, const V &value, std::chrono::milliseconds ttl)
 Puts an entry into this map.
template<typename K>
boost::future< void > lock (const K &key)
 Acquires the lock for the specified key.
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.
template<typename K>
boost::future< bool > is_locked (const K &key)
 Checks the lock for the specified key.
template<typename K>
boost::future< bool > try_lock (const K &key)
 Tries to acquire the lock for the specified key.
template<typename K>
boost::future< bool > try_lock (const K &key, std::chrono::milliseconds timeout)
 Tries to acquire the lock for the specified key.
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.
template<typename K>
boost::future< void > unlock (const K &key)
 Releases the lock for the specified key.
template<typename K>
boost::future< void > force_unlock (const K &key)
 Releases the lock for the specified key regardless of the lock owner.
template<typename MapInterceptor>
boost::future< std::string > add_interceptor (const MapInterceptor &interceptor)
 Adds an interceptor for this map.
boost::future< boost::uuids::uuid > add_entry_listener (entry_listener &&listener, bool include_value)
 Adds an entry listener for this map.
template<typename P>
boost::future< boost::uuids::uuid > add_entry_listener (entry_listener &&listener, const P &predicate, bool include_value)
 Adds an entry listener for this map.
template<typename K>
boost::future< boost::uuids::uuid > add_entry_listener (entry_listener &&listener, bool include_value, const K &key)
 Adds the specified entry listener for the specified key.
template<typename K, typename V>
boost::future< boost::optional< entry_view< K, V > > > get_entry_view (const K &key)
 Returns the EntryView for the specified key.
template<typename K>
boost::future< bool > evict (const K &key)
 Evicts the specified key from this map.
template<typename K, typename V>
boost::future< std::unordered_map< K, V > > get_all (const std::unordered_set< K > &keys)
 Returns the entries for the given keys.
template<typename K>
boost::future< std::vector< K > > key_set ()
 Returns a vector clone of the keys contained in this map.
template<typename K, typename P, class = typename std::enable_if< !std::is_base_of<query::paging_predicate_marker, P>::value>::type>
boost::future< std::vector< K > > key_set (const P &predicate)
 Queries the map based on the specified predicate and returns the keys of matching entries.
template<typename K, typename V>
boost::future< std::vector< K > > key_set (query::paging_predicate< K, V > &predicate)
 Queries the map based on the specified predicate and returns the keys of matching entries.
template<typename V>
boost::future< std::vector< V > > values ()
 Returns a vector clone of the values contained in this map.
template<typename V, typename P, class = typename std::enable_if< !std::is_base_of<query::paging_predicate_marker, P>::value>::type>
boost::future< std::vector< V > > values (const P &predicate)
 Returns a vector clone of the values contained in this map.
template<typename K, typename V>
boost::future< std::vector< V > > values (query::paging_predicate< K, V > &predicate)
 Returns a vector clone of the values contained in this map.
template<typename K, typename V>
boost::future< std::vector< std::pair< K, V > > > entry_set ()
 Returns a std::vector< std::pair<K, V> > clone of the mappings contained in this map.
template<typename K, typename V, typename P, class = typename std::enable_if< !std::is_base_of<query::paging_predicate_marker, P>::value>::type>
boost::future< std::vector< std::pair< K, V > > > entry_set (const P &predicate)
 Queries the map based on the specified predicate and returns the matching entries.
template<typename K, typename V>
boost::future< std::vector< std::pair< K, V > > > entry_set (query::paging_predicate< K, V > &predicate)
 Queries the map based on the specified predicate and returns the matching entries.
boost::future< void > add_index (const config::index_config &config)
 Adds an index to this map for the specified entries so that queries can run faster.
template<typename... T>
boost::future< void > add_index (config::index_config::index_type type, T... attributes)
 Convenient method to add an index to this map with the given type and attributes.
boost::future< void > clear ()
template<typename K, typename ResultType, typename EntryProcessor>
boost::future< boost::optional< ResultType > > execute_on_key (const K &key, const EntryProcessor &entry_processor)
 Applies the user defined EntryProcessor to the entry mapped by the key.
template<typename K, typename ResultType, typename EntryProcessor>
boost::future< boost::optional< ResultType > > submit_to_key (const K &key, const EntryProcessor &entry_processor)
 Applies the user defined EntryProcessor to the entry mapped by the key.
template<typename K, typename ResultType, typename EntryProcessor>
boost::future< std::unordered_map< K, boost::optional< ResultType > > > execute_on_keys (const std::unordered_set< K > &keys, const EntryProcessor &entry_processor)
 Applies the user defined EntryProcessor to the entries mapped by the collection of keys.
template<typename K, typename ResultType, typename EntryProcessor>
boost::future< std::unordered_map< K, boost::optional< ResultType > > > execute_on_entries (const EntryProcessor &entry_processor)
 Applies the user defined EntryProcessor to the all entries in the map.
template<typename K, typename ResultType, typename EntryProcessor, typename P>
boost::future< std::unordered_map< K, boost::optional< ResultType > > > execute_on_entries (const EntryProcessor &entry_processor, const P &predicate)
 Applies the user defined EntryProcessor to the all entries in the map.
template<typename K, typename V>
boost::future< void > put_all (const std::unordered_map< K, V > &entries)
 Copies all of the mappings from the specified map to this map (optional operation).
monitor::local_map_statsget_local_map_stats ()
 Returns LocalMapStats for this map.
template<typename K, typename V>
query::paging_predicate< K, V > new_paging_predicate (size_t predicate_page_size)
template<typename K, typename V, typename INNER_PREDICATE>
query::paging_predicate< K, V > new_paging_predicate (size_t predicate_page_size, const INNER_PREDICATE &predicate)
template<typename K, typename V, typename COMPARATOR>
query::paging_predicate< K, V > new_paging_predicate (COMPARATOR &&comparator, size_t predicate_page_size)
template<typename K, typename V, typename INNER_PREDICATE, typename COMPARATOR>
query::paging_predicate< K, V > new_paging_predicate (const INNER_PREDICATE &predicate, COMPARATOR &&comparator, size_t predicate_page_size)

Static Public Attributes

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

Protected Member Functions

virtual boost::future< boost::optional< serialization::pimpl::data > > get_internal (const serialization::pimpl::data &key_data)
virtual boost::future< bool > contains_key_internal (const serialization::pimpl::data &key_data)
virtual boost::future< boost::optional< serialization::pimpl::data > > remove_internal (const serialization::pimpl::data &key_data)
virtual boost::future< bool > remove_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data)
virtual boost::future< protocol::ClientMessage > remove_all_internal (const serialization::pimpl::data &predicate_data)
virtual boost::future< protocol::ClientMessage > delete_internal (const serialization::pimpl::data &key_data)
virtual boost::future< bool > try_remove_internal (const serialization::pimpl::data &key_data, std::chrono::milliseconds timeout)
virtual boost::future< bool > try_put_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data, std::chrono::milliseconds timeout)
virtual boost::future< boost::optional< serialization::pimpl::data > > put_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data, std::chrono::milliseconds ttl)
virtual boost::future< protocol::ClientMessage > try_put_transient_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data, std::chrono::milliseconds ttl)
virtual boost::future< boost::optional< serialization::pimpl::data > > put_if_absent_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data, std::chrono::milliseconds ttl)
virtual boost::future< bool > replace_if_same_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data, const serialization::pimpl::data &new_value_data)
virtual boost::future< boost::optional< serialization::pimpl::data > > replace_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data)
virtual boost::future< protocol::ClientMessage > set_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &value_data, std::chrono::milliseconds ttl)
virtual boost::future< bool > evict_internal (const serialization::pimpl::data &key_data)
virtual boost::future< EntryVector > get_all_internal (int partition_id, const std::vector< serialization::pimpl::data > &partition_keys)
virtual boost::future< boost::optional< serialization::pimpl::data > > execute_on_key_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &processor)
boost::future< boost::optional< serialization::pimpl::data > > submit_to_key_internal (const serialization::pimpl::data &key_data, const serialization::pimpl::data &processor)
template<typename K, typename EntryProcessor>
boost::future< EntryVector > execute_on_keys_internal (const std::unordered_set< K > &keys, const EntryProcessor &entry_processor)
virtual boost::future< protocol::ClientMessage > put_all_internal (int partition_id, const EntryVector &entries)

Protected Attributes

monitor::impl::LocalMapStatsImpl local_map_stats_

Static Protected Attributes

static const std::chrono::milliseconds UNSET { -1 }
 Default TTL value of a record.

Friends

class spi::ProxyManager

Detailed Description

Concurrent, distributed, observable and queryable map client.

Notice that this class have a private constructor. You can access get an IMap in the following way

 auto client = new_client().get();
 auto imap = client.get_map("aMap").get();

Definition at line 62 of file imap.h.

Constructor & Destructor Documentation

◆ imap()

hazelcast::client::imap::imap ( const std::string & instance_name,
spi::ClientContext * context )
inline

Definition at line 69 of file imap.h.

70 : proxy::IMapImpl(instance_name, context)
71 {}

Member Function Documentation

◆ add_entry_listener() [1/3]

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

Adds an entry listener for this map.

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
registrationId of added listener that can be used to remove the entry listener.

Definition at line 531 of file imap.h.

534 {
535 const auto listener_flags = listener.flags_;
536 return proxy::IMapImpl::add_entry_listener(
537 std::unique_ptr<impl::BaseEventHandler>(
538 new impl::EntryEventHandler<
539 protocol::codec::map_addentrylistener_handler>(
540 get_name(),
541 get_context().get_client_cluster_service(),
542 get_context().get_serialization_service(),
543 std::move(listener),
544 include_value,
545 get_context().get_logger())),
546 include_value,
547 listener_flags);
548 }

◆ add_entry_listener() [2/3]

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

Adds the specified entry listener for the specified key.

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
keykey to listen
includeValuetrue if EntryEvent should contain the value.

Definition at line 603 of file imap.h.

607 {
608 const auto listener_flags = listener.flags_;
609 return proxy::IMapImpl::add_entry_listener(
610 std::shared_ptr<impl::BaseEventHandler>(
611 new impl::EntryEventHandler<
612 protocol::codec::map_addentrylistenertokey_handler>(
613 get_name(),
614 get_context().get_client_cluster_service(),
615 get_context().get_serialization_service(),
616 std::move(listener),
617 include_value,
618 get_context().get_logger())),
619 include_value,
620 to_data<K>(key),
621 listener_flags);
622 }

◆ add_entry_listener() [3/3]

template<typename P>
boost::future< boost::uuids::uuid > hazelcast::client::imap::add_entry_listener ( entry_listener && listener,
const P & predicate,
bool include_value )
inline

Adds an entry listener for this map.

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
predicateThe query filter to use when returning the events to the user.
includeValuetrue if EntryEvent should contain the value.
Returns
registrationId of added listener that can be used to remove the entry listener.

Definition at line 568 of file imap.h.

572 {
573 const auto listener_flags = listener.flags_;
574 return proxy::IMapImpl::add_entry_listener(
575 std::unique_ptr<impl::BaseEventHandler>(
576 new impl::EntryEventHandler<
577 protocol::codec::map_addentrylistenerwithpredicate_handler>(
578 get_name(),
579 get_context().get_client_cluster_service(),
580 get_context().get_serialization_service(),
581 std::move(listener),
582 include_value,
583 get_context().get_logger())),
584 to_data<P>(predicate),
585 include_value,
586 listener_flags);
587 }

◆ add_index() [1/2]

template<typename... T>
boost::future< void > hazelcast::client::imap::add_index ( config::index_config::index_type type,
T... attributes )
inline

Convenient method to add an index to this map with the given type and attributes.

Attributes are indexed in ascending order.

Parameters
typeIndex type.
attributesAttributes to be indexed.

Definition at line 914 of file imap.h.

916 {
917 return add_index(
918 config::index_config(type, std::forward<T>(attributes)...));
919 }
boost::future< void > add_index(const config::index_config &config)
Adds an index to this map for the specified entries so that queries can run faster.
Definition imap.h:901

◆ add_index() [2/2]

boost::future< void > hazelcast::client::imap::add_index ( const config::index_config & config)
inline

Adds an index to this map for the specified entries so that queries can run faster.

Let's say your map values are Employee objects.

  struct Employee {
    bool active;
    int32_t age;
    std::string name;
    // other fields

  }

If you are querying your values mostly based on age and active then you may consider indexing these fields.

  auto imap = client.getMap("employees");
  imap.addIndex(config::index_config(config::index_config::index_type::SORTED,
"age"));  // Sorted index for range queries
  imap.addIndex(config::index_config(config::index_config::index_type::HASH,
"active"));  // Sorted index for range queries

Index attribute should either have a getter method or be public. You should also make sure to add the indexes before adding entries to this map.

Time to Index

Indexing time is executed in parallel on each partition by operation threads. The Map is not blocked during this operation.

The time taken in proportional to the size of the Map and the number Members.

Searches while indexes are being built

Until the index finishes being created, any searches for the attribute will use a full Map scan, thus avoiding using a partially built index and returning incorrect results.

Parameters
configIndex configuration.

Definition at line 901 of file imap.h.

902 {
903 return to_void_future(proxy::IMapImpl::add_index_data(config));
904 }

◆ add_interceptor()

template<typename MapInterceptor>
boost::future< std::string > hazelcast::client::imap::add_interceptor ( const MapInterceptor & interceptor)
inline

Adds an interceptor for this map.

Added interceptor will intercept operations and execute user defined methods and will cancel operations if user defined method throw exception.

Interceptor should be serializable. Notice that map interceptor runs on the nodes. Because of that same class should be implemented in java side with same classId and factoryId.

Parameters
interceptormap interceptor
Returns
id of registered interceptor

Definition at line 510 of file imap.h.

512 {
513 return proxy::IMapImpl::add_interceptor(to_data(interceptor));
514 }

◆ clear()

boost::future< void > hazelcast::client::imap::clear ( )
inline

Definition at line 921 of file imap.h.

922 {
923 return to_void_future(proxy::IMapImpl::clear_data());
924 }

◆ contains_key()

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

check if this map contains key.

Parameters
key
Returns
true if contains, false otherwise

Definition at line 79 of file imap.h.

80 {
81 return contains_key_internal(to_data(key));
82 }

◆ contains_key_internal()

virtual boost::future< bool > hazelcast::client::imap::contains_key_internal ( const serialization::pimpl::data & key_data)
inlineprotectedvirtual

Definition at line 1146 of file imap.h.

1148 {
1149 return proxy::IMapImpl::contains_key(key_data);
1150 }

◆ contains_value()

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

check if this map contains value.

Parameters
value
Returns
true if contains, false otherwise

Definition at line 90 of file imap.h.

91 {
92 return proxy::IMapImpl::contains_value(to_data(value));
93 }

◆ delete_entry()

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

removes entry from map.

Does not return anything.

Parameters
keyThe key of the map entry to remove.

Definition at line 188 of file imap.h.

189 {
190 return to_void_future(delete_internal(to_data(key)));
191 }

◆ delete_internal()

virtual boost::future< protocol::ClientMessage > hazelcast::client::imap::delete_internal ( const serialization::pimpl::data & key_data)
inlineprotectedvirtual

Definition at line 1171 of file imap.h.

1173 {
1174 return proxy::IMapImpl::delete_entry(key_data);
1175 }

◆ entry_set() [1/3]

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

Returns a std::vector< std::pair<K, V> > clone of the mappings contained in this map.

The vector is NOT backed by the map, so changes to the map are NOT reflected in the set, and vice-versa.

Returns
a vector clone of the keys mappings in this map

Definition at line 812 of file imap.h.

813 {
814 return to_entry_object_vector<K, V>(proxy::IMapImpl::entry_set_data());
815 }

◆ entry_set() [2/3]

template<typename K, typename V, typename P, class = typename std::enable_if< !std::is_base_of<query::paging_predicate_marker, P>::value>::type>
boost::future< std::vector< std::pair< K, V > > > hazelcast::client::imap::entry_set ( const P & predicate)
inline

Queries the map based on the specified predicate and returns the matching entries.

Specified predicate runs on all members in parallel.

Parameters
predicatequery criteria
Returns
result entry vector of the query

Definition at line 833 of file imap.h.

834 {
835 return to_entry_object_vector<K, V>(
836 proxy::IMapImpl::entry_set_data(to_data(predicate)));
837 }

◆ entry_set() [3/3]

template<typename K, typename V>
boost::future< std::vector< std::pair< K, V > > > hazelcast::client::imap::entry_set ( query::paging_predicate< K, V > & predicate)
inline

Queries the map based on the specified predicate and returns the matching entries.

Specified predicate runs on all members in parallel.

Parameters
predicatequery criteria
Returns
result entry vector of the query

Definition at line 850 of file imap.h.

852 {
853 predicate.set_iteration_type(query::iteration_type::ENTRY);
854 auto future = entry_set_for_paging_predicate_data(
855 protocol::codec::holder::paging_predicate_holder::of(
856 predicate, serialization_service_));
857 return entry_set_to_object_vector_with_predicate<K, V>(
858 std::move(future), predicate);
859 }

◆ evict()

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

Evicts the specified key from this map.

If a MapStore defined for this map, then the entry is not deleted from the underlying MapStore, evict only removes the entry from the memory.

Parameters
keykey to evict
Returns
true if the key is evicted, false otherwise.

Definition at line 651 of file imap.h.

652 {
653 return evict_internal(to_data(key));
654 }

◆ evict_internal()

virtual boost::future< bool > hazelcast::client::imap::evict_internal ( const serialization::pimpl::data & key_data)
inlineprotectedvirtual

Definition at line 1239 of file imap.h.

1241 {
1242 return proxy::IMapImpl::evict(key_data);
1243 }

◆ execute_on_entries() [1/2]

template<typename K, typename ResultType, typename EntryProcessor>
boost::future< std::unordered_map< K, boost::optional< ResultType > > > hazelcast::client::imap::execute_on_entries ( const EntryProcessor & entry_processor)
inline

Applies the user defined EntryProcessor to the all entries in the map.

Returns the results mapped by each key in the map.

EntryProcessor should be serializable. Notice that map EntryProcessor runs on the nodes. Because of that, same class should be implemented in java side with same classId and factoryId.

Template Parameters
ResultTypethat entry processor will return
EntryProcessortype of entry processor class
Parameters
entryProcessorthat will be applied

Definition at line 1005 of file imap.h.

1006 {
1007 return to_object_map<K, ResultType>(
1008 proxy::IMapImpl::execute_on_entries_data(to_data(entry_processor)));
1009 }

◆ execute_on_entries() [2/2]

template<typename K, typename ResultType, typename EntryProcessor, typename P>
boost::future< std::unordered_map< K, boost::optional< ResultType > > > hazelcast::client::imap::execute_on_entries ( const EntryProcessor & entry_processor,
const P & predicate )
inline

Applies the user defined EntryProcessor to the all entries in the map.

Returns the results mapped by each key in the map.

EntryProcessor should be serializable. Notice that map EntryProcessor runs on the nodes. Because of that, same class should be implemented in java side with same classId and factoryId.

Template Parameters
ResultTypethat entry processor will return
EntryProcessortype of entry processor class
predicateThe filter to apply for selecting the entries at the server side.
Parameters
entryProcessorthat will be applied

Definition at line 1031 of file imap.h.

1033 {
1034 return to_object_map<K, ResultType>(
1035 proxy::IMapImpl::execute_on_entries_data(to_data(entry_processor),
1036 to_data(predicate)));
1037 }

◆ execute_on_key()

template<typename K, typename ResultType, typename EntryProcessor>
boost::future< boost::optional< ResultType > > hazelcast::client::imap::execute_on_key ( const K & key,
const EntryProcessor & entry_processor )
inline

Applies the user defined EntryProcessor to the entry mapped by the key.

Returns the the ResultType which is result of the process() method of EntryProcessor.

EntryProcessor should be serializable. Notice that map EntryProcessor runs on the nodes. Because of that, same class should be implemented in java side with same classId and factoryId.

Template Parameters
EntryProcessortype of entry processor class
ResultTypethat entry processor will return
Parameters
entryProcessorthat will be applied
keyof entry that entryProcessor will be applied on
Returns
result of entry process.

Definition at line 942 of file imap.h.

945 {
946 return to_object<ResultType>(
947 execute_on_key_internal(to_data(key), to_data(entry_processor)));
948 }

◆ execute_on_key_internal()

virtual boost::future< boost::optional< serialization::pimpl::data > > hazelcast::client::imap::execute_on_key_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & processor )
inlineprotectedvirtual

Definition at line 1253 of file imap.h.

1255 {
1256 return proxy::IMapImpl::execute_on_key_data(key_data, processor);
1257 }

◆ execute_on_keys()

template<typename K, typename ResultType, typename EntryProcessor>
boost::future< std::unordered_map< K, boost::optional< ResultType > > > hazelcast::client::imap::execute_on_keys ( const std::unordered_set< K > & keys,
const EntryProcessor & entry_processor )
inline

Applies the user defined EntryProcessor to the entries mapped by the collection of keys.

Returns the results mapped by each key in the map.

Notice that map EntryProcessor runs on the nodes. Because of that, same class should be implemented in java side

Template Parameters
ResultTypethat entry processor will return
EntryProcessortype of entry processor class
keysThe keys for which the entry processor will be applied.
Parameters
entryProcessorthat will be applied

Definition at line 983 of file imap.h.

985 {
986 return to_object_map<K, ResultType>(
987 execute_on_keys_internal<K, EntryProcessor>(keys, entry_processor));
988 }

◆ execute_on_keys_internal()

template<typename K, typename EntryProcessor>
boost::future< EntryVector > hazelcast::client::imap::execute_on_keys_internal ( const std::unordered_set< K > & keys,
const EntryProcessor & entry_processor )
inlineprotected

Definition at line 1267 of file imap.h.

1270 {
1271 if (keys.empty()) {
1272 return boost::make_ready_future(EntryVector());
1273 }
1274 std::vector<serialization::pimpl::data> keysData;
1275 for (const auto& k : keys) {
1276 keysData.push_back(to_data<K>(k));
1277 }
1278 return proxy::IMapImpl::execute_on_keys_data(
1279 keysData, to_data<EntryProcessor>(entry_processor));
1280 }

◆ force_unlock()

template<typename K>
boost::future< void > hazelcast::client::imap::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 492 of file imap.h.

493 {
494 return to_void_future(proxy::IMapImpl::force_unlock(to_data(key)));
495 }

◆ get()

template<typename K, typename V>
boost::future< boost::optional< V > > hazelcast::client::imap::get ( const K & key)
inline

get the value.

Parameters
key
Returns
value value, if there is no mapping for key then returns boost::none.

Definition at line 102 of file imap.h.

103 {
104 return to_object<V>(get_internal(to_data(key)));
105 }

◆ get_all()

template<typename K, typename V>
boost::future< std::unordered_map< K, V > > hazelcast::client::imap::get_all ( const std::unordered_set< K > & keys)
inline

Returns the entries for the given keys.

Parameters
keyskeys to get
Returns
map of entries

Definition at line 663 of file imap.h.

665 {
666 if (keys.empty()) {
667 return boost::make_ready_future(std::unordered_map<K, V>());
668 }
669
670 std::unordered_map<int, std::vector<serialization::pimpl::data>>
671 partition_to_key_data;
672 // group the request per server
673 for (auto& key : keys) {
674 auto key_data = to_data<K>(key);
675
676 auto partitionId = get_partition_id(key_data);
677 partition_to_key_data[partitionId].push_back(std::move(key_data));
678 }
679
680 std::vector<boost::future<EntryVector>> futures;
681 futures.reserve(partition_to_key_data.size());
682 for (auto& entry : partition_to_key_data) {
683 futures.push_back(get_all_internal(entry.first, entry.second));
684 }
685
686 return to_object_map<K, V>(futures);
687 }

◆ get_all_internal()

virtual boost::future< EntryVector > hazelcast::client::imap::get_all_internal ( int partition_id,
const std::vector< serialization::pimpl::data > & partition_keys )
inlineprotectedvirtual

Definition at line 1245 of file imap.h.

1248 {
1249 return proxy::IMapImpl::get_all_data(partition_id, partition_keys);
1250 }

◆ get_entry_view()

template<typename K, typename V>
boost::future< boost::optional< entry_view< K, V > > > hazelcast::client::imap::get_entry_view ( const K & key)
inline

Returns the EntryView for the specified key.

Parameters
keykey of the entry
Returns
EntryView of the specified key
See also
EntryView

Definition at line 633 of file imap.h.

635 {
636 auto f = proxy::IMapImpl::get_entry_view_data(to_data(key));
637 return to_object_entry_view<K, V>(std::move(f));
638 }

◆ get_internal()

virtual boost::future< boost::optional< serialization::pimpl::data > > hazelcast::client::imap::get_internal ( const serialization::pimpl::data & key_data)
inlineprotectedvirtual

Definition at line 1141 of file imap.h.

1142 {
1143 return proxy::IMapImpl::get_data(key_data);
1144 }

◆ get_local_map_stats()

monitor::local_map_stats & hazelcast::client::imap::get_local_map_stats ( )
inline

Returns LocalMapStats for this map.

LocalMapStats is the statistics for the local portion of this distributed map and contains information such as ownedEntryCount backupEntryCount, lastUpdateTime, lockedEntryCount.

Since this stats are only for the local portion of this map, if you need the cluster-wide MapStats then you need to get the LocalMapStats from all members of the cluster and combine them.

Returns
this map's local statistics.

Definition at line 1088 of file imap.h.

1088{ return local_map_stats_; }

◆ is_locked()

template<typename K>
boost::future< bool > hazelcast::client::imap::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 395 of file imap.h.

396 {
397 return proxy::IMapImpl::is_locked(to_data(key));
398 }

◆ key_set() [1/3]

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

Returns a vector clone of the keys contained in this map.

The vector is NOT backed by the map, so changes to the map are NOT reflected in the vector, and vice-versa.

Returns
a vector clone of the keys contained in this map

Definition at line 698 of file imap.h.

699 {
700 return to_object_vector<K>(proxy::IMapImpl::key_set_data());
701 }

◆ key_set() [2/3]

template<typename K, typename P, class = typename std::enable_if< !std::is_base_of<query::paging_predicate_marker, P>::value>::type>
boost::future< std::vector< K > > hazelcast::client::imap::key_set ( const P & predicate)
inline

Queries the map based on the specified predicate and returns the keys of matching entries.

Specified predicate runs on all members in parallel.

Parameters
predicatequery criteria
Returns
result key set of the query

Definition at line 719 of file imap.h.

720 {
721 return to_object_vector<K>(
722 proxy::IMapImpl::key_set_data(to_data(predicate)));
723 }

◆ key_set() [3/3]

template<typename K, typename V>
boost::future< std::vector< K > > hazelcast::client::imap::key_set ( query::paging_predicate< K, V > & predicate)
inline

Queries the map based on the specified predicate and returns the keys of matching entries.

Specified predicate runs on all members in parallel.

Parameters
predicatequery criteria
Returns
result key set of the query

Definition at line 737 of file imap.h.

739 {
740 predicate.set_iteration_type(query::iteration_type::KEY);
741 auto future = key_set_for_paging_predicate_data(
742 protocol::codec::holder::paging_predicate_holder::of(
743 predicate, serialization_service_));
744 return keys_to_object_vector_with_predicate(std::move(future),
745 predicate);
746 }

◆ lock() [1/2]

template<typename K>
boost::future< void > hazelcast::client::imap::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 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.

Definition at line 357 of file imap.h.

358 {
359 return to_void_future(lock(key, UNSET));
360 }
boost::future< void > lock(const K &key)
Acquires the lock for the specified key.
Definition imap.h:357
static const std::chrono::milliseconds UNSET
Default TTL value of a record.
Definition imap.h:1136

◆ lock() [2/2]

template<typename K>
boost::future< void > hazelcast::client::imap::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 381 of file imap.h.

382 {
383 return to_void_future(proxy::IMapImpl::lock(to_data(key), lease_time));
384 }

◆ new_paging_predicate() [1/4]

template<typename K, typename V, typename COMPARATOR>
query::paging_predicate< K, V > hazelcast::client::imap::new_paging_predicate ( COMPARATOR && comparator,
size_t predicate_page_size )
inline

Definition at line 1108 of file imap.h.

1111 {
1112 return query::paging_predicate<K, V>(get_serialization_service(),
1113 std::move(comparator),
1114 predicate_page_size);
1115 }

◆ new_paging_predicate() [2/4]

template<typename K, typename V, typename INNER_PREDICATE, typename COMPARATOR>
query::paging_predicate< K, V > hazelcast::client::imap::new_paging_predicate ( const INNER_PREDICATE & predicate,
COMPARATOR && comparator,
size_t predicate_page_size )
inline

Definition at line 1121 of file imap.h.

1125 {
1126 return query::paging_predicate<K, V>(get_serialization_service(),
1127 predicate,
1128 std::move(comparator),
1129 predicate_page_size);
1130 }

◆ new_paging_predicate() [3/4]

template<typename K, typename V>
query::paging_predicate< K, V > hazelcast::client::imap::new_paging_predicate ( size_t predicate_page_size)
inline

Definition at line 1091 of file imap.h.

1093 {
1094 return query::paging_predicate<K, V>(get_serialization_service(),
1095 predicate_page_size);
1096 }

◆ new_paging_predicate() [4/4]

template<typename K, typename V, typename INNER_PREDICATE>
query::paging_predicate< K, V > hazelcast::client::imap::new_paging_predicate ( size_t predicate_page_size,
const INNER_PREDICATE & predicate )
inline

Definition at line 1099 of file imap.h.

1102 {
1103 return query::paging_predicate<K, V>(
1104 get_serialization_service(), predicate_page_size, predicate);
1105 }

◆ put() [1/2]

template<typename K, typename V, typename R = V>
boost::future< boost::optional< R > > hazelcast::client::imap::put ( const K & key,
const V & value )
inline

put new entry into map.

Parameters
key
value
Returns
the previous value. if there is no mapping for key, then returns boost::none.

Definition at line 115 of file imap.h.

116 {
117 return put<K, V, R>(key, value, UNSET);
118 }
boost::future< boost::optional< R > > put(const K &key, const V &value)
put new entry into map.
Definition imap.h:115

◆ put() [2/2]

template<typename K, typename V, typename R = V>
boost::future< boost::optional< R > > hazelcast::client::imap::put ( const K & key,
const V & value,
std::chrono::milliseconds ttl )
inline

Puts an entry into this map with a given ttl (time to live) value.

Entry will expire and get evicted after the ttl. If ttl is 0, then the entry lives forever.

Parameters
keykey of the entry
valuevalue of the entry
ttlmaximum time for this entry to stay in the map. 0 means infinite.
Returns
the previous value. if there is no mapping for key, then returns boost::none.

Definition at line 133 of file imap.h.

136 {
137 return to_object<R>(put_internal(to_data(key), to_data(value), ttl));
138 }

◆ put_all()

template<typename K, typename V>
boost::future< void > hazelcast::client::imap::put_all ( const std::unordered_map< K, V > & entries)
inline

Copies all of the mappings from the specified map to this map (optional operation).

The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.

Parameters
entriesmappings to be stored in this map

Definition at line 1050 of file imap.h.

1051 {
1052 std::unordered_map<int, EntryVector> entryMap;
1053 for (auto& entry : entries) {
1054 serialization::pimpl::data key_data = to_data(entry.first);
1055 int partitionId = get_partition_id(key_data);
1056 entryMap[partitionId].push_back(
1057 std::make_pair(key_data, to_data(entry.second)));
1058 }
1059
1060 std::vector<boost::future<protocol::ClientMessage>> resultFutures;
1061 for (auto&& partitionEntry : entryMap) {
1062 auto partitionId = partitionEntry.first;
1063 resultFutures.push_back(
1064 put_all_internal(partitionId, std::move(partitionEntry.second)));
1065 }
1066 return boost::when_all(resultFutures.begin(), resultFutures.end())
1067 .then(boost::launch::sync,
1068 [](boost::future<boost::csbl::vector<
1069 boost::future<protocol::ClientMessage>>> futures) {
1070 for (auto& f : futures.get()) {
1071 f.get();
1072 }
1073 });
1074 }

◆ put_all_internal()

virtual boost::future< protocol::ClientMessage > hazelcast::client::imap::put_all_internal ( int partition_id,
const EntryVector & entries )
inlineprotectedvirtual

Definition at line 1282 of file imap.h.

1285 {
1286 return proxy::IMapImpl::put_all_data(partition_id, entries);
1287 }

◆ put_if_absent() [1/2]

template<typename K, typename V, typename R = V>
boost::future< boost::optional< V > > hazelcast::client::imap::put_if_absent ( const K & key,
const V & value )
inline

Puts an entry into this map, if the specified key is not already associated with a value.

Parameters
keykey with which the specified value is to be associated
value
Returns
the previous value, if there is no mapping for key then returns boost::none.

Definition at line 258 of file imap.h.

260 {
261 return put_if_absent(key, value, UNSET);
262 }
boost::future< boost::optional< V > > put_if_absent(const K &key, const V &value)
Puts an entry into this map, if the specified key is not already associated with a value.
Definition imap.h:258

◆ put_if_absent() [2/2]

template<typename K, typename V, typename R = V>
boost::future< boost::optional< V > > hazelcast::client::imap::put_if_absent ( const K & key,
const V & value,
std::chrono::milliseconds ttl )
inline

Puts an entry into this map with a given ttl (time to live) value if the specified key is not already associated with a value.

Entry will expire and get evicted after the ttl.

Parameters
keykey of the entry
valuevalue of the entry
ttlmaximum time for this entry to stay in the map
Returns
the previous value of the entry, if there is no mapping for key then returns boost::none.

Definition at line 277 of file imap.h.

278 {
279 return to_object<R>(
280 put_if_absent_internal(to_data(key), to_data(value), ttl));
281 }

◆ put_if_absent_internal()

virtual boost::future< boost::optional< serialization::pimpl::data > > hazelcast::client::imap::put_if_absent_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data,
std::chrono::milliseconds ttl )
inlineprotectedvirtual

Definition at line 1209 of file imap.h.

1212 {
1213 return proxy::IMapImpl::put_if_absent_data(key_data, value_data, ttl);
1214 }

◆ put_internal()

virtual boost::future< boost::optional< serialization::pimpl::data > > hazelcast::client::imap::put_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data,
std::chrono::milliseconds ttl )
inlineprotectedvirtual

Definition at line 1193 of file imap.h.

1196 {
1197 return proxy::IMapImpl::put_data(key_data, value_data, ttl);
1198 }

◆ put_transient()

template<typename K, typename V>
boost::future< void > hazelcast::client::imap::put_transient ( const K & key,
const V & value,
std::chrono::milliseconds ttl )
inline

Same as put(K, V, int64_t, TimeUnit) but MapStore, if defined, will not be called to store/persist the entry.

If ttl is 0, then the entry lives forever.

Parameters
keykey of the entry
valuevalue of the entry
ttlmaximum time for this entry to stay in the map in milliseconds, 0 means infinite.

Definition at line 240 of file imap.h.

243 {
244 return to_void_future(
245 try_put_transient_internal(to_data(key), to_data(value), ttl));
246 }

◆ remove() [1/2]

template<typename K, typename V>
boost::future< boost::optional< V > > hazelcast::client::imap::remove ( const K & key)
inline

remove entry form map

Parameters
key
Returns
the previous value. if there is no mapping for key then returns boost::none.

Definition at line 147 of file imap.h.

148 {
149 return to_object<V>(remove_internal(to_data(key)));
150 }

◆ remove() [2/2]

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

removes entry from map if there is an entry with same key and value.

Parameters
keykey of the entry to be removed
valuevalue of the entry to be removed
Returns
true if the entry with key and value exists and removed, false otherwise

Definition at line 160 of file imap.h.

161 {
162 return remove_internal(to_data(key), to_data(value));
163 }

◆ remove_all()

template<typename P>
boost::future< void > hazelcast::client::imap::remove_all ( const P & predicate)
inline

Removes all entries which match with the supplied predicate.

If this map has index, matching entries will be found via index search, otherwise they will be found by full-scan.

Note that calling this method also removes all entries from callers Near Cache.

Parameters
predicatematching entries with this predicate will be removed from this map

Definition at line 177 of file imap.h.

178 {
179 return to_void_future(remove_all_internal(to_data<P>(predicate)));
180 }

◆ remove_all_internal()

virtual boost::future< protocol::ClientMessage > hazelcast::client::imap::remove_all_internal ( const serialization::pimpl::data & predicate_data)
inlineprotectedvirtual

Definition at line 1165 of file imap.h.

1167 {
1168 return proxy::IMapImpl::remove_all(predicate_data);
1169 }

◆ remove_internal() [1/2]

virtual boost::future< boost::optional< serialization::pimpl::data > > hazelcast::client::imap::remove_internal ( const serialization::pimpl::data & key_data)
inlineprotectedvirtual

Definition at line 1153 of file imap.h.

1154 {
1155 return proxy::IMapImpl::remove_data(key_data);
1156 }

◆ remove_internal() [2/2]

virtual boost::future< bool > hazelcast::client::imap::remove_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data )
inlineprotectedvirtual

Definition at line 1158 of file imap.h.

1161 {
1162 return proxy::IMapImpl::remove(key_data, value_data);
1163 }

◆ replace() [1/2]

template<typename K, typename V, typename N = V>
boost::future< bool > hazelcast::client::imap::replace ( const K & key,
const V & old_value,
const N & new_value )
inline

Replaces the entry for a key only if currently mapped to a given value.

Parameters
keykey with which the specified value is associated
oldValuevalue expected to be associated with the specified key
newValue
Returns
true if the value was replaced

Definition at line 291 of file imap.h.

294 {
295 return replace_if_same_internal(
296 to_data(key), to_data(old_value), to_data(new_value));
297 }

◆ replace() [2/2]

template<typename K, typename V, typename R = V>
boost::future< boost::optional< R > > hazelcast::client::imap::replace ( const K & key,
const V & value )
inline

Replaces the entry for a key only if currently mapped to some value.

Parameters
keykey with which the specified value is associated
value
Returns
the previous value of the entry, if there is no mapping for key then returns boost::none.

Definition at line 307 of file imap.h.

308 {
309 return to_object<R>(replace_internal(to_data(key), to_data(value)));
310 }

◆ replace_if_same_internal()

virtual boost::future< bool > hazelcast::client::imap::replace_if_same_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data,
const serialization::pimpl::data & new_value_data )
inlineprotectedvirtual

Definition at line 1216 of file imap.h.

1220 {
1221 return proxy::IMapImpl::replace(key_data, value_data, new_value_data);
1222 }

◆ replace_internal()

virtual boost::future< boost::optional< serialization::pimpl::data > > hazelcast::client::imap::replace_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data )
inlineprotectedvirtual

Definition at line 1225 of file imap.h.

1227 {
1228 return proxy::IMapImpl::replace_data(key_data, value_data);
1229 }

◆ set() [1/2]

template<typename K, typename V, typename R = V>
boost::future< void > hazelcast::client::imap::set ( const K & key,
const V & value )
inline

Puts an entry into this map.

Similar to put operation except that set doesn't return the old value which is more efficient.

Parameters
key
value

Definition at line 320 of file imap.h.

321 {
322 return to_void_future(set(key, value, UNSET));
323 }
boost::future< void > set(const K &key, const V &value)
Puts an entry into this map.
Definition imap.h:320

◆ set() [2/2]

template<typename K, typename V>
boost::future< void > hazelcast::client::imap::set ( const K & key,
const V & value,
std::chrono::milliseconds ttl )
inline

Puts an entry into this map.

Similar to put operation except that set doesn't return the old value which is more efficient.

Parameters
keykey with which the specified value is associated
value
ttlmaximum time in milliseconds for this entry to stay in the map 0 means infinite.

Definition at line 335 of file imap.h.

338 {
339 return to_void_future(set_internal(to_data(key), to_data(value), ttl));
340 }

◆ set_internal()

virtual boost::future< protocol::ClientMessage > hazelcast::client::imap::set_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data,
std::chrono::milliseconds ttl )
inlineprotectedvirtual

Definition at line 1231 of file imap.h.

1235 {
1236 return proxy::IMapImpl::set(key_data, value_data, ttl);
1237 }

◆ submit_to_key()

template<typename K, typename ResultType, typename EntryProcessor>
boost::future< boost::optional< ResultType > > hazelcast::client::imap::submit_to_key ( const K & key,
const EntryProcessor & entry_processor )
inline

Applies the user defined EntryProcessor to the entry mapped by the key.

Returns immediately with a Future representing that task.

Parameters
keykey to be processed
entryProcessorprocessor to process the key
Returns
Future from which the result of the operation can be retrieved.

Definition at line 960 of file imap.h.

963 {
964 return to_object<ResultType>(
965 submit_to_key_internal(to_data(key), to_data(entry_processor)));
966 }

◆ submit_to_key_internal()

boost::future< boost::optional< serialization::pimpl::data > > hazelcast::client::imap::submit_to_key_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & processor )
inlineprotected

Definition at line 1260 of file imap.h.

1262 {
1263 return submit_to_key_data(key_data, processor);
1264 }

◆ try_lock() [1/3]

template<typename K>
boost::future< bool > hazelcast::client::imap::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 410 of file imap.h.

411 {
412 return try_lock(key, std::chrono::milliseconds(0));
413 }
boost::future< bool > try_lock(const K &key)
Tries to acquire the lock for the specified key.
Definition imap.h:410

◆ try_lock() [2/3]

template<typename K>
boost::future< bool > hazelcast::client::imap::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
keykey to lock in this map
timeoutmaximum time in milliseconds 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 432 of file imap.h.

434 {
435 return proxy::IMapImpl::try_lock(to_data(key), timeout);
436 }

◆ try_lock() [3/3]

template<typename K>
boost::future< bool > hazelcast::client::imap::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
keykey to lock in this map
timeoutmaximum 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 456 of file imap.h.

459 {
460 return proxy::IMapImpl::try_lock(to_data(key), timeout, lease_time);
461 }

◆ try_put()

template<typename K, typename V>
boost::future< bool > hazelcast::client::imap::try_put ( const K & key,
const V & value,
std::chrono::milliseconds timeout )
inline

Tries to put the given key, value into this map within specified timeout value.

If this method returns false, it means that the caller thread couldn't acquire the lock for the key within timeout duration, thus put operation is not successful.

Parameters
keykey of the entry
valuevalue of the entry
timeoutmaximum time to wait
Returns
true if the put is successful, false otherwise.

Definition at line 222 of file imap.h.

225 {
226 return try_put_internal(to_data(key), to_data(value), timeout);
227 }

◆ try_put_internal()

virtual boost::future< bool > hazelcast::client::imap::try_put_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data,
std::chrono::milliseconds timeout )
inlineprotectedvirtual

Definition at line 1184 of file imap.h.

1188 {
1189 return proxy::IMapImpl::try_put(key_data, value_data, timeout);
1190 }

◆ try_put_transient_internal()

virtual boost::future< protocol::ClientMessage > hazelcast::client::imap::try_put_transient_internal ( const serialization::pimpl::data & key_data,
const serialization::pimpl::data & value_data,
std::chrono::milliseconds ttl )
inlineprotectedvirtual

Definition at line 1200 of file imap.h.

1204 {
1205 return proxy::IMapImpl::put_transient(key_data, value_data, ttl);
1206 }

◆ try_remove()

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

Tries to remove the entry with the given key from this map within specified timeout value.

If the key is already locked by another thread and/or member, then this operation will wait timeout amount for acquiring the lock.

Parameters
keykey of the entry
timeoutmaximum time to wait for acquiring the lock for the key

Definition at line 203 of file imap.h.

205 {
206 return try_remove_internal(to_data(key), timeout);
207 }

◆ try_remove_internal()

virtual boost::future< bool > hazelcast::client::imap::try_remove_internal ( const serialization::pimpl::data & key_data,
std::chrono::milliseconds timeout )
inlineprotectedvirtual

Definition at line 1177 of file imap.h.

1180 {
1181 return proxy::IMapImpl::try_remove(key_data, timeout);
1182 }

◆ unlock()

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

Releases the lock for the specified key.

It never blocks and returns immediately.

If the current thread is the holder of this lock then the hold count is decremented. If the hold count is now zero then the lock is released. If the current thread is not the holder of this lock then illegal_monitor_state is thrown.

Parameters
keykey to lock.
Exceptions
illegal_monitor_stateif the current thread does not hold this lock MTODO

Definition at line 478 of file imap.h.

479 {
480 return to_void_future(proxy::IMapImpl::unlock(to_data(key)));
481 }

◆ values() [1/3]

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

Returns a vector clone of the values contained in this map.

The vector is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.

Returns
a vector clone of the values contained in this map

Definition at line 757 of file imap.h.

758 {
759 return to_object_vector<V>(proxy::IMapImpl::values_data());
760 }

◆ values() [2/3]

template<typename V, typename P, class = typename std::enable_if< !std::is_base_of<query::paging_predicate_marker, P>::value>::type>
boost::future< std::vector< V > > hazelcast::client::imap::values ( const P & predicate)
inline

Returns a vector clone of the values contained in this map.

The vector is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.

Parameters
predicatethe criteria for values to match
Returns
a vector clone of the values contained in this map

Definition at line 776 of file imap.h.

777 {
778 return to_object_vector<V>(
779 proxy::IMapImpl::values_data(to_data(predicate)));
780 }

◆ values() [3/3]

template<typename K, typename V>
boost::future< std::vector< V > > hazelcast::client::imap::values ( query::paging_predicate< K, V > & predicate)
inline

Returns a vector clone of the values contained in this map.

The vector is NOT backed by the map, so changes to the map are NOT reflected in the collection, and vice-versa.

Parameters
predicatethe criteria for values to match
Returns
a vector clone of the values contained in this map

Definition at line 793 of file imap.h.

795 {
796 predicate.set_iteration_type(query::iteration_type::VALUE);
797 auto future = values_for_paging_predicate_data(
798 protocol::codec::holder::paging_predicate_holder::of(
799 predicate, serialization_service_));
800 return values_to_object_vector_with_predicate(std::move(future),
801 predicate);
802 }

◆ spi::ProxyManager

friend class spi::ProxyManager
friend

Definition at line 64 of file imap.h.

Member Data Documentation

◆ local_map_stats_

monitor::impl::LocalMapStatsImpl hazelcast::client::imap::local_map_stats_
protected

Definition at line 1138 of file imap.h.

◆ SERVICE_NAME

const char* hazelcast::client::imap::SERVICE_NAME = "hz:impl:mapService"
staticconstexpr

Definition at line 67 of file imap.h.

◆ UNSET

const std::chrono::milliseconds hazelcast::client::imap::UNSET { -1 }
staticprotected

Default TTL value of a record.

Definition at line 1136 of file imap.h.


The documentation for this class was generated from the following files:
  • hazelcast/include/hazelcast/client/imap.h
  • hazelcast/src/hazelcast/client/proxy.cpp