mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-06 00:25:55 +00:00
This commit attaches the mmap-backed roaring bitmaps as storage to the fragments. Currently snapshotting is not supported from Pilosa so the WAL will grow indefinitely, however, it is not a difficult change to make.
46 lines
962 B
Go
46 lines
962 B
Go
package pilosa_test
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
|
|
"github.com/umbel/pilosa"
|
|
)
|
|
|
|
// Index is a test wrapper for pilosa.Index.
|
|
type Index struct {
|
|
*pilosa.Index
|
|
}
|
|
|
|
// NewIndex returns a new instance of Index with a temporary path.
|
|
func NewIndex() *Index {
|
|
path, err := ioutil.TempDir("", "pilosa-")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &Index{Index: pilosa.NewIndex(path)}
|
|
}
|
|
|
|
// MustOpenIndex creates and opens an index at a temporary path. Panic on error.
|
|
func MustOpenIndex() *Index {
|
|
i := NewIndex()
|
|
if err := i.Open(); err != nil {
|
|
panic(err)
|
|
}
|
|
return i
|
|
}
|
|
|
|
// Close closes the index and removes all underlying data.
|
|
func (i *Index) Close() error {
|
|
defer os.RemoveAll(i.Path())
|
|
return i.Index.Close()
|
|
}
|
|
|
|
// MustFragment returns a given fragment. Panic on error.
|
|
func (i *Index) MustFragment(db, frame string, slice uint64) *Fragment {
|
|
f, err := i.Index.Fragment(db, frame, slice)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return &Fragment{Fragment: f}
|
|
}
|