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

Unified Diff: service/datastore/key.go

Issue 1309803004: Add transaction buffer filter. (Closed) Base URL: https://github.com/luci/gae.git@add_query_support
Patch Set: Fix builtin+ancestor+multi-eq+multiIterator bug, add more txnBuf test Created 5 years, 3 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
Index: service/datastore/key.go
diff --git a/service/datastore/key.go b/service/datastore/key.go
index 3bf02e861e3f99118fab2258070106b04ca45091..47bbad297ee8567f0e491bbce61ff08d2e19ee50 100644
--- a/service/datastore/key.go
+++ b/service/datastore/key.go
@@ -359,6 +359,22 @@ func (k *Key) Less(other *Key) bool {
return len(k.toks) < len(other.toks)
}
+// HasAncestor returns true iff other is an ancestor of k.
Vadim Sh. 2015/09/28 18:52:56 ... or k is other.
iannucci 2015/09/29 03:21:37 Yes. Done.
+func (k *Key) HasAncestor(other *Key) bool {
+ if k.appID != other.appID || k.namespace != other.namespace {
+ return false
+ }
+ if len(k.toks) < len(other.toks) {
+ return false
+ }
+ for i, tok := range other.toks {
+ if tok != k.toks[i] {
+ return false
+ }
+ }
+ return true
+}
+
// GQL returns a correctly formatted Cloud Datastore GQL key literal.
//
// The flavor of GQL that this emits is defined here:

Powered by Google App Engine
This is Rietveld 408576698