memdb

package
v0.3.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferManager

type BufferManager interface {
	// AllocBuffer allocates a new DataPointBuffer.
	AllocBuffer(familyTime int64) (buf DataPointBuffer, err error)
	// GarbageCollect cleans all dirty buffers.
	GarbageCollect()
	// Cleanup cleans all history buffers.
	Cleanup()
}

BufferManager represents data points write buffer manager, maintains all buffers for spec shard.

func NewBufferManager

func NewBufferManager(path string) BufferManager

NewBufferManager creates a BufferManager instance.

type DataPointBuffer

type DataPointBuffer interface {
	io.Closer
	// AllocPage allocates the page buffer for writing data point.
	AllocPage() (buf []byte, err error)
	// Release marks data point buffer is dirty.
	Release()
	// IsDirty returns data point buffer if dirty, dirty buffer can be collect.
	IsDirty() bool
}

DataPointBuffer represents data point buffer write buffer based on memory map file

type MemoryDatabase

type MemoryDatabase interface {
	// MarkReadOnly marks memory database cannot writable.
	MarkReadOnly()
	// IsReadOnly returns memory database if it is readonly.
	IsReadOnly() bool
	// AcquireWrite acquires writing data points
	AcquireWrite()
	// WithLock retrieves the lock of memdb, and returns the release function
	WithLock() (release func())
	// WriteRow must be called after WithLock
	// Used for batch write
	WriteRow(row *metric.StorageRow) error
	// CompleteWrite completes writing data points
	CompleteWrite()
	// FlushFamilyTo flushes the corresponded family data to builder.
	// Close is not in the flushing process.
	FlushFamilyTo(flusher metricsdata.Flusher) error
	// MemSize returns the memory-size of this metric-store
	MemSize() int64
	// DataFilter filters the data based on condition
	flow.DataFilter
	// Closer closes the memory database resource
	io.Closer
	// FamilyTime returns the family time of this memdb
	FamilyTime() int64
	// Uptime returns duration since created
	Uptime() time.Duration
	// NumOfMetrics returns the number of metrics.
	NumOfMetrics() int
	// NumOfSeries returns the number of series.
	NumOfSeries() int
}

MemoryDatabase is a database-like concept of Shard as memTable in cassandra.

func NewMemoryDatabase

func NewMemoryDatabase(cfg MemoryDatabaseCfg) (MemoryDatabase, error)

NewMemoryDatabase returns a new MemoryDatabase.

type MemoryDatabaseCfg

type MemoryDatabaseCfg struct {
	FamilyTime int64
	Name       string
	BufferMgr  BufferManager
}

MemoryDatabaseCfg represents the memory database config

type MetricBucketStore

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

MetricBucketStore represents int map using roaring bitmap

func NewMetricBucketStore

func NewMetricBucketStore() *MetricBucketStore

NewMetricBucketStore creates a int map

func (*MetricBucketStore) Get

func (m *MetricBucketStore) Get(key uint32) (mStoreINTF, bool)

Get returns value by key, if exist returns it, else returns nil, false

func (*MetricBucketStore) Keys

func (m *MetricBucketStore) Keys() *roaring.Bitmap

Keys returns the all keys

func (*MetricBucketStore) Put

func (m *MetricBucketStore) Put(key uint32, value mStoreINTF)

Put puts the value by key

func (*MetricBucketStore) Size

func (m *MetricBucketStore) Size() int

Size returns the size of keys

func (*MetricBucketStore) Values

func (m *MetricBucketStore) Values() [][]mStoreINTF

Values returns the all values

func (*MetricBucketStore) WalkEntry

func (m *MetricBucketStore) WalkEntry(fn func(key uint32, value mStoreINTF) error) error

WalkEntry walks each kv entry via fn.

type MetricStore

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

MetricStore represents int map using roaring bitmap

func NewMetricStore

func NewMetricStore() *MetricStore

NewMetricStore creates a int map

func (*MetricStore) Get

func (m *MetricStore) Get(key uint32) (tStoreINTF, bool)

Get returns value by key, if exist returns it, else returns nil, false

func (*MetricStore) Keys

func (m *MetricStore) Keys() *roaring.Bitmap

Keys returns the all keys

func (*MetricStore) Put

func (m *MetricStore) Put(key uint32, value tStoreINTF)

Put puts the value by key

func (*MetricStore) Size

func (m *MetricStore) Size() int

Size returns the size of keys

func (*MetricStore) Values

func (m *MetricStore) Values() [][]tStoreINTF

Values returns the all values

func (*MetricStore) WalkEntry

func (m *MetricStore) WalkEntry(fn func(key uint32, value tStoreINTF) error) error

WalkEntry walks each kv entry via fn.

Jump to

Keyboard shortcuts

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