kv
sample
Sample visible KV rows.
strata kv sampledb.kv.sample(prefix: 'Optional[str | bytes]' = None, *, count: 'Optional[int]' = None) -> 'Sample'wire kv_sample
Returns a deterministic bounded sample of visible KV rows plus the total matching count.
Paginated responses use opaque cursors. Clients should pass the returned cursor back to the same command shape and must not parse cursor contents.
To see the complete help for this command, run:
strata kv sample --helphelp(db.kv.sample)
Example
A representative sample plus the total population size.
strata kv put a 1created astrata kv put b 2created bstrata kv put c 3created cstrata kv sampleKEY VERSION VALUEa … 1b … 2c … 3
_ = db.kv.put("a", "1")_ = db.kv.put("b", "2")_ = db.kv.put("c", "3")db.kv.sample().total_count
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| branch | string or null | no | Target branch. Defaults to the executor handle branch. |
| count | integer or null | no | Optional sample count. Defaults to 10. |
| prefix | any | no | Optional key prefix. |
| space | string or null | no | Target product space. Defaults to `"default"`. |
Returns
SamplePage<SampleItem>
- dataobject
Shared pagination continuation facts.
- typestring
Errors
Recover by code. Retry policy and commit outcome come from the shipped error registry.
| Code | Retry | Commit outcome |
|---|---|---|
| failed_precondition.engine.runtime_closed | never | not_started |
| not_found.engine.branch | never | not_applicable |
| invalid_argument.engine.product_space | never | not_started |
| invalid_argument.engine.kv_key | never | not_started |