Skip to content

Commit 9689d67

Browse files
committed
add tsdb storage engine (& many misc changes in support)
1 parent f01bba1 commit 9689d67

17 files changed

Lines changed: 1071 additions & 187 deletions

File tree

AGENTS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,25 @@ fn should_return_error_when_key_not_found() {
6565
- Use `BytesMut` for mutable byte buffers during encoding
6666
- The `bytes` crate is available as a workspace dependency
6767

68+
### Imports
69+
70+
- Place all `use` statements at the module level, not inside functions or methods
71+
- Group imports logically (standard library, external crates, local modules)
72+
73+
```rust
74+
// Good
75+
use bytes::{BufMut, BytesMut};
76+
77+
fn some_function() {
78+
let mut buf = BytesMut::new();
79+
}
80+
81+
// Bad
82+
fn some_function() {
83+
use bytes::BufMut; // Don't do this
84+
}
85+
```
86+
6887
### Dependencies
6988

7089
- **slatedb**: The underlying storage engine for all database implementations

Cargo.lock

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ version = "0.1.0"
1111
edition = "2024"
1212

1313
[workspace.dependencies]
14-
slatedb = "0.9.1"
15-
opendata-common = { path = "./opendata-common" }
16-
rstest = "0.19"
14+
async-trait = "0.1"
1715
bytes = "1.0"
1816
chrono = "0.4"
17+
dashmap = "6.1.0"
18+
opendata-common = { path = "./opendata-common" }
19+
rstest = "0.19"
20+
slatedb = "0.9.1"
1921
tokio = { version = "1.0", features = ["full"] }
20-
async-trait = "0.1"
2122
tracing = "0.1"

open-tsdb/Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@ version.workspace = true
44
edition.workspace = true
55

66
[dependencies]
7-
slatedb.workspace = true
8-
opendata-common.workspace = true
7+
async-trait.workspace = true
98
bytes.workspace = true
10-
roaring = "0.7"
11-
tsz = "0.1"
12-
blake3 = "1.8.2"
139
chrono.workspace = true
14-
promql-parser = "0.6"
10+
dashmap.workspace = true
11+
opendata-common.workspace = true
12+
slatedb.workspace = true
1513
tokio.workspace = true
16-
async-trait.workspace = true
1714
tracing.workspace = true
1815

16+
blake3 = "1.8.2"
17+
promql-parser = "0.6"
18+
roaring = "0.7"
19+
tsz = "0.1"
20+
1921
[dev-dependencies]
2022
rstest.workspace = true

open-tsdb/README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,31 +158,26 @@ execution to map series IDs back to their label sets when needed.
158158
- `time_bucket` (u32): The number of minutes since the UNIX epoch
159159
- `series_fingerprint` (u128): The fingerprint of the label set, computed as a hash of the labels
160160

161-
The series fingerprint is computed using the labels of the series, which means
162-
there is a small chance that two series with different labels will have the same
163-
fingerprint. Prometheus makes the same trade-off and accepts the risk of
164-
collisions. The value contains the series ID(s) that correspond to this
165-
fingerprint, typically a single series ID. Note that these IDs are scoped to a
166-
single time bucket so the cardinality is measured in the number of series in the
167-
bucket, not globally.
161+
The series fingerprint is computed using the labels of the series. The value
162+
contains the series ID that corresponds to this fingerprint. Note that these IDs
163+
are scoped to a single time bucket so the cardinality is measured in the number
164+
of series in the bucket, not globally.
168165

169166
**Value Schema:**
170167

171168
```
172169
┌──────────────────────────────────────────────────────────┐
173170
│ SeriesDictionaryValue │
174171
├──────────────────────────────────────────────────────────┤
175-
FixedElementArray<series_id: u32>
172+
│ series_id: u32
176173
└──────────────────────────────────────────────────────────┘
177174
```
178175

179176
**Structure:**
180177

181-
- The value is a `FixedElementArray<u32>` encoding the list of `series_id` values that
182-
have the specified fingerprint. In the common case of no collisions, this array
183-
contains a single `series_id`. When collisions occur, multiple series IDs are
184-
stored, and the forward index must be consulted to disambiguate by comparing
185-
the actual label sets.
178+
- The value is a single `series_id` (u32) that has the specified fingerprint.
179+
Hash collisions are assumed not to occur (we should consider changing this
180+
to a FixedElementArray<SeriesId> to allow for hash collisions).
186181

187182
### `ForwardIndex` (`RecordType::ForwardIndex` = `0x03`)
188183

0 commit comments

Comments
 (0)