cockroach: github.com/cockroachdb/cockroach/pkg/storage/spanset Index | Files

package spanset

import "github.com/cockroachdb/cockroach/pkg/storage/spanset"

Index

Package Files

batch.go merge.go spanset.go

func GetDBEngine Uses

func GetDBEngine(e engine.Reader, span roachpb.Span) engine.Reader

GetDBEngine recursively searches for the underlying rocksDB engine.

func NewBatch Uses

func NewBatch(b engine.Batch, spans *SpanSet) engine.Batch

NewBatch returns an engine.Batch that asserts access of the underlying Batch against the given SpanSet. We only consider span boundaries, associated timestamps are not considered.

func NewBatchAt Uses

func NewBatchAt(b engine.Batch, spans *SpanSet, ts hlc.Timestamp) engine.Batch

NewBatchAt returns an engine.Batch that asserts access of the underlying Batch against the given SpanSet at the given timestamp. If the zero timestamp is used, all accesses are considered non-MVCC.

func NewReadWriter Uses

func NewReadWriter(rw engine.ReadWriter, spans *SpanSet) engine.ReadWriter

NewReadWriter returns an engine.ReadWriter that asserts access of the underlying ReadWriter against the given SpanSet.

func NewReadWriterAt Uses

func NewReadWriterAt(rw engine.ReadWriter, spans *SpanSet, ts hlc.Timestamp) engine.ReadWriter

NewReadWriterAt returns an engine.ReadWriter that asserts access of the underlying ReadWriter against the given SpanSet at a given timestamp. If zero timestamp is provided, accesses are considered non-MVCC.

type Iterator Uses

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

Iterator wraps an engine.Iterator and ensures that it can only be used to access spans in a SpanSet.

func NewIterator Uses

func NewIterator(iter engine.Iterator, spans *SpanSet) *Iterator

NewIterator constructs an iterator that verifies access of the underlying iterator against the given SpanSet. Timestamps associated with the spans in the spanset are not considered, only the span boundaries are checked.

func NewIteratorAt Uses

func NewIteratorAt(iter engine.Iterator, spans *SpanSet, ts hlc.Timestamp) *Iterator

NewIteratorAt constructs an iterator that verifies access of the underlying iterator against the given SpanSet at the given timestamp.

func (*Iterator) CheckForKeyCollisions Uses

func (i *Iterator) CheckForKeyCollisions(
    sstData []byte, start, end roachpb.Key,
) (enginepb.MVCCStats, error)

CheckForKeyCollisions is part of the engine.Iterator interface.

func (*Iterator) Close Uses

func (i *Iterator) Close()

Close is part of the engine.Iterator interface.

func (*Iterator) ComputeStats Uses

func (i *Iterator) ComputeStats(
    start, end roachpb.Key, nowNanos int64,
) (enginepb.MVCCStats, error)

ComputeStats is part of the engine.Iterator interface.

func (*Iterator) FindSplitKey Uses

func (i *Iterator) FindSplitKey(
    start, end, minSplitKey roachpb.Key, targetSize int64,
) (engine.MVCCKey, error)

FindSplitKey is part of the engine.Iterator interface.

func (*Iterator) Iterator Uses

func (i *Iterator) Iterator() engine.Iterator

Iterator returns the underlying engine.Iterator.

func (*Iterator) Key Uses

func (i *Iterator) Key() engine.MVCCKey

Key is part of the engine.Iterator interface.

func (*Iterator) MVCCGet Uses

func (i *Iterator) MVCCGet(
    key roachpb.Key, timestamp hlc.Timestamp, opts engine.MVCCGetOptions,
) (*roachpb.Value, *roachpb.Intent, error)

MVCCGet is part of the engine.MVCCIterator interface.

func (*Iterator) MVCCOpsSpecialized Uses

func (i *Iterator) MVCCOpsSpecialized() bool

MVCCOpsSpecialized is part of the engine.MVCCIterator interface.

func (*Iterator) MVCCScan Uses

func (i *Iterator) MVCCScan(
    start, end roachpb.Key, max int64, timestamp hlc.Timestamp, opts engine.MVCCScanOptions,
) (kvData [][]byte, numKVs int64, resumeSpan *roachpb.Span, intents []roachpb.Intent, err error)

