Skip to content

Commit

Permalink
Merge branch '0.26.1-scylladb'
Browse files Browse the repository at this point in the history
  • Loading branch information
vponomaryov committed Jul 2, 2024
2 parents 2cc0138 + 60f9573 commit e1c9852
Show file tree
Hide file tree
Showing 14 changed files with 574 additions and 406 deletions.
118 changes: 53 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "latte-cli"
description = "A database benchmarking tool for Apache Cassandra"
version = "0.25.2-scylladb"
version = "0.26.1-scylladb"
authors = ["Piotr Kołaczkowski <[email protected]>"]
edition = "2021"
readme = "README.md"
Expand All @@ -14,19 +14,18 @@ path = "src/main.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow = "1.0"
base64 = "0.21"
base64 = "0.22"
rmp = "0.8.10"
rmp-serde = "1.0.0-beta.2"
chrono = { version = "0.4.18", features = ["serde"] }
clap = { version = "4", features = ["derive", "cargo", "env"] }
console = "0.15.0"
cpu-time = "1.0.0"
ctrlc = "3.2.1"
err-derive = "0.3"
futures = "0.3"
hdrhistogram = "7.1.0"
hytra = "0.1.2"
itertools = "0.12"
itertools = "0.13"
jemallocator = "0.5"
lazy_static = "1.4.0"
metrohash = "1.0"
Expand All @@ -43,13 +42,13 @@ scylla = { version = "0.13", features = ["ssl"] }
search_path = "0.1"
serde = { version = "1.0.116", features = ["derive"] }
serde_json = "1.0.57"
statrs = "0.16"
statrs = "0.17"
status-line = "0.2.0"
strum = { version = "0.26", features = ["derive"] }
strum_macros = "0.26"
time = "0.3"
thiserror = "1.0.26"
tokio = { version = "1", features = ["rt", "rt-multi-thread", "time", "parking_lot"] }
tokio = { version = "1", features = ["rt", "rt-multi-thread", "time", "parking_lot", "signal"] }
tokio-stream = "0.1"
tracing = "0.1"
tracing-subscriber = "0.3"
Expand Down
39 changes: 27 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,19 @@ pub async fn run(ctx, i) {
}
```
Query parameters can be bound and passed by names as well:
```rust
const INSERT = "my_insert";
pub async fn prepare(ctx) {
ctx.prepare(INSERT, "INSERT INTO test.test(id, data) VALUES (:id, :data)").await?;
}
pub async fn run(ctx, i) {
ctx.execute_prepared(INSERT, #{id: 5, data: "foo"}).await
}
```
### Populating the database
Read queries are more interesting when they return non-empty result sets.
Expand Down Expand Up @@ -209,18 +222,20 @@ are pure, i.e. invoking them multiple times with the same parameters yields alwa
- `latte::hash_select(i, vector)` – selects an item from a vector based on a hash
- `latte::blob(i, len)` – generates a random binary blob of length `len`
- `latte::normal(i, mean, std_dev)` – generates a floating point number from a normal distribution
#### Numeric conversions
Rune represents integers as 64-bit signed values. Therefore, it is possible to directly pass a Rune integer to
a Cassandra column of type `bigint`. However, binding a 64-bit value to smaller integer column types, like
`int`, `smallint` or `tinyint` will result in a runtime error. As long as an integer value does not exceed the bounds,
you can convert it to smaller signed integer types by using the following instance functions:
- `x.to_i32()` – converts a float or integer to a 32-bit signed integer, compatible with Cassandra `int` type
- `x.to_i16()` – converts a float or integer to a 16-bit signed integer, compatible with Cassandra `smallint` type
- `x.to_i8()` – converts a float or integer to an 8-bit signed integer, compatible with Cassandra `tinyint` type
- `x.clamp(min, max)` – restricts the range of an integer or a float value to given range
- `latte::uniform(i, min, max)` – generates a floating point number from a uniform distribution
#### Type conversions
Rune uses 64-bit representation for integers and floats.
Since version 0.28 Rune numbers are automatically converted to proper target query parameter type,
therefore you don't need to do explicit conversions. E.g. you can pass an integer as a parameter
of Cassandra type `smallint`. If the number is too big to fit into the range allowed by the target
type, a runtime error will be signalled.

The following methods are available:
- `x.to_integer()` – converts a float to an integer
- `x.to_float()` – converts an integer to a float
- `x.to_string()` – converts a float or integer to a string
- `x.clamp(min, max)` – restricts the range of an integer or a float value to given range
You can also convert between floats and integers by calling `to_integer` or `to_float` instance functions.
Expand Down
Loading

0 comments on commit e1c9852

Please sign in to comment.