0
0
Fork 0

added build tag 'leveldb' to enable this kv store

by default we now use the pure go boltdb kv store
it is less tested at this point but appears to work
test pass, and moves us closer to the goal of being
able to just "go get" bleve
This commit is contained in:
Marty Schoch 2014-08-25 15:18:24 -04:00
parent 45a7a6dd8e
commit ef59abe4c9
12 changed files with 65 additions and 26 deletions

View File

@ -77,8 +77,8 @@ import (
_ "github.com/couchbaselabs/bleve/analysis/language/tr"
// kv stores
_ "github.com/couchbaselabs/bleve/index/store/boltdb"
_ "github.com/couchbaselabs/bleve/index/store/inmem"
_ "github.com/couchbaselabs/bleve/index/store/leveldb"
)
var bleveExpVar = expvar.NewMap("bleve")
@ -130,7 +130,7 @@ func init() {
Config.DefaultHighlighter = &htmlHighlighterName
// default kv store
Config.DefaultKVStore = "leveldb"
Config.DefaultKVStore = "boltdb"
bootDuration := time.Since(bootStart)
bleveExpVar.Add("bootDuration", int64(bootDuration))

21
config_leveldb.go Normal file
View File

@ -0,0 +1,21 @@
// Copyright (c) 2014 Couchbase, Inc.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build leveldb full
package bleve
import (
_ "github.com/couchbaselabs/bleve/index/store/leveldb"
)
func init() {
// install leveldb as the default kv store
Config.DefaultKVStore = "leveldb"
}

View File

@ -6,6 +6,9 @@
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build leveldb full
package leveldb
import (

View File

@ -6,6 +6,9 @@
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build leveldb full
package leveldb
import (

View File

@ -6,6 +6,9 @@
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build leveldb full
package leveldb
import (

View File

@ -6,6 +6,9 @@
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build leveldb full
package leveldb
import (

View File

@ -6,6 +6,9 @@
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build leveldb full
package leveldb
import (

View File

@ -6,6 +6,9 @@
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
// +build leveldb full
package upside_down
import (

View File

@ -9,7 +9,7 @@
package upside_down
import (
"github.com/couchbaselabs/bleve/index/store/leveldb"
"github.com/couchbaselabs/bleve/index/store/boltdb"
"os"
"testing"
"time"
@ -20,7 +20,7 @@ import (
func TestDump(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}

View File

@ -14,13 +14,13 @@ import (
"testing"
"github.com/couchbaselabs/bleve/document"
"github.com/couchbaselabs/bleve/index/store/leveldb"
"github.com/couchbaselabs/bleve/index/store/boltdb"
)
func TestIndexFieldReader(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {

View File

@ -19,7 +19,7 @@ import (
"github.com/couchbaselabs/bleve/analysis/tokenizers/regexp_tokenizer"
"github.com/couchbaselabs/bleve/document"
"github.com/couchbaselabs/bleve/index"
"github.com/couchbaselabs/bleve/index/store/leveldb"
"github.com/couchbaselabs/bleve/index/store/boltdb"
)
var testAnalyzer = &analysis.Analyzer{
@ -29,7 +29,7 @@ var testAnalyzer = &analysis.Analyzer{
func TestIndexOpenReopen(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -52,7 +52,7 @@ func TestIndexOpenReopen(t *testing.T) {
// now close it
idx.Close()
store, err = leveldb.Open("test", true, false)
store, err = boltdb.Open("test", "bleve")
if err != nil {
t.Fatalf("error opening store: %v", err)
}
@ -69,7 +69,7 @@ func TestIndexOpenReopen(t *testing.T) {
func TestIndexInsert(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -107,7 +107,7 @@ func TestIndexInsert(t *testing.T) {
func TestIndexInsertThenDelete(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -175,7 +175,7 @@ func TestIndexInsertThenDelete(t *testing.T) {
func TestIndexInsertThenUpdate(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -224,7 +224,7 @@ func TestIndexInsertThenUpdate(t *testing.T) {
func TestIndexInsertMultiple(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -258,7 +258,7 @@ func TestIndexInsertMultiple(t *testing.T) {
// close and reopen and and one more to testing counting works correctly
idx.Close()
store, err = leveldb.Open("test", true, false)
store, err = boltdb.Open("test", "bleve")
idx = NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -283,7 +283,7 @@ func TestIndexInsertMultiple(t *testing.T) {
func TestIndexInsertWithStore(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}
@ -340,7 +340,7 @@ func TestIndexInsertWithStore(t *testing.T) {
func TestIndexInternalCRUD(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -391,7 +391,7 @@ func TestIndexInternalCRUD(t *testing.T) {
func TestIndexBatch(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
idx := NewUpsideDownCouch(store)
err = idx.Open()
if err != nil {
@ -465,7 +465,7 @@ func TestIndexBatch(t *testing.T) {
func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}
@ -616,7 +616,7 @@ func TestIndexInsertUpdateDeleteWithMultipleTypesStored(t *testing.T) {
func TestIndexInsertFields(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}
@ -655,7 +655,7 @@ func TestIndexInsertFields(t *testing.T) {
func TestIndexUpdateComposites(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}
@ -724,7 +724,7 @@ func TestIndexUpdateComposites(t *testing.T) {
func TestIndexFieldsMisc(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}
@ -761,7 +761,7 @@ func TestIndexFieldsMisc(t *testing.T) {
func TestIndexTermReaderCompositeFields(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}
@ -801,7 +801,7 @@ func TestIndexTermReaderCompositeFields(t *testing.T) {
func TestIndexDocumentFieldTerms(t *testing.T) {
defer os.RemoveAll("test")
store, err := leveldb.Open("test", true, true)
store, err := boltdb.Open("test", "bleve")
if err != nil {
t.Error(err)
}

View File

@ -24,7 +24,7 @@ func TestIndexMeta(t *testing.T) {
}
// create meta
im := &indexMeta{Storage: "leveldb"}
im := &indexMeta{Storage: "boltdb"}
err = im.Save(testIndexPath)
if err != nil {
t.Error(err)
@ -36,8 +36,8 @@ func TestIndexMeta(t *testing.T) {
if err != nil {
t.Error(err)
}
if im.Storage != "leveldb" {
t.Errorf("expected storage 'leveldb', got '%s'", im.Storage)
if im.Storage != "boltdb" {
t.Errorf("expected storage 'boltdb', got '%s'", im.Storage)
}
// save a meta that already exists