Template Class Hashmap¶
- Defined in File hashmap.h
 
Nested Relationships¶
Inheritance Relationships¶
Base Type¶
public shad::AbstractDataStructure< Hashmap< KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY > >(Template Class AbstractDataStructure)
Class Documentation¶
- 
template <typename KTYPE, typename VTYPE, typename KEY_COMPARE = MemCmp<KTYPE>, typename INSERT_POLICY = Overwriter<VTYPE>>
classHashmap: public shad::AbstractDataStructure<Hashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>>¶ The Hashmap data structure.
SHAD’s Hashmap is a distributed, thread-safe, associative container.
- Warning
 - obects of type KTYPE and VTYPE need to be trivially copiable.
 - Template Parameters
 KTYPE: type of the hashmap keys.VTYPE: type of the hashmap values.KEY_COMPARE: key comparison function; default is MemCmp<KTYPE>.
- Template Parameters
 INSERT_POLICY: insertion policy; default is overwrite (i.e. insertions overwrite previous values associated to the same key, if any).
Public Types
- 
template<>
usingvalue_type= std::pair<KTYPE, VTYPE>¶ 
- 
template<>
usingHmapT= Hashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>¶ 
- 
template<>
usingLMapT= LocalHashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>¶ 
- 
template<>
usingObjectID= typename AbstractDataStructure::ObjectID¶ 
- 
template<>
usingShadHashmapPtr= typename AbstractDataStructure<HmapT>::SharedPtr¶ 
- 
template<>
usingiterator= map_iterator<Hashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>, const std::pair<KTYPE, VTYPE>, std::pair<KTYPE, VTYPE>>¶ 
- 
template<>
usingconst_iterator= map_iterator<Hashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>, const std::pair<KTYPE, VTYPE>, std::pair<KTYPE, VTYPE>>¶ 
- 
template<>
usinglocal_iterator= lmap_iterator<LocalHashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>, const std::pair<KTYPE, VTYPE>>¶ 
- 
template<>
usingconst_local_iterator= lmap_iterator<LocalHashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>, const std::pair<KTYPE, VTYPE>>¶ 
- 
template<>
usingBuffersVector= typename impl::BuffersVector<EntryT, HmapT>¶ 
- 
template<>
usingLookupResult= typename LocalHashmap::LookupResult¶ 
Public Functions
- 
ObjectID 
GetGlobalID() const¶ Create method.
Creates a newhashmap instance.
- Return
 - A shared pointer to the newly created hashmap instance. Getter of the Global Identifier.
 - Return
 - The global identifier associated with the hashmap instance.
 - Parameters
 numEntries: Expected number of entries.
- 
size_t 
Size() const¶ Overall size of the hashmap (number of entries).
- Warning
 - Calling the size method may result in one-to-all communication among localities to retrieve consinstent information.
 - Return
 - the size of the hashmap.
 
- 
std::pair<typename Hashmap<KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY>::iterator, bool> 
Insert(const KTYPE &key, const VTYPE &value)¶ Insert a key-value pair in the hashmap.
- Return
 - an iterator either to the inserted value or to the previously inserted value that prevented the insertion.
 - Parameters
 key: the key.value: the value to copy into the hashmap.
- 
void 
AsyncInsert(rt::Handle &handle, const KTYPE &key, const VTYPE &value)¶ Asynchronously Insert a key-value pair in the hashmap.
- Warning
 - Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
 - Return
 - a pointer to the value if the the key-value was inserted or a pointer to a previously inserted value.
 - Parameters
 handle: Reference to the handle to be used to wait for completion.key: the key.value: the value to copy into the hashMap.
- 
void 
BufferedInsert(const KTYPE &key, const VTYPE &value)¶ Buffered Insert method. Inserts a key-value pair, using aggregation buffers.
- Warning
 - Insertions are finalized only after calling the WaitForBufferedInsert() method.
 - Parameters
 key: The key.value: The value.
- 
void 
BufferedAsyncInsert(rt::Handle &handle, const KTYPE &key, const VTYPE &value)¶ Asynchronous Buffered Insert method. Asynchronously inserts a key-value pair, using aggregation buffers.
- Warning
 - asynchronous buffered insertions are finalized only after calling the rt::waitForCompletion(rt::Handle &handle) method AND the WaitForBufferedInsert() method, in this order.
 - Parameters
 handle: Reference to the handlekey: The key.value: The value.
- 
void 
WaitForBufferedInsert()¶ Finalize method for buffered insertions.
- 
void 
Erase(const KTYPE &key)¶ Remove a key-value pair from the hashmap.
- Parameters
 key: the key.
- 
void 
AsyncErase(rt::Handle &handle, const KTYPE &key)¶ Asynchronously remove a key-value pair from the hashmap.
- Warning
 - Asynchronous operations are guaranteed to have completed only after calling the rt::waitForCompletion(rt::Handle &handle) method.
 - Parameters
 handle: Reference to the handle to be used to wait for completion.key: the key.
