Documentation ¶
Index ¶
- Constants
- func LoadBlocksDirIntoCache(paths []string, c Cache, logger log.Logger) error
- func ParseTime(s string) (model.Time, error)
- type Block
- type BlockClient
- type BlockDirectory
- type BlockRef
- type BlocksCache
- func (c *BlocksCache) Get(ctx context.Context, key string) (BlockDirectory, bool)
- func (c *BlocksCache) Put(ctx context.Context, key string, value BlockDirectory) error
- func (c *BlocksCache) PutInc(ctx context.Context, key string, value BlockDirectory) error
- func (c *BlocksCache) PutMany(ctx context.Context, keys []string, values []BlockDirectory) error
- func (c *BlocksCache) Release(ctx context.Context, key string) error
- func (c *BlocksCache) Stop()
- type BloomClient
- func (b *BloomClient) DeleteBlocks(ctx context.Context, references []BlockRef) error
- func (b *BloomClient) DeleteMetas(ctx context.Context, refs []MetaRef) error
- func (b *BloomClient) GetBlock(ctx context.Context, ref BlockRef) (BlockDirectory, error)
- func (b *BloomClient) GetBlocks(ctx context.Context, refs []BlockRef) ([]BlockDirectory, error)
- func (b *BloomClient) GetMeta(ctx context.Context, ref MetaRef) (Meta, error)
- func (b *BloomClient) GetMetas(ctx context.Context, refs []MetaRef) ([]Meta, error)
- func (b *BloomClient) IsObjectNotFoundErr(err error) bool
- func (b *BloomClient) ObjectClient() client.ObjectClient
- func (b *BloomClient) PutBlock(ctx context.Context, block Block) error
- func (b *BloomClient) PutMeta(ctx context.Context, meta Meta) error
- func (b *BloomClient) Stop()
- type BloomStore
- func (b *BloomStore) Allocator() mempool.Allocator
- func (b *BloomStore) Block(ref BlockRef) (loc Location)
- func (b *BloomStore) BloomMetrics() *v1.Metrics
- func (b *BloomStore) Client(ts model.Time) (Client, error)
- func (b *BloomStore) FetchBlocks(ctx context.Context, blocks []BlockRef, opts ...FetchOption) ([]*CloseableBlockQuerier, error)
- func (b *BloomStore) FetchMetas(ctx context.Context, params MetaSearchParams) ([]Meta, error)
- func (b *BloomStore) Fetcher(ts model.Time) (*Fetcher, error)
- func (b *BloomStore) Meta(ref MetaRef) (loc Location)
- func (BloomStore) ParseBlockKey(loc Location) (BlockRef, error)
- func (BloomStore) ParseMetaKey(loc Location) (MetaRef, error)
- func (b *BloomStore) ResolveMetas(ctx context.Context, params MetaSearchParams) ([][]MetaRef, []*Fetcher, error)
- func (b *BloomStore) Stop()
- func (BloomStore) Tenant(tenant, table string) Location
- func (b *BloomStore) TenantFilesForInterval(ctx context.Context, interval Interval, ...) (map[string][]client.StorageObject, error)
- func (BloomStore) TenantPrefix(loc Location) (string, error)
- type Cache
- type Client
- type ClosableReadSeekerAdapter
- type CloseableBlockQuerier
- type Entry
- type FetchOption
- type Fetcher
- type ForEachBlockCallback
- type Interface
- type Interval
- type KeyResolver
- type Location
- type Meta
- type MetaClient
- type MetaRef
- type MetaSearchParams
- type PrefixedResolver
- type Ref
- type ShardedPrefixedResolver
- type Shipper
- type Store
- type StoreBase
Constants ¶
const ( BloomPrefix = "bloom" MetasPrefix = "metas" BlocksPrefix = "blocks" )
Variables ¶
This section is empty.
Functions ¶
func LoadBlocksDirIntoCache ¶
Types ¶
type Block ¶
type Block struct { BlockRef Data io.ReadSeekCloser }
type BlockClient ¶
type BlockDirectory ¶
A BlockDirectory is a local file path that contains a bloom block. It maintains a counter for currently active readers.
func NewBlockDirectory ¶
func NewBlockDirectory(ref BlockRef, path string) BlockDirectory
NewBlockDirectory creates a new BlockDirectory. Must exist on disk.
func (BlockDirectory) BlockQuerier ¶
func (b BlockDirectory) BlockQuerier( alloc mempool.Allocator, close func() error, maxPageSize int, metrics *v1.Metrics, ) *CloseableBlockQuerier
BlockQuerier returns a new block querier from the directory. The passed function `close` is called when the the returned querier is closed.
func (BlockDirectory) Size ¶
func (b BlockDirectory) Size() int64
type BlockRef ¶
type BlockRef struct { Ref compression.Codec }
func BlockRefFromKey ¶ added in v3.1.0
func BlocksForMetas ¶
func BlocksForMetas(metas []Meta, interval Interval, keyspaces []v1.FingerprintBounds) (refs []BlockRef)
BlocksForMetas returns all the blocks from all the metas listed that are within the requested bounds
type BlocksCache ¶
type BlocksCache struct {
// contains filtered or unexported fields
}
BlocksCache is an in-memory cache that manages block directories on the filesystem.
func NewFsBlocksCache ¶
func NewFsBlocksCache(cfg config.BlocksCacheConfig, reg prometheus.Registerer, logger log.Logger) *BlocksCache
NewFsBlocksCache returns a new file-system mapping cache for bloom blocks, where entries map block directories on disk.
func (*BlocksCache) Get ¶
func (c *BlocksCache) Get(ctx context.Context, key string) (BlockDirectory, bool)
Get implements Cache. Get returns the stored value against the given key.
func (*BlocksCache) Put ¶
func (c *BlocksCache) Put(ctx context.Context, key string, value BlockDirectory) error
Put implements Cache. It stores a value with given key.
func (*BlocksCache) PutInc ¶
func (c *BlocksCache) PutInc(ctx context.Context, key string, value BlockDirectory) error
PutInc implements Cache. It stores a value with given key and increments the ref counter on that item.
func (*BlocksCache) PutMany ¶
func (c *BlocksCache) PutMany(ctx context.Context, keys []string, values []BlockDirectory) error
PutMany implements Cache.
type BloomClient ¶
type BloomClient struct { KeyResolver // contains filtered or unexported fields }
func NewBloomClient ¶
func NewBloomClient(cfg bloomStoreConfig, client client.ObjectClient, logger log.Logger) (*BloomClient, error)
func (*BloomClient) DeleteBlocks ¶
func (b *BloomClient) DeleteBlocks(ctx context.Context, references []BlockRef) error
func (*BloomClient) DeleteMetas ¶
func (b *BloomClient) DeleteMetas(ctx context.Context, refs []MetaRef) error
func (*BloomClient) GetBlock ¶
func (b *BloomClient) GetBlock(ctx context.Context, ref BlockRef) (BlockDirectory, error)
GetBlock downloads the blocks from objectStorage and returns the directory in which the block data resides
func (*BloomClient) GetBlocks ¶
func (b *BloomClient) GetBlocks(ctx context.Context, refs []BlockRef) ([]BlockDirectory, error)
func (*BloomClient) GetMeta ¶
GetMeta fetches the meta file for given MetaRef from object storage and decodes the JSON data into a Meta. If the meta file is not found in storage or decoding fails, the empty Meta is returned along with the error.
func (*BloomClient) IsObjectNotFoundErr ¶
func (b *BloomClient) IsObjectNotFoundErr(err error) bool
func (*BloomClient) ObjectClient ¶
func (b *BloomClient) ObjectClient() client.ObjectClient
func (*BloomClient) PutBlock ¶
func (b *BloomClient) PutBlock(ctx context.Context, block Block) error
func (*BloomClient) Stop ¶
func (b *BloomClient) Stop()
type BloomStore ¶
type BloomStore struct {
// contains filtered or unexported fields
}
func NewBloomStore ¶
func NewBloomStore( periodicConfigs []config.PeriodConfig, storageConfig storage.Config, clientMetrics storage.ClientMetrics, metasCache cache.Cache, blocksCache Cache, allocator mempool.Allocator, reg prometheus.Registerer, logger log.Logger, ) (*BloomStore, error)
func (*BloomStore) Allocator ¶ added in v3.2.0
func (b *BloomStore) Allocator() mempool.Allocator
Allocator implements Store.
func (*BloomStore) Block ¶
func (b *BloomStore) Block(ref BlockRef) (loc Location)
Impements KeyResolver
func (*BloomStore) BloomMetrics ¶
func (b *BloomStore) BloomMetrics() *v1.Metrics
func (*BloomStore) Client ¶
func (b *BloomStore) Client(ts model.Time) (Client, error)
Client implements Store.
func (*BloomStore) FetchBlocks ¶
func (b *BloomStore) FetchBlocks(ctx context.Context, blocks []BlockRef, opts ...FetchOption) ([]*CloseableBlockQuerier, error)
FetchBlocks implements Store.
func (*BloomStore) FetchMetas ¶
func (b *BloomStore) FetchMetas(ctx context.Context, params MetaSearchParams) ([]Meta, error)
FetchMetas implements Store.
func (*BloomStore) Fetcher ¶
func (b *BloomStore) Fetcher(ts model.Time) (*Fetcher, error)
Fetcher implements Store.
func (*BloomStore) Meta ¶
func (b *BloomStore) Meta(ref MetaRef) (loc Location)
Impements KeyResolver
func (BloomStore) ParseBlockKey ¶
func (BloomStore) ParseMetaKey ¶
func (*BloomStore) ResolveMetas ¶
func (b *BloomStore) ResolveMetas(ctx context.Context, params MetaSearchParams) ([][]MetaRef, []*Fetcher, error)
ResolveMetas implements Store.
func (*BloomStore) TenantFilesForInterval ¶
func (b *BloomStore) TenantFilesForInterval( ctx context.Context, interval Interval, filter func(tenant string, object client.StorageObject) bool, ) (map[string][]client.StorageObject, error)
func (BloomStore) TenantPrefix ¶
type Cache ¶
type Cache interface { Put(ctx context.Context, key string, value BlockDirectory) error PutInc(ctx context.Context, key string, value BlockDirectory) error PutMany(ctx context.Context, keys []string, values []BlockDirectory) error Get(ctx context.Context, key string) (BlockDirectory, bool) Release(ctx context.Context, key string) error Stop() }
type Client ¶
type Client interface { MetaClient BlockClient IsObjectNotFoundErr(err error) bool ObjectClient() client.ObjectClient Stop() }
type ClosableReadSeekerAdapter ¶
type ClosableReadSeekerAdapter struct {
io.ReadSeeker
}
CloseableReadSeekerAdapter is a wrapper around io.ReadSeeker to make it io.Closer if it doesn't already implement it.
func (ClosableReadSeekerAdapter) Close ¶
func (c ClosableReadSeekerAdapter) Close() error
type CloseableBlockQuerier ¶
type CloseableBlockQuerier struct { BlockRef *v1.BlockQuerier // contains filtered or unexported fields }
func (*CloseableBlockQuerier) Close ¶
func (c *CloseableBlockQuerier) Close() error
func (*CloseableBlockQuerier) SeriesIter ¶
func (c *CloseableBlockQuerier) SeriesIter() (iter.PeekIterator[*v1.SeriesWithBlooms], error)
type Entry ¶
type Entry struct { Key string Value BlockDirectory // contains filtered or unexported fields }
type FetchOption ¶
type FetchOption func(opts *options)
func WithFetchAsync ¶
func WithFetchAsync(v bool) FetchOption
func WithIgnoreNotFound ¶
func WithIgnoreNotFound(v bool) FetchOption
func WithPool ¶
func WithPool(v mempool.Allocator) FetchOption
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
func NewFetcher ¶
func (*Fetcher) FetchBlocks ¶
func (f *Fetcher) FetchBlocks(ctx context.Context, refs []BlockRef, opts ...FetchOption) ([]*CloseableBlockQuerier, error)
FetchBlocks implements fetcher
type ForEachBlockCallback ¶
type ForEachBlockCallback func(bq *v1.BlockQuerier, bounds v1.FingerprintBounds) error
type Interval ¶
Interval defines a time range with start end end time where the start is inclusive, the end is non-inclusive.
func NewInterval ¶
func ParseIntervalFromAddr ¶
ParseBoundsFromAddr parses a fingerprint bounds from a string Does not support negative times (times prior to Unix epoch).
func ParseIntervalFromParts ¶
ParseIntervalFromParts parses a fingerprint bounds already separated strings
func (Interval) Cmp ¶
func (i Interval) Cmp(ts model.Time) v1.BoundsCheck
Cmp returns the position of a time relative to the interval
type KeyResolver ¶
type KeyResolver interface { Meta(MetaRef) Location ParseMetaKey(Location) (MetaRef, error) Block(BlockRef) Location ParseBlockKey(Location) (BlockRef, error) Tenant(tenant, table string) Location TenantPrefix(loc Location) (string, error) }
KeyResolver is an interface for resolving keys to locations. This is used to determine where items are stored in object storage _and_ on disk. Using an interface allows us to abstract away platform specifics (e.g. OS path-specifics, object storage difference, etc) TODO(owen-d): implement resolvers that schema-aware, allowing us to change the locations of data across schema boundaries (for instance to upgrade|improve).
func NewPrefixedResolver ¶
func NewPrefixedResolver(prefix string, resolver KeyResolver) KeyResolver
func NewShardedPrefixedResolver ¶
func NewShardedPrefixedResolver(prefixes []string, resolver KeyResolver) (KeyResolver, error)
type Meta ¶
type Meta struct { MetaRef `json:"-"` // The specific TSDB files used to generate the block. Sources []tsdb.SingleTenantTSDBIdentifier // A list of blocks that were generated Blocks []BlockRef }
todo rename it
func FilterMetasOverlappingBounds ¶ added in v3.1.0
func FilterMetasOverlappingBounds(metas []Meta, bounds v1.FingerprintBounds) []Meta
FilterMetasOverlappingBounds filters metas that are within the given bounds. the input metas are expected to be sorted by fingerprint.
func (Meta) MostRecentSource ¶
func (m Meta) MostRecentSource() (tsdb.SingleTenantTSDBIdentifier, bool)
type MetaClient ¶
type MetaRef ¶
type MetaRef struct {
Ref
}
func MetaRefFrom ¶
func MetaRefFrom( tenant, table string, bounds v1.FingerprintBounds, sources []tsdb.SingleTenantTSDBIdentifier, blocks []BlockRef, ) (MetaRef, error)
func MetaRefFromKey ¶ added in v3.1.0
type MetaSearchParams ¶
type MetaSearchParams struct { TenantID string Interval Interval Keyspace v1.FingerprintBounds }
type PrefixedResolver ¶
type PrefixedResolver struct { KeyResolver // contains filtered or unexported fields }
func (PrefixedResolver) Block ¶
func (p PrefixedResolver) Block(ref BlockRef) Location
func (PrefixedResolver) Meta ¶
func (p PrefixedResolver) Meta(ref MetaRef) Location
type Ref ¶
type Ref struct { TenantID string TableName string Bounds v1.FingerprintBounds StartTimestamp, EndTimestamp model.Time Checksum uint32 }
func (Ref) Cmp ¶
func (r Ref) Cmp(fp uint64) v1.BoundsCheck
Cmp returns the fingerprint's position relative to the bounds
type ShardedPrefixedResolver ¶
type ShardedPrefixedResolver struct { KeyResolver // contains filtered or unexported fields }
func (ShardedPrefixedResolver) Block ¶
func (r ShardedPrefixedResolver) Block(ref BlockRef) Location
func (ShardedPrefixedResolver) Meta ¶
func (r ShardedPrefixedResolver) Meta(ref MetaRef) Location
type Shipper ¶
type Shipper struct {
// contains filtered or unexported fields
}
func NewShipper ¶
type StoreBase ¶ added in v3.2.0
type StoreBase interface { ResolveMetas(ctx context.Context, params MetaSearchParams) ([][]MetaRef, []*Fetcher, error) FetchMetas(ctx context.Context, params MetaSearchParams) ([]Meta, error) FetchBlocks(ctx context.Context, refs []BlockRef, opts ...FetchOption) ([]*CloseableBlockQuerier, error) TenantFilesForInterval( ctx context.Context, interval Interval, filter func(tenant string, object client.StorageObject) bool, ) (map[string][]client.StorageObject, error) Fetcher(ts model.Time) (*Fetcher, error) Client(ts model.Time) (Client, error) Stop() }