| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 d.data.delMulti(keys, cb) | 57 d.data.delMulti(keys, cb) |
| 58 return nil | 58 return nil |
| 59 } | 59 } |
| 60 | 60 |
| 61 func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) { | 61 func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) { |
| 62 return newCursor(s) | 62 return newCursor(s) |
| 63 } | 63 } |
| 64 | 64 |
| 65 func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error { | 65 func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error { |
| 66 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 66 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 67 » err := executeQuery(fq, d.ns, false, idx, head, cb) | 67 » err := executeQuery(fq, d.data.aid, d.ns, false, idx, head, cb) |
| 68 if d.data.maybeAutoIndex(err) { | 68 if d.data.maybeAutoIndex(err) { |
| 69 idx, head = d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 69 idx, head = d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 70 » » err = executeQuery(fq, d.ns, false, idx, head, cb) | 70 » » err = executeQuery(fq, d.data.aid, d.ns, false, idx, head, cb) |
| 71 } | 71 } |
| 72 return err | 72 return err |
| 73 } | 73 } |
| 74 | 74 |
| 75 func (d *dsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { | 75 func (d *dsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { |
| 76 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 76 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 77 » ret, err = countQuery(fq, d.ns, false, idx, head) | 77 » ret, err = countQuery(fq, d.data.aid, d.ns, false, idx, head) |
| 78 if d.data.maybeAutoIndex(err) { | 78 if d.data.maybeAutoIndex(err) { |
| 79 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) | 79 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) |
| 80 » » ret, err = countQuery(fq, d.ns, false, idx, head) | 80 » » ret, err = countQuery(fq, d.data.aid, d.ns, false, idx, head) |
| 81 } | 81 } |
| 82 return | 82 return |
| 83 } | 83 } |
| 84 | 84 |
| 85 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) { | 85 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) { |
| 86 if len(idxs) == 0 { | 86 if len(idxs) == 0 { |
| 87 return | 87 return |
| 88 } | 88 } |
| 89 | 89 |
| 90 for _, i := range idxs { | 90 for _, i := range idxs { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { | 167 func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { |
| 168 // note that autoIndex has no effect inside transactions. This is becaus
e | 168 // note that autoIndex has no effect inside transactions. This is becaus
e |
| 169 // the transaction guarantees a consistent view of head at the time that
the | 169 // the transaction guarantees a consistent view of head at the time that
the |
| 170 // transaction opens. At best, we could add the index on head, but then
return | 170 // transaction opens. At best, we could add the index on head, but then
return |
| 171 // the error anyway, but adding the index then re-snapping at head would | 171 // the error anyway, but adding the index then re-snapping at head would |
| 172 // potentially reveal other entities not in the original transaction sna
pshot. | 172 // potentially reveal other entities not in the original transaction sna
pshot. |
| 173 // | 173 // |
| 174 // It's possible that if you have full-consistency and also auto index e
nabled | 174 // It's possible that if you have full-consistency and also auto index e
nabled |
| 175 // that this would make sense... but at that point you should probably j
ust | 175 // that this would make sense... but at that point you should probably j
ust |
| 176 // add the index up front. | 176 // add the index up front. |
| 177 » return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb) | 177 » return executeQuery(q, d.data.parent.aid, d.ns, true, d.data.snap, d.dat
a.snap, cb) |
| 178 } | 178 } |
| 179 | 179 |
| 180 func (d *txnDsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { | 180 func (d *txnDsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) { |
| 181 » return countQuery(fq, d.ns, true, d.data.snap, d.data.snap) | 181 » return countQuery(fq, d.data.parent.aid, d.ns, true, d.data.snap, d.data
.snap) |
| 182 } | 182 } |
| 183 | 183 |
| 184 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { | 184 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { |
| 185 return errors.New("datastore: nested transactions are not supported") | 185 return errors.New("datastore: nested transactions are not supported") |
| 186 } | 186 } |
| 187 | 187 |
| 188 func (*txnDsImpl) Testable() ds.Testable { | 188 func (*txnDsImpl) Testable() ds.Testable { |
| 189 return nil | 189 return nil |
| 190 } | 190 } |
| OLD | NEW |