MVCCScan is part of the engine.MVCCIterator interface.

func (*Iterator) Next Uses

func (i *Iterator) Next()

Next is part of the engine.Iterator interface.

func (*Iterator) NextKey Uses

func (i *Iterator) NextKey()

NextKey is part of the engine.Iterator interface.

func (*Iterator) Prev Uses

func (i *Iterator) Prev()

Prev is part of the engine.Iterator interface.

func (*Iterator) SeekGE Uses

func (i *Iterator) SeekGE(key engine.MVCCKey)

SeekGE is part of the engine.Iterator interface.

func (*Iterator) SeekLT Uses

func (i *Iterator) SeekLT(key engine.MVCCKey)

SeekLT is part of the engine.Iterator interface.

func (*Iterator) SetUpperBound Uses

func (i *Iterator) SetUpperBound(key roachpb.Key)

SetUpperBound is part of the engine.Iterator interface.

func (*Iterator) Stats Uses

func (i *Iterator) Stats() engine.IteratorStats

Stats is part of the engine.Iterator interface.

func (*Iterator) UnsafeKey Uses

func (i *Iterator) UnsafeKey() engine.MVCCKey

UnsafeKey is part of the engine.Iterator interface.

func (*Iterator) UnsafeValue Uses

func (i *Iterator) UnsafeValue() []byte

UnsafeValue is part of the engine.Iterator interface.

func (*Iterator) Valid Uses

func (i *Iterator) Valid() (bool, error)

Valid is part of the engine.Iterator interface.

func (*Iterator) Value Uses

func (i *Iterator) Value() []byte

Value is part of the engine.Iterator interface.

func (*Iterator) ValueProto Uses

func (i *Iterator) ValueProto(msg protoutil.Message) error

ValueProto is part of the engine.Iterator interface.

type ReadWriter Uses

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

ReadWriter is used outside of the spanset package internally, in ccl.

func (ReadWriter) ApplyBatchRepr Uses

func (s ReadWriter) ApplyBatchRepr(repr []byte, sync bool) error

func (ReadWriter) Clear Uses

func (s ReadWriter) Clear(key engine.MVCCKey) error

func (ReadWriter) ClearIterRange Uses

func (s ReadWriter) ClearIterRange(iter engine.Iterator, start, end roachpb.Key) error

func (ReadWriter) ClearRange Uses

func (s ReadWriter) ClearRange(start, end engine.MVCCKey) error

func (ReadWriter) Close Uses

func (s ReadWriter) Close()

func (ReadWriter) Closed Uses

func (s ReadWriter) Closed() bool

func (ReadWriter) ExportToSst Uses

func (s ReadWriter) ExportToSst(
    startKey, endKey roachpb.Key,
    startTS, endTS hlc.Timestamp,
    exportAllRevisions bool,
    io engine.IterOptions,
) ([]byte, roachpb.BulkOpSummary, error)

ExportToSst is part of the engine.Reader interface.

func (ReadWriter) Get Uses

func (s ReadWriter) Get(key engine.MVCCKey) ([]byte, error)

func (ReadWriter) GetProto Uses

func (s ReadWriter) GetProto(
    key engine.MVCCKey, msg protoutil.Message,
) (bool, int64, int64, error)

func (ReadWriter) Iterate Uses

func (s ReadWriter) Iterate(
    start, end roachpb.Key, f func(engine.MVCCKeyValue) (bool, error),
) error

func (ReadWriter) LogData Uses

func (s ReadWriter) LogData(data []byte) error

func (ReadWriter) LogLogicalOp Uses

func (s ReadWriter) LogLogicalOp(
    op engine.MVCCLogicalOpType, details engine.MVCCLogicalOpDetails,
)

func (ReadWriter) Merge Uses

func (s ReadWriter) Merge(key engine.MVCCKey, value []byte) error

func (ReadWriter) NewIterator Uses

func (s ReadWriter) NewIterator(opts engine.IterOptions) engine.Iterator

func (ReadWriter) Put Uses

func (s ReadWriter) Put(key engine.MVCCKey, value []byte) error

func (ReadWriter) SingleClear Uses

func (s ReadWriter) SingleClear(key engine.MVCCKey) error

