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

Unified Diff: impl/memory/datastore.go

Issue 1309803004: Add transaction buffer filter. (Closed) Base URL: https://github.com/luci/gae.git@add_query_support
Patch Set: fix comments 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: impl/memory/datastore.go
diff --git a/impl/memory/datastore.go b/impl/memory/datastore.go
index 84f5adddb53b2fbbb571bed4ff50c868532da881..d45f8e2e5167f474cc2168036a09195fbea4e19b 100644
--- a/impl/memory/datastore.go
+++ b/impl/memory/datastore.go
@@ -29,6 +29,11 @@ func useRDS(c context.Context) context.Context {
})
}
+// NewDatastore creates a new standalone memory implementation of the datastore.
+func NewDatastore(aid, ns string) ds.RawInterface {
+ return &dsImpl{newDataStoreData(aid), ns, context.Background()}
+}
+
//////////////////////////////////// dsImpl ////////////////////////////////////
// dsImpl exists solely to bind the current c to the datastore data.
@@ -64,20 +69,20 @@ func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) {
func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error {
idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent())
- err := executeQuery(fq, d.ns, false, idx, head, cb)
+ err := executeQuery(fq, d.data.aid, d.ns, false, idx, head, cb)
if d.data.maybeAutoIndex(err) {
idx, head = d.data.getQuerySnaps(!fq.EventuallyConsistent())
- err = executeQuery(fq, d.ns, false, idx, head, cb)
+ err = executeQuery(fq, d.data.aid, d.ns, false, idx, head, cb)
}
return err
}
func (d *dsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) {
idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent())
- ret, err = countQuery(fq, d.ns, false, idx, head)
+ ret, err = countQuery(fq, d.data.aid, d.ns, false, idx, head)
if d.data.maybeAutoIndex(err) {
idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent())
- ret, err = countQuery(fq, d.ns, false, idx, head)
+ ret, err = countQuery(fq, d.data.aid, d.ns, false, idx, head)
}
return
}
@@ -174,11 +179,11 @@ func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
// It's possible that if you have full-consistency and also auto index enabled
// that this would make sense... but at that point you should probably just
// add the index up front.
- return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb)
+ return executeQuery(q, d.data.parent.aid, d.ns, true, d.data.snap, d.data.snap, cb)
}
func (d *txnDsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) {
- return countQuery(fq, d.ns, true, d.data.snap, d.data.snap)
+ return countQuery(fq, d.data.parent.aid, d.ns, true, d.data.snap, d.data.snap)
}
func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.TransactionOptions) error {

Powered by Google App Engine
This is Rietveld 408576698