public class TokenRangeReadStatementGenerator extends Object
| Constructor and Description |
|---|
TokenRangeReadStatementGenerator(com.datastax.oss.driver.api.core.metadata.schema.RelationMetadata table,
com.datastax.oss.driver.api.core.metadata.Metadata metadata) |
| Modifier and Type | Method and Description |
|---|---|
List<com.datastax.oss.driver.api.core.cql.Statement<?>> |
generate(int splitCount)
Generates default SELECT statements to read the entire table, with a minimum of
splitCount statements. |
List<com.datastax.oss.driver.api.core.cql.Statement<?>> |
generate(int splitCount,
Function<com.datastax.oss.driver.api.core.metadata.token.TokenRange,com.datastax.oss.driver.api.core.cql.Statement<?>> statementFactory)
Generates SELECT statements to read the entire table, with a minimum of
splitCount
statements and using the given factory to generate statements. |
public TokenRangeReadStatementGenerator(@NonNull
com.datastax.oss.driver.api.core.metadata.schema.RelationMetadata table,
@NonNull
com.datastax.oss.driver.api.core.metadata.Metadata metadata)
table - The table (or materialized view) to scan.metadata - The cluster metadata to use.@NonNull public List<com.datastax.oss.driver.api.core.cql.Statement<?>> generate(int splitCount)
splitCount statements.
For a given split / token range, the generated statement is a statement of the form: SELECT col1, col2,... FROM table WHERE token(...) >
[range.start()] AND token(...) <= [range.end()]).
Note that the splitting algorithm doesn't guarantee an exact number of splits, but rather a
minimum number. The number of resulting statements depends on the set of primary token ranges
in the ring and how contiguous token ranges are distributed across the ring. In particular with
vnodes, the total number of statements can be much higher than splitCount.
splitCount - The minimum desired number of statements to generate (on a best-effort
basis).@NonNull public List<com.datastax.oss.driver.api.core.cql.Statement<?>> generate(int splitCount, @NonNull Function<com.datastax.oss.driver.api.core.metadata.token.TokenRange,com.datastax.oss.driver.api.core.cql.Statement<?>> statementFactory)
splitCount
statements and using the given factory to generate statements.
For each split / token range, the generated statement is a statement
resulting from applying statementFactory to the token range; statement factories should
typically generate a statement of the form: SELECT col1, col2,... FROM table WHERE
token(...) > ? AND token(...) <= ?). Please note that this method does not fully validate that
the statements created by the factory are valid, and thus should be used with caution.
Note that the splitting algorithm doesn't guarantee an exact number of splits, but rather a
minimum number. The number of resulting statements depends on the set of primary token ranges
in the ring and how contiguous token ranges are distributed across the ring. In particular with
vnodes, the total number of statements can be much higher than splitCount.
splitCount - The minimum desired number of statements to generate (on a best-effort
basis).statementFactory - The factory to use to generate statements for each split.Copyright © 2017–2020 DataStax. All rights reserved.