Comments (13)
Paging is supported: https://docs.rs/cdrs-tokio/latest/cdrs_tokio/cluster/session/struct.Session.html#method.paged
from cdrs-tokio.
Thank you!
When I try to use it like here:
cdrs-tokio/cdrs-tokio/examples/paged_query.rs
Lines 155 to 160 in bca96dd
{unknown} no method named 'query_with_params' found for struct 'SessionPager' in the current scope
it looks like it been added after the release of 7.0.1?
from cdrs-tokio.
That method has been available for 2 years: https://github.com/krojew/cdrs-tokio/blame/master/cdrs-tokio/src/cluster/pager.rs#L76 . You would need to show your whole code to see what's wrong.
from cdrs-tokio.
Sorry I missed that the regular query function is query_with_params
while the one for pager is query_with_param
(without the s). Do you think it will be a good thought to make them the same?
I looked at the example here:
cdrs-tokio/cdrs-tokio/examples/paged_query.rs
Lines 160 to 181 in d0a7e04
and I wonder if there is a way to iterate through the rows in async way?
I tried:
loop {
futures.push(tokio::spawn(query_pager.next()));
if !query_pager.has_more() {
break;
}
}
but could not be done due borrowing.
from cdrs-tokio.
Of course - pager is 100% async. The problem with your loop is that you spawn a task for each next
call. That''s not how async in Rust should be used - simply call query_pager.next().await
in your loop.
from cdrs-tokio.
But then it will await for each iteration to be done. it is not concurrent in this way
from cdrs-tokio.
No - that's not how async works. Each await point switches to another task to proceed concurrently (at least in most runtimes). You can read more about async here: https://rust-lang.github.io/async-book/
from cdrs-tokio.
I have this code:
loop {
let now = Instant::now();
for row in query_pager.next().await? {
results.push(row);
}
println!("inside: {}", now.elapsed().as_millis());
if !query_pager.has_more() {
break;
}
}
which doesn't seem to execute concurrently. the sum of the time in each iteration is the total of the whole loop.
from cdrs-tokio.
It executes concurrently with other tasks run by the async executor. What you seem to want is having a parallel pager, which is not possible, since the pager needs to store current state.
from cdrs-tokio.
The performance is very similar to the the one without the pager. Isn't it should be different?
from cdrs-tokio.
That depends on the situation. If the performance is the same, that suggests it's not very dependent on the amount of data, but other factors. Pager will usually not give you better performance in itself - its main goal is to split the data when it gets large enough. You can use the pager in combination with async tasks to process rows concurrently as they come, instead of processing on single data set. That should give you a performance boost.
from cdrs-tokio.
I see. Thank you so much it was very helpful!
from cdrs-tokio.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from cdrs-tokio.
Related Issues (20)
- Keyspace setup falls Transport to infinite loop HOT 1
- schema change event is never received HOT 23
- Add support for HTTP proxy HOT 2
- error UnexpectedWriteType("CAS")) with multiple tokio tasks HOT 10
- Trouble with dropped connections on Session HOT 5
- increase in size for a byte array HOT 23
- Add non exhaustive to proto enums HOT 1
- TLS Example HOT 1
- Support for tracing informations HOT 4
- Range end index 88 out of range for slice of length 83 HOT 2
- Session can hit errors if used immediately
- rustc stack overflow when deriving IntoCdrsValue and TryFromRow if struct contains static string reference HOT 4
- Case where a machine is up but unreachable HOT 44
- High CPU usage for cdrs_tokio::transport::AsyncTransport::start_processing HOT 19
- exec_with_params is returning ErrorType::Unprepared. HOT 7
- Row to serde_json::Value HOT 12
- ExponentialReconnectionPolicy panics after several attempts HOT 1
- Protocol v5 tests HOT 3
- Bug in transport.rs HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cdrs-tokio.