|
@@ -1,9 +1,8 @@
|
|
-package ezleveldb
|
|
|
|
|
|
+package ezdb
|
|
|
|
|
|
import (
|
|
import (
|
|
"os"
|
|
"os"
|
|
|
|
|
|
- "github.com/annybs/ezdb"
|
|
|
|
"github.com/syndtr/goleveldb/leveldb"
|
|
"github.com/syndtr/goleveldb/leveldb"
|
|
"github.com/syndtr/goleveldb/leveldb/opt"
|
|
"github.com/syndtr/goleveldb/leveldb/opt"
|
|
)
|
|
)
|
|
@@ -12,7 +11,7 @@ type LevelDBCollection[T any] struct {
|
|
path string
|
|
path string
|
|
|
|
|
|
db *leveldb.DB
|
|
db *leveldb.DB
|
|
- m ezdb.DocumentMarshaler[T, []byte]
|
|
|
|
|
|
+ m DocumentMarshaler[T, []byte]
|
|
|
|
|
|
optOpen *opt.Options
|
|
optOpen *opt.Options
|
|
optRead *opt.ReadOptions
|
|
optRead *opt.ReadOptions
|
|
@@ -94,7 +93,7 @@ func (c *LevelDBCollection[T]) Has(key string) (bool, error) {
|
|
return c.db.Has([]byte(key), c.optRead)
|
|
return c.db.Has([]byte(key), c.optRead)
|
|
}
|
|
}
|
|
|
|
|
|
-func (c *LevelDBCollection[T]) Iter() ezdb.Iterator[T] {
|
|
|
|
|
|
+func (c *LevelDBCollection[T]) Iter() Iterator[T] {
|
|
i := &LevelDBIterator[T]{
|
|
i := &LevelDBIterator[T]{
|
|
i: c.db.NewIterator(nil, c.optRead),
|
|
i: c.db.NewIterator(nil, c.optRead),
|
|
m: c.m,
|
|
m: c.m,
|
|
@@ -117,7 +116,7 @@ func (c *LevelDBCollection[T]) Open() error {
|
|
}
|
|
}
|
|
|
|
|
|
func (c *LevelDBCollection[T]) Put(key string, src T) error {
|
|
func (c *LevelDBCollection[T]) Put(key string, src T) error {
|
|
- if err := ezdb.ValidateKey(key); err != nil {
|
|
|
|
|
|
+ if err := ValidateKey(key); err != nil {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
@@ -130,7 +129,7 @@ func (c *LevelDBCollection[T]) Put(key string, src T) error {
|
|
}
|
|
}
|
|
|
|
|
|
// LevelDB creates a new collection using LevelDB storage.
|
|
// LevelDB creates a new collection using LevelDB storage.
|
|
-func LevelDB[T any](path string, m ezdb.DocumentMarshaler[T, []byte], o *LevelDBOptions) *LevelDBCollection[T] {
|
|
|
|
|
|
+func LevelDB[T any](path string, m DocumentMarshaler[T, []byte], o *LevelDBOptions) *LevelDBCollection[T] {
|
|
c := &LevelDBCollection[T]{
|
|
c := &LevelDBCollection[T]{
|
|
path: path,
|
|
path: path,
|
|
|
|
|