-
Notifications
You must be signed in to change notification settings - Fork 44
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
Can I transfer Arc<Vec<Row>> between 2 tokio thread? #89
Comments
Use In order to transfer type across threads, |
Thank you. however, I have another question. can I update this line by using Arc::new....? |
You cannot. Though Though I'm not sure what is your case, it is better to use Another option is https://quietboil.github.io/sibyl/. It uses Oracle Call Interface directly. On the other hand rust-oracle uses the interface via ODPI-C. I'm not sure which is faster. |
I tested millions rows data in oracle by using jdbc and rust-oracle.In different data type, some queries show rust is faster and the other show jdbc is faster. the record is below:
my boss believe there must be a way that rust read all type data is faster than jdbc. So, I must explain:
all sql like: test case is below:
4)jdbc: rs.next()
|
In the flame graph of version 0.6.1-dev in #44 (comment), As for the difference of seconds between NUMBER(28.18) and NUMBER(10.0), I guess that is caused by here. |
@tc19901016 Did you try slightly bigger arraysize values? For such a large number of rows I would have left prefetch size at its default. @kubo ping us if you need help, or to nudge us about requests like oracle/odpi#172 |
@kubo You are right. 2)In rust-itercol test(test case 1), Number(28,18) increase get_string_unchecked cost than Number(10). |
@tc19901016 |
No,I can't open rust-oracle-private page: By the way, I tried read data through odpi directly. But, some step I don't know how to write.
this issue(oracle/odpi#70) tell me the preparing steps before dpiStmt_fetchRows(), does not tell me how to get data. |
Sorry, I posted wrong URL. It was pushed to public repository also. 0c49553 |
@kubo ODPI-C 5.4 will be tagged very soon |
I have tested Number(28,18) columns case(30 col * 5670,0000 rows). Commit<0c49553> can improve about 40% get::<, f64> speed. According the below table, old version cost 44-27=17 seconds in get::<, f64>, and new version cost 37-27=10 seconds.
|
I tried to use odpi interface derictly to fetch rows. But, I only get the first row's data. I don't know how to iterate the dpiVar(every column has a dpiVar) to get the list of column data.
thank you. |
I've not tested the following code. for offset in new_index..(new_index + num_rows) {
for col_index in 0..col_num {
let (index, var_handle, var_data) = newVarHandles[col_index as usize];
let var_data = var_data.offset(offset as isize);
print!("{},",dpiData_getInt64(var_data));
}
println!("");
//todo how to fetch next row's data. thank you.
} |
I committed e64754f. It skips the following UTF-8 validation. |
Could you use
The following code fetch row as a tuple containing 30 let rows = stmt.query_as<(f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64, f64)>(&[]).unwrap();
let col_len = rows.column_info().len();
let mut count=0;
for row in rows{
let r = row?;
count+=1;
} |
I tested f6430columns5670,0000 in e64754f, result is below:
test summary:
Thank you, I think query_as is very efficient. I will try to use query_as to read data from oracle. |
My rust program has a oracle-read thread and a consume thread.
1)oracle-read thread use [ResultSet.next] to get Row and send a Arc<Vec> to tokio::sync::mpcs::unbounded queue.
2)consume thread receive Arc<Vec> and do something.
but Rust compiler outut some error:
*mut oracle::binding::binding::dpiVector
cannot be shared between threads safelythank you
the oracle-read code is below:
the consume thread code is below:
queue code:let (tx, mut rx):(UnboundedSender<(Arc<Vec>, i32, i32)>, UnboundedReceiver<(Arc<Vec>, i32, i32)>)=mpsc::unbounded_channel();
detail error is below:
error[E0277]: *mut oracle::binding::binding::dpiVector cannot be shared between threads safely
--> connectorsdm\src\dispatcher.rs:191:48
|
191 | let read_task=tokio::spawn(async move {
| _______________------------^
| | |
| | required by a bound introduced by this call
192 | | let mut data_reader = crate::sources::oracle::OracleTextSourceDataReader::new(conn_url.unwrap().as_str(), sql.as_str());
193 | | data_reader.read_data_to_queue(tx);
194 | | });
| |^ *mut oracle::binding::binding::dpiVector cannot be shared between threads safely
|
= help: within SqlValue<'static>, the trait Sync is not implemented for *mut oracle::binding::binding::dpiVector, which is required by {async block@connectorsdm\src\dispatcher.rs:191:48: 194:22}: Send
note: required because it appears within the type oracle::binding::binding::dpiDataBuffer
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\oracle-0.6.2\src\binding\binding.rs:846:11
|
846 | pub union dpiDataBuffer {
| ^^^^^^^^^^^^^
note: required because it appears within the type oracle::binding::binding::dpiData
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\oracle-0.6.2\src\binding\binding.rs:1797:12
|
1797 | pub struct dpiData {
| ^^^^^^^
= note: required because it appears within the type &'static mut oracle::binding::binding::dpiData
note: required because it appears within the type oracle::sql_value::DpiData<'static>
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\oracle-0.6.2\src\sql_value.rs:128:6
|
128 | enum DpiData<'a> {
| ^^^^^^^
note: required because it appears within the type SqlValue<'static>
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\oracle-0.6.2\src\sql_value.rs:143:12
|
143 | pub struct SqlValue<'a> {
| ^^^^^^^^
= note: required for std::ptr::Unique<SqlValue<'static>> to implement Sync
note: required because it appears within the type alloc::raw_vec::RawVec<SqlValue<'static>>
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\raw_vec.rs:69:19
note: required because it appears within the type Vec<SqlValue<'static>>
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\vec\mod.rs:398:12
note: required because it appears within the type oracle::Row
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\oracle-0.6.2\src\row.rs:34:12
|
34 | pub struct Row {
| ^^^
= note: required for std::ptr::Uniqueoracle::Row to implement Sync
note: required because it appears within the type alloc::raw_vec::RawVecoracle::Row
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\raw_vec.rs:69:19
note: required because it appears within the type Vecoracle::Row
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081\library\alloc\src\vec\mod.rs:398:12
= note: required for Arc<Vecoracle::Row> to implement Send
= note: required because it appears within the type (Arc<Vecoracle::Row>, i32, i32)
= note: required for tokio::sync::mpsc::chan::Chan<(Arc<Vecoracle::Row>, i32, i32), tokio::sync::mpsc::unbounded::Semaphore> to implement Sync
= note: 1 redundant requirement hidden
= note: required for Arc<tokio::sync::mpsc::chan::Chan<(Arc<Vecoracle::Row>, i32, i32), tokio::sync::mpsc::unbounded::Semaphore>> to implement Send
note: required because it appears within the type tokio::sync::mpsc::chan::Tx<(Arc<Vecoracle::Row>, i32, i32), tokio::sync::mpsc::unbounded::Semaphore>
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\tokio-1.40.0\src\sync\mpsc\chan.rs:19:19
|
19 | pub(crate) struct Tx<T, S> {
| ^^
note: required because it appears within the type UnboundedSender<(Arc<Vecoracle::Row>, i32, i32)>
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\tokio-1.40.0\src\sync\mpsc\unbounded.rs:11:12
|
11 | pub struct UnboundedSender {
| ^^^^^^^^^^^^^^^
note: required because it's used within this async block
--> connectorsdm\src\dispatcher.rs:191:48
|
191 | let read_task=tokio::spawn(async move {
| ___________________________^
192 | | let mut data_reader = crate::sources::oracle::OracleTextSourceDataReader::new(conn_url.unwrap().as_str(), sql.as_str());
193 | | data_reader.read_data_to_queue(tx);
194 | | });
| |^
note: required by a bound in tokio::spawn
--> C:\Users\tianchuan01.cargo\registry\src\mirrors.ustc.edu.cn-12df342d903acd47\tokio-1.40.0\src\task\spawn.rs:167:21
|
165 | pub fn spawn(future: F) -> JoinHandle<F::Output>
| ----- required by a bound in this function
166 | where
167 | F: Future + Send + 'static,
| ^^^^ required by this bound in spawn
The text was updated successfully, but these errors were encountered: