Skip to content

Commit 904556b

Browse files
authored
feat(cubesql): Remove unexpected clone (reduce memory consumption) (#6185)
1 parent 47571e5 commit 904556b

File tree

1 file changed

+5
-11
lines changed
  • rust/cubesql/cubesql/src/compile/engine/df

1 file changed

+5
-11
lines changed

rust/cubesql/cubesql/src/compile/engine/df/scan.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ struct CubeScanOneShotStream {
363363
transport: Arc<dyn TransportService>,
364364
meta: LoadRequestMeta,
365365
options: CubeScanOptions,
366-
fired: bool,
367366
}
368367

369368
impl CubeScanOneShotStream {
@@ -385,20 +384,15 @@ impl CubeScanOneShotStream {
385384
transport,
386385
meta,
387386
options,
388-
fired: false,
389387
}
390388
}
391389

392390
fn poll_next(&mut self) -> Option<ArrowResult<RecordBatch>> {
393-
if !self.fired {
394-
self.fired = true;
395-
396-
if let Some(batch) = &self.data {
397-
return Some(Ok(batch.clone()));
398-
}
391+
if let Some(batch) = self.data.take() {
392+
Some(Ok(batch))
393+
} else {
394+
None
399395
}
400-
401-
None
402396
}
403397
}
404398

@@ -581,7 +575,7 @@ fn load_to_stream_sync(one_shot_stream: &mut CubeScanOneShotStream) -> Result<()
581575
let res =
582576
std::thread::spawn(move || handle.block_on(load_data(req, auth, transport, meta, options)))
583577
.join()
584-
.map_err(|_| DataFusionError::Execution(format!("Can't load to steram")))?;
578+
.map_err(|_| DataFusionError::Execution(format!("Can't load to stream")))?;
585579

586580
one_shot_stream.data = Some(transform_response(
587581
res.unwrap().data,

0 commit comments

Comments
 (0)