Global and Distributed dictionaries for Julia.
This package provides two types of distributed dictionaries:
GlobalDictwhere the same key-value pair is stored on all participating workers.DistributedDictwhere the key-value pairs are distributed over the participating workers based on the key's hash value.
-
GlobalDict(pids=PidsWorkers(); name::AbstractString=next_name(), ktype=Any, vtype=Any)where-
pidsis one ofPidsAll(),PidsWorkers()orPids([ids...])wherePidsAll()represents all processes in the clusterPidsWorkers()represents all worker processes in the clusterPids([ids...])represents a specific subset of workers identified by their pids.
-
nameis a logical name for the dictionary. It should be unique across any such dictionary created across modules or different packages. Usually left unspecified in which case the system creates a unique name. -
ktypeis the type of the keys. Defaults toAny. -
vtypeis the type of the values. Defaults toAny.
-
-
DistributedDict(pids=PidsWorkers(); name::AbstractString=next_name(), ktype=Any, vtype=Any)similar to theGlobalDictconstructor. -
GlobalDict()andDistributedDict()only distribute over worker processes, i.e., excluding the master. Keyword args remain the same. -
GlobalDict(pids::Array)andDistributedDict(pids::Array)distribute on the specified pids. Keyword args remain the same.
The following functions of Associative are implemented:
isemptylengthgetget!getindexsetindex!pop!delete!
Any closure wrapped in a ValueF will execute the closure on the node where the key is being assigned.
For example, for a GlobalDict,
d[k] = ValueF(()->myid())
will set the value of d[k] to 2 on pid 2, 3 on pid 3 and so on.
And for a DistributedDict, it will be set only on the node that the key hashes to.
The global and distributed dictionaries created by GlobalDict and DistributedDict are NOT collected when the objects go out of scope.
They have to be necessarily released by calling delete!(d::GlobalDict) and delete!(d::DistributedDict) respectively.
-
Concurrent updates : This current version makes no attempt to handle race conditions when multiple tasks or processes update the same key. For example, if
dis aGlobalDict,d[k] = vsetsktovon all participating workers. If two tasks try to setd[k] = v1and ``d[k] = v2at the same time, there is no guarantee the value will be either allv1` or all `v2` on all workers. -
More
Associativefunctions to be implemented. -
Handle worker exits : Resiliency in the event of workers exiting has to be handled.