Skip to content

Commit

Permalink
removed bleve-mem, as it duplicates mem kvStoreName
Browse files Browse the repository at this point in the history
  • Loading branch information
steveyen committed Apr 10, 2015
1 parent 117d9e2 commit d708f98
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 59 deletions.
1 change: 0 additions & 1 deletion docs/api-ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ supported index types:
* alias - supports fan-out of queries to multiple index targets
* blackhole - ignores all incoming data and is not queryable; used for testing
* bleve - full-text index powered by the bleve full-text-search engine
* bleve-mem - full-text index powered by bleve (in memory only)

**param: planParams**: optional, string (JSON), form parameter

Expand Down
37 changes: 4 additions & 33 deletions pindex_impl_bleve.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ type BleveParams struct {
func NewBleveParams() *BleveParams {
return &BleveParams{
Mapping: *bleve.NewIndexMapping(),
Store: map[string]interface{}{
"kvStoreName": bleve.Config.DefaultKVStore,
},
}
}

Expand Down Expand Up @@ -113,19 +116,6 @@ func init() {
" powered by the bleve full-text-search engine",
StartSample: NewBleveParams(),
})

RegisterPIndexImplType("bleve-mem", &PIndexImplType{
Validate: ValidateBlevePIndexImpl,

New: NewBlevePIndexImpl,
Open: OpenBlevePIndexImpl,
Count: CountBlevePIndexImpl,
Query: QueryBlevePIndexImpl,

Description: "bleve-mem - full-text index" +
" powered by bleve (in memory only)",
StartSample: NewBleveParams(),
})
}

func ValidateBlevePIndexImpl(indexType, indexName, indexParams string) error {
Expand All @@ -146,20 +136,6 @@ func NewBlevePIndexImpl(indexType, indexParams, path string,
}
}

blevePath := path
if indexType == "bleve-mem" {
blevePath = "" // Force bleve to use memory-only storage.

// For a normal, non-empty path, bleve will create the
// directory (and also expects path not to exist yet
// beforehand). And, for an empty path, we need to create the
// directory here because bleve won't do so.
err := os.MkdirAll(path, 0700)
if err != nil {
return nil, nil, err
}
}

kvStoreName, ok := bleveParams.Store["kvStoreName"].(string)
if !ok || kvStoreName == "" {
kvStoreName = bleve.Config.DefaultKVStore
Expand All @@ -184,7 +160,7 @@ func NewBlevePIndexImpl(indexType, indexParams, path string,
}

bindex, err :=
bleve.NewUsing(blevePath, &bleveParams.Mapping, kvStoreName, kvConfig)
bleve.NewUsing(path, &bleveParams.Mapping, kvStoreName, kvConfig)
if err != nil {
return nil, nil, fmt.Errorf("bleve: new index, path: %s,"+
" kvStoreName: %s, kvConfig: %#v, err: %s",
Expand All @@ -204,11 +180,6 @@ func NewBlevePIndexImpl(indexType, indexParams, path string,

func OpenBlevePIndexImpl(indexType, path string,
restart func()) (PIndexImpl, Dest, error) {
if indexType == "bleve-mem" {
return nil, nil, fmt.Errorf("bleve: cannot re-open bleve-mem,"+
" path: %s", path)
}

buf, err := ioutil.ReadFile(path +
string(os.PathSeparator) + "PINDEX_BLEVE_META")
if err != nil {
Expand Down
21 changes: 0 additions & 21 deletions pindex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,27 +165,6 @@ func TestBlackholePIndexImpl(t *testing.T) {
}
}

func TestNewPIndexBleveMem(t *testing.T) {
emptyDir, _ := ioutil.TempDir("./tmp", "test")
defer os.RemoveAll(emptyDir)

pindex, err := NewPIndex(nil, "fake", "uuid",
"bleve-mem", "indexName", "indexUUID", "",
"sourceType", "sourceName", "sourceUUID", "sourceParams", "sourcePartitions",
PIndexPath(emptyDir, "fake"))
if pindex == nil || err != nil {
t.Errorf("expected NewPIndex to work")
}
pindex2, err := OpenPIndex(nil, PIndexPath(emptyDir, "fake"))
if pindex2 != nil || err == nil {
t.Errorf("expected OpenPIndex to fail for bleve-mem")
}
err = pindex.Close(true)
if err != nil {
t.Errorf("expected Close to work")
}
}

func TestErrorConsistencyWait(t *testing.T) {
e := &ErrorConsistencyWait{}
if e.Error() == "" {
Expand Down
4 changes: 0 additions & 4 deletions rest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,6 @@ func TestHandlersForOneBleveIndexWithNILFeed(t *testing.T) {
testHandlersForOneBleveTypeIndexWithNILFeed(t, "bleve")
}

func TestHandlersForOneBleveMemIndexWithNILFeed(t *testing.T) {
testHandlersForOneBleveTypeIndexWithNILFeed(t, "bleve-mem")
}

func testHandlersForOneBleveTypeIndexWithNILFeed(t *testing.T, indexType string) {
emptyDir, _ := ioutil.TempDir("./tmp", "test")
defer os.RemoveAll(emptyDir)
Expand Down

0 comments on commit d708f98

Please sign in to comment.