Chromium Code Reviews| Index: filter/dsQueryBatch/context.go |
| diff --git a/filter/dsQueryBatch/context.go b/filter/dsQueryBatch/context.go |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d9f8f7b2d2fd2ff8bfd56ac79f9a92d035e13525 |
| --- /dev/null |
| +++ b/filter/dsQueryBatch/context.go |
| @@ -0,0 +1,28 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package dsQueryBatch |
| + |
| +import ( |
| + ds "github.com/luci/gae/service/datastore" |
| + "golang.org/x/net/context" |
| +) |
| + |
| +// BatchQueries installs a datastore filter that causes all queries to be broken |
| +// into a series of iterative fixed-size queries. The batching uses cursors to |
| +// chain the iterations together. |
| +// |
| +// This helps accommodate query size or time limits enforced by the backing |
| +// datastore implementation. |
| +// |
| +// Note that the expansion of a single query into a series of queries may lose |
| +// some guarantees afforded to single queries by the backing implementation. |
|
iannucci
2016/03/31 22:40:30
concise please!
dnj
2016/03/31 23:54:06
Done.
|
| +func BatchQueries(c context.Context, batchSize int32) context.Context { |
| + return ds.AddRawFilters(c, func(ic context.Context, ri ds.RawInterface) ds.RawInterface { |
| + return &iterQueryFilter{ |
| + RawInterface: ri, |
| + batchSize: batchSize, |
| + } |
| + }) |
| +} |