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

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

Issue 1357343002: Add missing AllocateIDs API. (Closed) Base URL: https://github.com/luci/gae.git@master
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 22 matching lines...) Expand all
33 33
34 // dsImpl exists solely to bind the current c to the datastore data. 34 // dsImpl exists solely to bind the current c to the datastore data.
35 type dsImpl struct { 35 type dsImpl struct {
36 data *dataStoreData 36 data *dataStoreData
37 ns string 37 ns string
38 c context.Context 38 c context.Context
39 } 39 }
40 40
41 var _ ds.RawInterface = (*dsImpl)(nil) 41 var _ ds.RawInterface = (*dsImpl)(nil)
42 42
43 func (d *dsImpl) AllocateIDs(incomplete *ds.Key, n int) (int64, error) {
44 start := d.data.allocateIDs(incomplete, n)
45 return start, nil
46 }
47
43 func (d *dsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMultiC B) error { 48 func (d *dsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMultiC B) error {
44 d.data.putMulti(keys, vals, cb) 49 d.data.putMulti(keys, vals, cb)
45 return nil 50 return nil
46 } 51 }
47 52
48 func (d *dsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.GetMul tiCB) error { 53 func (d *dsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.GetMul tiCB) error {
49 return d.data.getMulti(keys, cb) 54 return d.data.getMulti(keys, cb)
50 } 55 }
51 56
52 func (d *dsImpl) DeleteMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error { 57 func (d *dsImpl) DeleteMulti(keys []*ds.Key, cb ds.DeleteMultiCB) error {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 106
102 ////////////////////////////////// txnDsImpl /////////////////////////////////// 107 ////////////////////////////////// txnDsImpl ///////////////////////////////////
103 108
104 type txnDsImpl struct { 109 type txnDsImpl struct {
105 data *txnDataStoreData 110 data *txnDataStoreData
106 ns string 111 ns string
107 } 112 }
108 113
109 var _ ds.RawInterface = (*txnDsImpl)(nil) 114 var _ ds.RawInterface = (*txnDsImpl)(nil)
110 115
116 func (d *txnDsImpl) AllocateIDs(incomplete *ds.Key, n int) (int64, error) {
117 start := d.data.parent.allocateIDs(incomplete, n)
118 return start, nil
119 }
120
111 func (d *txnDsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMul tiCB) error { 121 func (d *txnDsImpl) PutMulti(keys []*ds.Key, vals []ds.PropertyMap, cb ds.PutMul tiCB) error {
112 return d.data.run(func() error { 122 return d.data.run(func() error {
113 d.data.putMulti(keys, vals, cb) 123 d.data.putMulti(keys, vals, cb)
114 return nil 124 return nil
115 }) 125 })
116 } 126 }
117 127
118 func (d *txnDsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.Get MultiCB) error { 128 func (d *txnDsImpl) GetMulti(keys []*ds.Key, _meta ds.MultiMetaGetter, cb ds.Get MultiCB) error {
119 return d.data.run(func() error { 129 return d.data.run(func() error {
120 return d.data.getMulti(keys, cb) 130 return d.data.getMulti(keys, cb)
(...skipping 14 matching lines...) Expand all
135 return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb) 145 return executeQuery(q, d.ns, true, d.data.snap, d.data.snap, cb)
136 } 146 }
137 147
138 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error { 148 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error {
139 return errors.New("datastore: nested transactions are not supported") 149 return errors.New("datastore: nested transactions are not supported")
140 } 150 }
141 151
142 func (*txnDsImpl) Testable() ds.Testable { 152 func (*txnDsImpl) Testable() ds.Testable {
143 return nil 153 return nil
144 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698