Skip to content

Commit

Permalink
docs: adjust to new terminology
Browse files Browse the repository at this point in the history
- renamed `queries` directory to `statements`.
- renamed `queries.md` -> `statements.md`.
- rename `simple.md` -> `unprepared.md`

Apart from that, I adjusted the documentation to use the new terminology.
  • Loading branch information
muzarski committed Feb 26, 2025
1 parent 826041b commit 3c5c5f6
Show file tree
Hide file tree
Showing 28 changed files with 211 additions and 211 deletions.
26 changes: 13 additions & 13 deletions docs/source/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [Quick start](quickstart/quickstart.md)
- [Creating a project](quickstart/create-project.md)
- [Running Scylla using Docker](quickstart/scylla-docker.md)
- [Connecting and running a simple query](quickstart/example.md)
- [Connecting and executing a simple CQL statement](quickstart/example.md)

- [Migration guides](migration-guides/migration-guides.md)
- [Adjusting code to changes in serialization API introduced in 0.11](migration-guides/0.11-serialization.md)
Expand All @@ -16,18 +16,18 @@
- [Authentication](connecting/authentication.md)
- [TLS](connecting/tls.md)

- [Making queries](queries/queries.md)
- [Simple query](queries/simple.md)
- [Query values](queries/values.md)
- [Query result](queries/result.md)
- [Prepared query](queries/prepared.md)
- [Batch statement](queries/batch.md)
- [Paged query](queries/paged.md)
- [Lightweight transaction query (LWT)](queries/lwt.md)
- [USE keyspace](queries/usekeyspace.md)
- [Schema agreement](queries/schema-agreement.md)
- [Query timeouts](queries/timeouts.md)
- [Timestamp generators](queries/timestamp-generators.md)
- [Executing CQL statements](statements/statements.md)
- [Unprepared statement](statements/unprepared.md)
- [Statement values](statements/values.md)
- [Query result](statements/result.md)
- [Prepared statement](statements/prepared.md)
- [Batch statement](statements/batch.md)
- [Paged query](statements/paged.md)
- [Lightweight transaction statement (LWT)](statements/lwt.md)
- [USE keyspace](statements/usekeyspace.md)
- [Schema agreement](statements/schema-agreement.md)
- [Request timeouts](statements/timeouts.md)
- [Timestamp generators](statements/timestamp-generators.md)

