| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 raw[i] = suffix[:offset] | 156 raw[i] = suffix[:offset] |
| 157 suffix = suffix[offset:] | 157 suffix = suffix[offset:] |
| 158 if needInvert { | 158 if needInvert { |
| 159 raw[i] = invert(raw[i]) | 159 raw[i] = invert(raw[i]) |
| 160 } | 160 } |
| 161 } | 161 } |
| 162 | 162 |
| 163 return | 163 return |
| 164 } | 164 } |
| 165 | 165 |
| 166 func countQuery(fq *ds.FinalizedQuery, ns string, isTxn bool, idx, head *memStor
e) (ret int64, err error) { |
| 167 if len(fq.Project()) == 0 && !fq.KeysOnly() { |
| 168 fq, err = fq.Original().KeysOnly(true).Finalize() |
| 169 if err != nil { |
| 170 return |
| 171 } |
| 172 } |
| 173 err = executeQuery(fq, ns, isTxn, idx, head, func(_ *ds.Key, _ ds.Proper
tyMap, _ ds.CursorCB) bool { |
| 174 ret++ |
| 175 return true |
| 176 }) |
| 177 return |
| 178 } |
| 179 |
| 166 func executeQuery(fq *ds.FinalizedQuery, ns string, isTxn bool, idx, head *memSt
ore, cb ds.RawRunCB) error { | 180 func executeQuery(fq *ds.FinalizedQuery, ns string, isTxn bool, idx, head *memSt
ore, cb ds.RawRunCB) error { |
| 167 rq, err := reduce(fq, ns, isTxn) | 181 rq, err := reduce(fq, ns, isTxn) |
| 168 if err == ds.ErrNullQuery { | 182 if err == ds.ErrNullQuery { |
| 169 return nil | 183 return nil |
| 170 } | 184 } |
| 171 if err != nil { | 185 if err != nil { |
| 172 return err | 186 return err |
| 173 } | 187 } |
| 174 | 188 |
| 175 idxs, err := getIndexes(rq, idx) | 189 idxs, err := getIndexes(rq, idx) |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 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)) |
| 230 } | 244 } |
| 231 | 245 |
| 232 return strategy.handle( | 246 return strategy.handle( |
| 233 rawData, decodedProps, keyProp.Value().(*ds.Key), | 247 rawData, decodedProps, keyProp.Value().(*ds.Key), |
| 234 getCursorFn(suffix)) | 248 getCursorFn(suffix)) |
| 235 }) | 249 }) |
| 236 | 250 |
| 237 return nil | 251 return nil |
| 238 } | 252 } |
| OLD | NEW |