0
0

remove forestdb for now

not any benfefit in maintaining this for the time being
This commit is contained in:
Marty Schoch 2014-09-12 16:55:11 -04:00
parent 8c16d68c00
commit 2294b24b9d
5 changed files with 0 additions and 281 deletions

View File

@ -1,53 +0,0 @@
// 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 forestdb
package goforestdb
type ForestDBBatch struct {
store *ForestDBStore
keys [][]byte
vals [][]byte
}
func newForestDBBatch(store *ForestDBStore) *ForestDBBatch {
rv := ForestDBBatch{
store: store,
keys: make([][]byte, 0),
vals: make([][]byte, 0),
}
return &rv
}
func (i *ForestDBBatch) Set(key, val []byte) {
i.keys = append(i.keys, key)
i.vals = append(i.vals, val)
}
func (i *ForestDBBatch) Delete(key []byte) {
i.keys = append(i.keys, key)
i.vals = append(i.vals, nil)
}
func (i *ForestDBBatch) Execute() error {
for index, key := range i.keys {
val := i.vals[index]
if val == nil {
i.store.Delete(key)
} else {
i.store.Set(key, val)
}
}
return nil
}
func (i *ForestDBBatch) Close() error {
return nil
}

View File

@ -1,99 +0,0 @@
// 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 forestdb
package goforestdb
import (
"github.com/couchbaselabs/goforestdb"
)
type ForestDBIterator struct {
store *ForestDBStore
valid bool
curr *forestdb.Doc
iter *forestdb.Iterator
}
func newForestDBIterator(store *ForestDBStore) *ForestDBIterator {
rv := ForestDBIterator{
store: store,
}
return &rv
}
func (f *ForestDBIterator) SeekFirst() {
if f.iter != nil {
f.iter.Close()
f.iter = nil
}
var err error
f.iter, err = f.store.db.IteratorInit([]byte{}, nil, forestdb.ITR_NONE)
if err != nil {
f.valid = false
return
}
f.valid = true
f.Next()
}
func (f *ForestDBIterator) Seek(key []byte) {
if f.iter != nil {
f.iter.Close()
f.iter = nil
}
var err error
f.iter, err = f.store.db.IteratorInit(key, nil, forestdb.ITR_NONE)
if err != nil {
f.valid = false
return
}
f.valid = true
f.Next()
}
func (f *ForestDBIterator) Next() {
var err error
f.curr, err = f.iter.Next()
if err != nil {
f.valid = false
}
}
func (f *ForestDBIterator) Current() ([]byte, []byte, bool) {
if f.valid {
return f.Key(), f.Value(), true
}
return nil, nil, false
}
func (f *ForestDBIterator) Key() []byte {
if f.valid && f.curr != nil {
return f.curr.Key()
}
return nil
}
func (f *ForestDBIterator) Value() []byte {
if f.valid && f.curr != nil {
return f.curr.Body()
}
return nil
}
func (f *ForestDBIterator) Valid() bool {
return f.valid
}
func (f *ForestDBIterator) Close() {
f.valid = false
f.iter.Close()
f.iter = nil
}

View File

@ -1,70 +0,0 @@
// 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 forestdb
package goforestdb
import (
"github.com/blevesearch/bleve/index/store"
"github.com/couchbaselabs/goforestdb"
)
type ForestDBStore struct {
path string
db *forestdb.Database
}
func Open(path string) (*ForestDBStore, error) {
rv := ForestDBStore{
path: path,
}
var err error
rv.db, err = forestdb.Open(path, nil)
if err != nil {
return nil, err
}
return &rv, nil
}
func (f *ForestDBStore) Get(key []byte) ([]byte, error) {
res, err := f.db.GetKV(key)
if err != nil && err != forestdb.RESULT_KEY_NOT_FOUND {
return nil, err
}
return res, nil
}
func (f *ForestDBStore) Set(key, val []byte) error {
return f.db.SetKV(key, val)
}
func (f *ForestDBStore) Delete(key []byte) error {
return f.db.DeleteKV(key)
}
func (f *ForestDBStore) Commit() error {
return f.db.Commit(forestdb.COMMIT_NORMAL)
}
func (f *ForestDBStore) Close() error {
return f.db.Close()
}
func (f *ForestDBStore) Iterator(key []byte) store.KVIterator {
rv := newForestDBIterator(f)
rv.Seek(key)
return rv
}
func (f *ForestDBStore) NewBatch() store.KVBatch {
return newForestDBBatch(f)
}

View File

@ -1,29 +0,0 @@
// 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 forestdb
package goforestdb
import (
"os"
"testing"
"github.com/blevesearch/bleve/index/store/test"
)
func TestForestDBStore(t *testing.T) {
s, err := Open("test")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll("test")
store_test.CommonTestKVStore(t, s)
}

View File

@ -1,30 +0,0 @@
// 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 forestdb
package upside_down
import (
"os"
"testing"
"github.com/blevesearch/bleve/index/store/goforestdb"
)
func BenchmarkForestDBIndexing(b *testing.B) {
s, err := goforestdb.Open("test")
if err != nil {
b.Fatal(err)
}
defer os.RemoveAll("test")
defer s.Close()
CommonBenchmarkIndex(b, s)
}