DuckDBBatchResult

com.softinio.duck4s.algebra.DuckDBBatchResult
case class DuckDBBatchResult(updateCounts: Array[Int], successCount: Int, failureCount: Int)

Result of executing a batch operation, containing update counts and statistics.

This class encapsulates the results of executing a batch operation, providing both detailed update counts for each operation in the batch and summary statistics about successes and failures.

Value parameters

failureCount

the number of operations that failed

successCount

the number of operations that completed successfully

updateCounts

array of update counts for each operation in the batch. Non-negative values indicate the number of rows affected by that operation. Negative values indicate failures.

Attributes

See also

DuckDBBatch.executeBatch for executing batch operations

DuckDBBatch for batch operation management

Since

0.1.0

Example
 val result = for { batch <- Right(DuckDBBatch(stmt)) _ <-
 batch.addBatch(("Alice", 25), ("Bob", 30), ("Charlie", 35)) result <-
 batch.executeBatch() } yield result
result match { case Right(batchResult) => println(s"Total operations:
${batchResult.updateCounts.length}") println(s"Successful:
${batchResult.successCount}") println(s"Failed:
${batchResult.failureCount}")
// Check individual operation results
batchResult.updateCounts.zipWithIndex.foreach { case (count, index) => if
(count >= 0) { println(s"Operation $index: $count rows affected") } else {
println(s"Operation $index: failed") } }
// Check if all operations succeeded if (batchResult.isAllSuccessful) {
println("All operations completed successfully!") }
case Left(error) => println(s"Batch execution failed: $error") } 
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

Returns a list of indices for operations that failed.

Returns a list of indices for operations that failed.

Attributes

Returns

indices of operations with negative update counts

Since

0.1.0

Example
 val failedIndices = batchResult.failedOperationIndices if
 (failedIndices.nonEmpty) { println(s"Operations that failed:
 ${failedIndices.mkString(", ")}") } 

Returns true if all operations in the batch completed successfully.

Returns true if all operations in the batch completed successfully.

Attributes

Returns

true if failureCount is 0, false otherwise

Since

0.1.0

Example
 if (batchResult.isAllSuccessful) { println("Batch completed without
 errors") } else { println(s"${batchResult.failureCount} operations
 failed") } 

Returns the total number of operations in the batch.

Returns the total number of operations in the batch.

Attributes

Returns

the length of the updateCounts array

Since

0.1.0

Example
println(s"Executed ${batchResult.totalOperations} operations")

Returns the total number of rows affected by all successful operations.

Returns the total number of rows affected by all successful operations.

This sums up all non-negative update counts, giving the total number of rows that were affected by the entire batch operation.

Attributes

Returns

the sum of all successful update counts

Since

0.1.0

Example
 println(s"Total rows affected: ${batchResult.totalRowsAffected}")

Inherited methods

Attributes

Inherited from:
Product

Attributes

Inherited from:
Product