From 03ec401e625efa18bc472d8e88cfc4f0c1690fda Mon Sep 17 00:00:00 2001 From: Rohit Nayak Date: Wed, 27 Nov 2024 11:35:31 +0100 Subject: [PATCH] Add docs. Default vindex is now xxhash Signed-off-by: Rohit Nayak --- .../map-shard-for-value.go | 2 +- .../map-shard-for-value.md | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 tools/map-shard-for-value/map-shard-for-value.md diff --git a/tools/map-shard-for-value/map-shard-for-value.go b/tools/map-shard-for-value/map-shard-for-value.go index ef9b3591180..6ffad6f861d 100755 --- a/tools/map-shard-for-value/map-shard-for-value.go +++ b/tools/map-shard-for-value/map-shard-for-value.go @@ -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() diff --git a/tools/map-shard-for-value/map-shard-for-value.md b/tools/map-shard-for-value/map-shard-for-value.md new file mode 100644 index 00000000000..f2e8d9df17e --- /dev/null +++ b/tools/map-shard-for-value/map-shard-for-value.md @@ -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 +