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/datastore_query_execution.go

Issue 1521823003: Clean up callback interfaces. (Closed) Base URL: https://github.com/luci/gae.git@extra
Patch Set: fixins Created 5 years 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/datastore_data.go ('k') | impl/memory/datastore_query_execution_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/datastore_query_execution.go
diff --git a/impl/memory/datastore_query_execution.go b/impl/memory/datastore_query_execution.go
index eb42c780c76f2ec9ec5e5afea09ca7f7a01f2948..6fdd28bbf68fc7bcfee0c77429739309b7a770e5 100644
--- a/impl/memory/datastore_query_execution.go
+++ b/impl/memory/datastore_query_execution.go
@@ -22,7 +22,7 @@ type queryStrategy interface {
// - key is the decoded Key from the index row (the last item in rawData and
// decodedProps)
// - gc is the getCursor function to be passed to the user's callback
- handle(rawData [][]byte, decodedProps []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) bool
+ handle(rawData [][]byte, decodedProps []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) error
}
type projectionLookup struct {
@@ -60,7 +60,7 @@ func newProjectionStrategy(fq *ds.FinalizedQuery, rq *reducedQuery, cb ds.RawRun
return ret
}
-func (s *projectionStrategy) handle(rawData [][]byte, decodedProps []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) bool {
+func (s *projectionStrategy) handle(rawData [][]byte, decodedProps []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) error {
projectedRaw := [][]byte(nil)
if s.distinct != nil {
projectedRaw = make([][]byte, len(decodedProps))
@@ -74,7 +74,7 @@ func (s *projectionStrategy) handle(rawData [][]byte, decodedProps []ds.Property
}
if s.distinct != nil {
if !s.distinct.Add(string(serialize.Join(projectedRaw...))) {
- return true
+ return nil
}
}
return s.cb(key, pmap, gc)
@@ -86,9 +86,9 @@ type keysOnlyStrategy struct {
dedup stringset.Set
}
-func (s *keysOnlyStrategy) handle(rawData [][]byte, _ []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) bool {
+func (s *keysOnlyStrategy) handle(rawData [][]byte, _ []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) error {
if !s.dedup.Add(string(rawData[len(rawData)-1])) {
- return true
+ return nil
}
return s.cb(key, nil, gc)
}
@@ -110,16 +110,16 @@ func newNormalStrategy(aid, ns string, cb ds.RawRunCB, head *memStore) queryStra
return &normalStrategy{cb, aid, ns, coll, stringset.New(0)}
}
-func (s *normalStrategy) handle(rawData [][]byte, _ []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) bool {
+func (s *normalStrategy) handle(rawData [][]byte, _ []ds.Property, key *ds.Key, gc func() (ds.Cursor, error)) error {
rawKey := rawData[len(rawData)-1]
if !s.dedup.Add(string(rawKey)) {
- return true
+ return nil
}
rawEnt := s.head.Get(rawKey)
if rawEnt == nil {
// entity doesn't exist at head
- return true
+ return nil
}
pm, err := serialize.ReadPropertyMap(bytes.NewBuffer(rawEnt), serialize.WithoutContext, s.aid, s.ns)
memoryCorruption(err)
@@ -171,9 +171,9 @@ func countQuery(fq *ds.FinalizedQuery, aid, ns string, isTxn bool, idx, head *me
return
}
}
- err = executeQuery(fq, aid, ns, isTxn, idx, head, func(_ *ds.Key, _ ds.PropertyMap, _ ds.CursorCB) bool {
+ err = executeQuery(fq, aid, ns, isTxn, idx, head, func(_ *ds.Key, _ ds.PropertyMap, _ ds.CursorCB) error {
ret++
- return true
+ return nil
})
return
}
@@ -225,14 +225,14 @@ func executeQuery(fq *ds.FinalizedQuery, aid, ns string, isTxn bool, idx, head *
}
}
- multiIterate(idxs, func(suffix []byte) bool {
+ return multiIterate(idxs, func(suffix []byte) error {
if offset > 0 {
offset--
- return true
+ return nil
}
if hasLimit {
if limit <= 0 {
- return false
+ return ds.Stop
}
limit--
}
@@ -248,6 +248,4 @@ func executeQuery(fq *ds.FinalizedQuery, aid, ns string, isTxn bool, idx, head *
rawData, decodedProps, keyProp.Value().(*ds.Key),
getCursorFn(suffix))
})
-
- return nil
}
« no previous file with comments | « impl/memory/datastore_data.go ('k') | impl/memory/datastore_query_execution_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698