block

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2025 License: AGPL-3.0 Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirNameSegment    = "segments"
	DirNameBlock      = "blocks"
	DirNameDLQ        = "dlq"
	DirNameAnonTenant = tenant.DefaultTenantID

	FileNameProfilesParquet = "profiles.parquet"
	FileNameDataObject      = "block.bin"
	FileNameMetadataObject  = "meta.pb"
)

Variables

View Source
var (
	ErrNoBlocksToMerge    = fmt.Errorf("no blocks to merge")
	ErrShardMergeMismatch = fmt.Errorf("only blocks from the same shard can be merged")
)

Functions

func BuildObjectPath

func BuildObjectPath(tenant string, shard uint32, level uint32, block string) string

func Compact

func Compact(
	ctx context.Context,
	blocks []*metastorev1.BlockMeta,
	storage objstore.Bucket,
	options ...CompactionOption,
) (m []*metastorev1.BlockMeta, err error)

func MetadataDLQObjectPath

func MetadataDLQObjectPath(md *metastorev1.BlockMeta) string

func NewMergeRowProfileIterator

func NewMergeRowProfileIterator(src []*Dataset) (iter.Iterator[ProfileEntry], error)

func NewProfileRowIterator

func NewProfileRowIterator(s *Dataset) (iter.Iterator[ProfileEntry], error)

func ObjectPath

func ObjectPath(md *metastorev1.BlockMeta) string

Types

type CompactionOption

type CompactionOption func(*compactionConfig)

func WithCompactionDestination

func WithCompactionDestination(storage objstore.Bucket) CompactionOption

func WithCompactionObjectOptions

func WithCompactionObjectOptions(options ...ObjectOption) CompactionOption

func WithCompactionTempDir

func WithCompactionTempDir(tempdir string) CompactionOption

func WithSampleObserver added in v1.13.0

func WithSampleObserver(observer SampleObserver) CompactionOption

type CompactionPlan

type CompactionPlan struct {
	// contains filtered or unexported fields
}

func PlanCompaction

func PlanCompaction(objects Objects) ([]*CompactionPlan, error)

func (*CompactionPlan) Compact

func (b *CompactionPlan) Compact(
	ctx context.Context,
	dst objstore.Bucket,
	tempdir string,
	observer SampleObserver,
) (m *metastorev1.BlockMeta, err error)

type Dataset

type Dataset struct {
	// contains filtered or unexported fields
}

func NewDataset

func NewDataset(meta *metastorev1.Dataset, obj *Object) *Dataset

func (*Dataset) Close

func (s *Dataset) Close() error

func (*Dataset) CloseWithError

func (s *Dataset) CloseWithError(err error) (closeErr error)

CloseWithError closes the dataset and disposes all the resources associated with it.

Any further attempts to open the dataset will return the provided error.

func (*Dataset) Index

func (s *Dataset) Index() phlaredb.IndexReader

func (*Dataset) Metadata added in v1.13.0

func (s *Dataset) Metadata() *metastorev1.Dataset

func (*Dataset) Name added in v1.13.0

func (s *Dataset) Name() string

func (*Dataset) Open

func (s *Dataset) Open(ctx context.Context, sections ...Section) error

Open opens the dataset, initializing the sections specified.

Open may be called multiple times concurrently, but the dataset is only initialized once. While it is possible to open the dataset repeatedly after close, the caller must pass the failure reason to the CloseWithError call, preventing further use, if applicable.

func (*Dataset) ProfileRowReader

func (s *Dataset) ProfileRowReader() parquet.RowReader

func (*Dataset) Profiles

func (s *Dataset) Profiles() *ParquetFile

func (*Dataset) Symbols

func (s *Dataset) Symbols() symdb.SymbolsReader

func (*Dataset) TenantID added in v1.13.0

func (s *Dataset) TenantID() string

type DatasetFormat added in v1.13.0

type DatasetFormat uint32
const (
	DatasetFormat0 DatasetFormat = iota
	DatasetFormat1
)

type DatasetOption

type DatasetOption func(*Dataset)

func WithDatasetMaxSizeLoadInMemory

func WithDatasetMaxSizeLoadInMemory(size int) DatasetOption

type DedupeProfileRowIterator

type DedupeProfileRowIterator struct {
	iter.Iterator[ProfileEntry]
	// contains filtered or unexported fields
}

