storage

package
v0.0.0-...-f23273e Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompressionStats

type CompressionStats struct {
	OriginalSize     int64
	CompressedSize   int64
	CompressionRatio float64
	CompressionType  CompressionType
}

CompressionStats holds statistics about compression

type CompressionType

type CompressionType int

CompressionType represents the type of compression to use

const (
	// NoCompression indicates no compression should be used
	NoCompression CompressionType = iota
	// GzipCompression indicates gzip compression should be used
	GzipCompression
	// LZWCompression indicates LZW compression should be used
	LZWCompression
)

type Row

type Row struct {
	Key       []byte
	Timestamp time.Time
	Data      []byte
}

Row represents a single row in the db

func NewRow

func NewRow(key []byte, timestamp time.Time, data []byte) Row

NewRow creates a new row

type RowBatch

type RowBatch struct {
	Rows []Row
}

RowBatch is a batch of rows for bulk operations

func NewRowBatch

func NewRowBatch(capacity int) *RowBatch

NewRowBatch creates a new batch of rows

func (*RowBatch) Add

func (b *RowBatch) Add(row Row)

Add adds a row to the batch

type Table

type Table struct {
	MinTS time.Time // Add this field
	MaxTS time.Time // Add this field
	// contains filtered or unexported fields
}

Table represents a collection of tablets

func NewTable

func NewTable(name string, dataDir string, ttl time.Duration) (*Table, error)

NewTable creates a new table

func (*Table) AddDiskTablet

func (t *Table) AddDiskTablet(tablet *Tablet)

func (*Table) Backup

func (t *Table) Backup(backupDir string) error

Backup creates a backup of the table

func (*Table) Cleanup

func (t *Table) Cleanup() error

Cleanup removes expired data

func (*Table) Close

func (t *Table) Close() error

Close closes the table

func (*Table) CompactAll

func (t *Table) CompactAll() error

CompactAll forces compaction of all tablets

func (*Table) Delete

func (t *Table) Delete() error

Delete removes all table data

func (*Table) Flush

func (t *Table) Flush() error

Flush forces a flush of the in-memory tablet

func (*Table) GetStats

func (t *Table) GetStats() TableStats

GetStats returns statistics about the table

func (*Table) Insert

func (t *Table) Insert(row Row) error

Insert adds a row to the table

func (*Table) Merge

func (t *Table) Merge() error

Merge triggers a merge operation on disk tablets

func (*Table) Name

func (t *Table) Name() string

Name returns the table name

func (*Table) Query

func (t *Table) Query(startTime, endTime time.Time) ([]Row, error)

Query executes a query on the table

func (*Table) Restore

func (t *Table) Restore(backupDir string) error

Restore restores the table from a backup

func (*Table) SetMaxTabletSize

func (t *Table) SetMaxTabletSize(size int64)

SetMaxTabletSize sets the maximum tablet size

func (*Table) SetTTL

func (t *Table) SetTTL(ttl time.Duration)

SetTTL sets the time-to-live for data in the table

type TableStats

type TableStats struct {
	Name          string
	DiskTablets   int
	InMemoryRows  int
	TotalDiskRows int64
	DiskSize      int64
	LastMergeTime time.Time
	LastFlushTime time.Time
	OldestData    time.Time
	NewestData    time.Time
}

TableStats holds statistics about a table

type Tablet

type Tablet struct {
	ID        string
	MinTS     time.Time
	MaxTS     time.Time
	Rows      []Row
	IsOnDisk  bool
	FilePath  string
	BlockSize int64
	// contains filtered or unexported fields
}

Tablet represents a collection of rows either in memory or on disk.

func NewTablet

func NewTablet(id string, blockSize int64) *Tablet

NewTablet creates a new tablet.

func (*Tablet) AddRow

func (t *Tablet) AddRow(row Row)

AddRow adds a row to the tablet

func (*Tablet) Delete

func (t *Tablet) Delete() error

Delete removes the tablet from disk

func (*Tablet) FlushToDisk

func (t *Tablet) FlushToDisk(dir string) error

FlushToDisk writes the tablet to disk FlushToDisk writes the tablet to disk

func (*Tablet) LoadMetadata

func (t *Tablet) LoadMetadata() error

LoadMetadata loads the tablet's metadata from disk

func (*Tablet) Query

func (t *Tablet) Query(startTime, endTime time.Time) ([]Row, error)

Query returns rows within the given timestamp range

func (*Tablet) Size

func (t *Tablet) Size() int

Size returns the number of rows in the tablet

func (*Tablet) Sort

func (t *Tablet) Sort()

Sort sorts the rows in the tablet

type TabletIndex

type TabletIndex struct {
	BlockOffsets []int64   // Offset of each block in the file
	LastKeys     [][]byte  // Last key in each block
	BlockCount   int       // Number of blocks
	MinTS        time.Time // Minimum timestamp in the tablet
	MaxTS        time.Time // Maximum timestamp in the tablet
}

TabletIndex represents the index structure for a tablet

Jump to

Keyboard shortcuts

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