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

Side by Side Diff: impl/memory/datastore.go

Issue 1367003002: Add missing Count api (Closed) Base URL: https://github.com/luci/gae.git@move_serialization_helpers
Patch Set: 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 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) { 62 func (d *dsImpl) DecodeCursor(s string) (ds.Cursor, error) {
63 return newCursor(s) 63 return newCursor(s)
64 } 64 }
65 65
66 func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error { 66 func (d *dsImpl) Run(fq *ds.FinalizedQuery, cb ds.RawRunCB) error {
67 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent()) 67 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent())
68 return executeQuery(fq, d.ns, false, idx, head, cb) 68 return executeQuery(fq, d.ns, false, idx, head, cb)
69 } 69 }
70 70
71 func (d *dsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) {
72 idx, head := d.data.getQuerySnaps(!fq.EventuallyConsistent())
73 return countQuery(fq, d.ns, false, idx, head)
74 }
75
71 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) { 76 func (d *dsImpl) AddIndexes(idxs ...*ds.IndexDefinition) {
72 if len(idxs) == 0 { 77 if len(idxs) == 0 {
73 return 78 return
74 } 79 }
75 80
76 for _, i := range idxs { 81 for _, i := range idxs {
77 if !i.Compound() { 82 if !i.Compound() {
78 panic(fmt.Errorf("Attempted to add non-compound index: % s", i)) 83 panic(fmt.Errorf("Attempted to add non-compound index: % s", i))
79 } 84 }
80 } 85 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 143 }
139 144
140 func (d *txnDsImpl) DecodeCursor(s string) (ds.Cursor, error) { 145 func (d *txnDsImpl) DecodeCursor(s string) (ds.Cursor, error) {
141 return newCursor(s) 146 return newCursor(s)
142 } 147 }
143 148
144 func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error { 149 func (d *txnDsImpl) Run(q *ds.FinalizedQuery, cb ds.RawRunCB) error {
145 return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb) 150 return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb)
146 } 151 }
147 152
153 func (d *txnDsImpl) Count(fq *ds.FinalizedQuery) (ret int64, err error) {
154 return countQuery(fq, d.ns, true, d.data.snap, d.data.snap)
155 }
156
148 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error { 157 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error {
149 return errors.New("datastore: nested transactions are not supported") 158 return errors.New("datastore: nested transactions are not supported")
150 } 159 }
151 160
152 func (*txnDsImpl) Testable() ds.Testable { 161 func (*txnDsImpl) Testable() ds.Testable {
153 return nil 162 return nil
154 } 163 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698