Skip to content

Feature Request: Support minsize=0 #65

Open

Description

@ojwoodford

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.

Activity

  1. lmiq commented on Jun 27, 2026

    @lmiq
    Collaborator

    Two points:

    1. Maybe it would be more consistent if we had defined that the chunks is always equal to n, returning empty chunks if the minsize option was not set. Changing that now would be breaking and I'm not sure if worth the trouble.

    2. The only complication of minsize=0 is what is the type of the empty chunks, and the consequences of inheriting the type of the other chunks. I'm not sure if that can cause instabilities in some contexts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions