fb0f4bbecd
Previously bleve allowed you to create a memory-only index by simply passing "" as the path argument to the New() method. This was not clear when reading the code, and led to some problematic error cases as well. Now, to create a memory-only index one should use the NewMemOnly() method. Passing "" as the path argument to the New() method will now return os.ErrInvalid. Advanced users calling NewUsing() can create disk-based or memory-only indexes, but the change here is that pass "" as the path argument no longer defaults you into getting a memory-only index. Instead, the KV store is selected manually, just as it is for the disk-based solutions. Here is an example use of the NewUsing() method to create a memory-only index: NewUsing("", indexMapping, Config.DefaultIndexType, Config.DefaultMemKVStore, nil) Config.DefaultMemKVStore is just a new default value added to the configuration, it currently points to gtreap.Name (which could have been used directly instead for more control) closes #427
82 lines
1.6 KiB
Go
82 lines
1.6 KiB
Go
package metrics
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/blevesearch/bleve/index/store"
|
|
"github.com/blevesearch/bleve/index/store/gtreap"
|
|
"github.com/blevesearch/bleve/index/store/test"
|
|
)
|
|
|
|
func open(t *testing.T, mo store.MergeOperator) store.KVStore {
|
|
rv, err := New(mo, map[string]interface{}{
|
|
"kvStoreName_actual": gtreap.Name,
|
|
"path": "",
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return rv
|
|
}
|
|
|
|
func cleanup(t *testing.T, s store.KVStore) {
|
|
err := s.Close()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|
|
|
|
func TestMetricsKVCrud(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestKVCrud(t, s)
|
|
}
|
|
|
|
func TestMetricsReaderIsolation(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestReaderIsolation(t, s)
|
|
}
|
|
|
|
func TestMetricsReaderOwnsGetBytes(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestReaderOwnsGetBytes(t, s)
|
|
}
|
|
|
|
func TestMetricsWriterOwnsBytes(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestWriterOwnsBytes(t, s)
|
|
}
|
|
|
|
func TestMetricsPrefixIterator(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestPrefixIterator(t, s)
|
|
}
|
|
|
|
func TestMetricsPrefixIteratorSeek(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestPrefixIteratorSeek(t, s)
|
|
}
|
|
|
|
func TestMetricsRangeIterator(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestRangeIterator(t, s)
|
|
}
|
|
|
|
func TestMetricsRangeIteratorSeek(t *testing.T) {
|
|
s := open(t, nil)
|
|
defer cleanup(t, s)
|
|
test.CommonTestRangeIteratorSeek(t, s)
|
|
}
|
|
|
|
func TestMetricsMerge(t *testing.T) {
|
|
s := open(t, &test.TestMergeCounter{})
|
|
defer cleanup(t, s)
|
|
test.CommonTestMerge(t, s)
|
|
}
|