RepoStats: set default shard count to 1
Currently, Zoekt always reports 0 shards even if a repository has more
than 1 shard.
The reason is that `shardedSeacher.List` aggregates stats by calling
`Stats.Add` while looping over shards. However, since shards have a
default shard count of 0, the shard count never changes.
Change-Id: I06ca00952240a21cd27581055169683366562be8
diff --git a/index_test.go b/index_test.go
index d731444..c8f987f 100644
--- a/index_test.go
+++ b/index_test.go
@@ -1087,6 +1087,9 @@
if len(res.Repos) != 1 || res.Repos[0].Repository.Name != "reponame" {
t.Fatalf("got %v, want 1 matches", res)
}
+ if got := res.Repos[0].Stats.Shards; got != 1 {
+ t.Fatalf("got %d, want 1 shard", got)
+ }
q = &query.Repo{Pattern: "bla"}
res, err = searcher.List(context.Background(), q)
if err != nil {
diff --git a/indexdata.go b/indexdata.go
index 6c02cd5..7072951 100644
--- a/indexdata.go
+++ b/indexdata.go
@@ -104,6 +104,7 @@
IndexBytes: int64(d.memoryUse()),
ContentBytes: int64(int(last) + int(lastFN)),
Documents: len(d.newlinesIndex) - 1,
+ Shards: 1,
}
d.repoListEntry = RepoListEntry{
Repository: d.repoMetaData,