func (*DedupeProfileRowIterator) Next

func (it *DedupeProfileRowIterator) Next() bool

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object represents a block or a segment in the object storage.

func NewObject

func NewObject(storage objstore.Bucket, md *metastorev1.BlockMeta, opts ...ObjectOption) *Object

func (*Object) Close

func (obj *Object) Close() error

func (*Object) CloseWithError

func (obj *Object) CloseWithError(err error) (closeErr error)

CloseWithError closes the object, releasing all the acquired resources, once the last reference is released. If the provided error is not nil, the object will be marked as failed, preventing any further use.

func (*Object) Download

func (obj *Object) Download(ctx context.Context) error

func (*Object) IsNotExists added in v1.13.0

func (obj *Object) IsNotExists(err error) bool

func (*Object) Metadata added in v1.13.0

func (obj *Object) Metadata() *metastorev1.BlockMeta

func (*Object) Open

func (obj *Object) Open(ctx context.Context) error

Open opens the object, loading the data into memory if it's small enough.

Open may be called multiple times concurrently, but the object is only initialized once. While it is possible to open the object repeatedly after close, the caller must pass the failure reason to the "CloseWithError" call, preventing further use, if applicable.

func (*Object) ReadMetadata added in v1.13.0

func (obj *Object) ReadMetadata(ctx context.Context) (*metastorev1.BlockMeta, error)

ReadMetadata fetches the full block metadata from the storage. It the object does not include the metadata offset, the method returns the metadata entry the object was opened with.

func (*Object) SetMetadata added in v1.13.0

func (obj *Object) SetMetadata(md *metastorev1.BlockMeta)

type ObjectOption

type ObjectOption func(*Object)

func WithObjectDownload

func WithObjectDownload(dir string) ObjectOption

func WithObjectMaxSizeLoadInMemory

func WithObjectMaxSizeLoadInMemory(size int) ObjectOption

func WithObjectPath

func WithObjectPath(path string) ObjectOption

type Objects

type Objects []*Object

func ObjectsFromMetas

func ObjectsFromMetas(storage objstore.Bucket, blocks []*metastorev1.BlockMeta, options ...ObjectOption) Objects

ObjectsFromMetas binds block metas to corresponding objects in the storage.

func (Objects) Close

func (s Objects) Close() error

func (Objects) Open

func (s Objects) Open(ctx context.Context) error

type ParquetFile

type ParquetFile struct {
	*parquet.File
	// contains filtered or unexported fields
}

func (*ParquetFile) Close

func (f *ParquetFile) Close() error

func (*ParquetFile) Column

func (f *ParquetFile) Column(ctx context.Context, columnName string, predicate query.Predicate) query.Iterator

func (*ParquetFile) RowReader

func (f *ParquetFile) RowReader() parquet.RowReader

type ProfileEntry

type ProfileEntry struct {
	Dataset *Dataset

	Timestamp   int64
	Fingerprint model.Fingerprint
	Labels      phlaremodel.Labels
	Row         schemav1.ProfileRow
}

type SampleObserver added in v1.13.0

type SampleObserver interface {
	symdb.SymbolsObserver

	// Evaluate is called before the compactor rewrites any symbols.
	// An "observe" callback function is returned to be called after writing the resulting blocks.
	// This method must not modify the entry.
	Evaluate(ProfileEntry) (observe func())
}

type Section

type Section uint32
const (
	SectionProfiles Section = iota
	SectionTSDB
	SectionSymbols
	SectionDatasetIndex
)

type ULIDGenerator

type ULIDGenerator struct {
	// contains filtered or unexported fields
}

ULIDGenerator generates deterministic ULIDs for blocks in an idempotent way: for the same set of objects, the generator will always produce the same set of ULIDs.

We require block identifiers to be deterministic to ensure deduplication of the blocks.

func NewULIDGenerator

func NewULIDGenerator(objects Objects) *ULIDGenerator

func (*ULIDGenerator) ULID

func (g *ULIDGenerator) ULID() ulid.ULID

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func NewBlockWriter

func NewBlockWriter(tmpdir string) (*Writer, error)

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Offset

func (w *Writer) Offset() uint64

func (*Writer) Upload added in v1.13.0

func (w *Writer) Upload(ctx context.Context, bucket objstore.Bucket, path string) error

func (*Writer) Write added in v1.13.0

func (w *Writer) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL