cockroach: Index | Files

package raftentry

import ""

Package raftentry provides a cache for entries to avoid extra deserializations.


Package Files

cache.go metrics.go ring_buffer.go

type Cache Uses

type Cache struct {
    // contains filtered or unexported fields

Cache is a specialized data structure for storing deserialized raftpb.Entry values tailored to the access patterns of the storage package. Cache is safe for concurrent access.

func NewCache Uses

func NewCache(maxBytes uint64) *Cache

NewCache creates a cache with a max size. Size must be less than math.MaxInt32.

func (*Cache) Add Uses

func (c *Cache) Add(id roachpb.RangeID, ents []raftpb.Entry, truncate bool)

Add inserts ents into the cache. If truncate is true, the method also removes all entries with indices equal to or greater than the indices of the entries provided. ents is expected to consist of entries with a contiguous sequence of indices.

func (*Cache) Clear Uses

func (c *Cache) Clear(id roachpb.RangeID, hi uint64)

Clear removes all entries on the given range with index less than hi.

func (*Cache) Drop Uses

func (c *Cache) Drop(id roachpb.RangeID)

Drop drops all cached entries associated with the specified range.

func (*Cache) Get Uses

func (c *Cache) Get(id roachpb.RangeID, idx uint64) (e raftpb.Entry, ok bool)

Get returns the entry for the specified index and true for the second return value. If the index is not present in the cache, false is returned.

func (*Cache) Metrics Uses

func (c *Cache) Metrics() Metrics

Metrics returns a struct which contains metrics for the raft entry cache.

func (*Cache) Scan Uses

func (c *Cache) Scan(
    ents []raftpb.Entry, id roachpb.RangeID, lo, hi, maxBytes uint64,
) (_ []raftpb.Entry, bytes uint64, nextIdx uint64, exceededMaxBytes bool)

Scan returns entries between [lo, hi) for specified range. If any entries are returned for the specified indices, they will start with index lo and proceed sequentially without gaps until 1) all entries exclusive of hi are fetched, 2) fetching another entry would add up to more than maxBytes of data, or 3) a cache miss occurs. The returned size reflects the size of the returned entries.

type Metrics Uses

type Metrics struct {
    // NB: the values in the gauges are updated asynchronously and may hold stale
    // values in the face of concurrent updates.
    Size     *metric.Gauge
    Bytes    *metric.Gauge
    Accesses *metric.Counter
    Hits     *metric.Counter

Metrics is the set of metrics for the raft entry cache.

Package raftentry imports 9 packages (graph) and is imported by 2 packages. Updated 2020-05-16. Refresh now. Tools for package owners.