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

Unified Diff: impl/memory/plist.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint Created 5 years, 5 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/memcache_test.go ('k') | impl/memory/plist_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/plist.go
diff --git a/memory/plist.go b/impl/memory/plist.go
similarity index 90%
rename from memory/plist.go
rename to impl/memory/plist.go
index f91b97cf1e3cdd833ecd94ad6ac7e8cd14bb4f99..22a942b313f035fe6e56579c360a0e89936f2d0d 100644
--- a/memory/plist.go
+++ b/impl/memory/plist.go
@@ -9,9 +9,7 @@ import (
"fmt"
"sort"
- "github.com/luci/gae"
- "github.com/luci/gae/helper"
-
+ rds "github.com/luci/gae/service/rawdatastore"
"github.com/luci/gkvlite"
)
@@ -23,13 +21,13 @@ func (s qIndexSlice) Len() int { return len(s) }
func (s qIndexSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s qIndexSlice) Less(i, j int) bool { return s[i].Less(s[j]) }
-func defaultIndicies(kind string, pmap gae.DSPropertyMap) []*qIndex {
+func defaultIndicies(kind string, pmap rds.PropertyMap) []*qIndex {
ret := make(qIndexSlice, 0, 2*len(pmap)+1)
ret = append(ret, &qIndex{kind, false, nil})
for name, pvals := range pmap {
needsIndex := false
for _, v := range pvals {
- if v.IndexSetting() == gae.ShouldIndex {
+ if v.IndexSetting() == rds.ShouldIndex {
needsIndex = true
break
}
@@ -46,7 +44,7 @@ func defaultIndicies(kind string, pmap gae.DSPropertyMap) []*qIndex {
return ret
}
-func indexEntriesWithBuiltins(k gae.DSKey, pm gae.DSPropertyMap, complexIdxs []*qIndex) *memStore {
+func indexEntriesWithBuiltins(k rds.Key, pm rds.PropertyMap, complexIdxs []*qIndex) *memStore {
sip := partiallySerialize(pm)
return sip.indexEntries(k, append(defaultIndicies(k.Kind(), pm), complexIdxs...))
}
@@ -61,7 +59,7 @@ func (s serializedPvals) Less(i, j int) bool { return bytes.Compare(s[i], s[j])
// prop name -> [<serialized DSProperty>, ...]
type serializedIndexablePmap map[string]serializedPvals
-func partiallySerialize(pm gae.DSPropertyMap) (ret serializedIndexablePmap) {
+func partiallySerialize(pm rds.PropertyMap) (ret serializedIndexablePmap) {
if len(pm) == 0 {
return
}
@@ -71,11 +69,11 @@ func partiallySerialize(pm gae.DSPropertyMap) (ret serializedIndexablePmap) {
for k, vals := range pm {
newVals := make(serializedPvals, 0, len(vals))
for _, v := range vals {
- if v.IndexSetting() == gae.NoIndex {
+ if v.IndexSetting() == rds.NoIndex {
continue
}
buf.Reset()
- helper.WriteDSProperty(buf, v, helper.WithoutContext)
+ rds.WriteProperty(buf, v, rds.WithoutContext)
newVal := make([]byte, buf.Len())
copy(newVal, buf.Bytes())
newVals = append(newVals, newVal)
@@ -177,7 +175,7 @@ func (m *matcher) match(idx *qIndex, sip serializedIndexablePmap) (indexRowGen,
return m.buf, true
}
-func (sip serializedIndexablePmap) indexEntries(k gae.DSKey, idxs []*qIndex) *memStore {
+func (sip serializedIndexablePmap) indexEntries(k rds.Key, idxs []*qIndex) *memStore {
ret := newMemStore()
idxColl := ret.SetCollection("idx", nil)
// getIdxEnts retrieves an index collection or adds it if it's not there.
@@ -190,7 +188,7 @@ func (sip serializedIndexablePmap) indexEntries(k gae.DSKey, idxs []*qIndex) *me
}
buf := &bytes.Buffer{}
- helper.WriteDSKey(buf, helper.WithoutContext, k)
+ rds.WriteKey(buf, rds.WithoutContext, k)
keyData := buf.Bytes()
walkPermutations := func(prefix []byte, irg indexRowGen, ents *memCollection) {
@@ -214,7 +212,7 @@ func (sip serializedIndexablePmap) indexEntries(k gae.DSKey, idxs []*qIndex) *me
} else if idx.ancestor {
for ancKey := k; ancKey != nil; ancKey = ancKey.Parent() {
buf := &bytes.Buffer{}
- helper.WriteDSKey(buf, helper.WithoutContext, ancKey)
+ rds.WriteKey(buf, rds.WithoutContext, ancKey)
walkPermutations(buf.Bytes(), irg, idxEnts)
}
} else {
@@ -226,7 +224,7 @@ func (sip serializedIndexablePmap) indexEntries(k gae.DSKey, idxs []*qIndex) *me
return ret
}
-func updateIndicies(store *memStore, key gae.DSKey, oldEnt, newEnt gae.DSPropertyMap) {
+func updateIndicies(store *memStore, key rds.Key, oldEnt, newEnt rds.PropertyMap) {
idxColl := store.GetCollection("idx")
if idxColl == nil {
idxColl = store.SetCollection("idx", nil)
« no previous file with comments | « impl/memory/memcache_test.go ('k') | impl/memory/plist_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698