-
Notifications
You must be signed in to change notification settings - Fork 111
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
Query paging API: hardening, robustness, explicitness #1061
Changes from all commits
e2758fe
22f558b
9648b3d
6d9249f
5dc11b2
e6f0268
e415267
c008d76
1eaf42c
bfa853c
343b500
dfe79e9
6ae5fa6
c5140c9
4f8cf18
d0f0fb4
ec1c2e7
f82d85a
a1286de
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,11 @@ use scylla::IntoTypedRows; | |
// We can insert it by reference to not move the whole blob | ||
let to_insert: Vec<u8> = vec![1, 2, 3, 4, 5]; | ||
session | ||
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&to_insert,)) | ||
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&to_insert,)) | ||
.await?; | ||
|
||
// Read blobs from the table | ||
let result = session.query("SELECT a FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also a full scan, just page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are so many unpaged queries present in our docs... I suggest postponing rewrite of them to a separate follow-up PR. |
||
let mut iter = result.rows_typed::<(Vec<u8>,)>()?; | ||
while let Some((blob_value,)) = iter.next().transpose()? { | ||
println!("{:?}", blob_value); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,11 @@ use scylla::IntoTypedRows; | |
// Insert a list of ints into the table | ||
let my_list: Vec<i32> = vec![1, 2, 3, 4, 5]; | ||
session | ||
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_list,)) | ||
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_list,)) | ||
.await?; | ||
|
||
// Read a list of ints from the table | ||
let result = session.query("SELECT a FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paged. |
||
let mut iter = result.rows_typed::<(Vec<i32>,)>()?; | ||
while let Some((list_value,)) = iter.next().transpose()? { | ||
println!("{:?}", list_value); | ||
|
@@ -39,11 +39,11 @@ use scylla::IntoTypedRows; | |
// Insert a set of ints into the table | ||
let my_set: Vec<i32> = vec![1, 2, 3, 4, 5]; | ||
session | ||
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,)) | ||
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,)) | ||
.await?; | ||
|
||
// Read a set of ints from the table | ||
let result = session.query("SELECT a FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?; | ||
let mut iter = result.rows_typed::<(Vec<i32>,)>()?; | ||
while let Some((list_value,)) = iter.next().transpose()? { | ||
println!("{:?}", list_value); | ||
|
@@ -63,11 +63,11 @@ use std::collections::HashSet; | |
// Insert a set of ints into the table | ||
let my_set: HashSet<i32> = vec![1, 2, 3, 4, 5].into_iter().collect(); | ||
session | ||
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,)) | ||
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,)) | ||
.await?; | ||
|
||
// Read a set of ints from the table | ||
let result = session.query("SELECT a FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paged. |
||
let mut iter = result.rows_typed::<(HashSet<i32>,)>()?; | ||
while let Some((list_value,)) = iter.next().transpose()? { | ||
println!("{:?}", list_value); | ||
|
@@ -87,11 +87,11 @@ use std::collections::BTreeSet; | |
// Insert a set of ints into the table | ||
let my_set: BTreeSet<i32> = vec![1, 2, 3, 4, 5].into_iter().collect(); | ||
session | ||
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,)) | ||
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_set,)) | ||
.await?; | ||
|
||
// Read a set of ints from the table | ||
let result = session.query("SELECT a FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paged. |
||
let mut iter = result.rows_typed::<(BTreeSet<i32>,)>()?; | ||
while let Some((list_value,)) = iter.next().transpose()? { | ||
println!("{:?}", list_value); | ||
|
@@ -116,11 +116,11 @@ let mut my_map: HashMap<String, i32> = HashMap::new(); | |
my_map.insert("abcd".to_string(), 16); | ||
|
||
session | ||
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,)) | ||
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,)) | ||
.await?; | ||
|
||
// Read a map from the table | ||
let result = session.query("SELECT a FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paged. |
||
let mut iter = result.rows_typed::<(HashMap<String, i32>,)>()?; | ||
while let Some((map_value,)) = iter.next().transpose()? { | ||
println!("{:?}", map_value); | ||
|
@@ -142,11 +142,11 @@ let mut my_map: BTreeMap<String, i32> = BTreeMap::new(); | |
my_map.insert("abcd".to_string(), 16); | ||
|
||
session | ||
.query("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,)) | ||
.query_unpaged("INSERT INTO keyspace.table (a) VALUES(?)", (&my_map,)) | ||
.await?; | ||
|
||
// Read a map from the table | ||
let result = session.query("SELECT a FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT a FROM keyspace.table", &[]).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paged. |
||
let mut iter = result.rows_typed::<(BTreeMap<String, i32>,)>()?; | ||
while let Some((map_value,)) = iter.next().transpose()? { | ||
println!("{:?}", map_value); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ use scylla::IntoTypedRows; | |
use scylla::frame::value::Counter; | ||
|
||
// Read counter from the table | ||
let result = session.query("SELECT c FROM keyspace.table", &[]).await?; | ||
let result = session.query_unpaged("SELECT c FROM keyspace.table", &[]).await?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Paged. |
||
let mut iter = result.rows_typed::<(Counter,)>()?; | ||
while let Some((counter_value,)) = iter.next().transpose()? { | ||
let counter_int_value: i64 = counter_value.0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, this is precisely the kind of query and place you want people NOT to use
query_unpaged
. :-)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...which explains why we need this refactor that much :P