File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -141,11 +141,17 @@ def load_item_from_chunk(
141141 del self ._chunk_filepaths [chunk_filepath ]
142142
143143 if chunk_filepath not in self ._chunk_filepaths :
144- exists = os .path .exists (chunk_filepath ) and os .stat (chunk_filepath ).st_size >= chunk_bytes
144+ # Get size of chunk header
145+ # The number of items + the number of offsets (number of items in the chunk + 1)
146+ # multiplied by the header encoding dtype (np.uint32)
147+ chunk_header_bytes = (1 + self ._chunks [chunk_index ]["chunk_size" ] + 1 ) * 4
148+ filesize_bytes = chunk_bytes + chunk_header_bytes
149+
150+ exists = os .path .exists (chunk_filepath ) and os .stat (chunk_filepath ).st_size >= filesize_bytes
145151
146152 while not exists :
147153 sleep (0.1 )
148- exists = os .path .exists (chunk_filepath ) and os .stat (chunk_filepath ).st_size >= chunk_bytes
154+ exists = os .path .exists (chunk_filepath ) and os .stat (chunk_filepath ).st_size >= filesize_bytes
149155
150156 self ._chunk_filepaths [chunk_filepath ] = True
151157
You can’t perform that action at this time.
0 commit comments