pkoracle

package
v0.10.3-0...-930112e Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

pkoracle package contains pk - segment mapping logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BloomFilterSet

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

BloomFilterSet is one implementation of Candidate with bloom filter in statslog.

func NewBloomFilterSet

func NewBloomFilterSet(segmentID int64, paritionID int64, segType commonpb.SegmentState) *BloomFilterSet

NewBloomFilterSet returns a new BloomFilterSet.

func (*BloomFilterSet) AddHistoricalStats

func (s *BloomFilterSet) AddHistoricalStats(stats *storage.PkStatistics)

AddHistoricalStats add loaded historical stats.

func (*BloomFilterSet) BatchPkExist

func (s *BloomFilterSet) BatchPkExist(lc *storage.BatchLocationsCache) []bool

func (*BloomFilterSet) ID

func (s *BloomFilterSet) ID() int64

ID implement candidate.

func (*BloomFilterSet) MayPkExist

func (s *BloomFilterSet) MayPkExist(lc *storage.LocationsCache) bool

MayPkExist returns whether any bloom filters returns positive.

func (*BloomFilterSet) Partition

func (s *BloomFilterSet) Partition() int64

Partition implements candidate.

func (*BloomFilterSet) Type

Type implements candidate.

func (*BloomFilterSet) UpdateBloomFilter

func (s *BloomFilterSet) UpdateBloomFilter(pks []storage.PrimaryKey)

UpdateBloomFilter updates currentStats with provided pks.

type Candidate

type Candidate interface {
	// MayPkExist checks whether primary key could exists in this candidate.
	MayPkExist(lc *storage.LocationsCache) bool
	BatchPkExist(lc *storage.BatchLocationsCache) []bool

	ID() int64
	Partition() int64
	Type() commonpb.SegmentState
}

Candidate is the interface for pk oracle candidate.

func NewCandidateKey

func NewCandidateKey(id int64, partitionID int64, typ commonpb.SegmentState) Candidate

NewCandidateKey creates a candidateKey and returns as Candidate.

type CandidateFilter

type CandidateFilter func(candidate candidateWithWorker) bool

CandidateFilter filter type for candidate.

func WithPartitionID

func WithPartitionID(partitionID int64) CandidateFilter

WithPartitionID returns CandidateFilter with provided partitionID.

func WithSegmentIDs

func WithSegmentIDs(segmentIDs ...int64) CandidateFilter

WithSegmentIDs returns CandidateFilter with provided segment ids.

func WithSegmentType

func WithSegmentType(typ commonpb.SegmentState) CandidateFilter

WithSegmentType returns CandiateFilter with provided segment type.

func WithWorkerID

func WithWorkerID(workerID int64) CandidateFilter

WithWorkerID returns CandidateFilter with provided worker id.

type PkOracle

type PkOracle interface {
	// GetCandidates returns segment candidates of which pk might belongs to.
	Get(pk storage.PrimaryKey, filters ...CandidateFilter) ([]int64, error)
	BatchGet(pks []storage.PrimaryKey, filters ...CandidateFilter) map[int64][]bool
	// RegisterCandidate adds candidate into pkOracle.
	Register(candidate Candidate, workerID int64) error
	// RemoveCandidate removes candidate
	Remove(filters ...CandidateFilter) error
	// CheckCandidate checks whether candidate with provided key exists.
	Exists(candidate Candidate, workerID int64) bool
}

PkOracle interface for pk oracle.

func NewPkOracle

func NewPkOracle() PkOracle

NewPkOracle returns pkOracle as PkOracle interface.

Jump to

Keyboard shortcuts

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