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

Side by Side Diff: filter/txnBuf/query_merger.go

Issue 2342063003: Differentiate between single- and multi- props. (Closed)
Patch Set: Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package txnBuf 5 package txnBuf
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "sort" 9 "sort"
10 10
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 // The result of this function is the series of serialized properties, one per 255 // The result of this function is the series of serialized properties, one per
256 // order column, which represent this key/pm's first entry in the composite 256 // order column, which represent this key/pm's first entry in the composite
257 // index that would point to it (e.g. the one with `order` sort orders). 257 // index that would point to it (e.g. the one with `order` sort orders).
258 func toComparableString(start, end []byte, order []ds.IndexColumn, k *ds.Key, pm ds.PropertyMap) (row, key []byte) { 258 func toComparableString(start, end []byte, order []ds.IndexColumn, k *ds.Key, pm ds.PropertyMap) (row, key []byte) {
259 doCmp := true 259 doCmp := true
260 soFar := []byte{} 260 soFar := []byte{}
261 ps := serialize.PropertyMapPartially(k, nil) 261 ps := serialize.PropertyMapPartially(k, nil)
262 for _, ord := range order { 262 for _, ord := range order {
263 row, ok := ps[ord.Property] 263 row, ok := ps[ord.Property]
264 if !ok { 264 if !ok {
265 » » » if vals, ok := pm[ord.Property]; ok { 265 » » » row = serialize.PropertySlice(pm.Slice(ord.Property))
266 » » » » row = serialize.PropertySlice(vals)
267 » » » }
268 } 266 }
269 sort.Sort(row) 267 sort.Sort(row)
270 foundOne := false 268 foundOne := false
271 for _, serialized := range row { 269 for _, serialized := range row {
272 if ord.Descending { 270 if ord.Descending {
273 serialized = serialize.Invert(serialized) 271 serialized = serialize.Invert(serialized)
274 } 272 }
275 if doCmp { 273 if doCmp {
276 maybe := serialize.Join(soFar, serialized) 274 maybe := serialize.Join(soFar, serialized)
277 cmp := bytes.Compare(maybe, start) 275 cmp := bytes.Compare(maybe, start)
(...skipping 11 matching lines...) Expand all
289 } 287 }
290 if !foundOne { 288 if !foundOne {
291 return nil, nil 289 return nil, nil
292 } 290 }
293 } 291 }
294 if end != nil && bytes.Compare(soFar, end) >= 0 { 292 if end != nil && bytes.Compare(soFar, end) >= 0 {
295 return nil, nil 293 return nil, nil
296 } 294 }
297 return soFar, ps["__key__"][0] 295 return soFar, ps["__key__"][0]
298 } 296 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698