viirya commented on PR #5587:
URL: https://github.com/apache/arrow-rs/pull/5587#issuecomment-2039944940
I just tried it. Looks like it works.
> Because `Scalar` is not a `Send`, although it is simply a wrapper of
`Array`, I guess it cannot be used as `Send` automatically? I think it cannot
be but let me try it first. Thanks.
Interesting. So even `Scalar` is not a `Send`, if Rust compiler knows it is
a wrapper of `Array`, it will be automatically a `Send`?
```rust
fn get_arrow_datum(datum: &Datum) -> Result<Box<dyn ArrowDatum + Send>> {
match datum.literal() {
PrimitiveLiteral::Boolean(value) =>
Ok(Box::new(BooleanArray::new_scalar(*value))),
PrimitiveLiteral::Int(value) =>
Ok(Box::new(Int32Array::new_scalar(*value))),
PrimitiveLiteral::Long(value) =>
Ok(Box::new(Int64Array::new_scalar(*value))),
PrimitiveLiteral::Float(value) =>
Ok(Box::new(Float32Array::new_scalar(value.as_f32()))),
PrimitiveLiteral::Double(value) =>
Ok(Box::new(Float64Array::new_scalar(value.as_f64()))),
l => Err(Error::new(
ErrorKind::DataInvalid,
format!("Unsupported literal type: {:?}", l),
)),
}
}
fn some_func(...) {
let literal = get_arrow_datum(&literal)?;
....
move |batch| {
let left = batch.column(term_index);
lt(left, literal.as_ref())
},
....
}
```
--
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]