- [Execution profiles](execution-profiles/execution-profiles.md)
- [Creating a profile and setting it](execution-profiles/create-and-use.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
index
quickstart/quickstart
connecting/connecting
queries/queries
statements/statements
execution-profiles/execution-profiles
data-types/data-types
load-balancing/load-balancing
Expand Down
4 changes: 2 additions & 2 deletions docs/source/data-types/data-types.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ to achieve seamless sending and receiving of CQL values.

See the following chapters for examples on how to send and receive each data type.

See [Query values](../queries/values.md) for more information about sending values in queries.\
See [Query result](../queries/result.md) for more information about reading values from queries
See [Statement values](../statements/values.md) for more information about sending values along with statements.\
See [Query result](../statements/result.md) for more information about retrieving values from queries

Database types and their Rust equivalents:
* `Boolean` <----> `bool`
Expand Down
2 changes: 1 addition & 1 deletion docs/source/execution-profiles/create-and-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let session: Session = SessionBuilder::new()
```

### Example
To create an `ExecutionProfile` and attach it to a `Query`:
To create an `ExecutionProfile` and attach it to a `Statement`:
```rust
# extern crate scylla;
# use std::error::Error;
Expand Down
12 changes: 6 additions & 6 deletions docs/source/execution-profiles/priority.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ let session: Session = SessionBuilder::new()

let mut query = Statement::from("SELECT * FROM ks.table");

// Query is not assigned any specific profile, so session's profile is applied.
// Therefore, the query will be executed with Consistency::One.
// Statement is not assigned any specific profile, so session's profile is applied.
// Therefore, the statement will be executed with Consistency::One.
session.query_unpaged(query.clone(), ()).await?;

query.set_execution_profile_handle(Some(query_profile.into_handle()));
// Query's profile is applied.
// Therefore, the query will be executed with Consistency::Two.
// Statement's profile is applied.
// Therefore, the statement will be executed with Consistency::Two.
session.query_unpaged(query.clone(), ()).await?;

query.set_consistency(Consistency::Three);
// An option is set directly on the query.
// Therefore, the query will be executed with Consistency::Three.
// An option is set directly on the Statement.
// Therefore, the statement will be executed with Consistency::Three.
session.query_unpaged(query, ()).await?;

# Ok(())
Expand Down
12 changes: 6 additions & 6 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Although optimized for Scylla, the driver is also compatible with [Apache Cassan


## Contents
* [Quick start](quickstart/quickstart.md) - Setting up a Rust project using `scylla-rust-driver` and running a few queries
* [Quick start](quickstart/quickstart.md) - Setting up a Rust project using `scylla-rust-driver` and executing a few CQL statements
* [Migration guides](migration-guides/migration-guides.md) - How to update the code that used an older version of this driver
* [Connecting to the cluster](connecting/connecting.md) - Configuring a connection to scylla cluster
* [Making queries](queries/queries.md) - Making different types of queries (simple, prepared, batch, paged)
* [Execution profiles](execution-profiles/execution-profiles.md) - Grouping query execution configuration options together and switching them all at once
* [CQL statement execution](statements/statements.md) - Executing different types of CQL statement (simple, prepared, batch, paged)
* [Execution profiles](execution-profiles/execution-profiles.md) - Grouping statement execution configuration options together and switching them all at once
* [Data Types](data-types/data-types.md) - How to use various column data types
* [Load balancing](load-balancing/load-balancing.md) - Load balancing configuration
* [Retry policy configuration](retry-policy/retry-policy.md) - What to do when a query fails, query idempotence
* [Driver metrics](metrics/metrics.md) - Statistics about the driver - number of queries, latency etc.
* [Retry policy configuration](retry-policy/retry-policy.md) - What to do when execution attempt fails, statement idempotence
* [Driver metrics](metrics/metrics.md) - Statistics about the driver - number of executed statements, latency etc.
* [Logging](logging/logging.md) - Viewing and integrating logs produced by the driver
* [Query tracing](tracing/tracing.md) - Tracing query execution
* [Request tracing](tracing/tracing.md) - Tracing request execution
* [Database schema](schema/schema.md) - Fetching and inspecting database schema
32 changes: 0 additions & 32 deletions docs/source/queries/lwt.md

This file was deleted.

18 changes: 9 additions & 9 deletions docs/source/retry-policy/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let session: Session = SessionBuilder::new()
# }
```

To use in a [simple query](../queries/simple.md):
To use in an [unprepared statement](../statements/unprepared.md):
```rust
# extern crate scylla;
# use scylla::client::session::Session;
Expand All @@ -41,25 +41,25 @@ use scylla::statement::unprepared::Statement;
use scylla::client::execution_profile::ExecutionProfile;
use scylla::policies::retry::DefaultRetryPolicy;

// Create a Query manually and set the retry policy
let mut my_query: Statement = Statement::new("INSERT INTO ks.tab (a) VALUES(?)");
my_query.set_retry_policy(Some(Arc::new(DefaultRetryPolicy::new())));
// Create a Statement manually and set the retry policy
let mut my_statement: Statement = Statement::new("INSERT INTO ks.tab (a) VALUES(?)");
my_statement.set_retry_policy(Some(Arc::new(DefaultRetryPolicy::new())));

// You can also set retry policy in an execution profile
let handle = ExecutionProfile::builder()
.retry_policy(Arc::new(DefaultRetryPolicy::new()))
.build()
.into_handle();
my_query.set_execution_profile_handle(Some(handle));
my_statement.set_execution_profile_handle(Some(handle));

// Run the query using this retry policy
// Execute the statement using this retry policy
let to_insert: i32 = 12345;
session.query_unpaged(my_query, (to_insert,)).await?;
session.query_unpaged(my_statement, (to_insert,)).await?;
# Ok(())
# }
```

To use in a [prepared query](../queries/prepared.md):
To use in a [prepared statement](../statements/prepared.md):
```rust
# extern crate scylla;
# use scylla::client::session::Session;
Expand All @@ -83,7 +83,7 @@ let handle = ExecutionProfile::builder()
.into_handle();
prepared.set_execution_profile_handle(Some(handle));

// Run the query using this retry policy
// Execute the statement using this retry policy
let to_insert: i32 = 12345;
session.execute_unpaged(&prepared, (to_insert,)).await?;
# Ok(())
Expand Down
16 changes: 8 additions & 8 deletions docs/source/retry-policy/downgrading-consistency.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ let session: Session = SessionBuilder::new()
# }
```

To use in a [simple query](../queries/simple.md):
To use in an [unprepared statement](../statements/unprepared.md):
```rust
# extern crate scylla;
# use scylla::client::session::Session;
Expand All @@ -87,18 +87,18 @@ let handle = ExecutionProfile::builder()
.build()
.into_handle();

// Create a Query manually and set the retry policy
let mut my_query: Statement = Statement::new("INSERT INTO ks.tab (a) VALUES(?)");
my_query.set_execution_profile_handle(Some(handle));
// Create a Statement manually and set the retry policy
let mut my_statement: Statement = Statement::new("INSERT INTO ks.tab (a) VALUES(?)");
my_statement.set_execution_profile_handle(Some(handle));

// Run the query using this retry policy
// Execute the statement using this retry policy
let to_insert: i32 = 12345;
session.query_unpaged(my_query, (to_insert,)).await?;
session.query_unpaged(my_statement, (to_insert,)).await?;
# Ok(())
# }
```

To use in a [prepared query](../queries/prepared.md):
To use in a [prepared statement](../statements/prepared.md):
```rust
# extern crate scylla;
# use scylla::client::session::Session;
Expand All @@ -122,7 +122,7 @@ let mut prepared: PreparedStatement = session
prepared.set_execution_profile_handle(Some(handle));


// Run the query using this retry policy
// Execute the statement using this retry policy
let to_insert: i32 = 12345;
session.execute_unpaged(&prepared, (to_insert,)).await?;
# Ok(())
Expand Down
14 changes: 7 additions & 7 deletions docs/source/retry-policy/fallthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ let session: Session = SessionBuilder::new()
# }
```

To use in a [simple query](../queries/simple.md):
To use in an [unprepared statement](../statements/unprepared.md):
```rust
# extern crate scylla;
# use scylla::client::session::Session;
Expand All @@ -45,18 +45,18 @@ let handle = ExecutionProfile::builder()
.build()
.into_handle();

// Create a Query manually and set the retry policy
let mut my_query: Statement = Statement::new("INSERT INTO ks.tab (a) VALUES(?)");
my_query.set_execution_profile_handle(Some(handle));
// Create a Statement manually and set the retry policy
let mut my_statement: Statement = Statement::new("INSERT INTO ks.tab (a) VALUES(?)");
my_statement.set_execution_profile_handle(Some(handle));

// Run the query using this retry policy
// Execute the statement using this retry policy
let to_insert: i32 = 12345;
session.query_unpaged(my_query, (to_insert,)).await?;
session.query_unpaged(my_statement, (to_insert,)).await?;
# Ok(())
# }
```

To use in a [prepared query](../queries/prepared.md):
To use in a [prepared statement](../statements/prepared.md):
```rust
# extern crate scylla;
# use scylla::client::session::Session;
Expand Down
4 changes: 2 additions & 2 deletions docs/source/retry-policy/retry-policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Idempotence has to be specified manually, the driver is not able to figure it ou
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use scylla::statement::unprepared::Statement;
use scylla::statement::prepared::PreparedStatement;
use scylla::prepared_statement::PreparedStatement;

// Specify that a Query is idempotent
// Specify that a Statement is idempotent
let mut my_query: Statement = Statement::new("SELECT a FROM ks.tab");
my_query.set_is_idempotent(true);

Expand Down
20 changes: 10 additions & 10 deletions docs/source/queries/batch.md → docs/source/statements/batch.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Batch statement

A batch statement allows to execute many data-modifying statements at once.\
These statements can be [simple](simple.md) or [prepared](prepared.md).\
These statements can be [unprepared](unprepared.md) or [prepared](prepared.md).\
Only `INSERT`, `UPDATE` and `DELETE` statements are allowed.

```rust
Expand All @@ -16,12 +16,12 @@ use scylla::statement::prepared::PreparedStatement;
// Create a batch statement
let mut batch: Batch = Default::default();

// Add a simple statement to the batch using its text
// Add an unprepared statement to the batch using its text
batch.append_statement("INSERT INTO ks.tab(a, b) VALUES(1, 2)");

// Add a simple statement created manually to the batch
let simple: Statement = Statement::new("INSERT INTO ks.tab (a, b) VALUES(3, 4)");
batch.append_statement(simple);
// Add an unprepared statement created manually to the batch
let unprepared: Statement = Statement::new("INSERT INTO ks.tab (a, b) VALUES(3, 4)");
batch.append_statement(unprepared);

// Add a prepared statement to the batch
let prepared: PreparedStatement = session
Expand All @@ -41,8 +41,8 @@ session.batch(&batch, batch_values).await?;
```

> ***Warning***\
> Using simple statements with bind markers in batches is strongly discouraged.
> For each simple statement with a non-empty list of values in the batch,
> Using unprepared statements with bind markers in batches is strongly discouraged.
> For each unprepared statement with a non-empty list of values in the batch,
> the driver will send a prepare request, and it will be done **sequentially**.
> Results of preparation are not cached between `Session::batch` calls.
> Consider preparing the statements before putting them into the batch.
Expand Down Expand Up @@ -103,7 +103,7 @@ See [Batch API documentation](https://docs.rs/scylla/latest/scylla/statement/bat
for more options

### Batch values
Batch takes a tuple of values specified just like in [simple](simple.md) or [prepared](prepared.md) queries.
Batch takes a tuple of values specified just like in [unprepared](unprepared.md) or [prepared](prepared.md) statements.

Length of batch values must be equal to the number of statements in a batch.\
Each statement must have its values specified, even if they are empty.
Expand Down Expand Up @@ -142,10 +142,10 @@ session.batch(&batch, batch_values).await?;
# Ok(())
# }
```
For more information about sending values in a statement see [Query values](values.md)
For more information about sending values in a statement see [Statement values](values.md)


### Performance
Batch statements do not use token/shard aware load balancing, batches are sent to a random node.

Use [prepared queries](prepared.md) for best performance
Use [prepared statements](prepared.md) for best performance
32 changes: 32 additions & 0 deletions docs/source/statements/lwt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Lightweight transaction (LWT) statement

A lightweight transaction statement can be expressed just like any other statement, via `Session`, with the notable difference of having an additional consistency level parameter - the `serial_consistency_level`.


### Format of the statement
A lightweight transaction statement is not a separate type - it can be expressed just like any other statements: via `Statement`, `PreparedStatement`, batches, and so on. The difference lays in the statement string itself - when it contains a condition (e.g. `IF NOT EXISTS`), it becomes a lightweight transaction. It's important to remember that CQL specification requires a separate, additional consistency level to be defined for LWT statements - `serial_consistency_level`. The serial consistency level can only be set to two values: `SerialConsistency::Serial` or `SerialConsistency::LocalSerial`. The "local" variant makes the transaction consistent only within the same datacenter. For convenience, Scylla Rust Driver sets the default consistency level to `LocalSerial`, as it's more commonly used. For cross-datacenter consistency, please remember to always override the default with `SerialConsistency::Serial`.
```rust
# extern crate scylla;
# use scylla::client::session::Session;
# use std::error::Error;
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
use scylla::statement::unprepared::Statement;
use scylla::statement::{Consistency, SerialConsistency};

// Create a Statement manually to change the Consistency to ONE
let mut my_statement: Statement = Statement::new("INSERT INTO ks.tab (a) VALUES(?) IF NOT EXISTS".to_string());
my_statement.set_consistency(Consistency::One);
// Use cross-datacenter serial consistency
my_statement.set_serial_consistency(Some(SerialConsistency::Serial));

// Insert a value into the table
let to_insert: i32 = 12345;
session.query_unpaged(my_statement, (to_insert,)).await?;
# Ok(())
# }
```

The rest of the API remains identical for LWT and non-LWT statements.

See [Statement API documentation](https://docs.rs/scylla/latest/scylla/statement/struct.Statement.html) for more options

Loading

0 comments on commit 3c5c5f6

Please sign in to comment.