sundy-li commented on PR #7019:
URL: https://github.com/apache/opendal/pull/7019#issuecomment-3660377400
> Hi, I understand this change, but I’m unsure how it might affect us. Could
you demonstrate the differences in opendal users' application before and after
this change in opendal?
As it could happen in the following situation:
```
pub fn create_source(
ctx: Arc<dyn TableContext>,
output: Arc<OutputPort>,
push_downs: Option<PushDownInfo>,
) -> Result<ProcessorPtr> {
let tenant = ctx.get_tenant();
let location_prefix = format!("_query_spill/{}/",
tenant.tenant_name());
let limit = push_downs.as_ref().and_then(|x| x.limit);
let operator = DataOperator::instance().spill_operator();
let lister = operator.lister_with(&location_prefix).recursive(true);
let stream = {
let prefix = location_prefix.clone();
let mut counter = 0;
let ctx = ctx.clone();
let builder =
ListerStreamSourceBuilder::with_lister_fut(operator, lister);
builder
.limit_opt(limit)
.chunk_size(MAX_BATCH_SIZE)
.build(move |entries| {
counter += entries.len();
let block = Self::block_from_entries(&prefix, entries)?;
ctx.set_status_info(format!("{} entries processed",
counter).as_str());
Ok(block)
})?
};
StreamSource::create(ctx.get_scan_progress(), Some(stream), output)
}
```
`lister` could capture the lifetime of `operator` and `&location_prefix`, so
we can't return the stream outside.
The borrow check would faild as it thought `stream` can't escape the
lifetime.
```
error[E0597]: `operator` does not live long enough
--> src/query/storages/system/src/temp_files_table.rs:155:22
|
154 | let operator = DataOperator::instance().spill_operator();
| -------- binding `operator` declared here
155 | let lister =
operator.lister_with(&location_prefix).recursive(true);
| ^^^^^^^^ borrowed value does not live long enough
...
161 | let builder =
ListerStreamSourceBuilder::with_lister_fut(operator, lister);
|
------------------------------------------------------------ argument requires
that `operator` is borrowed for `'static`
...
174 | }
| - `operator` dropped here while still borrowed
|
note: this call may capture more lifetimes than intended, because Rust 2024
has adjusted the `impl Trait` lifetime capture rules
--> src/query/storages/system/src/temp_files_table.rs:155:22
|
155 | let lister =
operator.lister_with(&location_prefix).recursive(true);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]