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

Unified Diff: impl/memory/gkvlite_utils.go

Issue 1302813003: impl/memory: Implement Queries (Closed) Base URL: https://github.com/luci/gae.git@add_multi_iterator
Patch Set: stringSet everywhere Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/memory/gkvlite_iter_test.go ('k') | impl/memory/gkvlite_utils_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/gkvlite_utils.go
diff --git a/impl/memory/gkvlite_utils.go b/impl/memory/gkvlite_utils.go
index ac64f9b7d7905f1233459120d4231e7e3671b309..6496c113e4fc37834c21fdc667e2e838c526382e 100644
--- a/impl/memory/gkvlite_utils.go
+++ b/impl/memory/gkvlite_utils.go
@@ -13,6 +13,7 @@ import (
)
func gkvCollide(o, n *memCollection, f func(k, ov, nv []byte)) {
+ // TODO(riannucci): reimplement in terms of *iterator.
oldItems, newItems := make(chan *gkvlite.Item), make(chan *gkvlite.Item)
walker := func(c *memCollection, ch chan<- *gkvlite.Item, wg *sync.WaitGroup) {
defer close(ch)
@@ -69,9 +70,7 @@ type memStore gkvlite.Store
func newMemStore() *memStore {
ret, err := gkvlite.NewStore(nil)
- if err != nil {
- panic(err)
- }
+ memoryCorruption(err)
return (*memStore)(ret)
}
@@ -95,6 +94,10 @@ func (ms *memStore) SetCollection(name string, cmp gkvlite.KeyCompare) *memColle
return (*memCollection)((*gkvlite.Store)(ms).SetCollection(name, cmp))
}
+func (ms *memStore) GetCollectionNames() []string {
+ return (*gkvlite.Store)(ms).GetCollectionNames()
+}
+
// memCollection is a gkvlite.Collection which will panic for anything which
// might otherwise return an error.
//
@@ -105,44 +108,34 @@ type memCollection gkvlite.Collection
func (mc *memCollection) Get(k []byte) []byte {
ret, err := (*gkvlite.Collection)(mc).Get(k)
- if err != nil {
- panic(err)
- }
+ memoryCorruption(err)
return ret
}
func (mc *memCollection) MinItem(withValue bool) *gkvlite.Item {
ret, err := (*gkvlite.Collection)(mc).MinItem(withValue)
- if err != nil {
- panic(err)
- }
+ memoryCorruption(err)
return ret
}
func (mc *memCollection) Set(k, v []byte) {
- if err := (*gkvlite.Collection)(mc).Set(k, v); err != nil {
- panic(err)
- }
+ err := (*gkvlite.Collection)(mc).Set(k, v)
+ memoryCorruption(err)
}
func (mc *memCollection) Delete(k []byte) bool {
ret, err := (*gkvlite.Collection)(mc).Delete(k)
- if err != nil {
- panic(err)
- }
+ memoryCorruption(err)
return ret
}
func (mc *memCollection) VisitItemsAscend(target []byte, withValue bool, visitor gkvlite.ItemVisitor) {
- if err := (*gkvlite.Collection)(mc).VisitItemsAscend(target, withValue, visitor); err != nil {
- panic(err)
- }
+ err := (*gkvlite.Collection)(mc).VisitItemsAscend(target, withValue, visitor)
+ memoryCorruption(err)
}
func (mc *memCollection) GetTotals() (numItems, numBytes uint64) {
numItems, numBytes, err := (*gkvlite.Collection)(mc).GetTotals()
- if err != nil {
- panic(err)
- }
+ memoryCorruption(err)
return
}
« no previous file with comments | « impl/memory/gkvlite_iter_test.go ('k') | impl/memory/gkvlite_utils_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698