| Index: go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go
 | 
| diff --git a/go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go b/go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go
 | 
| new file mode 100644
 | 
| index 0000000000000000000000000000000000000000..83f6225510e50d934e1159aa2d687da82cb101b7
 | 
| --- /dev/null
 | 
| +++ b/go/src/infra/gae/libs/wrapper/memory/gkvlite_utils.go
 | 
| @@ -0,0 +1,94 @@
 | 
| +// 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 memory
 | 
| +
 | 
| +import (
 | 
| +	"github.com/luci/gkvlite"
 | 
| +)
 | 
| +
 | 
| +// memStore is a gkvlite.Store which will panic for anything which might
 | 
| +// otherwise return an error.
 | 
| +//
 | 
| +// This is reasonable for in-memory Store objects, since the only errors that
 | 
| +// should occur happen with file IO on the underlying file (which of course
 | 
| +// doesn't exist).
 | 
| +type memStore gkvlite.Store
 | 
| +
 | 
| +func newMemStore() *memStore {
 | 
| +	ret, err := gkvlite.NewStore(nil)
 | 
| +	if err != nil {
 | 
| +		panic(err)
 | 
| +	}
 | 
| +	return (*memStore)(ret)
 | 
| +}
 | 
| +
 | 
| +func (bs *memStore) Snapshot() *memStore {
 | 
| +	return (*memStore)((*gkvlite.Store)(bs).Snapshot())
 | 
| +}
 | 
| +
 | 
| +func (bs *memStore) MakePrivateCollection(cmp gkvlite.KeyCompare) *memCollection {
 | 
| +	return (*memCollection)((*gkvlite.Store)(bs).MakePrivateCollection(cmp))
 | 
| +}
 | 
| +
 | 
| +func (bs *memStore) GetCollection(name string) *memCollection {
 | 
| +	return (*memCollection)((*gkvlite.Store)(bs).GetCollection(name))
 | 
| +}
 | 
| +
 | 
| +func (bs *memStore) SetCollection(name string, cmp gkvlite.KeyCompare) *memCollection {
 | 
| +	return (*memCollection)((*gkvlite.Store)(bs).SetCollection(name, cmp))
 | 
| +}
 | 
| +
 | 
| +// memCollection is a gkvlite.Collection which will panic for anything which
 | 
| +// might otherwise return an error.
 | 
| +//
 | 
| +// This is reasonable for in-memory Store objects, since the only errors that
 | 
| +// should occur happen with file IO on the underlying file (which of course
 | 
| +// doesn't exist.
 | 
| +type memCollection gkvlite.Collection
 | 
| +
 | 
| +func (bc *memCollection) Get(k []byte) []byte {
 | 
| +	ret, err := (*gkvlite.Collection)(bc).Get(k)
 | 
| +	if err != nil {
 | 
| +		panic(err)
 | 
| +	}
 | 
| +	return ret
 | 
| +}
 | 
| +
 | 
| +func (bc *memCollection) Set(k, v []byte) {
 | 
| +	err := (*gkvlite.Collection)(bc).Set(k, v)
 | 
| +	if err != nil {
 | 
| +		panic(err)
 | 
| +	}
 | 
| +}
 | 
| +
 | 
| +func (bc *memCollection) Delete(k []byte) bool {
 | 
| +	ret, err := (*gkvlite.Collection)(bc).Delete(k)
 | 
| +	if err != nil {
 | 
| +		panic(err)
 | 
| +	}
 | 
| +	return ret
 | 
| +}
 | 
| +
 | 
| +func (bc *memCollection) VisitItemsAscend(target []byte, withValue bool, visitor gkvlite.ItemVisitor) {
 | 
| +	err := (*gkvlite.Collection)(bc).VisitItemsAscend(target, withValue, visitor)
 | 
| +	if err != nil {
 | 
| +		panic(err)
 | 
| +	}
 | 
| +}
 | 
| +
 | 
| +func (bc *memCollection) VisitItemsDescend(target []byte, withValue bool, visitor gkvlite.ItemVisitor) {
 | 
| +	err := (*gkvlite.Collection)(bc).VisitItemsDescend(target, withValue, visitor)
 | 
| +	if err != nil {
 | 
| +		panic(err)
 | 
| +	}
 | 
| +}
 | 
| +
 | 
| +func (bc *memCollection) GetTotals() (numItems, numBytes uint64) {
 | 
| +	numItems, numBytes, err := (*gkvlite.Collection)(bc).GetTotals()
 | 
| +	if err != nil {
 | 
| +		panic(err)
 | 
| +	}
 | 
| +	return
 | 
| +}
 | 
| 
 |