19 #include <unordered_map>
20 #include <unordered_set>
26 #include <boost/container/vector.hpp>
28 #include "hazelcast/client/monitor/local_map_stats.h"
29 #include "hazelcast/client/monitor/impl/NearCacheStatsImpl.h"
30 #include "hazelcast/client/monitor/impl/LocalMapStatsImpl.h"
31 #include "hazelcast/client/proxy/IMapImpl.h"
32 #include "hazelcast/client/impl/EntryEventHandler.h"
33 #include "hazelcast/client/entry_listener.h"
34 #include "hazelcast/client/entry_view.h"
35 #include "hazelcast/client/serialization/serialization.h"
36 #include "hazelcast/util/exception_util.h"
37 #include "hazelcast/client/protocol/codec/codecs.h"
38 #include "hazelcast/client/spi/ClientContext.h"
40 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
42 #pragma warning(disable: 4251)
47 class hazelcast_client;
63 class HAZELCAST_API
imap :
public proxy::IMapImpl {
64 friend class spi::ProxyManager;
66 static constexpr
const char *SERVICE_NAME =
"hz:impl:mapService";
68 imap(
const std::string &instance_name, spi::ClientContext *context) : proxy::IMapImpl(instance_name,
78 return contains_key_internal(to_data(key));
88 return proxy::IMapImpl::contains_value(to_data(value));
96 template<
typename K,
typename V>
97 boost::future<boost::optional<V>>
get(
const K &key) {
98 return to_object<V>(get_internal(to_data(key)));
107 template<
typename K,
typename V,
typename R=V>
108 boost::future<boost::optional<R>>
put(
const K &key,
const V &value) {
109 return put<K, V, R>(key, value, UNSET);
122 template<
typename K,
typename V,
typename R=V>
123 boost::future<boost::optional<R>>
put(
const K &key,
const V &value, std::chrono::milliseconds ttl) {
124 return to_object<R>(put_internal(to_data(key), to_data(value), ttl));
132 template<
typename K,
typename V>
133 boost::future<boost::optional<V>>
remove(
const K &key) {
134 return to_object<V>(remove_internal(to_data(key)));
143 template<
typename K,
typename V>
144 boost::future<bool>
remove(
const K &key,
const V &value) {
145 return remove_internal(to_data(key), to_data(value));
157 template <
typename P>
159 return to_void_future(remove_all_internal(to_data<P>(predicate)));
167 template <
typename K>
169 return to_void_future(delete_internal(to_data(key)));
182 boost::future<bool>
try_remove(
const K &key, std::chrono::milliseconds timeout) {
183 return try_remove_internal(to_data(key), timeout);
198 template<
typename K,
typename V>
199 boost::future<bool>
try_put(
const K &key,
const V &value, std::chrono::milliseconds timeout) {
200 return try_put_internal(to_data(key), to_data(value), timeout);
212 template<
typename K,
typename V>
213 boost::future<void>
put_transient(
const K &key,
const V &value, std::chrono::milliseconds ttl) {
214 return to_void_future(try_put_transient_internal(to_data(key), to_data(value), ttl));
225 template<
typename K,
typename V,
typename R=V>
226 boost::future<boost::optional<V>>
put_if_absent(
const K &key,
const V &value) {
227 return put_if_absent(key, value, UNSET);
241 template<
typename K,
typename V,
typename R=V>
242 boost::future<boost::optional<V>>
put_if_absent(
const K &key,
const V &value, std::chrono::milliseconds ttl) {
243 return to_object<R>(put_if_absent_internal(to_data(key), to_data(value), ttl));
253 template<
typename K,
typename V,
typename N = V>
254 boost::future<bool>
replace(
const K &key,
const V &old_value,
const N &new_value) {
255 return replace_if_same_internal(to_data(key), to_data(old_value), to_data(new_value));
265 template<
typename K,
typename V,
typename R=V>
266 boost::future<boost::optional<R>>
replace(
const K &key,
const V &value) {
267 return to_object<R>(replace_internal(to_data(key), to_data(value)));
277 template<
typename K,
typename V,
typename R=V>
278 boost::future<void>
set(
const K &key,
const V &value) {
279 return to_void_future(set(key, value, UNSET));
291 template<
typename K,
typename V>
292 boost::future<void>
set(
const K &key,
const V &value, std::chrono::milliseconds ttl) {
293 return to_void_future(set_internal(to_data(key), to_data(value), ttl));
311 boost::future<void>
lock(
const K &key) {
312 return to_void_future(lock(key, UNSET));
334 boost::future<void>
lock(
const K &key, std::chrono::milliseconds lease_time) {
335 return to_void_future(proxy::IMapImpl::lock(to_data(key), lease_time));
348 return proxy::IMapImpl::is_locked(to_data(key));
362 return try_lock(key, std::chrono::milliseconds(0));
382 boost::future<bool>
try_lock(
const K &key, std::chrono::milliseconds timeout) {
383 return proxy::IMapImpl::try_lock(to_data(key), timeout);
405 template <
typename K>
406 boost::future<bool>
try_lock(
const K &key, std::chrono::milliseconds timeout, std::chrono::milliseconds lease_time) {
407 return proxy::IMapImpl::try_lock(to_data(key), timeout, lease_time);
424 boost::future<void>
unlock(
const K &key) {
425 return to_void_future(proxy::IMapImpl::unlock(to_data(key)));
438 return to_void_future(proxy::IMapImpl::force_unlock(to_data(key)));
452 template<
typename MapInterceptor>
454 return proxy::IMapImpl::add_interceptor(to_data(interceptor));
472 const auto listener_flags = listener.flags_;
473 return proxy::IMapImpl::add_entry_listener(
474 std::unique_ptr<impl::BaseEventHandler>(
475 new impl::EntryEventHandler<protocol::codec::map_addentrylistener_handler>(
476 get_name(), get_context().get_client_cluster_service(),
477 get_context().get_serialization_service(),
479 include_value, get_context().get_logger())), include_value, listener_flags);
498 boost::future<boost::uuids::uuid>
500 const auto listener_flags = listener.flags_;
501 return proxy::IMapImpl::add_entry_listener(
502 std::unique_ptr<impl::BaseEventHandler>(
503 new impl::EntryEventHandler<protocol::codec::map_addentrylistenerwithpredicate_handler>(
504 get_name(), get_context().get_client_cluster_service(),
505 get_context().get_serialization_service(),
507 include_value, get_context().get_logger())), to_data<P>(predicate), include_value, listener_flags);
525 const auto listener_flags = listener.flags_;
526 return proxy::IMapImpl::add_entry_listener(
527 std::shared_ptr<impl::BaseEventHandler>(
528 new impl::EntryEventHandler<protocol::codec::map_addentrylistenertokey_handler>(
529 get_name(), get_context().get_client_cluster_service(),
530 get_context().get_serialization_service(),
532 include_value, get_context().get_logger())), include_value, to_data<K>(key), listener_flags);
543 template<
typename K,
typename V>
545 return proxy::IMapImpl::get_entry_view_data(to_data(key)).then([=] (boost::future<boost::optional<map::data_entry_view>> f) {
546 auto dataView = f.get();
548 return boost::optional<entry_view<K, V>>();
550 auto v = to_object<V>(dataView->get_value());
551 return boost::make_optional(
entry_view<K, V>(key, std::move(v).value(), *std::move(dataView)));
566 boost::future<bool>
evict(
const K &key) {
567 return evict_internal(to_data(key));
576 template<
typename K,
typename V>
577 boost::future<std::unordered_map<K, V>>
get_all(
const std::unordered_set<K> &keys) {
579 return boost::make_ready_future(std::unordered_map<K, V>());
582 std::unordered_map<int, std::vector<serialization::pimpl::data>> partition_to_key_data;
584 for (
auto &key : keys) {
585 auto key_data = to_data<K>(key);
587 auto partitionId = get_partition_id(key_data);
588 partition_to_key_data[partitionId].push_back(std::move(key_data));
591 std::vector<boost::future<EntryVector>> futures;
592 futures.reserve(partition_to_key_data.size());
593 for (
auto &entry : partition_to_key_data) {
594 futures.push_back(get_all_internal(entry.first, entry.second));
597 return boost::when_all(futures.begin(), futures.end()).then(boost::launch::sync,
598 [=](boost::future<boost::csbl::vector<boost::future<EntryVector>>> results_data) {
599 std::unordered_map<K, V> result;
600 for (
auto &entryVectorFuture : results_data.get()) {
601 for (auto &entry : entryVectorFuture.get()) {
602 auto val = to_object<V>(
605 assert(val.has_value());
607 entry.first).value()] = std::move(
624 return to_object_vector<K>(proxy::IMapImpl::key_set_data());
638 template<typename K, typename P, class = typename std::enable_if<!std::is_base_of<query::paging_predicate_marker, P>::value>::type>
639 boost::future<std::vector<K>>
key_set(
const P &predicate) {
640 return to_object_vector<K>(proxy::IMapImpl::key_set_data(to_data(predicate)));
654 template<
typename K,
typename V>
656 predicate.set_iteration_type(query::iteration_type::KEY);
657 return key_set_for_paging_predicate_data(
658 protocol::codec::holder::paging_predicate_holder::of(predicate, serialization_service_)).then(
661 auto result = f.get();
662 predicate.set_anchor_data_list(std::move(result.second));
663 const auto &entries = result.first;
664 std::vector<K> values;
665 values.reserve(entries.size());
666 for(
const auto &e : entries) {
667 values.emplace_back(*to_object<K>(e));
682 return to_object_vector<V>(proxy::IMapImpl::values_data());
693 template<typename V, typename P, class = typename std::enable_if<!std::is_base_of<query::paging_predicate_marker, P>::value>::type>
694 boost::future<std::vector<V>>
values(
const P &predicate) {
695 return to_object_vector<V>(proxy::IMapImpl::values_data(to_data(predicate)));
707 template<
typename K,
typename V>
709 predicate.set_iteration_type(query::iteration_type::VALUE);
710 return values_for_paging_predicate_data(
711 protocol::codec::holder::paging_predicate_holder::of(predicate, serialization_service_)).then(
712 [=, &predicate](boost::future<std::pair<std::vector<serialization::pimpl::data>,
query::anchor_data_list>> f) {
713 auto result = f.get();
714 predicate.set_anchor_data_list(std::move(result.second));
715 const auto &entries = result.first;
716 std::vector<V> values;
717 values.reserve(entries.size());
718 for(
const auto &e : entries) {
719 values.emplace_back(*to_object<V>(e));
732 template<
typename K,
typename V>
733 boost::future<std::vector<std::pair<K, V>>>
entry_set() {
734 return to_entry_object_vector<K,V>(proxy::IMapImpl::entry_set_data());
747 template<typename K, typename V, typename P, class = typename std::enable_if<!std::is_base_of<query::paging_predicate_marker, P>::value>::type>
748 boost::future<std::vector<std::pair<K, V>>>
entry_set(
const P &predicate) {
749 return to_entry_object_vector<K,V>(proxy::IMapImpl::entry_set_data(to_data(predicate)));
762 template<
typename K,
typename V>
764 predicate.set_iteration_type(query::iteration_type::ENTRY);
765 return entry_set_for_paging_predicate_data(
766 protocol::codec::holder::paging_predicate_holder::of(predicate, serialization_service_)).then(
767 [=, &predicate](boost::future<std::pair<EntryVector, query::anchor_data_list>> f) {
768 auto result = f.get();
769 predicate.set_anchor_data_list(std::move(result.second));
770 const auto &entries_data = result.first;
771 std::vector<std::pair<K, V>> entries;
772 entries.reserve(entries_data.size());
773 for(
const auto &e : entries_data) {
774 entries.emplace_back(*to_object<K>(e.first), *to_object<V>(e.second));
820 return to_void_future(proxy::IMapImpl::add_index_data(config));
831 template<
typename ...T>
836 boost::future<void> clear() {
837 return to_void_future(proxy::IMapImpl::clear_data());
854 template<
typename K,
typename ResultType,
typename EntryProcessor>
855 boost::future<boost::optional<ResultType>>
execute_on_key(
const K &key,
const EntryProcessor &entry_processor) {
856 return to_object<ResultType>(execute_on_key_internal(to_data(key), to_data(entry_processor)));
869 template<
typename K,
typename ResultType,
typename EntryProcessor>
870 boost::future<boost::optional<ResultType>>
872 return to_object<ResultType>(submit_to_key_internal(to_data(key), to_data(entry_processor)));
887 template<
typename K,
typename ResultType,
typename EntryProcessor>
888 boost::future<std::unordered_map<K, boost::optional<ResultType>>>
889 execute_on_keys(
const std::unordered_set<K> &keys,
const EntryProcessor &entry_processor) {
890 return to_object_map<K, ResultType>(execute_on_keys_internal<K, EntryProcessor>(keys, entry_processor));
906 template<
typename K,
typename ResultType,
typename EntryProcessor>
907 boost::future<std::unordered_map<K, boost::optional<ResultType>>>
execute_on_entries(
const EntryProcessor &entry_processor) {
908 return to_object_map<K, ResultType>(proxy::IMapImpl::execute_on_entries_data(to_data(entry_processor)));
925 template<
typename K,
typename ResultType,
typename EntryProcessor,
typename P>
926 boost::future<std::unordered_map<K, boost::optional<ResultType>>>
928 return to_object_map<K, ResultType>(proxy::IMapImpl::execute_on_entries_data(to_data(entry_processor),
929 to_data(predicate)));
942 template<
typename K,
typename V>
943 boost::future<void>
put_all(
const std::unordered_map<K, V> &entries) {
944 std::unordered_map<int, EntryVector> entryMap;
945 for (
auto &entry : entries) {
946 serialization::pimpl::data key_data = to_data(entry.first);
947 int partitionId = get_partition_id(key_data);
948 entryMap[partitionId].push_back(std::make_pair(key_data, to_data(entry.second)));
951 std::vector<boost::future<protocol::ClientMessage>> resultFutures;
952 for (
auto &&partitionEntry : entryMap) {
953 auto partitionId = partitionEntry.first;
954 resultFutures.push_back(put_all_internal(partitionId, std::move(partitionEntry.second)));
956 return boost::when_all(resultFutures.begin(), resultFutures.end()).then(boost::launch::sync,
957 [](boost::future<boost::csbl::vector<boost::future<protocol::ClientMessage>>> futures) {
958 for (
auto &f : futures.get()) {
977 return local_map_stats_;
980 template<
typename K,
typename V>
985 template<
typename K,
typename V,
typename INNER_PREDICATE>
986 query::paging_predicate<K, V> new_paging_predicate(
size_t predicate_page_size,
const INNER_PREDICATE &predicate) {
987 return query::paging_predicate<K, V>(get_serialization_service(), predicate_page_size, predicate);
990 template<
typename K,
typename V,
typename COMPARATOR>
991 query::paging_predicate<K, V> new_paging_predicate(COMPARATOR &&comparator,
size_t predicate_page_size) {
992 return query::paging_predicate<K, V>(get_serialization_service(), std::move(comparator), predicate_page_size);
995 template<
typename K,
typename V,
typename INNER_PREDICATE,
typename COMPARATOR>
996 query::paging_predicate<K, V> new_paging_predicate(
const INNER_PREDICATE &predicate, COMPARATOR &&comparator,
size_t predicate_page_size) {
997 return query::paging_predicate<K, V>(get_serialization_service(), predicate, std::move(comparator), predicate_page_size);
1004 static constexpr std::chrono::milliseconds UNSET{-1};
1006 monitor::impl::LocalMapStatsImpl local_map_stats_;
1008 virtual boost::future<boost::optional<serialization::pimpl::data>> get_internal(
const serialization::pimpl::data &key_data) {
1009 return proxy::IMapImpl::get_data(key_data);
1012 virtual boost::future<bool> contains_key_internal(
const serialization::pimpl::data &key_data) {
1013 return proxy::IMapImpl::contains_key(key_data);
1016 virtual boost::future<boost::optional<serialization::pimpl::data>> remove_internal(
1017 const serialization::pimpl::data &key_data) {
1018 return proxy::IMapImpl::remove_data(key_data);
1021 virtual boost::future<bool> remove_internal(
1022 const serialization::pimpl::data &key_data,
const serialization::pimpl::data &value_data) {
1023 return proxy::IMapImpl::remove(key_data, value_data);
1026 virtual boost::future<protocol::ClientMessage> remove_all_internal(
const serialization::pimpl::data &predicate_data) {
1027 return proxy::IMapImpl::remove_all(predicate_data);
1030 virtual boost::future<protocol::ClientMessage> delete_internal(
const serialization::pimpl::data &key_data) {
1031 return proxy::IMapImpl::delete_entry(key_data);
1034 virtual boost::future<bool> try_remove_internal(
const serialization::pimpl::data &key_data, std::chrono::milliseconds timeout) {
1035 return proxy::IMapImpl::try_remove(key_data, timeout);
1038 virtual boost::future<bool> try_put_internal(
const serialization::pimpl::data &key_data,
1039 const serialization::pimpl::data &value_data, std::chrono::milliseconds timeout) {
1040 return proxy::IMapImpl::try_put(key_data, value_data, timeout);
1043 virtual boost::future<boost::optional<serialization::pimpl::data>> put_internal(
const serialization::pimpl::data &key_data,
1044 const serialization::pimpl::data &value_data,
1045 std::chrono::milliseconds ttl) {
1046 return proxy::IMapImpl::put_data(key_data, value_data, ttl);
1049 virtual boost::future<protocol::ClientMessage> try_put_transient_internal(
const serialization::pimpl::data &key_data,
1050 const serialization::pimpl::data &value_data, std::chrono::milliseconds ttl) {
1051 return proxy::IMapImpl::put_transient(key_data, value_data, ttl);
1054 virtual boost::future<boost::optional<serialization::pimpl::data>>
1055 put_if_absent_internal(
const serialization::pimpl::data &key_data,
1056 const serialization::pimpl::data &value_data,
1057 std::chrono::milliseconds ttl) {
1058 return proxy::IMapImpl::put_if_absent_data(key_data, value_data, ttl);
1061 virtual boost::future<bool> replace_if_same_internal(
const serialization::pimpl::data &key_data,
1062 const serialization::pimpl::data &value_data,
1063 const serialization::pimpl::data &new_value_data) {
1064 return proxy::IMapImpl::replace(key_data, value_data, new_value_data);
1067 virtual boost::future<boost::optional<serialization::pimpl::data>>
1068 replace_internal(
const serialization::pimpl::data &key_data,
1069 const serialization::pimpl::data &value_data) {
1070 return proxy::IMapImpl::replace_data(key_data, value_data);
1073 virtual boost::future<protocol::ClientMessage>
1074 set_internal(
const serialization::pimpl::data &key_data,
const serialization::pimpl::data &value_data,
1075 std::chrono::milliseconds ttl) {
1076 return proxy::IMapImpl::set(key_data, value_data, ttl);
1079 virtual boost::future<bool> evict_internal(
const serialization::pimpl::data &key_data) {
1080 return proxy::IMapImpl::evict(key_data);
1083 virtual boost::future<EntryVector>
1084 get_all_internal(
int partition_id,
const std::vector<serialization::pimpl::data> &partition_keys) {
1085 return proxy::IMapImpl::get_all_data(partition_id, partition_keys);
1088 virtual boost::future<boost::optional<serialization::pimpl::data>>
1089 execute_on_key_internal(
const serialization::pimpl::data &key_data,
1090 const serialization::pimpl::data &processor) {
1091 return proxy::IMapImpl::execute_on_key_data(key_data, processor);
1094 boost::future<boost::optional<serialization::pimpl::data>>
1095 submit_to_key_internal(
const serialization::pimpl::data &key_data,
1096 const serialization::pimpl::data &processor) {
1097 return submit_to_key_data(key_data, processor);
1100 template<
typename K,
typename EntryProcessor>
1101 boost::future<EntryVector> execute_on_keys_internal(
const std::unordered_set<K> &keys,
const EntryProcessor &entry_processor) {
1103 return boost::make_ready_future(EntryVector());
1105 std::vector<serialization::pimpl::data> keysData;
1106 for (
const auto &k : keys) {
1107 keysData.push_back(to_data<K>(k));
1109 return proxy::IMapImpl::execute_on_keys_data(keysData, to_data<EntryProcessor>(entry_processor));
1112 virtual boost::future<protocol::ClientMessage>
1113 put_all_internal(
int partition_id,
const EntryVector &entries) {
1114 return proxy::IMapImpl::put_all_data(partition_id, entries);
1119 template<
typename K,
typename V>
1120 std::vector<std::pair<K, boost::optional<V>>> sort_and_get(query::paging_predicate<K, V> &predicate, query::iteration_type iteration_type, std::vector<std::pair<K, V>> entries) {
1121 std::vector<std::pair<K, boost::optional<V>>> optionalEntries;
1122 optionalEntries.reserve(entries.size());
1123 for(
auto &&pair : entries) {
1124 optionalEntries.emplace_back(pair.first, boost::make_optional(pair.second));
1126 return sortAndGet(predicate, iteration_type, optionalEntries);
1129 template<
typename K,
typename V>
1130 std::vector<std::pair<K, boost::optional<V>>> sort_and_get(query::paging_predicate<K, V> &predicate, query::iteration_type iteration_type, std::vector<std::pair<K, boost::optional<V>>> entries) {
1131 std::sort(entries.begin(), entries.end(), [&] (
const std::pair<K, boost::optional<V>> &lhs,
const std::pair<K, boost::optional<V>> &rhs) {
1132 auto comparator = predicate.getComparator();
1134 switch(predicate.getIterationType()) {
1135 case query::iteration_type::VALUE:
1136 return lhs.second < rhs.second;
1138 return lhs.first < rhs.first;
1142 std::pair<const K *, const V *> leftVal(&lhs.first, lhs.second.get_ptr());
1143 std::pair<const K *, const V *> rightVal(&rhs.first, rhs.second.get_ptr());
1144 int result = comparator->compare(&leftVal, &rightVal);
1151 return lhs.first < rhs.first;
1154 std::pair<size_t, size_t> range = update_anchor<K, V>(entries, predicate, iteration_type);
1156 std::vector<std::pair<K, boost::optional<V>>> result;
1157 for (
size_t i = range.first; i < range.second; ++i) {
1158 auto entry = entries[i];
1159 result.push_back(std::make_pair(entry.first, entry.second));
1167 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
1168 #pragma warning(pop)
Map entry listener to get notified when a map entry is added, removed, updated, evicted,...
EntryView represents a readonly view of a map entry.
Concurrent, distributed, observable and queryable map client.
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.
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...
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 > 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< boost::uuids::uuid > add_entry_listener(entry_listener &&listener, bool include_value)
Adds an entry listener for this map.
boost::future< bool > remove(const K &key, const V &value)
removes entry from map if there is an entry with same key and value.
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.
boost::future< boost::optional< V > > get(const K &key)
get the value.
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.
boost::future< void > remove_all(const P &predicate)
Removes all entries which match with the supplied predicate.
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.
boost::future< std::vector< V > > values(const P &predicate)
Returns a vector clone of the values contained in this map.
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.
boost::future< boost::optional< R > > put(const K &key, const V &value)
put new entry into map.
boost::future< boost::optional< V > > remove(const K &key)
remove entry form map
boost::future< void > set(const K &key, const V &value)
Puts an entry into this map.
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.
boost::future< std::unordered_map< K, V > > get_all(const std::unordered_set< K > &keys)
Returns the entries for the given keys.
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< 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< 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.
boost::future< void > force_unlock(const K &key)
Releases the lock for the specified key regardless of the lock owner.
boost::future< boost::uuids::uuid > add_entry_listener(entry_listener &&listener, const P &predicate, bool include_value)
Adds an entry listener for this map.
boost::future< bool > contains_key(const K &key)
check if this map contains key.
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.
boost::future< void > lock(const K &key)
Acquires the lock for the specified key.
boost::future< std::string > add_interceptor(const MapInterceptor &interceptor)
Adds an interceptor for this map.
boost::future< std::vector< V > > values()
Returns a vector clone of the values contained in this map.
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.
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.
monitor::local_map_stats & get_local_map_stats()
Returns LocalMapStats for this map.
boost::future< std::vector< V > > values(query::paging_predicate< K, V > &predicate)
Returns a vector clone of the values contained in this map.
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).
boost::future< std::vector< K > > key_set()
Returns a vector clone of the keys contained in this map.
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.
boost::future< bool > contains_value(const V &value)
check if this map contains value.
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.
boost::future< bool > is_locked(const K &key)
Checks the lock for the specified key.
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.
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.
boost::future< bool > try_lock(const K &key, std::chrono::milliseconds timeout)
Tries to acquire the lock for the specified key.
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.
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.
boost::future< void > delete_entry(const K &key)
removes entry from map.
boost::future< bool > try_lock(const K &key)
Tries to acquire the lock for the specified key.
boost::future< bool > evict(const K &key)
Evicts the specified key from this map.
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.
boost::future< boost::optional< entry_view< K, V > > > get_entry_view(const K &key)
Returns the EntryView for the specified key.
boost::future< void > set(const K &key, const V &value, std::chrono::milliseconds ttl)
Puts an entry into this map.
boost::future< void > unlock(const K &key)
Releases the lock for the specified key.
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 th...
NOTE: paging_predicate can only be used with values(), keySet() and entries() methods!...
Configuration of an index.