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

Side by Side Diff: impl/memory/gkvlite_iter.go

Issue 1380613002: Fix bugs in impl/memory queries. (Closed) Base URL: https://github.com/luci/gae.git@add_appid
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « impl/memory/datastore_query_execution_test.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package memory 5 package memory
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "sync" 9 "sync"
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 for { 58 for {
59 stop := false 59 stop := false
60 restart := false 60 restart := false
61 61
62 for idx, it := range ts { 62 for idx, it := range ts {
63 if skip >= 0 && skip == idx { 63 if skip >= 0 && skip == idx {
64 continue 64 continue
65 } 65 }
66 def := defs[idx] 66 def := defs[idx]
67 67
68 » » » it.next(serialize.Join(def.prefix, suffix), func(itm *gk vlite.Item) { 68 » » » pfxLen := prefixLens[idx]
69 » » » it.next(serialize.Join(def.prefix[:pfxLen], suffix), fun c(itm *gkvlite.Item) {
69 if itm == nil { 70 if itm == nil {
70 // we hit the end of an iterator, we're now done with the whole 71 // we hit the end of an iterator, we're now done with the whole
71 // query. 72 // query.
72 stop = true 73 stop = true
73 return 74 return
74 } 75 }
75 76
76 » » » » sfxRO := itm.Key[prefixLens[idx]:] 77 » » » » sfxRO := itm.Key[pfxLen:]
77 78
78 if bytes.Compare(sfxRO, suffix) > 0 { 79 if bytes.Compare(sfxRO, suffix) > 0 {
79 // this row has a higher suffix than any thing we've seen before. Set 80 // this row has a higher suffix than any thing we've seen before. Set
80 // ourself to be the skip, and resart th is loop from the top. 81 // ourself to be the skip, and resart th is loop from the top.
81 suffix = append(suffix[:0], sfxRO...) 82 suffix = append(suffix[:0], sfxRO...)
82 skip = idx 83 skip = idx
83 if idx != 0 { 84 if idx != 0 {
84 // no point to restarting on the 0th index 85 // no point to restarting on the 0th index
85 restart = true 86 restart = true
86 } 87 }
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 t.ch <- &cmd{targ, func(i *gkvlite.Item) { 207 t.ch <- &cmd{targ, func(i *gkvlite.Item) {
207 defer close(waiter) 208 defer close(waiter)
208 209
209 if i == nil { 210 if i == nil {
210 t.stop() 211 t.stop()
211 } 212 }
212 cb(i) 213 cb(i)
213 }} 214 }}
214 <-waiter 215 <-waiter
215 } 216 }
OLDNEW
« no previous file with comments | « impl/memory/datastore_query_execution_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698