| Index: go/src/infra/gae/libs/gae/prod/datastore_key.go
|
| diff --git a/go/src/infra/gae/libs/gae/prod/datastore_key.go b/go/src/infra/gae/libs/gae/prod/datastore_key.go
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..03a39780f869cc7fdb7db7cd41ff6083707214b8
|
| --- /dev/null
|
| +++ b/go/src/infra/gae/libs/gae/prod/datastore_key.go
|
| @@ -0,0 +1,56 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package prod
|
| +
|
| +import (
|
| + "infra/gae/libs/gae"
|
| + "infra/gae/libs/gae/helper"
|
| +
|
| + "google.golang.org/appengine/datastore"
|
| +)
|
| +
|
| +type dsKeyImpl struct {
|
| + *datastore.Key
|
| +}
|
| +
|
| +var _ gae.DSKey = dsKeyImpl{}
|
| +
|
| +func (k dsKeyImpl) Equal(other gae.DSKey) bool { return k.Key.Equal(f2r(other)) }
|
| +func (k dsKeyImpl) Parent() gae.DSKey { return &dsKeyImpl{k.Key.Parent()} }
|
| +func (k dsKeyImpl) Root() gae.DSKey { return helper.DSKeyRoot(k) }
|
| +func (k dsKeyImpl) Valid(ns string, allowSpecial bool) bool {
|
| + return helper.DSKeyValid(k, ns, allowSpecial)
|
| +}
|
| +
|
| +func r2f(k *datastore.Key) gae.DSKey {
|
| + return &dsKeyImpl{k}
|
| +}
|
| +
|
| +func r2fe(k *datastore.Key, err error) (gae.DSKey, error) {
|
| + if err != nil {
|
| + return nil, err
|
| + }
|
| + return r2f(k), nil
|
| +}
|
| +
|
| +func f2r(k gae.DSKey) *datastore.Key {
|
| + return k.(dsKeyImpl).Key
|
| +}
|
| +
|
| +func mr2f(ks []*datastore.Key) []gae.DSKey {
|
| + ret := make([]gae.DSKey, len(ks))
|
| + for i, k := range ks {
|
| + ret[i] = r2f(k)
|
| + }
|
| + return ret
|
| +}
|
| +
|
| +func mf2r(ks []gae.DSKey) []*datastore.Key {
|
| + ret := make([]*datastore.Key, len(ks))
|
| + for i, k := range ks {
|
| + ret[i] = f2r(k)
|
| + }
|
| + return ret
|
| +}
|
|
|