| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package memory | 5 package memory |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | 9 "fmt" |
| 10 | 10 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 d.data.delMulti(keys, cb) | 85 d.data.delMulti(keys, cb) |
| 86 return nil | 86 return nil |
| 87 } | 87 } |
| 88 | 88 |
| 89 func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) { | 89 func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) { |
| 90 return newCursor(s) | 90 return newCursor(s) |
| 91 } | 91 } |
| 92 | 92 |
| 93 func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error { | 93 func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error { |
| 94 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 94 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 95 » err := executeQuery(fq, d.kc, false, idx, head, cb) | 95 » err := executeQuery(fq, d.kc, false, false, idx, head, cb) |
| 96 if d.data.maybeAutoIndex(err) { | 96 if d.data.maybeAutoIndex(err) { |
| 97 idx, head = d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 97 idx, head = d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 98 » » err = executeQuery(fq, d.kc, false, idx, head, cb) | 98 » » err = executeQuery(fq, d.kc, false, false, idx, head, cb) |
| 99 } | 99 } |
| 100 return err | 100 return err |
| 101 } | 101 } |
| 102 | 102 |
| 103 func (d *dsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { | 103 func (d *dsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { |
| 104 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 104 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 105 ret, err = countQuery(fq, d.kc, false, idx, head) | 105 ret, err = countQuery(fq, d.kc, false, idx, head) |
| 106 if d.data.maybeAutoIndex(err) { | 106 if d.data.maybeAutoIndex(err) { |
| 107 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 107 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 108 ret, err = countQuery(fq, d.kc, false, idx, head) | 108 ret, err = countQuery(fq, d.kc, false, idx, head) |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { | 200 func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { |
| 201 // note that autoIndex has no effect inside transactions. This is becaus
e | 201 // note that autoIndex has no effect inside transactions. This is becaus
e |
| 202 // the transaction guarantees a consistent view of head at the time that
the | 202 // the transaction guarantees a consistent view of head at the time that
the |
| 203 // transaction opens. At best, we could add the index on head, but then
return | 203 // transaction opens. At best, we could add the index on head, but then
return |
| 204 // the error anyway, but adding the index then re-snapping at head would | 204 // the error anyway, but adding the index then re-snapping at head would |
| 205 // potentially reveal other entities not in the original transaction sna
pshot. | 205 // potentially reveal other entities not in the original transaction sna
pshot. |
| 206 // | 206 // |
| 207 // It's possible that if you have full-consistency and also auto index e
nabled | 207 // It's possible that if you have full-consistency and also auto index e
nabled |
| 208 // that this would make sense... but at that point you should probably j
ust | 208 // that this would make sense... but at that point you should probably j
ust |
| 209 // add the index up front. | 209 // add the index up front. |
| 210 » return executeQuery(q, d.kc, true, d.data.snap, d.data.snap, cb) | 210 » return executeQuery(q, d.kc, true, false, d.data.snap, d.data.snap, cb) |
| 211 } | 211 } |
| 212 | 212 |
| 213 func (d *txnDsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { | 213 func (d *txnDsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { |
| 214 return countQuery(fq, d.kc, true, d.data.snap, d.data.snap) | 214 return countQuery(fq, d.kc, true, d.data.snap, d.data.snap) |
| 215 } | 215 } |
| 216 | 216 |
| 217 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { | 217 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { |
| 218 return errors.New("datastore: nested transactions are not supported") | 218 return errors.New("datastore: nested transactions are not supported") |
| 219 } | 219 } |
| 220 | 220 |
| 221 func (d *txnDsImpl) WithoutTransaction() context.Context { | 221 func (d *txnDsImpl) WithoutTransaction() context.Context { |
| 222 » return context.WithValue(d, currentTxnKey, nil) | 222 » return context.WithValue(d, ¤tTxnKey, nil) |
| 223 } | 223 } |
| 224 | 224 |
| 225 func (d *txnDsImpl) CurrentTransaction() ds.Transaction { | 225 func (d *txnDsImpl) CurrentTransaction() ds.Transaction { |
| 226 return d.data.txn | 226 return d.data.txn |
| 227 } | 227 } |
| 228 | 228 |
| 229 func (d *txnDsImpl) GetTestable() ds.Testable { return nil } | 229 func (d *txnDsImpl) GetTestable() ds.Testable { return nil } |
| OLD | NEW |