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 dsQueryBatch | 5 package dsQueryBatch |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 | 9 |
10 ds "github.com/luci/gae/service/datastore" | 10 ds "github.com/luci/gae/service/datastore" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 return err | 50 return err |
51 } | 51 } |
52 | 52 |
53 // If this is the last entry in our batch, get the curso
r and stop this | 53 // If this is the last entry in our batch, get the curso
r and stop this |
54 // query round. | 54 // query round. |
55 count++ | 55 count++ |
56 if count >= f.batchSize { | 56 if count >= f.batchSize { |
57 if cursor, err = getCursor(); err != nil { | 57 if cursor, err = getCursor(); err != nil { |
58 return fmt.Errorf("failed to get cursor:
%v", err) | 58 return fmt.Errorf("failed to get cursor:
%v", err) |
59 } | 59 } |
| 60 return ds.Stop |
60 } | 61 } |
61 return nil | 62 return nil |
62 }) | 63 }) |
63 if err != nil && err != ds.Stop { | 64 if err != nil && err != ds.Stop { |
64 return err | 65 return err |
65 } | 66 } |
66 | 67 |
67 // If we have no cursor, we're done. | 68 // If we have no cursor, we're done. |
68 if cursor == nil { | 69 if cursor == nil { |
69 break | 70 break |
70 } | 71 } |
71 | 72 |
72 // Reduce our limit for the next round. | 73 // Reduce our limit for the next round. |
73 if hasLimit { | 74 if hasLimit { |
74 limit -= count | 75 limit -= count |
75 if limit <= 0 { | 76 if limit <= 0 { |
76 break | 77 break |
77 } | 78 } |
78 } | 79 } |
79 } | 80 } |
80 return nil | 81 return nil |
81 } | 82 } |
OLD | NEW |