Rename WithCache functions as WithOptions

Where they now have 2 or more extra parameters.
This commit is contained in:
Bryan Boreham 2022-12-09 14:32:39 +00:00
parent 1aaabfee2d
commit 0bc8438f38
5 changed files with 11 additions and 11 deletions

View file

@ -322,11 +322,11 @@ type Block struct {
// OpenBlock opens the block in the directory. It can be passed a chunk pool, which is used
// to instantiate chunk structs.
func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (pb *Block, err error) {
return OpenBlockWithCache(logger, dir, pool, nil, nil)
return OpenBlockWithOptions(logger, dir, pool, nil, nil)
}
// OpenBlockWithCache is like OpenBlock but allows to pass a cache provider.
func OpenBlockWithCache(logger log.Logger, dir string, pool chunkenc.Pool, cache index.ReaderCacheProvider, shardFunc func(l labels.Labels) uint64) (pb *Block, err error) {
// OpenBlockWithOptions is like OpenBlock but allows to pass a cache provider and sharding function.
func OpenBlockWithOptions(logger log.Logger, dir string, pool chunkenc.Pool, cache index.ReaderCacheProvider, shardFunc func(l labels.Labels) uint64) (pb *Block, err error) {
if logger == nil {
logger = log.NewNopLogger()
}
@ -347,7 +347,7 @@ func OpenBlockWithCache(logger log.Logger, dir string, pool chunkenc.Pool, cache
}
closers = append(closers, cr)
indexReader, err := index.NewFileReaderWithCache(filepath.Join(dir, indexFilename), cache, shardFunc)
indexReader, err := index.NewFileReaderWithOptions(filepath.Join(dir, indexFilename), cache, shardFunc)
if err != nil {
return nil, err
}

View file

@ -1455,7 +1455,7 @@ func openBlocks(l log.Logger, dir string, loaded []*Block, chunkPool chunkenc.Po
cacheProvider = cache.GetBlockCacheProvider(meta.ULID.String())
}
block, err = OpenBlockWithCache(l, bDir, chunkPool, cacheProvider, shardFunc)
block, err = OpenBlockWithOptions(l, bDir, chunkPool, cacheProvider, shardFunc)
if err != nil {
corrupted[meta.ULID] = err
continue

View file

@ -1132,11 +1132,11 @@ func NewReaderWithCache(b ByteSlice, cacheProvider ReaderCacheProvider) (*Reader
// NewFileReader returns a new index reader against the given index file.
func NewFileReader(path string) (*Reader, error) {
return NewFileReaderWithCache(path, nil, nil)
return NewFileReaderWithOptions(path, nil, nil)
}
// NewFileReaderWithCache is like NewFileReader but allows to pass a cache provider.
func NewFileReaderWithCache(path string, cacheProvider ReaderCacheProvider, shardFunc func(l labels.Labels) uint64) (*Reader, error) {
// NewFileReaderWithOptions is like NewFileReader but allows to pass a cache provider and sharding function.
func NewFileReaderWithOptions(path string, cacheProvider ReaderCacheProvider, shardFunc func(l labels.Labels) uint64) (*Reader, error) {
f, err := fileutil.OpenMmapFile(path)
if err != nil {
return nil, err

View file

@ -249,7 +249,7 @@ func TestIndexRW_Postings(t *testing.T) {
cache = hashcache.NewSeriesHashCache(1024 * 1024 * 1024).GetBlockCacheProvider("test")
}
ir, err := NewFileReaderWithCache(fn, cache, func(l labels.Labels) uint64 { return l.Hash() })
ir, err := NewFileReaderWithOptions(fn, cache, func(l labels.Labels) uint64 { return l.Hash() })
require.NoError(t, err)
// List all postings for a given label value. This is what we expect to get
@ -646,7 +646,7 @@ func BenchmarkReader_ShardedPostings(b *testing.B) {
}
// Create a reader to read back all postings from the index.
ir, err := NewFileReaderWithCache(fn, cache, func(l labels.Labels) uint64 { return l.Hash() })
ir, err := NewFileReaderWithOptions(fn, cache, func(l labels.Labels) uint64 { return l.Hash() })
require.NoError(b, err)
b.ResetTimer()

View file

@ -271,7 +271,7 @@ func BenchmarkQuerierSelect(b *testing.B) {
seriesHashCache := hashcache.NewSeriesHashCache(1024 * 1024 * 1024)
blockdir := createBlockFromHead(b, tmpdir, h)
block, err := OpenBlockWithCache(nil, blockdir, nil, seriesHashCache.GetBlockCacheProvider("test"), func(l labels.Labels) uint64 { return l.Hash() })
block, err := OpenBlockWithOptions(nil, blockdir, nil, seriesHashCache.GetBlockCacheProvider("test"), func(l labels.Labels) uint64 { return l.Hash() })
require.NoError(b, err)
defer func() {
require.NoError(b, block.Close())