state

package
v0.10.3-0...-f06509b Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoadStateOnlyMeta    loadStateEnum = iota
	LoadStateDataLoading               // There will be only one goroutine access segment when loading.
	LoadStateDataLoaded
	LoadStateDataReleasing // There will be only one goroutine access segment when releasing.
	LoadStateReleased
)

LoadState represent the state transition of segment. LoadStateOnlyMeta: segment is created with meta, but not loaded. LoadStateDataLoading: segment is loading data. LoadStateDataLoaded: segment is full loaded, ready to be searched or queried. LoadStateDataReleasing: segment is releasing data. LoadStateReleased: segment is released. LoadStateOnlyMeta -> LoadStateDataLoading -> LoadStateDataLoaded -> LoadStateDataReleasing -> (LoadStateReleased or LoadStateOnlyMeta)

Variables

This section is empty.

Functions

func IsDataLoaded

func IsDataLoaded(state loadStateEnum) bool

IsDataLoaded checks if the segment is loaded.

func IsNotReleased

func IsNotReleased(state loadStateEnum) bool

IsNotReleased checks if the segment is not released.

Types

type LoadStateLock

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

LoadStateLock is the state of segment loading.

func NewLoadStateLock

func NewLoadStateLock(state loadStateEnum) *LoadStateLock

NewLoadStateLock creates a LoadState.

func (*LoadStateLock) PinIfNotReleased

func (ls *LoadStateLock) PinIfNotReleased() bool

PinIfNotReleased pin the segment into memory, avoid ReleaseAll to release it.

func (*LoadStateLock) RLockIf

func (ls *LoadStateLock) RLockIf(pred StatePredicate) bool

RLockIfNotReleased locks the segment if the state is not released.

func (*LoadStateLock) RUnlock

func (ls *LoadStateLock) RUnlock()

RUnlock unlocks the segment.

func (*LoadStateLock) StartLoadData

func (ls *LoadStateLock) StartLoadData() (LoadStateLockGuard, error)

StartLoadData starts load segment data Fast fail if segment is not in LoadStateOnlyMeta.

func (*LoadStateLock) StartReleaseAll

func (ls *LoadStateLock) StartReleaseAll() (g LoadStateLockGuard)

StartReleaseAll wait until the segment is releasable and starts releasing all segment.

func (*LoadStateLock) StartReleaseData

func (ls *LoadStateLock) StartReleaseData() (g LoadStateLockGuard)

StartReleaseData wait until the segment is releasable and starts releasing segment data.

func (*LoadStateLock) Unpin

func (ls *LoadStateLock) Unpin()

Unpin unpin the segment, then segment can be released by ReleaseAll.

type LoadStateLockGuard

type LoadStateLockGuard interface {
	Done(err error)
}

type StatePredicate

type StatePredicate func(state loadStateEnum) bool

Jump to

Keyboard shortcuts

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