mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
This commit moves ID-related types and functions to the top level package and moves remaining statsd wrapper into a `statsd` package.
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
package pilosa
|
|
|
|
// Storage represents
|
|
type Storage interface {
|
|
Open() error
|
|
Close() error
|
|
Flush()
|
|
|
|
Fetch(bitmap_id uint64, db, frame string, slice int) (*Bitmap, uint64)
|
|
Store(id uint64, db, frame string, slice int, filter uint64, bitmap *Bitmap) error
|
|
|
|
StoreBlock(id uint64, db, frame string, slice int, filter uint64, chunk uint64, block_index int32, block uint64) error
|
|
RemoveBlock(id uint64, db, frame string, slice int, chunk uint64, block_index int32)
|
|
|
|
StoreBit(bid uint64, db, frame string, slice int, filter uint64, chunk uint64, block_index int32, block, count uint64)
|
|
RemoveBit(id uint64, db, frame string, slice int, filter uint64, chunk uint64, block_index int32, count uint64)
|
|
}
|
|
|
|
var storageFns = make(map[string]NewStorageFunc)
|
|
|
|
// NewStorageFunc represents a function that instantiates a new storage engine.
|
|
type NewStorageFunc func(opt StorageOptions) Storage
|
|
|
|
// RegisterStorage registers a storage engine.
|
|
func RegisterStorage(name string, fn NewStorageFunc) {
|
|
if storageFns[name] != nil {
|
|
panic("storage engine already registered: " + name)
|
|
}
|
|
storageFns[name] = fn
|
|
}
|
|
|
|
// NewStorage returns a new Storage instance by name.
|
|
func NewStorage(name string, opt StorageOptions) Storage {
|
|
fn := storageFns[name]
|
|
if fn == nil {
|
|
panic("storage type not registered: " + name)
|
|
}
|
|
return fn(opt)
|
|
}
|
|
|
|
// StorageOptions represents the options passed to the storage engine.
|
|
type StorageOptions struct {
|
|
DB string
|
|
Slice int
|
|
Frame string
|
|
FragmentID SUUID
|
|
|
|
LevelDBPath string
|
|
}
|