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

Unified Diff: impl/memory/datastore_index.go

Issue 2604943002: impl/memory: Replace gkvlite with "treapstore". (Closed)
Patch Set: Comments. Created 3 years, 11 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/README.md ('k') | impl/memory/datastore_index_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_index.go
diff --git a/impl/memory/datastore_index.go b/impl/memory/datastore_index.go
index 0854d1a29abee29213c91af21ea8ab64795847ad..56b8e7a05f562258b83e91ae797728de208016ec 100644
--- a/impl/memory/datastore_index.go
+++ b/impl/memory/datastore_index.go
@@ -11,7 +11,6 @@ import (
ds "github.com/luci/gae/service/datastore"
"github.com/luci/gae/service/datastore/serialize"
- "github.com/luci/gkvlite"
)
type qIndexSlice []*ds.IndexDefinition
@@ -183,18 +182,12 @@ func walkCompIdxs(store memStore, endsWith *ds.IndexDefinition, cb func(*ds.Inde
}
it := itrDef.mkIter()
- defer it.stop()
- for !it.stopped {
- it.next(nil, func(i *gkvlite.Item) {
- if i == nil {
- return
- }
- qi, err := serialize.ReadIndexDefinition(bytes.NewBuffer(i.Key))
- memoryCorruption(err)
- if !cb(qi.Flip()) {
- it.stop()
- }
- })
+ for ent := it.next(); ent != nil; ent = it.next() {
+ qi, err := serialize.ReadIndexDefinition(bytes.NewBuffer(ent.key))
+ memoryCorruption(err)
+ if !cb(qi.Flip()) {
+ break
+ }
}
}
@@ -205,7 +198,7 @@ func mergeIndexes(ns string, store, oldIdx, newIdx memStore) {
oldIdx = oldIdx.Snapshot()
newIdx = newIdx.Snapshot()
- gkvCollide(oldIdx.GetCollection("idx"), newIdx.GetCollection("idx"), func(k, ov, nv []byte) {
+ memStoreCollide(oldIdx.GetCollection("idx"), newIdx.GetCollection("idx"), func(k, ov, nv []byte) {
prefixBuf = append(prefixBuf[:origPrefixBufLen], k...)
ks := string(prefixBuf)
@@ -216,17 +209,17 @@ func mergeIndexes(ns string, store, oldIdx, newIdx memStore) {
switch {
case ov == nil && nv != nil: // all additions
- newColl.VisitItemsAscend(nil, false, func(i *gkvlite.Item) bool {
- coll.Set(i.Key, []byte{})
+ newColl.ForEachItem(func(k, _ []byte) bool {
+ coll.Set(k, []byte{})
return true
})
case ov != nil && nv == nil: // all deletions
- oldColl.VisitItemsAscend(nil, false, func(i *gkvlite.Item) bool {
- coll.Delete(i.Key)
+ oldColl.ForEachItem(func(k, _ []byte) bool {
+ coll.Delete(k)
return true
})
case ov != nil && nv != nil: // merge
- gkvCollide(oldColl, newColl, func(k, ov, nv []byte) {
+ memStoreCollide(oldColl, newColl, func(k, ov, nv []byte) {
if nv == nil {
coll.Delete(k)
} else {
@@ -234,7 +227,7 @@ func mergeIndexes(ns string, store, oldIdx, newIdx memStore) {
}
})
default:
- impossible(fmt.Errorf("both values from gkvCollide were nil?"))
+ impossible(fmt.Errorf("both values from memStoreCollide were nil?"))
}
// TODO(riannucci): remove entries from idxColl and remove index collections
// when there are no index entries for that index any more.
@@ -250,12 +243,13 @@ func addIndexes(store memStore, aid string, compIdx []*ds.IndexDefinition) {
}
for _, ns := range namespaces(store) {
+ kctx := ds.MkKeyContext(aid, ns)
if allEnts := store.Snapshot().GetCollection("ents:" + ns); allEnts != nil {
- allEnts.VisitItemsAscend(nil, true, func(i *gkvlite.Item) bool {
- pm, err := rpm(i.Val)
+ allEnts.ForEachItem(func(ik, iv []byte) bool {
+ pm, err := rpm(iv)
memoryCorruption(err)
- prop, err := serialize.ReadProperty(bytes.NewBuffer(i.Key), serialize.WithoutContext, ds.MkKeyContext(aid, ns))
+ prop, err := serialize.ReadProperty(bytes.NewBuffer(ik), serialize.WithoutContext, kctx)
memoryCorruption(err)
k := prop.Value().(*ds.Key)
« no previous file with comments | « impl/memory/README.md ('k') | impl/memory/datastore_index_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698