OLD | NEW |
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 Loading... |
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 » » » if pslice := pm.Slice(ord.Property); len(pslice) > 0 { |
266 » » » » row = serialize.PropertySlice(vals) | 266 » » » » row = serialize.PropertySlice(pslice) |
267 } | 267 } |
268 } | 268 } |
269 sort.Sort(row) | 269 sort.Sort(row) |
270 foundOne := false | 270 foundOne := false |
271 for _, serialized := range row { | 271 for _, serialized := range row { |
272 if ord.Descending { | 272 if ord.Descending { |
273 serialized = serialize.Invert(serialized) | 273 serialized = serialize.Invert(serialized) |
274 } | 274 } |
275 if doCmp { | 275 if doCmp { |
276 maybe := serialize.Join(soFar, serialized) | 276 maybe := serialize.Join(soFar, serialized) |
(...skipping 12 matching lines...) Expand all Loading... |
289 } | 289 } |
290 if !foundOne { | 290 if !foundOne { |
291 return nil, nil | 291 return nil, nil |
292 } | 292 } |
293 } | 293 } |
294 if end != nil && bytes.Compare(soFar, end) >= 0 { | 294 if end != nil && bytes.Compare(soFar, end) >= 0 { |
295 return nil, nil | 295 return nil, nil |
296 } | 296 } |
297 return soFar, ps["__key__"][0] | 297 return soFar, ps["__key__"][0] |
298 } | 298 } |
OLD | NEW |