Module kmr4py :: Class KVS

Class KVS

source code

KVS. Note that there are dummy KVS'es which are temporarily created to hold the C structure of the KVS passed to mapper/reducer functions. A dummy KVS has None in its "mr" attribute.

Instance Methods
 
__init__(self, kmr_or_ckvs, keyty="opaque", valty="opaque")
Makes a KVS for a given KMR.
source code
 
__del__(self) source code
 
free(self)
Finishes the C part of a KVS.
source code
 
get_field_type(self, key_or_value)
Get a field type of a KVS.
source code
 
add(self, key, val)
Adds a key-value pair.
source code
 
add_kv(self, key, val)
Adds a key-value pair.
source code
 
add_kv_done(self)
Finishes adding key-value pairs.
source code
 
get_element_count(self)
Gets the total number of key-value pairs.
source code
 
local_element_count(self)
Gets the number of key-value pairs locally.
source code
 
map(self, fn, **mopts)
Maps simply.
source code
 
map_once(self, rank_zero_only, fn, **mopts)
Maps once with a dummy key-value pair.
source code
 
map_on_rank_zero(self, fn, **mopts)
Maps on rank0 only.
source code
 
map_rank_by_rank(self, fn, **mopts)
Maps sequentially with rank by rank for debugging.
source code
 
map_for_some(self, fn, **mopts)
Maps until some key-value are added.
source code
 
map_ms(self, fn, **mopts)
Maps in master-slave mode.
source code
 
map_ms_commands(self, fn, **xopts)
Maps in master-slave mode, and runs serial commands.
source code
 
map_via_spawn(self, fn, **xopts)
Maps on processes started by MPI_Comm_spawn().
source code
 
map_processes(self, nonmpi, fn, **sopts)
Maps on processes started by MPI_Comm_spawn().
source code
 
map_parallel_processes(self, fn, **sopts)
Maps on processes started by MPI_Comm_spawn().
source code
 
map_serial_processes(self, fn, **sopts)
Maps on processes started by MPI_Comm_spawn().
source code
 
reduce(self, fn, **mopts)
Reduces key-value pairs.
source code
 
reduce_as_one(self, fn, **mopts)
Reduces once as if all pairs had the same key.
source code
 
reduce_for_some(self, fn, **mopts)
Reduces until some key-value are added.
source code
 
reverse(self, **mopts)
Makes a new pair by swapping the key and the value.
source code
 
shuffle(self, **mopts)
Shuffles key-value pairs.
source code
 
replicate(self, **mopts)
Replicates key-value pairs to be visible on all ranks.
source code
 
distribute(self, cyclic, **mopts)
Distributes pairs approximately evenly to ranks.
source code
 
sort_locally(self, shuffling, **mopts)
Reorders key-value pairs in a single rank.
source code
 
sort(self, **mopts)
Sorts a KVS globally.
source code
 
concatenate(self, *morekvs)
Concatenates a number of KVS'es to one.
source code
 
read_files_reassemble(self, filename, color, offset, bytes_)
Reassembles files reading by ranks.
source code
 
read_file_by_segments(self, filename, color)
Reads one file by segments and reassembles.
source code
 
save(self)
Packs locally the contents of a KVS to a byte array.
source code
 
restore(self, data)
Unpacks locally the contents of a KVS from a byte array.
source code
Instance Variables
  mr
mr attribute holds a KMR context object.
Method Details

__init__(self, kmr_or_ckvs, keyty="opaque", valty="opaque")
(Constructor)

source code 

Makes a KVS for a given KMR. A KVS is created by specifying the datatypes stored in the key and the value, using the keywords "key=" and "value=". The datatype name is a string, one of "opaque", "cstring", "integer", and "float8". Thus, most mappers and reducers (precisely, the ones which accepts a function argument) take keyword arguments with the defaults key="opaque" and value="opaque". The datatypes affects the sorting order. Do not call constructors directly, but via KMR.make_kvs().


Instance Variable Details

mr

mr attribute holds a KMR context object. Note that mr is not accessible from mapping/reducing functions.