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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 func (d *dsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { | 62 func (d *dsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { |
63 d.data.delMulti(keys, cb) | 63 d.data.delMulti(keys, cb) |
64 return nil | 64 return nil |
65 } | 65 } |
66 | 66 |
67 func (d *dsImpl) NewQuery(kind string) ds.Query { | 67 func (d *dsImpl) NewQuery(kind string) ds.Query { |
68 return &queryImpl{ns: d.ns, kind: kind} | 68 return &queryImpl{ns: d.ns, kind: kind} |
69 } | 69 } |
70 | 70 |
| 71 func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) { |
| 72 return decodeCursor(s) |
| 73 } |
| 74 |
71 func (d *dsImpl) Run(q ds.Query, cb ds.RawRunCB) error { | 75 func (d *dsImpl) Run(q ds.Query, cb ds.RawRunCB) error { |
72 rq := q.(*queryImpl) | 76 rq := q.(*queryImpl) |
73 done, err := rq.valid(d.ns, true) | 77 done, err := rq.valid(d.ns, true) |
74 if done || err != nil { | 78 if done || err != nil { |
75 return err // will be nil if done | 79 return err // will be nil if done |
76 } | 80 } |
77 return nil | 81 return nil |
78 } | 82 } |
79 | 83 |
80 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) { | 84 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return d.data.getMulti(keys, cb) | 138 return d.data.getMulti(keys, cb) |
135 }) | 139 }) |
136 } | 140 } |
137 | 141 |
138 func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { | 142 func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { |
139 return d.data.run(func() error { | 143 return d.data.run(func() error { |
140 return d.data.delMulti(keys, cb) | 144 return d.data.delMulti(keys, cb) |
141 }) | 145 }) |
142 } | 146 } |
143 | 147 |
| 148 func (d *txnDsImpl) DecodeCursor(s string) (ds.Cursor, error) { |
| 149 return decodeCursor(s) |
| 150 } |
| 151 |
144 func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error { | 152 func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error { |
145 rq := q.(*queryImpl) | 153 rq := q.(*queryImpl) |
146 done, err := rq.valid(d.ns, true) | 154 done, err := rq.valid(d.ns, true) |
147 if done || err != nil { | 155 if done || err != nil { |
148 return err // will be nil if done | 156 return err // will be nil if done |
149 } | 157 } |
150 if rq.eventualConsistency { | 158 if rq.eventualConsistency { |
151 rq = rq.checkMutateClone(nil, nil) | 159 rq = rq.checkMutateClone(nil, nil) |
152 rq.eventualConsistency = false | 160 rq.eventualConsistency = false |
153 } | 161 } |
154 // TODO(riannucci): use head instead of snap for indexes | 162 // TODO(riannucci): use head instead of snap for indexes |
155 panic("NOT IMPLEMENTED") | 163 panic("NOT IMPLEMENTED") |
156 } | 164 } |
157 | 165 |
158 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { | 166 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { |
159 return errors.New("datastore: nested transactions are not supported") | 167 return errors.New("datastore: nested transactions are not supported") |
160 } | 168 } |
161 | 169 |
162 func (d *txnDsImpl) NewQuery(kind string) ds.Query { | 170 func (d *txnDsImpl) NewQuery(kind string) ds.Query { |
163 return &queryImpl{ns: d.ns, kind: kind} | 171 return &queryImpl{ns: d.ns, kind: kind} |
164 } | 172 } |
165 | 173 |
166 func (*txnDsImpl) Testable() ds.Testable { | 174 func (*txnDsImpl) Testable() ds.Testable { |
167 return nil | 175 return nil |
168 } | 176 } |
OLD | NEW |