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
27c9da23
Commit
27c9da23
authored
Jun 25, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add in support for batched writes
parent
aaac529a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
datastore.go
datastore.go
+34
-0
No files found.
datastore.go
View file @
27c9da23
...
@@ -100,6 +100,40 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -100,6 +100,40 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
return
qr
,
nil
return
qr
,
nil
}
}
type
ldbBatch
struct
{
b
*
leveldb
.
Batch
d
*
datastore
}
func
(
d
*
datastore
)
StartBatchOp
()
ds
.
Transaction
{
return
&
ldbBatch
{
b
:
new
(
leveldb
.
Batch
),
d
:
d
,
}
}
func
(
b
*
ldbBatch
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
v
,
ok
:=
val
.
([]
byte
)
if
!
ok
{
return
ds
.
ErrInvalidType
}
b
.
b
.
Put
(
key
.
Bytes
(),
v
)
// #dealwithit
return
nil
}
func
(
b
*
ldbBatch
)
Delete
(
key
ds
.
Key
)
error
{
b
.
b
.
Delete
(
key
.
Bytes
())
return
nil
}
func
(
b
*
ldbBatch
)
Commit
()
error
{
opts
:=
&
opt
.
WriteOptions
{
Sync
:
true
}
if
err
:=
b
.
d
.
DB
.
Write
(
b
.
b
,
opts
);
err
!=
nil
{
return
err
}
return
nil
}
func
(
d
*
datastore
)
runQuery
(
worker
goprocess
.
Process
,
qrb
*
dsq
.
ResultBuilder
)
{
func
(
d
*
datastore
)
runQuery
(
worker
goprocess
.
Process
,
qrb
*
dsq
.
ResultBuilder
)
{
var
rnge
*
util
.
Range
var
rnge
*
util
.
Range
...
...
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