| OLD | NEW |
| 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 | 9 |
| 10 "golang.org/x/net/context" | 10 "golang.org/x/net/context" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 func (d *dsImpl) NewKey(kind, stringID string, intID int64, parent ds.Key) ds.Ke
y { | 46 func (d *dsImpl) NewKey(kind, stringID string, intID int64, parent ds.Key) ds.Ke
y { |
| 47 return ds.NewKey(globalAppID, d.ns, kind, stringID, intID, parent) | 47 return ds.NewKey(globalAppID, d.ns, kind, stringID, intID, parent) |
| 48 } | 48 } |
| 49 | 49 |
| 50 func (d *dsImpl) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMultiCB
) error { | 50 func (d *dsImpl) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMultiCB
) error { |
| 51 d.data.putMulti(keys, vals, cb) | 51 d.data.putMulti(keys, vals, cb) |
| 52 return nil | 52 return nil |
| 53 } | 53 } |
| 54 | 54 |
| 55 func (d *dsImpl) GetMulti(keys []ds.Key, cb ds.GetMultiCB) error { | 55 func (d *dsImpl) GetMulti(keys []ds.Key, _meta ds.MultiMetaGetter, cb ds.GetMult
iCB) error { |
| 56 d.data.getMulti(keys, cb) | 56 d.data.getMulti(keys, cb) |
| 57 return nil | 57 return nil |
| 58 } | 58 } |
| 59 | 59 |
| 60 func (d *dsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { | 60 func (d *dsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { |
| 61 d.data.delMulti(keys, cb) | 61 d.data.delMulti(keys, cb) |
| 62 return nil | 62 return nil |
| 63 } | 63 } |
| 64 | 64 |
| 65 func (d *dsImpl) NewQuery(kind string) ds.Query { | 65 func (d *dsImpl) NewQuery(kind string) ds.Query { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 92 return ds.NewKey(globalAppID, d.ns, kind, stringID, intID, parent) | 92 return ds.NewKey(globalAppID, d.ns, kind, stringID, intID, parent) |
| 93 } | 93 } |
| 94 | 94 |
| 95 func (d *txnDsImpl) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMult
iCB) error { | 95 func (d *txnDsImpl) PutMulti(keys []ds.Key, vals []ds.PropertyMap, cb ds.PutMult
iCB) error { |
| 96 return d.data.run(func() error { | 96 return d.data.run(func() error { |
| 97 d.data.putMulti(keys, vals, cb) | 97 d.data.putMulti(keys, vals, cb) |
| 98 return nil | 98 return nil |
| 99 }) | 99 }) |
| 100 } | 100 } |
| 101 | 101 |
| 102 func (d *txnDsImpl) GetMulti(keys []ds.Key, cb ds.GetMultiCB) error { | 102 func (d *txnDsImpl) GetMulti(keys []ds.Key, _meta ds.MultiMetaGetter, cb ds.GetM
ultiCB) error { |
| 103 return d.data.run(func() error { | 103 return d.data.run(func() error { |
| 104 return d.data.getMulti(keys, cb) | 104 return d.data.getMulti(keys, cb) |
| 105 }) | 105 }) |
| 106 } | 106 } |
| 107 | 107 |
| 108 func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { | 108 func (d *txnDsImpl) DeleteMulti(keys []ds.Key, cb ds.DeleteMultiCB) error { |
| 109 return d.data.run(func() error { | 109 return d.data.run(func() error { |
| 110 return d.data.delMulti(keys, cb) | 110 return d.data.delMulti(keys, cb) |
| 111 }) | 111 }) |
| 112 } | 112 } |
| 113 | 113 |
| 114 func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error { | 114 func (d *txnDsImpl) Run(q ds.Query, cb ds.RawRunCB) error { |
| 115 rq := q.(*queryImpl) | 115 rq := q.(*queryImpl) |
| 116 if rq.ancestor == nil { | 116 if rq.ancestor == nil { |
| 117 return errors.New("memory: queries in transactions only support
ancestor queries") | 117 return errors.New("memory: queries in transactions only support
ancestor queries") |
| 118 } | 118 } |
| 119 panic("NOT IMPLEMENTED") | 119 panic("NOT IMPLEMENTED") |
| 120 } | 120 } |
| 121 | 121 |
| 122 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { | 122 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio
nOptions) error { |
| 123 return errors.New("datastore: nested transactions are not supported") | 123 return errors.New("datastore: nested transactions are not supported") |
| 124 } | 124 } |
| 125 | 125 |
| 126 func (d *txnDsImpl) NewQuery(kind string) ds.Query { | 126 func (d *txnDsImpl) NewQuery(kind string) ds.Query { |
| 127 return &queryImpl{ns: d.ns, kind: kind} | 127 return &queryImpl{ns: d.ns, kind: kind} |
| 128 } | 128 } |
| OLD | NEW |