public interface StatementBatcher
This component can also optionally cap the created batches by either a maximum number of child statements, a maximum size in bytes of actual data to be inserted, or both. Note however that the heuristic used to compute the inserted data size is not 100% accurate.
Important: for this utility to work properly, statements must have their routing key or their routing
token set. Furthermore, when grouping by replica set, it is also
required that they have their routing keyspace set.
| Modifier and Type | Method and Description |
|---|---|
default List<Statement<?>> |
batchAll(BatchableStatement<?>... statements)
Batches together all the given statements into one or more
BatchStatements,
regardless of their grouping key. |
List<Statement<?>> |
batchAll(Collection<BatchableStatement<?>> statements)
Batches together all the given statements into one or more
BatchStatements,
regardless of their grouping key. |
default List<Statement<?>> |
batchByGroupingKey(BatchableStatement<?>... statements)
Batches together the given statements into groups of statements having the same grouping key.
|
List<Statement<?>> |
batchByGroupingKey(Iterable<BatchableStatement<?>> statements)
Batches together the given statements into groups of statements having the same grouping key.
|
@NonNull default List<Statement<?>> batchByGroupingKey(@NonNull BatchableStatement<?>... statements)
The grouping key to use is determined by the batch mode in use by this statement batcher.
Note that when a resulting group contains only one statement, this method will not create a batch statement containing that single statement; instead, it will return that same statement.
When the number of statements for the same grouping key is greater than the maximum number of statements, or when their total data size is greater than the maximum data size, statements will be split into smaller batches.
When PARTITION_KEY is used, the grouping key is the
statement's routing key or routing token, whichever is available.
When REPLICA_SET is used, the grouping key is the replica set
owning the statement's routing key or routing token, whichever is available.
statements - the statements to batch together.@NonNull List<Statement<?>> batchByGroupingKey(@NonNull Iterable<BatchableStatement<?>> statements)
The grouping key to use is determined by the batch mode in use by this statement batcher.
Note that when a resulting group contains only one statement, this method will not create a batch statement containing that single statement; instead, it will return that same statement.
When the number of statements for the same grouping key is greater than the maximum number of statements, or when their total data size is greater than the maximum data size, statements will be split into smaller batches.
When PARTITION_KEY is used, the grouping key is the
statement's routing key or routing token, whichever is available.
When REPLICA_SET is used, the grouping key is the replica set
owning the statement's routing key or routing token, whichever is available.
statements - the statements to batch together.@NonNull default List<Statement<?>> batchAll(@NonNull BatchableStatement<?>... statements)
BatchStatements,
regardless of their grouping key. Each group size is capped by the maximum number of
statements and the maximum data size.
Note that when a resulting group contains only one statement, this method will not create a batch statement containing that single statement; instead, it will return that same statement.
When the number of statements is greater than the maximum number of statements, or when their total data size is greater than the maximum data size, statements will be split into smaller batches.
Use this method with caution; if the given statements do not share the same routing key, the resulting batch could lead to write throughput degradation.
statements - the statements to batch together.BatchStatements containing all the given statements batched together,
or the original statement, if only one was provided.@NonNull List<Statement<?>> batchAll(@NonNull Collection<BatchableStatement<?>> statements)
BatchStatements,
regardless of their grouping key. Each group size is capped by the maximum number of
statements and the maximum data size.
Note that when a resulting group contains only one statement, this method will not create a batch statement containing that single statement; instead, it will return that same statement.
When the number of statements is greater than the maximum number of statements, or when their total data size is greater than the maximum data size, statements will be split into smaller batches.
Use this method with caution; if the given statements do not share the same routing key, the resulting batch could lead to write throughput degradation.
statements - the statements to batch together.BatchStatements containing all the given statements batched together,
or the original statement, if only one was provided.Copyright © 2017–2021 DataStax. All rights reserved.