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

Side by Side 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: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 10
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 func (d *dsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { 62 func (d *dsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error {
63 d.data.delMulti(keys, cb) 63 d.data.delMulti(keys, cb)
64 return nil 64 return nil
65 } 65 }
66 66
67 func (d *dsImpl) NewQuery(kind string) ds.Query { 67 func (d *dsImpl) NewQuery(kind string) ds.Query {
68 return &queryImpl{ns: d.ns, kind: kind} 68 return &queryImpl{ns: d.ns, kind: kind}
69 } 69 }
70 70
71 func (d *dsImpl) Run(q ds.Query, cb ds.RawRunCB) error { 71 func (d *dsImpl) Run(q ds.Query, cb ds.RawRunCB) error {
72 » rq := q.(*queryImpl) 72 » _, err := q.(*queryImpl).prep(d.ns, true)
73 » done, err := rq.valid(d.ns, true) 73 » if err != nil {
74 » if done || err != nil { 74 » » if err == errQueryDone {
75 » » return err // will be nil if done 75 » » » return nil
76 » » }
77 » » return err
76 } 78 }
77 return nil 79 return nil
78 } 80 }
79 81
80 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) { 82 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) {
81 for _, i := range idxs { 83 for _, i := range idxs {
82 if !i.Compound() { 84 if !i.Compound() {
83 panic(fmt.Errorf("Attempted to add non-compound index: % s", i)) 85 panic(fmt.Errorf("Attempted to add non-compound index: % s", i))
84 } 86 }
85 } 87 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 }) 137 })
136 } 138 }
137 139
138 func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { 140 func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error {
139 return d.data.run(func() error { 141 return d.data.run(func() error {
140 return d.data.delMulti(keys, cb) 142 return d.data.delMulti(keys, cb)
141 }) 143 })
142 } 144 }
143 145
144 func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error { 146 func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error {
145 » rq := q.(*queryImpl) 147 » _, err := q.(*queryImpl).prep(d.ns, true)
146 » done, err := rq.valid(d.ns, true) 148 » if err != nil {
147 » if done || err != nil { 149 » » if err == errQueryDone {
148 » » return err // will be nil if done 150 » » » return nil
151 » » }
152 » » return err
149 } 153 }
150 » if rq.eventualConsistency { 154 » if q.(*queryImpl).eventualConsistency {
151 » » rq = rq.checkMutateClone(nil, nil) 155 » » // TODO(riannucci): use head instead of snap for indexes
152 » » rq.eventualConsistency = false
153 } 156 }
154 // TODO(riannucci): use head instead of snap for indexes
155 panic("NOT IMPLEMENTED") 157 panic("NOT IMPLEMENTED")
156 } 158 }
157 159
158 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error { 160 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error {
159 return errors.New("datastore: nested transactions are not supported") 161 return errors.New("datastore: nested transactions are not supported")
160 } 162 }
161 163
162 func (d *txnDsImpl) NewQuery(kind string) ds.Query { 164 func (d *txnDsImpl) NewQuery(kind string) ds.Query {
163 return &queryImpl{ns: d.ns, kind: kind} 165 return &queryImpl{ns: d.ns, kind: kind}
164 } 166 }
165 167
166 func (*txnDsImpl) Testable() ds.Testable { 168 func (*txnDsImpl) Testable() ds.Testable {
167 return nil 169 return nil
168 } 170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698