Comments (4)
is there any news about it ?
from scylla-rust-driver.
This issue is currently in a "pull requests welcome" state. It's generally on a roadmap, but the team is currently focused on providing performance benchmarks.
from scylla-rust-driver.
If someone needs func. like that - it is quite easy to impl according to usecase.
use super::{BatchValues, ScyllaError};
use scylla::batch::Batch;
use scylla::frame::value::SerializedValues;
use scylla::prepared_statement::PreparedStatement;
pub struct BatchPrepare {
batch: Batch,
values: Vec<SerializedValues>,
stmt_count: u32,
}
impl BatchPrepare {
pub fn new() -> Self {
Self {
batch: Batch::default(),
values: Vec::new(),
stmt_count: 0,
}
}
pub fn take(mut self) -> (Batch, Vec<SerializedValues>) {
let batch = std::mem::take(&mut self.batch);
let values = std::mem::take(&mut self.values);
self.stmt_count = 0;
(batch, values)
}
pub fn add_batch_stmt(&mut self, prepared_statement: PreparedStatement) {
self.batch.append_statement(prepared_statement);
self.stmt_count += 1;
}
pub fn add_values(&mut self, values: impl BatchValues) -> Result<(), ScyllaError> {
let v = values.as_batch_values()?;
self.values.push(v);
Ok(())
}
pub fn is_empty(&self) -> bool {
self.stmt_count == 0
}
}
use super::ScyllaError;
use scylla::frame::value::{SerializedValues, Value, ValueList};
fn add_value(s: &mut SerializedValues, val: &impl Value) -> Result<(), ScyllaError> {
s.add_value(val)
.map_err(|e| ScyllaError::Internal(e.into()))
}
pub trait BatchValues {
fn as_batch_values(&self) -> Result<SerializedValues, ScyllaError>;
}
impl<T: ValueList> BatchValues for &T {
fn as_batch_values(&self) -> Result<SerializedValues, ScyllaError> {
let s = <T as ValueList>::serialized(self).map_err(|e| ScyllaError::Internal(e.into()))?;
Ok(s.into_owned())
}
}
macro_rules! impl_batch_tuple {
( $($Ti:ident),* ; $($FieldI:tt),*) => {
impl<$($Ti),+> BatchValues for ($($Ti,)+)
where
$($Ti: Value),+
{
fn as_batch_values(&self) -> Result<SerializedValues, ScyllaError> {
let mut s = SerializedValues::new();
$(
add_value(&mut s, &self.$FieldI)?;
)*
Ok(s)
}
}
}
}
impl_batch_tuple!(T0; 0);
impl_batch_tuple!(T0, T1; 0, 1);
impl_batch_tuple!(T0, T1, T2; 0, 1, 2);
impl_batch_tuple!(T0, T1, T2, T3; 0, 1, 2, 3);
impl_batch_tuple!(T0, T1, T2, T3, T4; 0, 1, 2, 3, 4);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5; 0, 1, 2, 3, 4, 5);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6; 0, 1, 2, 3, 4, 5, 6);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7; 0, 1, 2, 3, 4, 5, 6, 7);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8; 0, 1, 2, 3, 4, 5, 6, 7, 8);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14);
impl_batch_tuple!(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15; 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
from scylla-rust-driver.
Ref: #941
from scylla-rust-driver.
Related Issues (20)
- `test_tracing` is probably flaky with Cassandra HOT 1
- Driver does not automatically re-prepare queries (follow up?) when running against cassandra HOT 9
- Deserialization refactor: add new deserialization traits
- Deserialization refactor: macros for the new traits HOT 1
- Deserialization refactor: implement `DeserializeRow` and `DeserializeCql` for current implementors of `FromRow` and `FromCql`
- Deserialization refactor: adjust the codebase to use `DeserializeRow` and `DeserializeCql` in the public API
- Deserialization refactor: adjust docs and provide a migration guide
- speculative_execution test flakiness HOT 2
- Describe API stability guarantees in README and docs.rs HOT 1
- RetryPolicy: adapt naming and docs to changes in LBP HOT 1
- DefaultPolicy test: change test nodes to be multi shard
- Enhancement Proposal: Simplifying Token Calculation for High-Frequency Append-Log Style Operations HOT 8
- PreparedStatement: document that cloning it is cheap HOT 2
- Re-structure modules for more reasonable layers' and components' separation
- Request execution API changes - umbrella issue
- Planned API breaking changes - umbrella issue
- Multiple create statement support. HOT 3
- CI: Split into static checks and tests
- Tablets: consider alternative implementation HOT 5
- scylla-cql: Prevent allocations when deserializing custom_payload.
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 scylla-rust-driver.