mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Rename WithCache functions as WithOptions
Where they now have 2 or more extra parameters.
This commit is contained in:
parent
1aaabfee2d
commit
0bc8438f38
|
@ -322,11 +322,11 @@ type Block struct {
|
||||||
// OpenBlock opens the block in the directory. It can be passed a chunk pool, which is used
|
// OpenBlock opens the block in the directory. It can be passed a chunk pool, which is used
|
||||||
// to instantiate chunk structs.
|
// to instantiate chunk structs.
|
||||||
func OpenBlock(logger log.Logger, dir string, pool chunkenc.Pool) (pb *Block, err error) {
|
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.
|
// OpenBlockWithOptions is like OpenBlock but allows to pass a cache provider and sharding function.
|
||||||
func OpenBlockWithCache(logger log.Logger, dir string, pool chunkenc.Pool, cache index.ReaderCacheProvider, shardFunc func(l labels.Labels) uint64) (pb *Block, err error) {
|
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 {
|
if logger == nil {
|
||||||
logger = log.NewNopLogger()
|
logger = log.NewNopLogger()
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ func OpenBlockWithCache(logger log.Logger, dir string, pool chunkenc.Pool, cache
|
||||||
}
|
}
|
||||||
closers = append(closers, cr)
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1455,7 +1455,7 @@ func openBlocks(l log.Logger, dir string, loaded []*Block, chunkPool chunkenc.Po
|
||||||
cacheProvider = cache.GetBlockCacheProvider(meta.ULID.String())
|
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 {
|
if err != nil {
|
||||||
corrupted[meta.ULID] = err
|
corrupted[meta.ULID] = err
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -1132,11 +1132,11 @@ func NewReaderWithCache(b ByteSlice, cacheProvider ReaderCacheProvider) (*Reader
|
||||||
|
|
||||||
// NewFileReader returns a new index reader against the given index file.
|
// NewFileReader returns a new index reader against the given index file.
|
||||||
func NewFileReader(path string) (*Reader, error) {
|
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.
|
// NewFileReaderWithOptions is like NewFileReader but allows to pass a cache provider and sharding function.
|
||||||
func NewFileReaderWithCache(path string, cacheProvider ReaderCacheProvider, shardFunc func(l labels.Labels) uint64) (*Reader, error) {
|
func NewFileReaderWithOptions(path string, cacheProvider ReaderCacheProvider, shardFunc func(l labels.Labels) uint64) (*Reader, error) {
|
||||||
f, err := fileutil.OpenMmapFile(path)
|
f, err := fileutil.OpenMmapFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -249,7 +249,7 @@ func TestIndexRW_Postings(t *testing.T) {
|
||||||
cache = hashcache.NewSeriesHashCache(1024 * 1024 * 1024).GetBlockCacheProvider("test")
|
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)
|
require.NoError(t, err)
|
||||||
|
|
||||||
// List all postings for a given label value. This is what we expect to get
|
// 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.
|
// 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)
|
require.NoError(b, err)
|
||||||
|
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
|
|
|
@ -271,7 +271,7 @@ func BenchmarkQuerierSelect(b *testing.B) {
|
||||||
|
|
||||||
seriesHashCache := hashcache.NewSeriesHashCache(1024 * 1024 * 1024)
|
seriesHashCache := hashcache.NewSeriesHashCache(1024 * 1024 * 1024)
|
||||||
blockdir := createBlockFromHead(b, tmpdir, h)
|
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)
|
require.NoError(b, err)
|
||||||
defer func() {
|
defer func() {
|
||||||
require.NoError(b, block.Close())
|
require.NoError(b, block.Close())
|
||||||
|
|
Loading…
Reference in a new issue