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 23 matching lines...) Expand all Loading... |
34 // dsImpl exists solely to bind the current c to the datastore data. | 34 // dsImpl exists solely to bind the current c to the datastore data. |
35 type dsImpl struct { | 35 type dsImpl struct { |
36 data *dataStoreData | 36 data *dataStoreData |
37 ns string | 37 ns string |
38 c context.Context | 38 c context.Context |
39 } | 39 } |
40 | 40 |
41 var _ ds.RawInterface = (*dsImpl)(nil) | 41 var _ ds.RawInterface = (*dsImpl)(nil) |
42 | 42 |
43 func (d *dsImpl) AllocateIDs(incomplete *ds.Key, n int) (int64, error) { | 43 func (d *dsImpl) AllocateIDs(incomplete *ds.Key, n int) (int64, error) { |
44 » start := d.data.allocateIDs(incomplete, n) | 44 » return d.data.allocateIDs(incomplete, n) |
45 » return start, nil | |
46 } | 45 } |
47 | 46 |
48 func (d *dsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMultiC
B) error { | 47 func (d *dsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMultiC
B) error { |
49 d.data.putMulti(keys, vals, cb) | 48 d.data.putMulti(keys, vals, cb) |
50 return nil | 49 return nil |
51 } | 50 } |
52 | 51 |
53 func (d *dsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.GetMul
tiCB) error { | 52 func (d *dsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.GetMul
tiCB) error { |
54 return d.data.getMulti(keys, cb) | 53 return d.data.getMulti(keys, cb) |
55 } | 54 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 } | 113 } |
115 | 114 |
116 func (d *dsImpl) Consistent(always bool) { | 115 func (d *dsImpl) Consistent(always bool) { |
117 d.data.setConsistent(always) | 116 d.data.setConsistent(always) |
118 } | 117 } |
119 | 118 |
120 func (d *dsImpl) AutoIndex(enable bool) { | 119 func (d *dsImpl) AutoIndex(enable bool) { |
121 d.data.setAutoIndex(enable) | 120 d.data.setAutoIndex(enable) |
122 } | 121 } |
123 | 122 |
| 123 func (d *dsImpl) DisableSpecialEntities(enabled bool) { |
| 124 d.data.setDisableSpecialEntities(enabled) |
| 125 } |
| 126 |
124 func (d *dsImpl) Testable() ds.Testable { | 127 func (d *dsImpl) Testable() ds.Testable { |
125 return d | 128 return d |
126 } | 129 } |
127 | 130 |
128 ////////////////////////////////// txnDsImpl /////////////////////////////////// | 131 ////////////////////////////////// txnDsImpl /////////////////////////////////// |
129 | 132 |
130 type txnDsImpl struct { | 133 type txnDsImpl struct { |
131 data *txnDataStoreData | 134 data *txnDataStoreData |
132 ns string | 135 ns string |
133 } | 136 } |
134 | 137 |
135 var _ ds.RawInterface = (*txnDsImpl)(nil) | 138 var _ ds.RawInterface = (*txnDsImpl)(nil) |
136 | 139 |
137 func (d *txnDsImpl) AllocateIDs(incomplete *ds.Key, n int) (int64, error) { | 140 func (d *txnDsImpl) AllocateIDs(incomplete *ds.Key, n int) (int64, error) { |
138 » start := d.data.parent.allocateIDs(incomplete, n) | 141 » return d.data.parent.allocateIDs(incomplete, n) |
139 » return start, nil | |
140 } | 142 } |
141 | 143 |
142 func (d *txnDsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMul
tiCB) error { | 144 func (d *txnDsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMul
tiCB) error { |
143 return d.data.run(func() error { | 145 return d.data.run(func() error { |
144 d.data.putMulti(keys, vals, cb) | 146 d.data.putMulti(keys, vals, cb) |
145 return nil | 147 return nil |
146 }) | 148 }) |
147 } | 149 } |
148 | 150 |
149 func (d *txnDsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.Get
MultiCB) error { | 151 func (d *txnDsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.Get
MultiCB) error { |
(...skipping 29 matching lines...) Expand all Loading... |
179 return countQuery(fq, d.ns, true, d.data.snap, d.data.snap) | 181 return countQuery(fq, d.ns, true, d.data.snap, d.data.snap) |
180 } | 182 } |
181 | 183 |
182 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 { |
183 return errors.New("datastore: nested transactions are not supported") | 185 return errors.New("datastore: nested transactions are not supported") |
184 } | 186 } |
185 | 187 |
186 func (*txnDsImpl) Testable() ds.Testable { | 188 func (*txnDsImpl) Testable() ds.Testable { |
187 return nil | 189 return nil |
188 } | 190 } |
OLD | NEW |