Skip to content

Commit b8a1fbb

Browse files
committed
tweak logic: start new coalesced group if coalescing would exceed coalesce_max_bytes
previous logic only started a new group if existing group was size already exceeded coalesce_max_bytes.
1 parent 51d77aa commit b8a1fbb

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/zarr/codecs/sharding.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -589,10 +589,8 @@ def _coalesce_chunks(
589589

590590
for chunk in sorted_chunks[1:]:
591591
gap_to_chunk = chunk.byte_slice.start - current_group[-1].byte_slice.stop
592-
current_group_size = (
593-
current_group[-1].byte_slice.stop - current_group[0].byte_slice.start
594-
)
595-
if gap_to_chunk < max_gap_bytes and current_group_size < coalesce_max_bytes:
592+
size_if_coalesced = chunk.byte_slice.stop - current_group[0].byte_slice.start
593+
if gap_to_chunk < max_gap_bytes and size_if_coalesced < coalesce_max_bytes:
596594
current_group.append(chunk)
597595
else:
598596
groups.append(current_group)

0 commit comments

Comments
 (0)