I have a situation where I kick off N tasks, and the nth task processes the nth chunk of several different collections. In some collections, the nth chunk might not exist, because the collection is shorter than n. Currently I have to write a wrapper function to avoid throwing an error in this case, as follows:
function ithchunk(N, taskid, collection)
c = index_chunks(collection; n=N)
return view(collection, taskid <= length(c) ? c[taskid] : 1:0)
end
However, if ChunkSplitters supported a minsize=0, such that N chunks were always returned, some of them being empty, then I could simply write:
ithchunk(N, taskid, collection) = chunks(collection; n=N, minsize=0)[taskid]
and be certain that this wouldn't throw an error for any taskid <= N. This could avoid any potential type instability resulting from the ternary operator in my wrapper function.
I have a situation where I kick off N tasks, and the nth task processes the nth chunk of several different collections. In some collections, the nth chunk might not exist, because the collection is shorter than n. Currently I have to write a wrapper function to avoid throwing an error in this case, as follows:
However, if ChunkSplitters supported a
minsize=0, such thatNchunks were always returned, some of them being empty, then I could simply write:and be certain that this wouldn't throw an error for any
taskid <= N. This could avoid any potential type instability resulting from the ternary operator in my wrapper function.