Use the hasnext and getnext functions
in a while loop within the reduce function to iteratively
get values from the ValueIterator object. For example,
function MeanDistReduceFun(sumLenKey, sumLenIter, outKVStore)
sumLen = [0 0];
while hasnext(sumLenIter)
sumLen = sumLen + getnext(sumLenIter);
end
add(outKVStore, 'Mean', sumLen(1)/sumLen(2));
end
Always call hasnext before getnext to
confirm availability of a value. mapreduce returns
an error if you call getnext with no remaining
values in the ValueIterator object.
Intermediate value iterator, specified as a ValueIterator object.
The mapreduce function automatically creates
this object during execution. The second input to the reduce function
specifies the variable name for the ValueIterator object,
which is the variable name to use with the hasnext and getnext functions.
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window.
Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.