- 
void 
Clear()¶ Clear the content of the hashmap.
- 
bool 
Lookup(const KTYPE &key, VTYPE *res)¶ Get the value associated to a key.
- Return
 - true if the entry is found, false otherwise.
 - Parameters
 key: the key.res: a pointer to the value if the the key-value was found and NULL if it does not exists.
- 
void 
AsyncLookup(rt::Handle &handle, const KTYPE &key, LookupResult *res)¶ Asynchronous lookup method.
- Warning
 - Asynchronous operations are guaranteed to have completed. only after calling the rt::waitForCompletion(rt::Handle &handle) method.
 - Parameters
 handle: Reference to the handle. to be used to wait for completion.key: The key.res: The result of the lookup operation.
- 
template <typename ApplyFunT, typename... Args>
voidApply(const KTYPE &key, ApplyFunT &&function, Args&... args)¶ Apply a user-defined function to a key-value pair.
- Template Parameters
 ApplyFunT: User-defined function type. The function prototype should be:void(const KTYPE&, VTYPE&, Args&);
...Args: Types of the function arguments.
- Parameters
 key: The key.function: The function to apply.args: The function arguments.
- 
template <typename ApplyFunT, typename... Args>
voidAsyncApply(rt::Handle &handle, const KTYPE &key, ApplyFunT &&function, Args&... args)¶ Asynchronously apply a user-defined function to a key-value pair.
- Template Parameters
 ApplyFunT: User-defined function type. The function prototype should be:void(rt::Handle &handle, const KTYPE&, VTYPE&, Args&);
...Args: Types of the function arguments.
- Parameters
 handle: Reference to the handle.key: The key.function: The function to apply.args: The function arguments.
- 
template <typename ApplyFunT, typename... Args>
voidForEachEntry(ApplyFunT &&function, Args&... args)¶ Apply a user-defined function to each key-value pair.
- Template Parameters
 ApplyFunT: User-defined function type. The function prototype should be:void(const KTYPE&, VTYPE&, Args&);
...Args: Types of the function arguments.
- Parameters
 function: The function to apply.args: The function arguments.
- 
template <typename ApplyFunT, typename... Args>
voidAsyncForEachEntry(rt::Handle &handle, ApplyFunT &&function, Args&... args)¶ Asynchronously apply a user-defined function to each key-value pair.
- Template Parameters
 ApplyFunT: User-defined function type. The function prototype should be:void(shad::rt::Handle&, const KTYPE&, VTYPE&, Args&);
...Args: Types of the function arguments.
- Parameters
 handle: Reference to the handle.function: The function to apply.args: The function arguments.
- 
template <typename ApplyFunT, typename... Args>
voidForEachKey(ApplyFunT &&function, Args&... args)¶ Apply a user-defined function to each key.
- Template Parameters
 ApplyFunT: User-defined function type. The function prototype should be:void(const KTYPE&, Args&);
...Args: Types of the function arguments.
- Parameters
 function: The function to apply.args: The function arguments.
- 
template <typename ApplyFunT, typename... Args>
voidAsyncForEachKey(rt::Handle &handle, ApplyFunT &&function, Args&... args)¶ Asynchronously apply a user-defined function to each key.
- Template Parameters
 ApplyFunT: User-defined function type. The function prototype should be:void(shad::rt::Handle&, const KTYPE&, Args&);
...Args: Types of the function arguments.
- Parameters
 handle: Reference to the handle.function: The function to apply.args: The function arguments.
- 
void 
PrintAllEntries()¶ 
- 
iterator 
begin()¶ 
- 
iterator 
end()¶ 
- 
const_iterator 
cbegin() const¶ 
- 
const_iterator 
cend() const¶ 
- 
const_iterator 
begin() const¶ 
- 
const_iterator 
end() const¶ 
- 
local_iterator 
local_begin()¶ 
- 
local_iterator 
local_end()¶ 
- 
const_local_iterator 
clocal_begin()¶ 
- 
const_local_iterator 
clocal_end()¶ 
- 
std::pair<iterator, bool> 
insert(const value_type &value)¶ 
- 
std::pair<iterator, bool> 
insert(const_iterator, const value_type &value)¶ 
- 
void 
buffered_async_flush()¶ 
Protected Functions
- 
Hashmap(ObjectID oid, const size_t numEntries)¶ 
Friends
- 
friend 
shad::Hashmap::map_iterator< Hashmap< KTYPE, VTYPE, KEY_COMPARE, INSERT_POLICY >, const std::pair< KTYPE, VTYPE >, std::pair< KTYPE, VTYPE > > 
- 
struct 
EntryT¶