diff --git a/block.go b/block.go index 42e11d951..3ed8c4a64 100644 --- a/block.go +++ b/block.go @@ -282,7 +282,7 @@ func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (*Block, error if err != nil { return nil, err } - ir, err := index.NewFileReader(filepath.Join(dir, "index")) + ir, err := index.NewFileReader(filepath.Join(dir, indexFilename)) if err != nil { return nil, err } diff --git a/index/index.go b/index/index.go index 74e08d465..ca33eac3f 100644 --- a/index/index.go +++ b/index/index.go @@ -45,6 +45,8 @@ const ( FormatV2 = 2 labelNameSeperator = "\xff" + + indexFilename = "index" ) type indexWriterSeries struct { diff --git a/index/index_test.go b/index/index_test.go index 2edd3956a..25c5be938 100644 --- a/index/index_test.go +++ b/index/index_test.go @@ -151,7 +151,7 @@ func TestIndexRW_Create_Open(t *testing.T) { testutil.Ok(t, err) defer os.RemoveAll(dir) - fn := filepath.Join(dir, "index") + fn := filepath.Join(dir, indexFilename) // An empty index must still result in a readable file. iw, err := NewWriter(fn) @@ -177,7 +177,7 @@ func TestIndexRW_Postings(t *testing.T) { testutil.Ok(t, err) defer os.RemoveAll(dir) - fn := filepath.Join(dir, "index") + fn := filepath.Join(dir, indexFilename) iw, err := NewWriter(fn) testutil.Ok(t, err) @@ -271,7 +271,7 @@ func TestPersistence_index_e2e(t *testing.T) { }) } - iw, err := NewWriter(filepath.Join(dir, "index")) + iw, err := NewWriter(filepath.Join(dir, indexFilename)) testutil.Ok(t, err) testutil.Ok(t, iw.AddSymbols(symbols)) @@ -331,7 +331,7 @@ func TestPersistence_index_e2e(t *testing.T) { err = iw.Close() testutil.Ok(t, err) - ir, err := NewFileReader(filepath.Join(dir, "index")) + ir, err := NewFileReader(filepath.Join(dir, indexFilename)) testutil.Ok(t, err) for p := range mi.postings { diff --git a/repair.go b/repair.go index 15f79d5f7..4aeffb554 100644 --- a/repair.go +++ b/repair.go @@ -64,7 +64,7 @@ func repairBadIndexVersion(logger log.Logger, dir string) error { if err != nil { return wrapErr(err, d) } - broken, err := os.Open(filepath.Join(d, "index")) + broken, err := os.Open(filepath.Join(d, indexFilename)) if err != nil { return wrapErr(err, d) } diff --git a/repair_test.go b/repair_test.go index 5fb780a5b..cbe21691e 100644 --- a/repair_test.go +++ b/repair_test.go @@ -30,7 +30,7 @@ func TestRepairBadIndexVersion(t *testing.T) { // at a broken revision. // // func main() { - // w, err := index.NewWriter("index") + // w, err := index.NewWriter(indexFilename) // if err != nil { // panic(err) // } @@ -72,7 +72,7 @@ func TestRepairBadIndexVersion(t *testing.T) { os.MkdirAll(filepath.Join(dbDir, "chunks"), 0777) defer os.RemoveAll(filepath.Join(dbDir, "chunks")) - r, err := index.NewFileReader(filepath.Join(dbDir, "index")) + r, err := index.NewFileReader(filepath.Join(dbDir, indexFilename)) testutil.Ok(t, err) p, err := r.Postings("b", "1") testutil.Ok(t, err) @@ -95,7 +95,7 @@ func TestRepairBadIndexVersion(t *testing.T) { testutil.Ok(t, err) db.Close() - r, err = index.NewFileReader(filepath.Join(tmpDbDir, "index")) + r, err = index.NewFileReader(filepath.Join(tmpDbDir, indexFilename)) testutil.Ok(t, err) p, err = r.Postings("b", "1") testutil.Ok(t, err)