type Span Uses

type Span struct {
    roachpb.Span
    Timestamp hlc.Timestamp
}

Span is used to represent a keyspan accessed by a request at a given timestamp. A zero timestamp indicates it's a non-MVCC access.

type SpanAccess Uses

type SpanAccess int

SpanAccess records the intended mode of access in a SpanSet.

const (
    SpanReadOnly SpanAccess = iota
    SpanReadWrite
    NumSpanAccess
)

Constants for SpanAccess. Higher-valued accesses imply lower-level ones.

func (SpanAccess) String Uses

func (a SpanAccess) String() string

String returns a string representation of the SpanAccess.

type SpanScope Uses

type SpanScope int

SpanScope divides access types into local and global keys.

const (
    SpanGlobal SpanScope = iota
    SpanLocal
    NumSpanScope
)

Constants for span scopes.

func (SpanScope) String Uses

func (a SpanScope) String() string

String returns a string representation of the SpanScope.

type SpanSet Uses

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

SpanSet tracks the set of key spans touched by a command, broken into MVCC and non-MVCC accesses. The set is divided into subsets for access type (read-only or read/write) and key scope (local or global; used to facilitate use by the separate local and global latches).

func (*SpanSet) AddMVCC Uses

func (s *SpanSet) AddMVCC(access SpanAccess, span roachpb.Span, timestamp hlc.Timestamp)

AddMVCC adds an MVCC span to the span set to be accessed at the given timestamp. This should typically be used for MVCC keys, user keys for e.g.

func (*SpanSet) AddNonMVCC Uses

func (s *SpanSet) AddNonMVCC(access SpanAccess, span roachpb.Span)

AddNonMVCC adds a non-MVCC span to the span set. This should typically local keys.

func (*SpanSet) AssertAllowed Uses

func (s *SpanSet) AssertAllowed(access SpanAccess, span roachpb.Span)

AssertAllowed calls CheckAllowed and fatals if the access is not allowed. Timestamps associated with the spans in the spanset are not considered, only the span boundaries are checked.

func (*SpanSet) BoundarySpan Uses

func (s *SpanSet) BoundarySpan(scope SpanScope) roachpb.Span

BoundarySpan returns a span containing all the spans with the given params.

func (*SpanSet) CheckAllowed Uses

func (s *SpanSet) CheckAllowed(access SpanAccess, span roachpb.Span) error

CheckAllowed returns an error if the access is not allowed over the given keyspan. Timestamps associated with the spans in the spanset are not considered, only the span boundaries are checked.

TODO(irfansharif): This does not currently work for spans that straddle across multiple added spans. Specifically a spanset with spans [a-c) and [b-d) added under read only and read write access modes respectively would fail at checking if read only access over the span [a-d) was requested. This is also a problem if the added spans were read only and the spanset wasn't already SortAndDedup-ed.

func (*SpanSet) CheckAllowedAt Uses

func (s *SpanSet) CheckAllowedAt(
    access SpanAccess, span roachpb.Span, timestamp hlc.Timestamp,
) error

CheckAllowedAt returns an error if the access is not allowed at over the given keyspan at the given timestamp.

func (*SpanSet) GetSpans Uses

func (s *SpanSet) GetSpans(access SpanAccess, scope SpanScope) []Span

GetSpans returns a slice of spans with the given parameters.

func (*SpanSet) Len Uses

func (s *SpanSet) Len() int

Len returns the total number of spans tracked across all accesses and scopes.

func (*SpanSet) Reserve Uses

func (s *SpanSet) Reserve(access SpanAccess, scope SpanScope, n int)

Reserve space for N additional spans.

func (*SpanSet) SortAndDedup Uses

func (s *SpanSet) SortAndDedup()

SortAndDedup sorts the spans in the SpanSet and removes any duplicates.

func (*SpanSet) String Uses

func (s *SpanSet) String() string

String prints a string representation of the SpanSet.

func (*SpanSet) Validate Uses

func (s *SpanSet) Validate() error

Validate returns an error if any spans that have been added to the set are invalid.

Package spanset imports 12 packages (graph) and is imported by 15 packages. Updated 2019-11-19. Refresh now. Tools for package owners.