OLD | NEW |
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 "fmt" | 9 "fmt" |
10 | 10 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 return newNormalStrategy(rq.aid, rq.ns, cb, head) | 137 return newNormalStrategy(rq.aid, rq.ns, cb, head) |
138 } | 138 } |
139 | 139 |
140 func parseSuffix(aid, ns string, suffixFormat []ds.IndexColumn, suffix []byte, c
ount int) (raw [][]byte, decoded []ds.Property) { | 140 func parseSuffix(aid, ns string, suffixFormat []ds.IndexColumn, suffix []byte, c
ount int) (raw [][]byte, decoded []ds.Property) { |
141 buf := serialize.Invertible(bytes.NewBuffer(suffix)) | 141 buf := serialize.Invertible(bytes.NewBuffer(suffix)) |
142 decoded = make([]ds.Property, len(suffixFormat)) | 142 decoded = make([]ds.Property, len(suffixFormat)) |
143 raw = make([][]byte, len(suffixFormat)) | 143 raw = make([][]byte, len(suffixFormat)) |
144 | 144 |
145 err := error(nil) | 145 err := error(nil) |
146 for i := range decoded { | 146 for i := range decoded { |
147 » » if count > 0 && i > count { | 147 » » if count >= 0 && i >= count { |
148 break | 148 break |
149 } | 149 } |
150 needInvert := suffixFormat[i].Descending | 150 needInvert := suffixFormat[i].Descending |
151 | 151 |
152 buf.SetInvert(needInvert) | 152 buf.SetInvert(needInvert) |
153 decoded[i], err = serialize.ReadProperty(buf, serialize.WithoutC
ontext, aid, ns) | 153 decoded[i], err = serialize.ReadProperty(buf, serialize.WithoutC
ontext, aid, ns) |
154 memoryCorruption(err) | 154 memoryCorruption(err) |
155 | 155 |
156 offset := len(suffix) - buf.Len() | 156 offset := len(suffix) - buf.Len() |
157 raw[i] = suffix[:offset] | 157 raw[i] = suffix[:offset] |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 impossible(fmt.Errorf("decoded index row doesn't end wit
h a Key: %#v", keyProp)) | 244 impossible(fmt.Errorf("decoded index row doesn't end wit
h a Key: %#v", keyProp)) |
245 } | 245 } |
246 | 246 |
247 return strategy.handle( | 247 return strategy.handle( |
248 rawData, decodedProps, keyProp.Value().(*ds.Key), | 248 rawData, decodedProps, keyProp.Value().(*ds.Key), |
249 getCursorFn(suffix)) | 249 getCursorFn(suffix)) |
250 }) | 250 }) |
251 | 251 |
252 return nil | 252 return nil |
253 } | 253 } |
OLD | NEW |