Skip to content

Commit

Permalink
Add docs. Default vindex is now xxhash
Browse files Browse the repository at this point in the history
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
  • Loading branch information
rohit-nayak-ps committed Nov 27, 2024
1 parent 0ad3578 commit 03ec401
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/map-shard-for-value/map-shard-for-value.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func generateUniformShardRanges(totalShards int) string {
}

func main() {
vindexName := flag.String("vindex", "hash", "name of the vindex")
vindexName := flag.String("vindex", "xxhash", "name of the vindex")
shardsCSV := flag.String("shards", "", "comma-separated list of shard ranges")
totalShards := flag.Int("total_shards", 0, "total number of uniformly distributed shards")
flag.Parse()
Expand Down
33 changes: 33 additions & 0 deletions tools/map-shard-for-value/map-shard-for-value.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Map Shard for Value Tool

### Overview

The `map-shard-for-value` tool maps a given value to a specific shard. This tool helps in determining
which shard a particular value belongs to, based on the vindex algorithm and shard ranges.

### Features

- Allows specifying the vindex type (e.g., `hash`, `xxhash`).
- Allows specifying the total number of shards to generate uniformly distributed shard ranges.
- Designed as a _filter_: Reads input values from `stdin` and outputs the corresponding shard information, so it can be
used to map values from a file or another program.

### Usage

```sh
make build
```

```sh
echo "1\n-1\n99" | ./map-shard-for-value --total_shards=4 --vindex=xxhash
echo "1\n-1\n99" | ./map-shard-for-value --vindex=hash --shards="-80,80-"
```

#### Flags

- `--vindex`: Specifies the name of the vindex to use (e.g., `hash`, `xxhash`) (default `xxhash`)

One of these is required:
- `--shards`: Comma-separated list of shard ranges
- `--total_shards`: Total number of shards, only if shards are uniformly distributed

0 comments on commit 03ec401

Please sign in to comment.