New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get raw blob data? #5
Comments
I was going to suggest that "Get the blob data as Instead of it, get the blob data as
|
Thanks for the detailed answer. the approach works great. the only problem is the endianess. fn hexstr_to_f32vec(s: &str) -> Vec<f32> {
let raw = hex::decode(s).unwrap();
let len = raw.len() / mem::size_of::<f32>();
unsafe { slice::from_raw_parts(raw.as_ptr() as *const f32, len) }.to_vec()
} the raw is in bigendian. so I have to add also, get the blob value as |
@swuecho I checked that bigendian f32 values in blob could be fetch as use std::mem;
use std::slice;
fn raw_to_f32vec(raw: &[u8]) -> Vec<f32> {
let len = raw.len() / mem::size_of::<f32>();
let mut f32vec = Vec::with_capacity(len);
for u32val in unsafe { slice::from_raw_parts(raw.as_ptr() as *const u32, len) } {
f32vec.push(f32::from_bits(u32::from_be(*u32val)))
}
f32vec
}
...
let conn = oracle::Connection::connect(username, password, database, &[]).unwrap();
let raw = conn.query_row_as::<Vec<u8>>("select blob_column from table_name where ...", &[]).unwrap());
let f32vec = raw_to_f32vec(&raw); |
Thanks @kubo. this works perfectly. |
I have multiple f32 stored together as blob. it there a way to read the raw blob. or even better to read the f32 to a vec.
I figure out sqlValue.get<f32>() should get a single one, but I have multiple of them. Thanks.
The text was updated successfully, but these errors were encountered: