Skip to content

Positive chunk sizes along an empty axis - #348

Open
Beforerr wants to merge 1 commit into
JuliaIO:mainfrom
Beforerr:fix-estimate-chunksize-zero
Open

Beforerr wants to merge 1 commit into
JuliaIO:mainfrom
Beforerr:fix-estimate-chunksize-zero

Conversation

@Beforerr

@Beforerr Beforerr commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Disk arrays with an empty axis cannot be read when DiskArrays picks their chunks itself:

using DiskArrays, DiskArrays.TestTypes
a = UnchunkedDiskArray(rand(3, 5))
Array(view(a, :, 1:0))                         # ArgumentError: Chunk sizes must be strictly positive
convert(Vector, UnchunkedDiskArray(zeros(0)))  # same

This shows up in practice with selections that match no records.

Root cause

Two places use an axis length as the chunk size, so an empty axis gets chunk size 0 and RegularChunks rejects it:

This is the zero chunk size discussed in #220, but produced by DiskArrays itself rather than by a backend's eachchunk fallback.

Fix

Clamp both to at least 1, as RegularChunks(max(s, 1), 0, s) is recommended for backends.

Fixes #292

estimate_chunksize used a zero-length axis as its chunk size, so views of an
Unchunked disk array with an empty range, e.g. Array(view(a, :, 1:0)), threw
"Chunk sizes must be strictly positive". Broadcasting over unchunked arrays
fell back to one chunk spanning the array, of size 0 along an empty axis, so
e.g. convert(Vector, a) of an empty one threw the same.

Fixes JuliaIO#292
@Beforerr
Beforerr force-pushed the fix-estimate-chunksize-zero branch from 9a97c8d to 7208470 Compare October 26, 2026 05:18
@Beforerr Beforerr changed the title Positive estimated chunk size along an empty axis Positive chunk sizes along an empty axis Oct 26, 2026

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eachchunkof zero dimensional array should work

1 participant