Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(475)

Unified Diff: filter/dsQueryBatch/context.go

Issue 1843313004: Add datastore iterating query filter. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@no-stop-in-raw
Patch Set: Comments, test edges. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | filter/dsQueryBatch/filter.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/dsQueryBatch/context.go
diff --git a/filter/dsQueryBatch/context.go b/filter/dsQueryBatch/context.go
new file mode 100644
index 0000000000000000000000000000000000000000..ec31ed2e0ac4e0efb833cc175e603861cb3d5706
--- /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 this expands a single query into a series of queries, which may
+// lose additional single-query consistency guarantees.
+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,
+ }
+ })
+}
« no previous file with comments | « no previous file | filter/dsQueryBatch/filter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698