package frostdb

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

Dependency Relation
	imports 55 packages, and imported by one package


Package-Level Type Names (total 27)
/* sort by: | */
func WithClearStorage() CloseOption func (*DB).Close(options ...CloseOption) error
( Closer) Close(cleanup bool) error
Close persists all data from the columnstore to storage. It is no longer valid to use the coumnstore for reads or writes, and the object should not longer be reused. DB gets or creates a database on the given ColumnStore with the given options. Note that if the database already exists, the options will be applied cumulatively to the database. DBs returns all the DB names of this column store. (*ColumnStore) DatabasesDir() string (*ColumnStore) DropDB(name string) error (*ColumnStore) GetDB(name string) (*DB, error) *ColumnStore : github.com/prometheus/common/expfmt.Closer *ColumnStore : io.Closer func New(options ...Option) (*ColumnStore, error)
DataSink is a remote destination for data. ( DataSink) Delete(ctx context.Context, name string) error ( DataSink) String() string ( DataSink) Upload(ctx context.Context, name string, r io.Reader) error DataSinkSource (interface) *DefaultObjstoreBucket *github.com/polarsignals/frostdb/storage.Iceberg DataSink : expvar.Var DataSink : fmt.Stringer func WithWriteOnlyStorage(ds DataSink) Option
DataSinkSource is a convenience interface for a data source and sink. ( DataSinkSource) Delete(ctx context.Context, name string) error ( DataSinkSource) Prefixes(ctx context.Context, prefix string) ([]string, error) ( DataSinkSource) Scan(ctx context.Context, prefix string, schema *dynparquet.Schema, filter logicalplan.Expr, lastBlockTimestamp uint64, callback func(context.Context, any) error) error ( DataSinkSource) String() string ( DataSinkSource) Upload(ctx context.Context, name string, r io.Reader) error *DefaultObjstoreBucket *github.com/polarsignals/frostdb/storage.Iceberg DataSinkSource : DataSink DataSinkSource : DataSource DataSinkSource : expvar.Var DataSinkSource : fmt.Stringer func WithReadWriteStorage(ds DataSinkSource) Option
DataSource is remote source of data that can be queried. ( DataSource) Prefixes(ctx context.Context, prefix string) ([]string, error) ( DataSource) Scan(ctx context.Context, prefix string, schema *dynparquet.Schema, filter logicalplan.Expr, lastBlockTimestamp uint64, callback func(context.Context, any) error) error ( DataSource) String() string DataSinkSource (interface) *DefaultObjstoreBucket *github.com/polarsignals/frostdb/index.LSM *github.com/polarsignals/frostdb/storage.Iceberg DataSource : expvar.Var DataSource : fmt.Stringer func WithReadOnlyStorage(ds DataSource) Option
(*DB) Close(options ...CloseOption) error (*DB) GetTable(name string) (*Table, error) HighWatermark returns the current high watermark. Snapshot performs a database snapshot and writes it to the database snapshots directory, as is done by automatic snapshots. Table will get or create a new table with the given name and config. If a table already exists with the given name, it will have it's configuration updated. TableNames returns the names of all the db's tables. (*DB) TableProvider() *DBTableProvider Wait is a blocking function that returns once the high watermark has equaled or exceeded the transaction id. Wait makes no differentiation between completed and aborted transactions. func (*ColumnStore).DB(ctx context.Context, name string, opts ...DBOption) (*DB, error) func (*ColumnStore).GetDB(name string) (*DB, error) func LoadSnapshot(ctx context.Context, db *DB, tx uint64, r io.ReaderAt, size int64, dir string, truncateWAL bool) (uint64, error) func NewDBTableProvider(db *DB) *DBTableProvider func NewGenericTable[T](db *DB, name string, mem memory.Allocator, options ...TableOption) (*GenericTable[T], error) func SnapshotDir(db *DB, tx uint64) string func StoreSnapshot(ctx context.Context, tx uint64, db *DB, snapshot io.Reader) error func WriteSnapshot(ctx context.Context, tx uint64, db *DB, w io.Writer) error
func WithCompactionAfterOpen(compact bool, tableNames []string) DBOption func (*ColumnStore).DB(ctx context.Context, name string, opts ...DBOption) (*DB, error)
(*DBTableProvider) GetTable(name string) (logicalplan.TableReader, error) *DBTableProvider : github.com/polarsignals/frostdb/query/logicalplan.TableProvider func NewDBTableProvider(db *DB) *DBTableProvider func (*DB).TableProvider() *DBTableProvider
DefaultObjstoreBucket is the default implementation of the DataSource and DataSink interface. Bucket storage.Bucket Attributes returns information about the specified object. ( DefaultObjstoreBucket) Close() error Delete removes the object with the given name. If object does not exist in the moment of deletion, Delete should throw error. Exists checks if the given object exists in the bucket. Get returns a reader for the given object name. GetRange returns a new range reader for the given object name and range. ( DefaultObjstoreBucket) GetReaderAt(ctx context.Context, name string) (io.ReaderAt, error) IsAccessDeniedErr returns true if access to object is denied. IsObjNotFoundErr returns true if error means that object is not found. Relevant to Get operations. Iter calls f for each entry in the given directory (not recursive.). The argument to f is the full object name including the prefix of the inspected directory. Entries are passed to function in sorted order. Name returns the bucket name for the provider. (*DefaultObjstoreBucket) Prefixes(ctx context.Context, prefix string) ([]string, error) ProcessFile will process a bucket block parquet file. (*DefaultObjstoreBucket) Scan(ctx context.Context, prefix string, _ *dynparquet.Schema, filter logicalplan.Expr, lastBlockTimestamp uint64, callback func(context.Context, any) error) error (*DefaultObjstoreBucket) String() string Upload the contents of the reader as an object into the bucket. Upload should be idempotent. *DefaultObjstoreBucket : DataSink *DefaultObjstoreBucket : DataSinkSource *DefaultObjstoreBucket : DataSource DefaultObjstoreBucket : github.com/polarsignals/frostdb/query/logicalplan.Named DefaultObjstoreBucket : github.com/polarsignals/frostdb/storage.Bucket DefaultObjstoreBucket : github.com/prometheus/common/expfmt.Closer DefaultObjstoreBucket : github.com/thanos-io/objstore.Bucket DefaultObjstoreBucket : github.com/thanos-io/objstore.BucketReader *DefaultObjstoreBucket : expvar.Var *DefaultObjstoreBucket : fmt.Stringer DefaultObjstoreBucket : io.Closer func NewDefaultBucket(b storage.Bucket, options ...DefaultObjstoreBucketOption) *DefaultObjstoreBucket func NewDefaultObjstoreBucket(b objstore.Bucket, options ...DefaultObjstoreBucketOption) *DefaultObjstoreBucket
func StorageWithBlockReaderLimit(limit int) DefaultObjstoreBucketOption func StorageWithLogger(logger log.Logger) DefaultObjstoreBucketOption func StorageWithTracer(tracer trace.Tracer) DefaultObjstoreBucketOption func NewDefaultBucket(b storage.Bucket, options ...DefaultObjstoreBucketOption) *DefaultObjstoreBucket func NewDefaultObjstoreBucket(b objstore.Bucket, options ...DefaultObjstoreBucketOption) *DefaultObjstoreBucket
( ErrCreateSchemaWriter) Error() string ErrCreateSchemaWriter : error
( ErrReadRow) Error() string ErrReadRow : error
TableName string ( ErrTableNotFound) Error() string ErrTableNotFound : error
( ErrWriteRow) Error() string ErrWriteRow : error
Type Parameters: T: any GenericTable is a wrapper around *Table that writes structs of type T. It consist of a generic arrow.Record builder that ingests structs of type T. The generated record is then passed to (*Table).InsertRecord. Struct tag `frostdb` is used to pass options for the schema for T. This api is opinionated. - Nested Columns are not supported # Tags Use `frostdb` to define tags that customizes field values. You can express everything needed to construct schema v1alpha1. Tags are defined as a comma separated list. The first item is the column name. Column name is optional, when omitted it is derived from the field name (snake_cased) Supported Tags delta_binary_packed | Delta binary packed encoding. brotli | Brotli compression. asc | Sorts in ascending order.Use asc(n) where n is an integer for sorting order. gzip | GZIP compression. snappy | Snappy compression. delta_length_byte_array | Delta Length Byte Array encoding. delta_byte_array | Delta Byte Array encoding. desc | Sorts in descending order.Use desc(n) where n is an integer for sorting order lz4_raw | LZ4_RAW compression. pre_hash | Prehash the column before storing it. null_first | When used wit asc nulls are smallest and with des nulls are largest. zstd | ZSTD compression. rle_dict | Dictionary run-length encoding. plain | Plain encoding. Example tagged Sample struct type Sample struct { ExampleType string `frostdb:"example_type,rle_dict,asc(0)"` Labels []Label `frostdb:"labels,rle_dict,null,dyn,asc(1),null_first"` Stacktrace []uuid.UUID `frostdb:"stacktrace,rle_dict,asc(3),null_first"` Timestamp int64 `frostdb:"timestamp,asc(2)"` Value int64 `frostdb:"value"` } # Dynamic columns Field of type map<string, T> is a dynamic column by default. type Example struct { // Use supported tags to customize the column value Labels map[string]string `frostdb:"labels"` } # Repeated columns Fields of type []int64, []float64, []bool, and []string are supported. These are represented as arrow.LIST. Generated schema for the repeated columns applies all supported tags. By default repeated fields are nullable. You can safely pass nil slices for repeated columns. Table *Table ( GenericTable) ActiveBlock() *TableBlock ( GenericTable) ActiveWriteBlock() (*TableBlock, func(), error) ( GenericTable) EnsureCompaction() error IndexConfig returns the index configuration for the table. It makes a copy of the column store index config and injects it's compactParts method. ( GenericTable) InsertRecord(ctx context.Context, record arrow.Record) (uint64, error) Iterator iterates in order over all granules in the table. It stops iterating when the iterator function returns false. (*GenericTable[T]) Release() ( GenericTable) RotateBlock(_ context.Context, block *TableBlock, opts ...RotateBlockOption) error ( GenericTable) Schema() *dynparquet.Schema SchemaIterator iterates in order over all granules in the table and returns all the schemas seen across the table. ( GenericTable) View(ctx context.Context, fn func(ctx context.Context, tx uint64) error) error Write builds arrow.Record directly from values and calls (*Table).InsertRecord. GenericTable : github.com/polarsignals/frostdb/query/logicalplan.TableReader func NewGenericTable[T](db *DB, name string, mem memory.Allocator, options ...TableOption) (*GenericTable[T], error)
func WithActiveMemorySize(size int64) Option func WithCompactionAfterRecovery(tableNames []string) Option func WithIndexConfig(indexConfig []*index.LevelConfig) Option func WithIndexDegree(indexDegree int) Option func WithLogger(logger log.Logger) Option func WithManualBlockRotation() Option func WithReadOnlyStorage(ds DataSource) Option func WithReadWriteStorage(ds DataSinkSource) Option func WithRecoveryConcurrency(concurrency int) Option func WithRegistry(reg prometheus.Registerer) Option func WithSnapshotTriggerSize(size int64) Option func WithSplitSize(size int) Option func WithStoragePath(path string) Option func WithTestingOptions(opts ...TestingOption) Option func WithTracer(tracer trace.Tracer) Option func WithWAL() Option func WithWriteOnlyStorage(ds DataSink) Option func New(options ...Option) (*ColumnStore, error)
( ParquetWriter) Close() error ( ParquetWriter) Flush() error ( ParquetWriter) WriteRows([]parquet.Row) (int, error) github.com/polarsignals/frostdb/dynparquet.ParquetWriter (interface) github.com/polarsignals/frostdb/dynparquet.PooledWriter *github.com/parquet-go/parquet-go.GenericWriter[...] *github.com/parquet-go/parquet-go.SortingWriter[...] *github.com/parquet-go/parquet-go.Writer ParquetWriter : github.com/apache/thrift/lib/go/thrift.Flusher ParquetWriter : github.com/parquet-go/parquet-go.RowWriter ParquetWriter : github.com/prometheus/common/expfmt.Closer ParquetWriter : io.Closer
func WithRotateBlockSkipPersist() RotateBlockOption func WithRotateBlockWaitGroup(wg *sync.WaitGroup) RotateBlockOption func (*Table).RotateBlock(_ context.Context, block *TableBlock, opts ...RotateBlockOption) error
( Sync) Sync() error *github.com/polarsignals/frostdb/index.FileCompaction *github.com/polarsignals/wal/fs.File github.com/polarsignals/wal/types.WritableFile (interface) github.com/coreos/etcd/pkg/fileutil.LockedFile *github.com/ipfs/go-log/v2.ZapEventLogger github.com/ncruces/go-sqlite3.VTabSavepointer (interface) github.com/ncruces/go-sqlite3.VTabTxn (interface) *github.com/pancsta/asyncmachine-go/pkg/history.BaseMemory github.com/pancsta/asyncmachine-go/pkg/history.Memory github.com/pancsta/asyncmachine-go/pkg/history.MemoryApi (interface) *github.com/pancsta/asyncmachine-go/pkg/history/bbolt.Memory *github.com/pancsta/asyncmachine-go/pkg/history/gorm.Memory *go.etcd.io/bbolt.DB *go.uber.org/zap.Logger go.uber.org/zap.Sink (interface) *go.uber.org/zap.SugaredLogger *go.uber.org/zap/zapcore.BufferedWriteSyncer go.uber.org/zap/zapcore.Core (interface) go.uber.org/zap/zapcore.WriteSyncer (interface) *os.File
(*Table) ActiveBlock() *TableBlock (*Table) ActiveWriteBlock() (*TableBlock, func(), error) (*Table) EnsureCompaction() error IndexConfig returns the index configuration for the table. It makes a copy of the column store index config and injects it's compactParts method. (*Table) InsertRecord(ctx context.Context, record arrow.Record) (uint64, error) Iterator iterates in order over all granules in the table. It stops iterating when the iterator function returns false. (*Table) RotateBlock(_ context.Context, block *TableBlock, opts ...RotateBlockOption) error (*Table) Schema() *dynparquet.Schema SchemaIterator iterates in order over all granules in the table and returns all the schemas seen across the table. (*Table) View(ctx context.Context, fn func(ctx context.Context, tx uint64) error) error *Table : github.com/polarsignals/frostdb/query/logicalplan.TableReader func (*DB).GetTable(name string) (*Table, error) func (*DB).Table(name string, config *tablepb.TableConfig) (*Table, error)
EnsureCompaction forces a TableBlock compaction. Index provides atomic access to the table index. (*TableBlock) InsertRecord(_ context.Context, tx uint64, record arrow.Record) error Persist uploads the block to the underlying bucket. Serialize the table block into a single Parquet file. Size returns the cumulative size of all buffers in the table. This is roughly the size of the table in bytes. func (*Table).ActiveBlock() *TableBlock func (*Table).ActiveWriteBlock() (*TableBlock, func(), error) func (*Table).RotateBlock(_ context.Context, block *TableBlock, opts ...RotateBlockOption) error
func FromConfig(config *tablepb.TableConfig) TableOption func WithBlockReaderLimit(n int) TableOption func WithoutWAL() TableOption func WithRowGroupSize(numRows int) TableOption func WithUniquePrimaryIndex(unique bool) TableOption func NewGenericTable[T](db *DB, name string, mem memory.Allocator, options ...TableOption) (*GenericTable[T], error) func NewTableConfig(schema proto.Message, options ...TableOption) *tablepb.TableConfig
func WithTestingNoDiskSpaceReclaimOnSnapshot() TestingOption func WithTestingWalOptions(opts ...wal.Option) TestingOption func WithTestingOptions(opts ...TestingOption) Option
type TxNode (struct)
Insert performs an insertion sort of the given tx. (*TxPool) Iterate(iterate func(txn uint64) bool) Stop stops the TxPool's cleaner goroutine. func NewTxPool(watermark *atomic.Uint64) *TxPool
( WAL) Close() error ( WAL) FirstIndex() (uint64, error) ( WAL) LastIndex() (uint64, error) ( WAL) Log(tx uint64, record *walpb.Record) error ( WAL) LogRecord(tx uint64, table string, record arrow.Record) error Replay replays WAL records from the given first index. If firstIndex is 0, the first index read from the WAL is used (i.e. given a truncation, using 0 is still valid). If the given firstIndex is less than the WAL's first index on disk, the replay happens from the first index on disk. If the handler panics, the WAL implementation will truncate the WAL up to the last valid index. ( WAL) Reset(nextTx uint64) error ( WAL) Truncate(tx uint64) error *github.com/polarsignals/frostdb/wal.FileWAL *github.com/polarsignals/frostdb/wal.NopWAL WAL : github.com/prometheus/common/expfmt.Closer WAL : io.Closer
Package-Level Functions (total 43)
DefaultIndexConfig returns the default level configs used. This is a function So that any modifications to the result will not affect the default config.
FromConfig sets the table configuration from the given config. NOTE: that this does not override the schema even though that is included in the passed in config.
func LoadSnapshot(ctx context.Context, db *DB, tx uint64, r io.ReaderAt, size int64, dir string, truncateWAL bool) (uint64, error)
func New(options ...Option) (*ColumnStore, error)
Type Parameters: T: any
NewTxPool returns a new TxPool and starts the pool cleaner routine. The transaction pool is used to keep track of completed transactions. It does this by inserting completed transactions into an ordered linked list. Ex: insert: 12 [9]->[10]->[13] => [9]->[10]->[12]->[13] Inserting a new node triggers the pool cleaner routine to run. The pool cleaner's job is to increment a high-watermark counter when it encounters contiguous transactions in the list, and then remove those elements in the pool. Ex: watermark: 7 insert: 8 [9]->[10]->[13] => [8]->[9]->[10]->[13] (cleaner notified) [8]->[9]->[10]->[13] ^ watermark++; delete 8 [9]->[10]->[13] ^ watermark++; delete 9 [10]->[13] ^ watermark++; delete 9 [13] watermark: 10 TxPool is a sorted lockless linked-list described in https://timharris.uk/papers/2001-disc.pdf
func SnapshotDir(db *DB, tx uint64) string
func StoreSnapshot(ctx context.Context, tx uint64, db *DB, snapshot io.Reader) error
WithBlockReaderLimit sets the limit of go routines that will be used to read persisted block files. A negative number indicates no limit.
func WithCompactionAfterOpen(compact bool, tableNames []string) DBOption
func WithIndexConfig(indexConfig []*index.LevelConfig) Option
func WithIndexDegree(indexDegree int) Option
func WithLogger(logger log.Logger) Option
WithoutWAL disables the WAL for this table.
WithRecoveryConcurrency limits the number of databases that are recovered simultaneously when calling frostdb.New. This helps limit memory usage on recovery.
WithRotateBlockSkipPersist instructs the block rotation operation to not persist the block to object storage.
WithRotateBlockWaitGroup provides a WaitGroup. The rotate block operation will call wg.Done once the block has been persisted. Otherwise, RotateBlock asynchronously persists the block.
WithRowGroupSize sets the size in number of rows for each row group for parquet files. A <= 0 value indicates no limit.
WithSnapshotTriggerSize specifies a size in bytes of uncompressed inserts that will trigger a snapshot of the whole database. This can be larger than the active memory size given that the active memory size tracks the size of *compressed* data, while snapshots are triggered based on the *uncompressed* data inserted into the database. The reason this choice was made is that if a database instance crashes, it is forced to reread all uncompressed inserts since the last snapshot from the WAL, which could potentially lead to unrecoverable OOMs on startup. Defining the snapshot trigger in terms of uncompressed bytes limits the memory usage on recovery to at most the snapshot trigger size (as long as snapshots were successful). If 0, snapshots are disabled. Note that snapshots (if enabled) are also triggered on block rotation of any database table. Snapshots are complementary to the WAL and will also be disabled if the WAL is disabled.
func WithWAL() Option
Package-Level Variables (total 2)
Package-Level Constants (total 6)
const B = 1
DefaultBlockReaderLimit is the concurrency limit for reading blocks.
const GiB = 1073741824
const KiB = 1024
const MiB = 1048576
const TiB = 1099511627776