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-datastore
Commits
1702774c
Commit
1702774c
authored
Jun 26, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename Transaction to Batch
parent
c3fa34b4
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
78 additions
and
78 deletions
+78
-78
basic_ds.go
basic_ds.go
+7
-7
callback/callback.go
callback/callback.go
+2
-2
coalesce/coalesce.go
coalesce/coalesce.go
+2
-2
datastore.go
datastore.go
+3
-3
flatfs/flatfs.go
flatfs/flatfs.go
+6
-6
fs/fs.go
fs/fs.go
+2
-2
keytransform/keytransform.go
keytransform/keytransform.go
+8
-8
leveldb/datastore.go
leveldb/datastore.go
+1
-1
lru/datastore.go
lru/datastore.go
+2
-2
measure/measure.go
measure/measure.go
+10
-10
mount/mount.go
mount/mount.go
+10
-10
panic/panic.go
panic/panic.go
+7
-7
sync/sync.go
sync/sync.go
+2
-2
tiered/tiered.go
tiered/tiered.go
+7
-7
timecache/timecache.go
timecache/timecache.go
+2
-2
transaction.go
transaction.go
+7
-7
No files found.
basic_ds.go
View file @
1702774c
...
@@ -63,8 +63,8 @@ func (d *MapDatastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -63,8 +63,8 @@ func (d *MapDatastore) Query(q dsq.Query) (dsq.Results, error) {
return
r
,
nil
return
r
,
nil
}
}
func
(
d
*
MapDatastore
)
Start
Batch
Op
()
Transaction
{
func
(
d
*
MapDatastore
)
Batch
()
Batch
{
return
NewBasic
Transaction
(
d
)
return
NewBasic
Batch
(
d
)
}
}
// NullDatastore stores nothing, but conforms to the API.
// NullDatastore stores nothing, but conforms to the API.
...
@@ -102,8 +102,8 @@ func (d *NullDatastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -102,8 +102,8 @@ func (d *NullDatastore) Query(q dsq.Query) (dsq.Results, error) {
return
dsq
.
ResultsWithEntries
(
q
,
nil
),
nil
return
dsq
.
ResultsWithEntries
(
q
,
nil
),
nil
}
}
func
(
d
*
NullDatastore
)
Start
Batch
Op
()
Transaction
{
func
(
d
*
NullDatastore
)
Batch
()
Batch
{
return
NewBasic
Transaction
(
d
)
return
NewBasic
Batch
(
d
)
}
}
// LogDatastore logs all accesses through the datastore.
// LogDatastore logs all accesses through the datastore.
...
@@ -163,7 +163,7 @@ func (d *LogDatastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -163,7 +163,7 @@ func (d *LogDatastore) Query(q dsq.Query) (dsq.Results, error) {
return
d
.
child
.
Query
(
q
)
return
d
.
child
.
Query
(
q
)
}
}
func
(
d
*
LogDatastore
)
Start
Batch
Op
()
Transaction
{
func
(
d
*
LogDatastore
)
Batch
()
Batch
{
log
.
Printf
(
"%s:
Start
Batch
Op
\n
"
,
d
.
Name
)
log
.
Printf
(
"%s: Batch
\n
"
,
d
.
Name
)
return
d
.
child
.
Start
Batch
Op
()
return
d
.
child
.
Batch
()
}
}
callback/callback.go
View file @
1702774c
...
@@ -41,7 +41,7 @@ func (c *Datastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -41,7 +41,7 @@ func (c *Datastore) Query(q dsq.Query) (dsq.Results, error) {
return
c
.
D
.
Query
(
q
)
return
c
.
D
.
Query
(
q
)
}
}
func
(
c
*
Datastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
c
*
Datastore
)
Batch
()
ds
.
Batch
{
c
.
F
()
c
.
F
()
return
c
.
D
.
Start
Batch
Op
()
return
c
.
D
.
Batch
()
}
}
coalesce/coalesce.go
View file @
1702774c
...
@@ -125,6 +125,6 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -125,6 +125,6 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
return
d
.
child
.
Query
(
q
)
return
d
.
child
.
Query
(
q
)
}
}
func
(
d
*
datastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
datastore
)
Batch
()
ds
.
Batch
{
return
ds
.
NewBasic
Transaction
(
d
)
return
ds
.
NewBasic
Batch
(
d
)
}
}
datastore.go
View file @
1702774c
...
@@ -68,8 +68,8 @@ type Datastore interface {
...
@@ -68,8 +68,8 @@ type Datastore interface {
//
//
Query
(
q
query
.
Query
)
(
query
.
Results
,
error
)
Query
(
q
query
.
Query
)
(
query
.
Results
,
error
)
//
Start
Batch
Op
begins a datastore transaction
// Batch begins a datastore transaction
Start
Batch
Op
()
Transaction
Batch
()
Batch
}
}
// ThreadSafeDatastore is an interface that all threadsafe datastore should
// ThreadSafeDatastore is an interface that all threadsafe datastore should
...
@@ -108,7 +108,7 @@ func GetBackedHas(ds Datastore, key Key) (bool, error) {
...
@@ -108,7 +108,7 @@ func GetBackedHas(ds Datastore, key Key) (bool, error) {
}
}
}
}
type
Transaction
interface
{
type
Batch
interface
{
Put
(
key
Key
,
val
interface
{})
error
Put
(
key
Key
,
val
interface
{})
error
Delete
(
key
Key
)
error
Delete
(
key
Key
)
error
...
...
flatfs/flatfs.go
View file @
1702774c
...
@@ -323,32 +323,32 @@ func (fs *Datastore) enumerateKeys(fi os.FileInfo, res []query.Entry) ([]query.E
...
@@ -323,32 +323,32 @@ func (fs *Datastore) enumerateKeys(fi os.FileInfo, res []query.Entry) ([]query.E
return
res
,
nil
return
res
,
nil
}
}
type
flatfs
Transaction
struct
{
type
flatfs
Batch
struct
{
puts
map
[
datastore
.
Key
]
interface
{}
puts
map
[
datastore
.
Key
]
interface
{}
deletes
map
[
datastore
.
Key
]
struct
{}
deletes
map
[
datastore
.
Key
]
struct
{}
ds
*
Datastore
ds
*
Datastore
}
}
func
(
fs
*
Datastore
)
Start
Batch
Op
()
datastore
.
Transaction
{
func
(
fs
*
Datastore
)
Batch
()
datastore
.
Batch
{
return
&
flatfs
Transaction
{
return
&
flatfs
Batch
{
puts
:
make
(
map
[
datastore
.
Key
]
interface
{}),
puts
:
make
(
map
[
datastore
.
Key
]
interface
{}),
deletes
:
make
(
map
[
datastore
.
Key
]
struct
{}),
deletes
:
make
(
map
[
datastore
.
Key
]
struct
{}),
ds
:
fs
,
ds
:
fs
,
}
}
}
}
func
(
bt
*
flatfs
Transaction
)
Put
(
key
datastore
.
Key
,
val
interface
{})
error
{
func
(
bt
*
flatfs
Batch
)
Put
(
key
datastore
.
Key
,
val
interface
{})
error
{
bt
.
puts
[
key
]
=
val
bt
.
puts
[
key
]
=
val
return
nil
return
nil
}
}
func
(
bt
*
flatfs
Transaction
)
Delete
(
key
datastore
.
Key
)
error
{
func
(
bt
*
flatfs
Batch
)
Delete
(
key
datastore
.
Key
)
error
{
bt
.
deletes
[
key
]
=
struct
{}{}
bt
.
deletes
[
key
]
=
struct
{}{}
return
nil
return
nil
}
}
func
(
bt
*
flatfs
Transaction
)
Commit
()
error
{
func
(
bt
*
flatfs
Batch
)
Commit
()
error
{
if
err
:=
bt
.
ds
.
putMany
(
bt
.
puts
);
err
!=
nil
{
if
err
:=
bt
.
ds
.
putMany
(
bt
.
puts
);
err
!=
nil
{
return
err
return
err
}
}
...
...
fs/fs.go
View file @
1702774c
...
@@ -130,10 +130,10 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) {
...
@@ -130,10 +130,10 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) {
return
r
,
nil
return
r
,
nil
}
}
func
(
d
*
Datastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
Datastore
)
Batch
()
ds
.
Batch
{
// just use basic transaction for now, this datastore
// just use basic transaction for now, this datastore
// isnt really used in performant code yet
// isnt really used in performant code yet
return
ds
.
NewBasic
Transaction
(
d
)
return
ds
.
NewBasic
Batch
(
d
)
}
}
// isDir returns whether given path is a directory
// isDir returns whether given path is a directory
...
...
keytransform/keytransform.go
View file @
1702774c
...
@@ -74,27 +74,27 @@ func (d *ktds) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -74,27 +74,27 @@ func (d *ktds) Query(q dsq.Query) (dsq.Results, error) {
return
dsq
.
DerivedResults
(
qr
,
ch
),
nil
return
dsq
.
DerivedResults
(
qr
,
ch
),
nil
}
}
func
(
d
*
ktds
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
ktds
)
Batch
()
ds
.
Batch
{
return
&
transform
Transaction
{
return
&
transform
Batch
{
dst
:
d
.
child
.
Start
Batch
Op
(),
dst
:
d
.
child
.
Batch
(),
f
:
d
.
ConvertKey
,
f
:
d
.
ConvertKey
,
}
}
}
}
type
transform
Transaction
struct
{
type
transform
Batch
struct
{
dst
ds
.
Transaction
dst
ds
.
Batch
f
KeyMapping
f
KeyMapping
}
}
func
(
t
*
transform
Transaction
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
func
(
t
*
transform
Batch
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
return
t
.
dst
.
Put
(
t
.
f
(
key
),
val
)
return
t
.
dst
.
Put
(
t
.
f
(
key
),
val
)
}
}
func
(
t
*
transform
Transaction
)
Delete
(
key
ds
.
Key
)
error
{
func
(
t
*
transform
Batch
)
Delete
(
key
ds
.
Key
)
error
{
return
t
.
dst
.
Delete
(
t
.
f
(
key
))
return
t
.
dst
.
Delete
(
t
.
f
(
key
))
}
}
func
(
t
*
transform
Transaction
)
Commit
()
error
{
func
(
t
*
transform
Batch
)
Commit
()
error
{
return
t
.
dst
.
Commit
()
return
t
.
dst
.
Commit
()
}
}
leveldb/datastore.go
View file @
1702774c
...
@@ -105,7 +105,7 @@ type ldbBatch struct {
...
@@ -105,7 +105,7 @@ type ldbBatch struct {
d
*
datastore
d
*
datastore
}
}
func
(
d
*
datastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
datastore
)
Batch
()
ds
.
Batch
{
return
&
ldbBatch
{
return
&
ldbBatch
{
b
:
new
(
leveldb
.
Batch
),
b
:
new
(
leveldb
.
Batch
),
d
:
d
,
d
:
d
,
...
...
lru/datastore.go
View file @
1702774c
...
@@ -55,6 +55,6 @@ func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -55,6 +55,6 @@ func (d *Datastore) Query(q dsq.Query) (dsq.Results, error) {
return
nil
,
errors
.
New
(
"KeyList not implemented."
)
return
nil
,
errors
.
New
(
"KeyList not implemented."
)
}
}
func
(
d
*
Datastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
Datastore
)
Batch
()
ds
.
Batch
{
return
ds
.
NewBasic
Transaction
(
d
)
return
ds
.
NewBasic
Batch
(
d
)
}
}
measure/measure.go
View file @
1702774c
...
@@ -148,36 +148,36 @@ func (m *measure) Query(q query.Query) (query.Results, error) {
...
@@ -148,36 +148,36 @@ func (m *measure) Query(q query.Query) (query.Results, error) {
return
res
,
err
return
res
,
err
}
}
type
measured
Transaction
struct
{
type
measured
Batch
struct
{
puts
int
puts
int
deletes
int
deletes
int
putts
datastore
.
Transaction
putts
datastore
.
Batch
delts
datastore
.
Transaction
delts
datastore
.
Batch
m
*
measure
m
*
measure
}
}
func
(
m
*
measure
)
Start
Batch
Op
()
datastore
.
Transaction
{
func
(
m
*
measure
)
Batch
()
datastore
.
Batch
{
return
&
measured
Transaction
{
return
&
measured
Batch
{
putts
:
m
.
backend
.
Start
Batch
Op
(),
putts
:
m
.
backend
.
Batch
(),
delts
:
m
.
backend
.
Start
Batch
Op
(),
delts
:
m
.
backend
.
Batch
(),
m
:
m
,
m
:
m
,
}
}
}
}
func
(
mt
*
measured
Transaction
)
Put
(
key
datastore
.
Key
,
val
interface
{})
error
{
func
(
mt
*
measured
Batch
)
Put
(
key
datastore
.
Key
,
val
interface
{})
error
{
mt
.
puts
++
mt
.
puts
++
return
mt
.
putts
.
Put
(
key
,
val
)
return
mt
.
putts
.
Put
(
key
,
val
)
}
}
func
(
mt
*
measured
Transaction
)
Delete
(
key
datastore
.
Key
)
error
{
func
(
mt
*
measured
Batch
)
Delete
(
key
datastore
.
Key
)
error
{
mt
.
deletes
++
mt
.
deletes
++
return
mt
.
delts
.
Delete
(
key
)
return
mt
.
delts
.
Delete
(
key
)
}
}
func
(
mt
*
measured
Transaction
)
Commit
()
error
{
func
(
mt
*
measured
Batch
)
Commit
()
error
{
if
mt
.
deletes
>
0
{
if
mt
.
deletes
>
0
{
before
:=
time
.
Now
()
before
:=
time
.
Now
()
err
:=
mt
.
delts
.
Commit
()
err
:=
mt
.
delts
.
Commit
()
...
...
mount/mount.go
View file @
1702774c
...
@@ -115,42 +115,42 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) {
...
@@ -115,42 +115,42 @@ func (d *Datastore) Query(q query.Query) (query.Results, error) {
return
r
,
nil
return
r
,
nil
}
}
type
mount
Transaction
struct
{
type
mount
Batch
struct
{
mounts
map
[
string
]
datastore
.
Transaction
mounts
map
[
string
]
datastore
.
Batch
d
*
Datastore
d
*
Datastore
}
}
func
(
d
*
Datastore
)
Start
Batch
Op
()
datastore
.
Transaction
{
func
(
d
*
Datastore
)
Batch
()
datastore
.
Batch
{
return
&
mount
Transaction
{
return
&
mount
Batch
{
mounts
:
make
(
map
[
string
]
datastore
.
Transaction
),
mounts
:
make
(
map
[
string
]
datastore
.
Batch
),
d
:
d
,
d
:
d
,
}
}
}
}
func
(
mt
*
mount
Transaction
)
Put
(
key
datastore
.
Key
,
val
interface
{})
error
{
func
(
mt
*
mount
Batch
)
Put
(
key
datastore
.
Key
,
val
interface
{})
error
{
child
,
loc
,
rest
:=
mt
.
d
.
lookup
(
key
)
child
,
loc
,
rest
:=
mt
.
d
.
lookup
(
key
)
t
,
ok
:=
mt
.
mounts
[
loc
.
String
()]
t
,
ok
:=
mt
.
mounts
[
loc
.
String
()]
if
!
ok
{
if
!
ok
{
t
=
child
.
Start
Batch
Op
()
t
=
child
.
Batch
()
mt
.
mounts
[
loc
.
String
()]
=
t
mt
.
mounts
[
loc
.
String
()]
=
t
}
}
return
t
.
Put
(
rest
,
val
)
return
t
.
Put
(
rest
,
val
)
}
}
func
(
mt
*
mount
Transaction
)
Delete
(
key
datastore
.
Key
)
error
{
func
(
mt
*
mount
Batch
)
Delete
(
key
datastore
.
Key
)
error
{
child
,
loc
,
rest
:=
mt
.
d
.
lookup
(
key
)
child
,
loc
,
rest
:=
mt
.
d
.
lookup
(
key
)
t
,
ok
:=
mt
.
mounts
[
loc
.
String
()]
t
,
ok
:=
mt
.
mounts
[
loc
.
String
()]
if
!
ok
{
if
!
ok
{
t
=
child
.
Start
Batch
Op
()
t
=
child
.
Batch
()
mt
.
mounts
[
loc
.
String
()]
=
t
mt
.
mounts
[
loc
.
String
()]
=
t
}
}
return
t
.
Delete
(
rest
)
return
t
.
Delete
(
rest
)
}
}
func
(
mt
*
mount
Transaction
)
Commit
()
error
{
func
(
mt
*
mount
Batch
)
Commit
()
error
{
for
_
,
t
:=
range
mt
.
mounts
{
for
_
,
t
:=
range
mt
.
mounts
{
err
:=
t
.
Commit
()
err
:=
t
.
Commit
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
panic/panic.go
View file @
1702774c
...
@@ -67,11 +67,11 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -67,11 +67,11 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
return
r
,
nil
return
r
,
nil
}
}
type
panic
Transaction
struct
{
type
panic
Batch
struct
{
t
ds
.
Transaction
t
ds
.
Batch
}
}
func
(
p
*
panic
Transaction
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
func
(
p
*
panic
Batch
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
err
:=
p
.
t
.
Put
(
key
,
val
)
err
:=
p
.
t
.
Put
(
key
,
val
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stdout
,
"panic datastore: %s"
,
err
)
fmt
.
Fprintf
(
os
.
Stdout
,
"panic datastore: %s"
,
err
)
...
@@ -80,7 +80,7 @@ func (p *panicTransaction) Put(key ds.Key, val interface{}) error {
...
@@ -80,7 +80,7 @@ func (p *panicTransaction) Put(key ds.Key, val interface{}) error {
return
nil
return
nil
}
}
func
(
p
*
panic
Transaction
)
Delete
(
key
ds
.
Key
)
error
{
func
(
p
*
panic
Batch
)
Delete
(
key
ds
.
Key
)
error
{
err
:=
p
.
t
.
Delete
(
key
)
err
:=
p
.
t
.
Delete
(
key
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stdout
,
"panic datastore: %s"
,
err
)
fmt
.
Fprintf
(
os
.
Stdout
,
"panic datastore: %s"
,
err
)
...
@@ -89,7 +89,7 @@ func (p *panicTransaction) Delete(key ds.Key) error {
...
@@ -89,7 +89,7 @@ func (p *panicTransaction) Delete(key ds.Key) error {
return
nil
return
nil
}
}
func
(
p
*
panic
Transaction
)
Commit
()
error
{
func
(
p
*
panic
Batch
)
Commit
()
error
{
err
:=
p
.
t
.
Commit
()
err
:=
p
.
t
.
Commit
()
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Fprintf
(
os
.
Stdout
,
"panic datastore: %s"
,
err
)
fmt
.
Fprintf
(
os
.
Stdout
,
"panic datastore: %s"
,
err
)
...
@@ -98,6 +98,6 @@ func (p *panicTransaction) Commit() error {
...
@@ -98,6 +98,6 @@ func (p *panicTransaction) Commit() error {
return
nil
return
nil
}
}
func
(
d
*
datastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
datastore
)
Batch
()
ds
.
Batch
{
return
&
panic
Transaction
{
d
.
child
.
Start
Batch
Op
()}
return
&
panic
Batch
{
d
.
child
.
Batch
()}
}
}
sync/sync.go
View file @
1702774c
...
@@ -64,8 +64,8 @@ func (d *MutexDatastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -64,8 +64,8 @@ func (d *MutexDatastore) Query(q dsq.Query) (dsq.Results, error) {
return
d
.
child
.
Query
(
q
)
return
d
.
child
.
Query
(
q
)
}
}
func
(
d
*
MutexDatastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
MutexDatastore
)
Batch
()
ds
.
Batch
{
d
.
RLock
()
d
.
RLock
()
defer
d
.
RUnlock
()
defer
d
.
RUnlock
()
return
d
.
child
.
Start
Batch
Op
()
return
d
.
child
.
Batch
()
}
}
tiered/tiered.go
View file @
1702774c
...
@@ -93,17 +93,17 @@ func (d tiered) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -93,17 +93,17 @@ func (d tiered) Query(q dsq.Query) (dsq.Results, error) {
return
d
[
len
(
d
)
-
1
]
.
Query
(
q
)
return
d
[
len
(
d
)
-
1
]
.
Query
(
q
)
}
}
type
tiered
Transaction
[]
ds
.
Transaction
type
tiered
Batch
[]
ds
.
Batch
func
(
d
tiered
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
tiered
)
Batch
()
ds
.
Batch
{
var
out
tiered
Transaction
var
out
tiered
Batch
for
_
,
ds
:=
range
d
{
for
_
,
ds
:=
range
d
{
out
=
append
(
out
,
ds
.
Start
Batch
Op
())
out
=
append
(
out
,
ds
.
Batch
())
}
}
return
out
return
out
}
}
func
(
t
tiered
Transaction
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
func
(
t
tiered
Batch
)
Put
(
key
ds
.
Key
,
val
interface
{})
error
{
for
_
,
ts
:=
range
t
{
for
_
,
ts
:=
range
t
{
err
:=
ts
.
Put
(
key
,
val
)
err
:=
ts
.
Put
(
key
,
val
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -113,7 +113,7 @@ func (t tieredTransaction) Put(key ds.Key, val interface{}) error {
...
@@ -113,7 +113,7 @@ func (t tieredTransaction) Put(key ds.Key, val interface{}) error {
return
nil
return
nil
}
}
func
(
t
tiered
Transaction
)
Delete
(
key
ds
.
Key
)
error
{
func
(
t
tiered
Batch
)
Delete
(
key
ds
.
Key
)
error
{
for
_
,
ts
:=
range
t
{
for
_
,
ts
:=
range
t
{
err
:=
ts
.
Delete
(
key
)
err
:=
ts
.
Delete
(
key
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -123,7 +123,7 @@ func (t tieredTransaction) Delete(key ds.Key) error {
...
@@ -123,7 +123,7 @@ func (t tieredTransaction) Delete(key ds.Key) error {
return
nil
return
nil
}
}
func
(
t
tiered
Transaction
)
Commit
()
error
{
func
(
t
tiered
Batch
)
Commit
()
error
{
for
_
,
ts
:=
range
t
{
for
_
,
ts
:=
range
t
{
err
:=
ts
.
Commit
()
err
:=
ts
.
Commit
()
if
err
!=
nil
{
if
err
!=
nil
{
...
...
timecache/timecache.go
View file @
1702774c
...
@@ -95,7 +95,7 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
...
@@ -95,7 +95,7 @@ func (d *datastore) Query(q dsq.Query) (dsq.Results, error) {
return
d
.
cache
.
Query
(
q
)
return
d
.
cache
.
Query
(
q
)
}
}
func
(
d
*
datastore
)
Start
Batch
Op
()
ds
.
Transaction
{
func
(
d
*
datastore
)
Batch
()
ds
.
Batch
{
// sorry, being lazy here
// sorry, being lazy here
return
ds
.
NewBasic
Transaction
(
d
)
return
ds
.
NewBasic
Batch
(
d
)
}
}
transaction.go
View file @
1702774c
package
datastore
package
datastore
// basic
Transaction
implements the transaction interface for datastores who do
// basic
Batch
implements the transaction interface for datastores who do
// not have any sort of underlying transactional support
// not have any sort of underlying transactional support
type
basic
Transaction
struct
{
type
basic
Batch
struct
{
puts
map
[
Key
]
interface
{}
puts
map
[
Key
]
interface
{}
deletes
map
[
Key
]
struct
{}
deletes
map
[
Key
]
struct
{}
target
Datastore
target
Datastore
}
}
func
NewBasic
Transaction
(
ds
Datastore
)
Transaction
{
func
NewBasic
Batch
(
ds
Datastore
)
Batch
{
return
&
basic
Transaction
{
return
&
basic
Batch
{
puts
:
make
(
map
[
Key
]
interface
{}),
puts
:
make
(
map
[
Key
]
interface
{}),
deletes
:
make
(
map
[
Key
]
struct
{}),
deletes
:
make
(
map
[
Key
]
struct
{}),
target
:
ds
,
target
:
ds
,
}
}
}
}
func
(
bt
*
basic
Transaction
)
Put
(
key
Key
,
val
interface
{})
error
{
func
(
bt
*
basic
Batch
)
Put
(
key
Key
,
val
interface
{})
error
{
bt
.
puts
[
key
]
=
val
bt
.
puts
[
key
]
=
val
return
nil
return
nil
}
}
func
(
bt
*
basic
Transaction
)
Delete
(
key
Key
)
error
{
func
(
bt
*
basic
Batch
)
Delete
(
key
Key
)
error
{
bt
.
deletes
[
key
]
=
struct
{}{}
bt
.
deletes
[
key
]
=
struct
{}{}
return
nil
return
nil
}
}
func
(
bt
*
basic
Transaction
)
Commit
()
error
{
func
(
bt
*
basic
Batch
)
Commit
()
error
{
for
k
,
val
:=
range
bt
.
puts
{
for
k
,
val
:=
range
bt
.
puts
{
if
err
:=
bt
.
target
.
Put
(
k
,
val
);
err
!=
nil
{
if
err
:=
bt
.
target
.
Put
(
k
,
val
);
err
!=
nil
{
return
err
return
err
...
...
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