Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-ds-leveldb
Commits
4a150350
Commit
4a150350
authored
Jul 16, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
betterify the everything
parent
e1ecea90
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
10 deletions
+8
-10
datastore.go
datastore.go
+6
-8
ds_test.go
ds_test.go
+2
-2
No files found.
datastore.go
View file @
4a150350
package
leveldb
import
(
"io"
ds
"github.com/jbenet/go-datastore"
"github.com/jbenet/go-datastore/Godeps/_workspace/src/github.com/jbenet/goprocess"
"github.com/jbenet/go-datastore/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb"
...
...
@@ -11,18 +9,13 @@ import (
dsq
"github.com/jbenet/go-datastore/query"
)
type
Datastore
interface
{
ds
.
ThreadSafeDatastore
io
.
Closer
}
type
datastore
struct
{
DB
*
leveldb
.
DB
}
type
Options
opt
.
Options
func
NewDatastore
(
path
string
,
opts
*
Options
)
(
D
atastore
,
error
)
{
func
NewDatastore
(
path
string
,
opts
*
Options
)
(
*
d
atastore
,
error
)
{
var
nopts
opt
.
Options
if
opts
!=
nil
{
nopts
=
opt
.
Options
(
*
opts
)
...
...
@@ -148,6 +141,11 @@ func (d *datastore) runQuery(worker goprocess.Process, qrb *dsq.ResultBuilder) {
}
}
func
(
d
*
datastore
)
Batch
()
(
ds
.
Batch
,
error
)
{
// TODO: implement batch on leveldb
return
nil
,
ds
.
ErrBatchUnsupported
}
// LevelDB needs to be closed.
func
(
d
*
datastore
)
Close
()
(
err
error
)
{
return
d
.
DB
.
Close
()
...
...
ds_test.go
View file @
4a150350
...
...
@@ -25,7 +25,7 @@ var testcases = map[string]string{
//
// d, close := newDS(t)
// defer close()
func
newDS
(
t
*
testing
.
T
)
(
D
atastore
,
func
())
{
func
newDS
(
t
*
testing
.
T
)
(
*
d
atastore
,
func
())
{
path
,
err
:=
ioutil
.
TempDir
(
"/tmp"
,
"testing_leveldb_"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
...
...
@@ -41,7 +41,7 @@ func newDS(t *testing.T) (Datastore, func()) {
}
}
func
addTestCases
(
t
*
testing
.
T
,
d
D
atastore
,
testcases
map
[
string
]
string
)
{
func
addTestCases
(
t
*
testing
.
T
,
d
*
d
atastore
,
testcases
map
[
string
]
string
)
{
for
k
,
v
:=
range
testcases
{
dsk
:=
ds
.
NewKey
(
k
)
if
err
:=
d
.
Put
(
dsk
,
[]
byte
(
v
));
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment