package index

Import Path
	github.com/polarsignals/frostdb/index (on go.dev)

Dependency Relation
	imports 23 packages, and imported by one package

Involved Source Files levels.go lsm.go lsm_list.go
Package-Level Type Names (total 11)
/* sort by: | */
func NewFileCompaction(dir string, maxSize int64, compact Compaction, logger log.Logger) (*FileCompaction, error)
const CompactionTypeParquetDisk const CompactionTypeParquetMemory const CompactionTypeUnknown
Compact will compact the given parts into a Parquet file written to the next level file. (*FileCompaction) MaxSize() int64 Reset is called when the level no longer has active parts in it at the end of a compaction. Snapshot takes a snapshot of the current level. It ignores the parts and just hard links the files into the snapshot directory. It will rotate the active file if it has data in it rendering all snapshotted files as immutable. Sync calls Sync on the underlying file. *FileCompaction : Level *FileCompaction : github.com/polarsignals/frostdb.Sync func NewFileCompaction(dir string, maxSize int64, compact Compaction, logger log.Logger) (*FileCompaction, error)
( Level) Compact(parts []parts.Part, options ...parts.Option) ([]parts.Part, int64, int64, error) ( Level) MaxSize() int64 ( Level) Reset() ( Level) Snapshot(parts []parts.Part, writer func(parts.Part) error, dir string) error *FileCompaction
LevelConfig is the configuration for a level in the LSM. The MaxSize is the maximum size of the level in bytes before it triggers a compaction into the next level. Compact Compaction Level SentinelType MaxSize int64 Type CompactionType func github.com/polarsignals/frostdb.DefaultIndexConfig() []*LevelConfig func github.com/polarsignals/frostdb.(*Table).IndexConfig() []*LevelConfig func NewLSM(dir string, schema *dynparquet.Schema, levels []*LevelConfig, watermark func() uint64, options ...LSMOption) (*LSM, error) func github.com/polarsignals/frostdb.WithIndexConfig(indexConfig []*LevelConfig) frostdb.Option
LSM is a log-structured merge-tree like index. It is implemented as a single linked list of parts. Arrow records are always added to the L0 list. When a list reaches it's configured max size it is compacted calling the levels Compact function and is then added as a new part to the next level. [L0]->[record]->[record]->[L1]->[record/parquet]->[record/parquet] etc. RWMutex sync.RWMutex (*LSM) Add(tx uint64, record arrow.Record) (*LSM) Close() error EnsureCompaction forces a compaction of all levels, regardless of whether the levels are below the target size. InsertPart inserts a part into the LSM tree. It will be inserted into the correct level. It does not check if the insert should cause a compaction. This should only be used during snapshot recovery. It will drop the insert on the floor if the part is older than a part in the next level of the LSM. This indicates that this part is already accounted for in the next level vis compaction. (*LSM) Iterate(iter func(node *Node) bool) LevelSize returns the size of a specific level in bytes. Lock locks rw for writing. If the lock is already locked for reading or writing, Lock blocks until the lock is available. (*LSM) MaxLevel() SentinelType (*LSM) Prefixes(_ context.Context, _ string) ([]string, error) RLock locks rw for reading. It should not be used for recursive read locking; a blocked Lock call excludes new readers from acquiring the lock. See the documentation on the [RWMutex] type. RLocker returns a [Locker] interface that implements the [Locker.Lock] and [Locker.Unlock] methods by calling rw.RLock and rw.RUnlock. RUnlock undoes a single [RWMutex.RLock] call; it does not affect other simultaneous readers. It is a run-time error if rw is not locked for reading on entry to RUnlock. Rotate will write all parts in the LSM into the external writer. No changes are made to the LSM. (*LSM) Scan(ctx context.Context, _ string, _ *dynparquet.Schema, filter logicalplan.Expr, tx uint64, callback func(context.Context, any) error) error Size returns the total size of the index in bytes. Snapshot creates a snapshot of the index at the given transaction. It will call the writer function with the parts in the index that are in-memory. (*LSM) String() string TryLock tries to lock rw for writing and reports whether it succeeded. Note that while correct uses of TryLock do exist, they are rare, and use of TryLock is often a sign of a deeper problem in a particular use of mutexes. TryRLock tries to lock rw for reading and reports whether it succeeded. Note that while correct uses of TryRLock do exist, they are rare, and use of TryRLock is often a sign of a deeper problem in a particular use of mutexes. Unlock unlocks rw for writing. It is a run-time error if rw is not locked for writing on entry to Unlock. As with Mutexes, a locked [RWMutex] is not associated with a particular goroutine. One goroutine may [RWMutex.RLock] ([RWMutex.Lock]) a RWMutex and then arrange for another goroutine to [RWMutex.RUnlock] ([RWMutex.Unlock]) it. (*LSM) WaitForPendingCompactions() *LSM : github.com/polarsignals/frostdb.DataSource *LSM : github.com/prometheus/common/expfmt.Closer *LSM : expvar.Var *LSM : fmt.Stringer *LSM : io.Closer *LSM : sync.Locker func NewLSM(dir string, schema *dynparquet.Schema, levels []*LevelConfig, watermark func() uint64, options ...LSMOption) (*LSM, error) func github.com/polarsignals/frostdb.(*TableBlock).Index() *LSM
LSMMetrics are the metrics for an LSM index. CompactionDuration prometheus.Observer Compactions *prometheus.CounterVec LevelSize *prometheus.GaugeVec func NewLSMMetrics(reg prometheus.Registerer) *LSMMetrics func LSMWithMetrics(metrics *LSMMetrics) LSMOption
func LSMWithLogger(logger log.Logger) LSMOption func LSMWithMetrics(metrics *LSMMetrics) LSMOption func NewLSM(dir string, schema *dynparquet.Schema, levels []*LevelConfig, watermark func() uint64, options ...LSMOption) (*LSM, error)
Node is a Part that is a part of a linked-list. Insert a Node into the list, in order by Tx. Iterate accesses every node in the list. (*Node) Part() parts.Part Prepend a node onto the front of the list. Sentinel adds a new sentinel node to the list, and returns the sub list starting from that sentinel. (*Node) String() string *Node : expvar.Var *Node : fmt.Stringer func NewList(sentinel SentinelType) *Node func (*Node).Prepend(part parts.Part) *Node func (*Node).Sentinel(s SentinelType) *Node
Returns the list of column chunks in this row group. The chunks are ordered in the order of leaf columns from the row group's schema. If the underlying implementation is not read-only, the returned parquet.ColumnChunk may implement other interfaces: for example, parquet.ColumnBuffer if the chunk is backed by an in-memory buffer, or typed writer interfaces like parquet.Int32Writer depending on the underlying type of values that can be written to the chunk. As an optimization, the row group may return the same slice across multiple calls to this method. Applications should treat the returned slice as read-only. DynamicColumns returns the concrete dynamic column names that were used create its concrete parquet schema with a dynamic parquet schema. DynamicRows return an iterator over the rows in the row group. Returns the number of rows in the group. ( ReleaseableRowGroup) Release() Returns a reader exposing the rows of the row group. As an optimization, the returned parquet.Rows object may implement parquet.RowWriterTo, and test the RowWriter it receives for an implementation of the parquet.RowGroupWriter interface. This optimization mechanism is leveraged by the parquet.CopyRows function to skip the generic row-by-row copy algorithm and delegate the copy logic to the parquet.Rows object. Returns the schema of rows in the group. Returns the list of sorting columns describing how rows are sorted in the group. The method will return an empty slice if the rows are not sorted. ( ReleaseableRowGroup) String() string ReleaseableRowGroup : github.com/polarsignals/frostdb/dynparquet.DynamicRowGroup ReleaseableRowGroup : github.com/polarsignals/frostdb/query/expr.Particulate ReleaseableRowGroup : github.com/parquet-go/parquet-go.RowGroup ReleaseableRowGroup : expvar.Var ReleaseableRowGroup : fmt.Stringer
( SentinelType) String() string SentinelType : expvar.Var SentinelType : fmt.Stringer func (*LSM).MaxLevel() SentinelType func NewList(sentinel SentinelType) *Node func (*LSM).LevelSize(t SentinelType) int64 func (*Node).Sentinel(s SentinelType) *Node const L0 const L1 const L2
Package-Level Functions (total 6)
func NewFileCompaction(dir string, maxSize int64, compact Compaction, logger log.Logger) (*FileCompaction, error)
NewList creates a new part list using atomic constructs.
NewLSM returns an LSM-like index of len(levels) levels. wait is a function that will block until the given transaction has been committed; this is used only during compaction to ensure that all the tx in the level up to the compaction tx have been committed before compacting.
Package-Level Constants (total 8)
CompactionTypeParquetDisk is a compaction type that will compact the parts into a Parquet file on disk.
CompactionTypeParquetMemory is a compaction type that will compact the parts into a Parquet file in memory.
const IndexFileExtension = ".idx"
const L0 SentinelType = 0
const L1 SentinelType = 1
const L2 SentinelType = 2
const ParquetCompactionTXKey = "compaction_tx"