Conversation
…tore ShardingIndexedCodec reads a shard index located at the end via store.get(keys, -indexSize), i.e. "the last N bytes". FilesystemStore, HttpStore and S3Store handle a negative start, but MemoryStore passed it straight to ByteBuffer.wrap and ReadOnlyZipStore to ZipArchiveInputStream.skip, which throws "Negative skip value". BufferedZipStore delegates to MemoryStore and was affected too. As a result, any partial read of a sharded array (index_location "end") from a zip archive failed, e.g. reading a boundary shard whose valid region is smaller than the shard shape. Convert a negative start into an absolute offset using the entry size, add a StoreTest case for suffix reads for all stores, and an end-to-end test reading a sub-region of a sharded array from a zip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes BioImageTools/ome-zarr-fiji-java#140
When only part of a shard is read, the sharding codec gets the shard index with
read(-indexSize), meaning "the last N bytes". FilesystemStore, HttpStore and S3Store handle that, but ReadOnlyZipStore passed the -N straight intozis.skip(), and MemoryStore intoByteBuffer.wrap().Unit Test Created : a shard file is 1092 bytes and its index is the last 68.
read(-68)should read from byte 1024 on. Before this fix, ReadOnlyZipStore tried to skip -68 bytes and crashed.If an array is smaller than one shard in some dimension (z=112 with 192³ shards in the issue), it hits every read.
size + start.StoreTest.testGetSuffixchecksread(-10)for all stores. The old test only read the tail withread(size - 10), so this case was never tested.ReadOnlyZipStoreTest.testPartialReadOfShardedArraywrites a sharded array, zips it, and reads a sub-region. Without the fix it fails with exactlyNegative skip value.