async fn execute_batch(
        &self,
        operations: Vec<Operation>,
        transactional: bool,
        query_schema: QuerySchemaRef,
    ) -> crate::Result<Vec<crate::Result<ResponseData>>> {
        if transactional {
            let queries = operations
                .into_iter()
                .map(|op| QueryGraphBuilder::new(query_schema.clone()).build(op))
                .collect::<std::result::Result<Vec<_>, _>>()?;

            let conn = self.connector.get_connection().await?;
            let tx = conn.start_transaction().await?;
            let mut results = Vec::with_capacity(queries.len());

            for (query, info) in queries {
                let interpreter = QueryInterpreter::new(ConnectionLike::Transaction(tx.as_ref()));
                let result = QueryPipeline::new(query, interpreter, info).execute().await;

                if result.is_err() {
                    tx.rollback().await?;
                }

                results.push(Ok(result?));
            }

            tx.commit().await?;
            Ok(results)
        } else {
            let mut futures = Vec::with_capacity(operations.len());

            for operation in operations {
                let conn = self.connector.get_connection().await?;
                futures.push(tokio::spawn(Self::execute_single_operation(
                    operation,
                    conn,
                    self.force_transactions,
                    query_schema.clone(),
                )));
            }

            let responses: Vec<_> = future::join_all(futures)
                .await
                .into_iter()
                .map(|res| res.expect("IO Error in tokio::spawn"))
                .collect();

            Ok(responses)
        }
    }
/// Executes a batch of operations.
///
/// If the batch is to be executed transactionally:
/// All operations are evaluated in sequence and the entire batch is rolled back if one operation fails,
/// returning the error.
///
/// If the batch is not transactional:
/// All operations are fanned out onto as many connections as possible and executed independently.
/// A failing operation does not fail the batch, instead, an error is returned alongside other responses.
/// Note that individual operations executed in non-transactional mode can still be transactions in themselves
/// if the query (e.g. a write op) requires it.
Executes a batch of operations.
If the batch is to be executed transactionally:
All operations are evaluated in sequence and the entire batch is rolled back if one operation fails,
returning the error.

If the batch is not transactional:
All operations are fanned out onto as many connections as possible and executed independently.
A failing operation does not fail the batch, instead, an error is returned alongside other responses.
Note that individual operations executed in non-transactional mode can still be transactions in themselves
if the query  requires it.
Executes a batch of operations . If the batch is to be executed transactionally : All operations are evaluated in sequence and the entire batch is rolled back if one operation fails returning the error . If the batch is not transactional : All operations are fanned out onto as many connections as possible and executed independently . A failing operation does not fail the batch instead an error is returned alongside other responses . Note that individual operations executed in non - transactional mode can still be transactions in themselves if the query requires it .
async fn execute_batch(
        &self,
        operations: Vec<Operation>,
        transactional: bool,
        query_schema: QuerySchemaRef,
    ) -> crate::Result<Vec<crate::Result<ResponseData>>> {
        if transactional {
            let queries = operations
                .into_iter()
                .map(|op| QueryGraphBuilder::new(query_schema.clone()).build(op))
                .collect::<std::result::Result<Vec<_>, _>>()?;
            let conn = self.connector.get_connection().await?;
            let tx = conn.start_transaction().await?;
            let mut results = Vec::with_capacity(queries.len());
            for (query, info) in queries {
                let interpreter = QueryInterpreter::new(ConnectionLike::Transaction(tx.as_ref()));
                let result = QueryPipeline::new(query, interpreter, info).execute().await;
                if result.is_err() {
                    tx.rollback().await?;
                }
                results.push(Ok(result?));
            }
            tx.commit().await?;
            Ok(results)
        } else {
            let mut futures = Vec::with_capacity(operations.len());
            for operation in operations {
                let conn = self.connector.get_connection().await?;
                futures.push(tokio::spawn(Self::execute_single_operation(
                    operation,
                    conn,
                    self.force_transactions,
                    query_schema.clone(),
                )));
            }
            let responses: Vec<_> = future::join_all(futures)
                .await
                .into_iter()
                .map(|res| res.expect("IO Error in tokio::spawn"))
                .collect();
            Ok(responses)
        }
    }
async fn execute_batch ( & self , operations : Vec < Operation > , transactional : bool , query_schema : QuerySchemaRef , ) -> crate :: Result < Vec < crate :: Result < ResponseData > > > { if transactional { let queries = operations . into_iter ( ) . map ( | op | QueryGraphBuilder :: new ( query_schema . clone ( ) ) . build ( op ) ) . collect :: < std :: result :: Result < Vec < _ > , _ > > ( ) ? ; let conn = self . connector . get_connection ( ) . await ? ; let tx = conn . start_transaction ( ) . await ? ; let mut results = Vec :: with_capacity ( queries . len ( ) ) ; for ( query , info ) in queries { let interpreter = QueryInterpreter :: new ( ConnectionLike :: Transaction ( tx . as_ref ( ) ) ) ; let result = QueryPipeline :: new ( query , interpreter , info ) . execute ( ) . await ; if result . is_err ( ) { tx . rollback ( ) . await ? ; } results . push ( Ok ( result ? ) ) ; } tx . commit ( ) . await ? ; Ok ( results ) } else { let mut futures = Vec :: with_capacity ( operations . len ( ) ) ; for operation in operations { let conn = self . connector . get_connection ( ) . await ? ; futures . push ( tokio :: spawn ( Self :: execute_single_operation ( operation , conn , self . force_transactions , query_schema . clone ( ) , ) ) ) ; } let responses : Vec < _ > = future :: join_all ( futures ) . await . into_iter ( ) . map ( | res | res . expect ( " " ) ) . collect ( ) ; Ok ( responses ) } }
Executes a batch of operations.
Executes a batch of operations .
&self
operations
Vec<Operation>
transactional
bool
query_schema
QuerySchemaRef
&self
operations
Vec<Operation>
transactional
bool
query_schema
QuerySchemaRef