Fix issue #727#800
Conversation
Convert chunk coordinates back to elements so that retrieval from chunk map can succeed. Added comments to affected code, along with one coincidental spelling fix.
jamesmudd
left a comment
There was a problem hiding this comment.
This fix looks reasonable but would it be possible to add tests that would have caught this?
|
I'll take a look at your test system. This bug should occur on any read outside the first chunk. Such reads will return no chunk, or in very rare cases a completely wrong chunk. |
|
I briefly looked over the tests that involve chunks. At least in the case of ChunkSlicingTest, the bug is not revealed because the chunk size in the selected datasets is 1x1x1. For an effective test, it would be necessary to create a file with some larger, perhaps odd-sized, chunk. The existing test code is probably sufficient if chunked_v4_datasets.hdf5 were reworked a little. |
|
Thanks for investigating I think the existing test files should have suitable datasets already take a look at https://github.com/jamesmudd/jhdf/blob/master/jhdf/src/test/resources/scripts/chunked_v4_datasets.py |
|
I'm a little confused. I think what you mean is that chunked_v4_datasets.py should be modified so that the large_int16 datasets have a chunk size larger than 1x1x1. |
There was a problem hiding this comment.
Pull request overview
Fixes incorrect scaling of chunk coordinates when identifying chunks overlapping a requested slice in ChunkedDatasetBase.findOverlappingChunks(), which could previously cause missed/incorrect chunk lookups during slice reads.
Changes:
- Convert slice bounds from element coordinates to chunk coordinates to compute the correct chunk coordinate range.
- Scale each candidate chunk coordinate back into element offsets before looking up the chunk (
ChunkOffsetmap key). - Minor comment grammar fix in
getDataBuffer().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Return the collection of all chunks that contain at least one element in the given hypercube. | ||
| @param offset In elements | ||
| @param shape In elements | ||
| **/ |
| /** | ||
| Given hypercube bounds in chunk coordinates, iterate all chunks within the hypercube. | ||
| **/ |
Fix scaling of chunk coordinates in ChunkedDatasetBase.findOverlappingChunks()