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

Unified Diff: impl/memory/datastore.go

Issue 1302813003: impl/memory: Implement Queries (Closed) Base URL: https://github.com/luci/gae.git@add_multi_iterator
Patch Set: minor fixes Created 5 years, 4 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 2e78c129eb7014c144cccb5b499cc8e1ff981d07..079c05dfde4b6fab38a79e3d8e40ecb4b4f9b6bd 100644
--- a/impl/memory/datastore.go
+++ b/impl/memory/datastore.go
@@ -69,19 +69,21 @@ func (d *dsImpl) NewQuery(kind string) ds.Query {
}
func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) {
- return decodeCursor(s)
+ return newCursor(s)
}
-func (d *dsImpl) Run(q ds.Query, cb ds.RawRunCB) error {
- rq := q.(*queryImpl)
- done, err := rq.valid(d.ns, true)
- if done || err != nil {
- return err // will be nil if done
- }
- return nil
+func (d *dsImpl) Run(qi ds.Query, cb ds.RawRunCB) error {
+ q := qi.(*queryImpl)
+ consistent := q.eqFilters["__ancestor__"] != nil && !q.eventualConsistency
+ idx, head := d.data.getQuerySnaps(consistent)
+ return executeQuery(qi, d.ns, false, idx, head, cb)
}
func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) {
+ if len(idxs) == 0 {
+ return
+ }
+
for _, i := range idxs {
if !i.Compound() {
panic(fmt.Errorf("Attempted to add non-compound index: %s", i))
@@ -90,7 +92,7 @@ func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) {
d.data.Lock()
defer d.data.Unlock()
- addIndex(d.data.store, d.ns, idxs)
+ addIndex(d.data.head, d.ns, idxs)
}
func (d *dsImpl) TakeIndexSnapshot() ds.TestingSnapshot {
@@ -146,21 +148,11 @@ func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error {
}
func (d *txnDsImpl) DecodeCursor(s string) (ds.Cursor, error) {
- return decodeCursor(s)
+ return newCursor(s)
}
func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error {
- rq := q.(*queryImpl)
- done, err := rq.valid(d.ns, true)
- if done || err != nil {
- return err // will be nil if done
- }
- if rq.eventualConsistency {
- rq = rq.checkMutateClone(nil, nil)
- rq.eventualConsistency = false
- }
- // TODO(riannucci): use head instead of snap for indexes
- panic("NOT IMPLEMENTED")
+ return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb)
}
func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.TransactionOptions) error {

Powered by Google App Engine
This is Rietveld 408576698