Skip to content

Commit de4da3e

Browse files
Remove EOF counter (#747)
1 parent e358a53 commit de4da3e

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/context/delta.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -196,29 +196,19 @@ pub async fn plan_to_object_store(
196196
let mut multipart_upload = store.put_multipart(&file_name).await?;
197197

198198
let error: object_store::Error;
199-
let mut eof_counter = 0;
200199
loop {
201200
match reader.read_buf(&mut part_buffer).await {
202201
Ok(0) if part_buffer.is_empty() => {
203-
// We've reached EOF and there are no pending writes to flush.
204-
// As per the docs size = 0 doesn't seem to guarantee that we've reached EOF, so we use
205-
// a heuristic: if we encounter Ok(0) 3 times in a row it's safe to assume it's EOF.
206-
// Another potential workaround is to use `stream_position` + `stream_len` to determine
207-
// whether we've reached the end (`stream_len` is nightly-only experimental API atm)
208-
eof_counter += 1;
209-
if eof_counter >= 3 {
210-
break;
211-
} else {
212-
continue;
213-
}
202+
// If part_buffer is empty, then it is not full
203+
// According to the the docs, if part_buffer is not full and size = 0, then we've reached EOF
204+
break;
214205
}
215206
Ok(size)
216207
if size != 0
217208
&& part_buffer.len()
218209
< PARTITION_FILE_MIN_PART_SIZE =>
219210
{
220211
// Keep filling the part buffer until it surpasses the minimum required size
221-
eof_counter = 0;
222212
continue;
223213
}
224214
Ok(_) => {

0 commit comments

Comments
 (0)