fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

Add ShardPrefixOverride to support custom shard naming (#1005)

Co-authored-by: Ravi Kumar <rkumar@gitlab.com>

author
Ravi Kumar
co-author
Ravi Kumar
committer
GitHub
date (Mar 18, 2026, 2:22 PM +0200) commit 6b56e687 parent c747a3bc
+17 -7
+17 -7
index/builder.go
··· 61 61 // IndexDir is a directory that holds *.zoekt index files. 62 62 IndexDir string 63 63 64 + // ShardPrefixOverride sets the prefix for shards name 65 + ShardPrefixOverride string 66 + 64 67 // SizeMax is the maximum file size 65 68 SizeMax int 66 69 ··· 182 185 fs.IntVar(&o.ShardMax, "shard_limit", x.ShardMax, "maximum corpus size for a shard") 183 186 fs.IntVar(&o.Parallelism, "parallelism", x.Parallelism, "maximum number of parallel indexing processes.") 184 187 fs.StringVar(&o.IndexDir, "index", x.IndexDir, "directory for search indices") 188 + fs.StringVar(&o.ShardPrefixOverride, "shard_prefix_override", x.ShardPrefixOverride, "prefix for shard name") 185 189 fs.BoolVar(&o.CTagsMustSucceed, "require_ctags", x.CTagsMustSucceed, "If set, ctags calls must succeed.") 186 190 fs.Var(largeFilesFlag{o}, "large_file", "A glob pattern where matching files are to be index regardless of their size. You can add multiple patterns by setting this more than once.") 187 191 ··· 214 218 args = append(args, "-index", o.IndexDir) 215 219 } 216 220 221 + if o.ShardPrefixOverride != "" { 222 + args = append(args, "-shard_prefix_override", o.ShardPrefixOverride) 223 + } 224 + 217 225 if o.CTagsMustSucceed { 218 226 args = append(args, "-require_ctags") 219 227 } ··· 334 342 } 335 343 336 344 func (o *Options) shardNameVersion(version, n int) string { 337 - var prefix string 345 + prefix := o.ShardPrefixOverride // ShardPrefixOverride takes precedence to support custom shard naming strategies 338 346 339 - // Sourcegraph specific: We use IDs in shard names on multi-tenant 340 - // instances to prevent conflicts. 341 - if tenant.UseIDBasedShardNames() { 342 - prefix = fmt.Sprintf("%09d_%09d", o.RepositoryDescription.TenantID, o.RepositoryDescription.ID) 343 - } else { 344 - prefix = o.RepositoryDescription.Name 347 + if prefix == "" { 348 + // Sourcegraph specific: We use IDs in shard names on multi-tenant 349 + // instances to prevent conflicts. 350 + if tenant.UseIDBasedShardNames() { 351 + prefix = fmt.Sprintf("%09d_%09d", o.RepositoryDescription.TenantID, o.RepositoryDescription.ID) 352 + } else { 353 + prefix = o.RepositoryDescription.Name 354 + } 345 355 } 346 356 347 357 return shardName(o.IndexDir, prefix, version, n)