Help us shape the future of Go! Take the 2026 Go Developer Survey

logindex

package
v0.57.21 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package logindex is an ordered key-value index on a storage Device that keeps the whole table in memory and writes it as a log.

A commit flushes the device's earlier writes and then appends one record to the current log file with a flush. An ordered commit appends its record without either flush. Recovery replays records only while their sequence continues, so a crash loses at most a suffix of the ordered commits. A checkpoint writes the table to a checkpoint file and then a manifest naming that checkpoint and the first log file written after it, and removes the files the manifest no longer names. Recovery loads the manifest's checkpoint and replays the later log records in sequence order.

The table is a memtable, whose snapshots serve read transactions without locks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Index

type Index struct {
	// Table serves the transactions.
	*memtable.Table
	// contains filtered or unexported fields
}

Index is the log-structured index.

func Open

func Open(ctx context.Context, dev device.Device, opts Options) (*Index, error)

Open recovers the index from dev, creating it when dev has none. ctx bounds the index's background checkpoints until Close.

func (*Index) Close

func (i *Index) Close() error

Close waits for a running checkpoint and returns the error of the last failed background checkpoint.

type Options

type Options struct {
	// CheckpointBytes is the log length that starts a checkpoint once the log
	// is also longer than half the last checkpoint. Zero selects 4 MiB.
	CheckpointBytes int64
	// Foreground runs each checkpoint inside the commit that starts it and
	// returns its error from that commit, which fixes the device call order.
	Foreground bool
}

Options configures an Index.

Jump to

Keyboard shortcuts

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