Chromium Code Reviews| 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 "infra/gae/libs/wrapper" | 10 "infra/gae/libs/wrapper" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 | 109 |
| 110 data *txnDataStoreData | 110 data *txnDataStoreData |
| 111 ns string | 111 ns string |
| 112 } | 112 } |
| 113 | 113 |
| 114 var ( | 114 var ( |
| 115 _ = wrapper.Datastore((*txnDsImpl)(nil)) | 115 _ = wrapper.Datastore((*txnDsImpl)(nil)) |
| 116 _ = wrapper.Testable((*txnDsImpl)(nil)) | 116 _ = wrapper.Testable((*txnDsImpl)(nil)) |
| 117 ) | 117 ) |
| 118 | 118 |
| 119 func (d *dsImpl) NewQuery(kind string) wrapper.DSQuery { | |
| 120 return &queryImpl{DSQuery: wrapper.DummyQY(), ns: d.ns, kind: kind} | |
| 121 } | |
| 122 | |
| 123 func (d *dsImpl) Run(q wrapper.DSQuery) wrapper.DSIterator { | |
| 124 rq := q.(*queryImpl) | |
| 125 rq = rq.normalize().checkCorrectness(d.ns, false) | |
|
M-A Ruel
2015/05/31 23:03:15
return &queryIterImp{q.(*queryImpl).normalize().ch
iannucci
2015/05/31 23:31:33
I think I had that originally and it seemed too li
| |
| 126 return &queryIterImpl{rq} | |
| 127 } | |
| 128 | |
| 129 func (d *dsImpl) GetAll(q wrapper.DSQuery, dst interface{}) ([]*datastore.Key, e rror) { | |
| 130 // TODO(riannucci): assert that dst is a slice of structs | |
| 131 return nil, nil | |
| 132 } | |
| 133 | |
| 134 func (d *dsImpl) Count(q wrapper.DSQuery) (ret int, err error) { | |
| 135 itr := d.Run(q.KeysOnly()) | |
| 136 for _, err = itr.Next(nil); err != nil; _, err = itr.Next(nil) { | |
| 137 ret++ | |
| 138 } | |
| 139 if err == datastore.Done { | |
| 140 err = nil | |
| 141 } | |
| 142 return | |
| 143 } | |
| 144 | |
| 119 func (d *txnDsImpl) BreakFeatures(err error, features ...string) { | 145 func (d *txnDsImpl) BreakFeatures(err error, features ...string) { |
| 120 d.data.BreakFeatures(err, features...) | 146 d.data.BreakFeatures(err, features...) |
| 121 } | 147 } |
| 122 func (d *txnDsImpl) UnbreakFeatures(features ...string) { | 148 func (d *txnDsImpl) UnbreakFeatures(features ...string) { |
| 123 d.data.UnbreakFeatures(features...) | 149 d.data.UnbreakFeatures(features...) |
| 124 } | 150 } |
| 125 | 151 |
| 126 func (d *txnDsImpl) Kind(src interface{}) string { | 152 func (d *txnDsImpl) Kind(src interface{}) string { |
| 127 return kind(d.ns, d.KindNameResolver(), src) | 153 return kind(d.ns, d.KindNameResolver(), src) |
| 128 } | 154 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 171 | 197 |
| 172 ////////////////////////////// private functions /////////////////////////////// | 198 ////////////////////////////// private functions /////////////////////////////// |
| 173 | 199 |
| 174 func newDSError(code pb.Error_ErrorCode, message ...string) *appengine_internal. APIError { | 200 func newDSError(code pb.Error_ErrorCode, message ...string) *appengine_internal. APIError { |
| 175 return &appengine_internal.APIError{ | 201 return &appengine_internal.APIError{ |
| 176 Detail: strings.Join(message, ""), | 202 Detail: strings.Join(message, ""), |
| 177 Service: "datastore_v3", | 203 Service: "datastore_v3", |
| 178 Code: int32(code), | 204 Code: int32(code), |
| 179 } | 205 } |
| 180 } | 206 } |
| OLD | NEW |