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