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 prod | 5 package prod |
6 | 6 |
7 import ( | 7 import ( |
8 ds "github.com/luci/gae/service/datastore" | 8 ds "github.com/luci/gae/service/datastore" |
9 "github.com/luci/gae/service/info" | 9 "github.com/luci/gae/service/info" |
10 "github.com/luci/luci-go/common/errors" | 10 "github.com/luci/luci-go/common/errors" |
(...skipping 164 matching lines...) Loading... |
175 } | 175 } |
176 | 176 |
177 return ret, nil | 177 return ret, nil |
178 } | 178 } |
179 | 179 |
180 func (d rdsImpl) DecodeCursor(s string) (ds.Cursor, error) { | 180 func (d rdsImpl) DecodeCursor(s string) (ds.Cursor, error) { |
181 return datastore.DecodeCursor(s) | 181 return datastore.DecodeCursor(s) |
182 } | 182 } |
183 | 183 |
184 func (d rdsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error { | 184 func (d rdsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error { |
185 tf := typeFilter{} | |
186 q, err := d.fixQuery(fq) | 185 q, err := d.fixQuery(fq) |
187 if err != nil { | 186 if err != nil { |
188 return err | 187 return err |
189 } | 188 } |
190 | 189 |
191 t := q.Run(d) | 190 t := q.Run(d) |
192 | 191 |
193 cfunc := func() (ds.Cursor, error) { | 192 cfunc := func() (ds.Cursor, error) { |
194 return t.Cursor() | 193 return t.Cursor() |
195 } | 194 } |
| 195 tf := typeFilter{} |
196 for { | 196 for { |
197 k, err := t.Next(&tf) | 197 k, err := t.Next(&tf) |
198 if err == datastore.Done { | 198 if err == datastore.Done { |
199 return nil | 199 return nil |
200 } | 200 } |
201 if err != nil { | 201 if err != nil { |
202 return err | 202 return err |
203 } | 203 } |
204 if !cb(dsR2F(k), tf.pm, cfunc) { | 204 if !cb(dsR2F(k), tf.pm, cfunc) { |
205 return nil | 205 return nil |
206 } | 206 } |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
| 210 func (d rdsImpl) Count(fq *ds.FinalizedQuery) (int64, error) { |
| 211 q, err := d.fixQuery(fq) |
| 212 if err != nil { |
| 213 return 0, err |
| 214 } |
| 215 ret, err := q.Count(d) |
| 216 return int64(ret), err |
| 217 } |
| 218 |
210 func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *ds.Tran
sactionOptions) error { | 219 func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *ds.Tran
sactionOptions) error { |
211 ropts := (*datastore.TransactionOptions)(opts) | 220 ropts := (*datastore.TransactionOptions)(opts) |
212 return datastore.RunInTransaction(d, f, ropts) | 221 return datastore.RunInTransaction(d, f, ropts) |
213 } | 222 } |
214 | 223 |
215 func (d rdsImpl) Testable() ds.Testable { | 224 func (d rdsImpl) Testable() ds.Testable { |
216 return nil | 225 return nil |
217 } | 226 } |
OLD | NEW |