Merge branch 'develop'

This commit is contained in:
siddontang 2014-07-29 08:58:38 +08:00
commit b85ce97e9f
6 changed files with 40 additions and 7 deletions

View File

@ -6,5 +6,5 @@ go get github.com/siddontang/go-log/log
go get github.com/siddontang/go-snappy/snappy go get github.com/siddontang/go-snappy/snappy
go get github.com/siddontang/copier go get github.com/siddontang/copier
go get github.com/syndtr/goleveldb/leveldb go get github.com/siddontang/goleveldb/leveldb
go get github.com/influxdb/gomdb go get github.com/influxdb/gomdb

View File

@ -1,7 +1,7 @@
package goleveldb package goleveldb
import ( import (
"github.com/syndtr/goleveldb/leveldb" "github.com/siddontang/goleveldb/leveldb"
) )
type WriteBatch struct { type WriteBatch struct {

View File

@ -1,11 +1,11 @@
package goleveldb package goleveldb
import ( import (
"github.com/siddontang/goleveldb/leveldb"
"github.com/siddontang/goleveldb/leveldb/cache"
"github.com/siddontang/goleveldb/leveldb/filter"
"github.com/siddontang/goleveldb/leveldb/opt"
"github.com/siddontang/ledisdb/store/driver" "github.com/siddontang/ledisdb/store/driver"
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/cache"
"github.com/syndtr/goleveldb/leveldb/filter"
"github.com/syndtr/goleveldb/leveldb/opt"
"os" "os"
) )

View File

@ -1,7 +1,7 @@
package goleveldb package goleveldb
import ( import (
"github.com/syndtr/goleveldb/leveldb/iterator" "github.com/siddontang/goleveldb/leveldb/iterator"
) )
type Iterator struct { type Iterator struct {

View File

@ -15,6 +15,9 @@ func (w *WriteBatch) Close() error {
} }
func (w *WriteBatch) Put(key, value []byte) { func (w *WriteBatch) Put(key, value []byte) {
if value == nil {
value = []byte{}
}
w.wb = append(w.wb, Write{key, value}) w.wb = append(w.wb, Write{key, value})
} }

View File

@ -37,6 +37,16 @@ func testSimple(db *DB, t *testing.T) {
} else if v != nil { } else if v != nil {
t.Fatal("must nil") t.Fatal("must nil")
} }
if err := db.Put(key, nil); err != nil {
t.Fatal(err)
}
if v, err := db.Get(key); err != nil {
t.Fatal(err)
} else if !bytes.Equal(v, []byte{}) {
t.Fatal("must empty")
}
} }
func testBatch(db *DB, t *testing.T) { func testBatch(db *DB, t *testing.T) {
@ -80,7 +90,27 @@ func testBatch(db *DB, t *testing.T) {
t.Fatal(string(v)) t.Fatal(string(v))
} }
wb.Put(key1, nil)
wb.Put(key2, []byte{})
if err := wb.Commit(); err != nil {
t.Fatal(err)
}
if v, err := db.Get(key1); err != nil {
t.Fatal(err)
} else if !bytes.Equal(v, []byte{}) {
t.Fatal("must empty")
}
if v, err := db.Get(key2); err != nil {
t.Fatal(err)
} else if !bytes.Equal(v, []byte{}) {
t.Fatal("must empty")
}
db.Delete(key1) db.Delete(key1)
db.Delete(key2)
} }
func checkIterator(it *RangeLimitIterator, cv ...int) error { func checkIterator(it *RangeLimitIterator, cv ...int) error {