| 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 rawdatastore | 5 package datastore |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 | 9 |
| 10 "github.com/luci/gae/service/info" | 10 "github.com/luci/gae/service/info" |
| 11 "github.com/luci/luci-go/common/errors" | 11 "github.com/luci/luci-go/common/errors" |
| 12 "golang.org/x/net/context" | 12 "golang.org/x/net/context" |
| 13 ) | 13 ) |
| 14 | 14 |
| 15 type checkFilter struct { | 15 type checkFilter struct { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 for _, err := range me.(errors.MultiError) { | 47 for _, err := range me.(errors.MultiError) { |
| 48 cb(nil, err) | 48 cb(nil, err) |
| 49 } | 49 } |
| 50 return nil | 50 return nil |
| 51 } | 51 } |
| 52 return tcf.Interface.GetMulti(keys, cb) | 52 return tcf.Interface.GetMulti(keys, cb) |
| 53 } | 53 } |
| 54 | 54 |
| 55 func (tcf *checkFilter) PutMulti(keys []Key, vals []PropertyLoadSaver, cb PutMul
tiCB) error { | 55 func (tcf *checkFilter) PutMulti(keys []Key, vals []PropertyLoadSaver, cb PutMul
tiCB) error { |
| 56 if len(keys) != len(vals) { | 56 if len(keys) != len(vals) { |
| 57 » » return fmt.Errorf("rawdatastore: GetMulti with mismatched keys/v
als lengths (%d/%d)", len(keys), len(vals)) | 57 » » return fmt.Errorf("datastore: GetMulti with mismatched keys/vals
lengths (%d/%d)", len(keys), len(vals)) |
| 58 } | 58 } |
| 59 if len(keys) == 0 { | 59 if len(keys) == 0 { |
| 60 return nil | 60 return nil |
| 61 } | 61 } |
| 62 lme := errors.LazyMultiError{Size: len(keys)} | 62 lme := errors.LazyMultiError{Size: len(keys)} |
| 63 for i, k := range keys { | 63 for i, k := range keys { |
| 64 if KeyIncomplete(k) { | 64 if KeyIncomplete(k) { |
| 65 k = NewKey(k.AppID(), k.Namespace(), k.Kind(), "", 1, k.
Parent()) | 65 k = NewKey(k.AppID(), k.Namespace(), k.Kind(), "", 1, k.
Parent()) |
| 66 } | 66 } |
| 67 if !KeyValid(k, false, tcf.aid, tcf.ns) { | 67 if !KeyValid(k, false, tcf.aid, tcf.ns) { |
| 68 lme.Assign(i, ErrInvalidKey) | 68 lme.Assign(i, ErrInvalidKey) |
| 69 continue | 69 continue |
| 70 } | 70 } |
| 71 v := vals[i] | 71 v := vals[i] |
| 72 if v == nil { | 72 if v == nil { |
| 73 » » » lme.Assign(i, errors.New("rawdatastore: PutMulti got nil
vals entry")) | 73 » » » lme.Assign(i, errors.New("datastore: PutMulti got nil va
ls entry")) |
| 74 } else { | 74 } else { |
| 75 lme.Assign(i, v.Problem()) | 75 lme.Assign(i, v.Problem()) |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 if me := lme.Get(); me != nil { | 78 if me := lme.Get(); me != nil { |
| 79 for _, err := range me.(errors.MultiError) { | 79 for _, err := range me.(errors.MultiError) { |
| 80 cb(nil, err) | 80 cb(nil, err) |
| 81 } | 81 } |
| 82 return nil | 82 return nil |
| 83 } | 83 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 114 } | 114 } |
| 115 return nil | 115 return nil |
| 116 } | 116 } |
| 117 return tcf.Interface.DeleteMulti(keys, cb) | 117 return tcf.Interface.DeleteMulti(keys, cb) |
| 118 } | 118 } |
| 119 | 119 |
| 120 func applyCheckFilter(c context.Context, i Interface) Interface { | 120 func applyCheckFilter(c context.Context, i Interface) Interface { |
| 121 inf := info.Get(c) | 121 inf := info.Get(c) |
| 122 return &checkFilter{i, inf.AppID(), inf.GetNamespace()} | 122 return &checkFilter{i, inf.AppID(), inf.GetNamespace()} |
| 123 } | 123 } |
| OLD | NEW |