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

Side by Side Diff: logdog/common/archive/index.go

Issue 2422393002: Fix sparse index handling, add index params. (Closed)
Patch Set: Created 4 years, 2 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 archive 5 package archive
6 6
7 import ( 7 import (
8 "io" 8 "io"
9 9
10 "github.com/golang/protobuf/proto" 10 "github.com/golang/protobuf/proto"
(...skipping 11 matching lines...) Expand all
22 22
23 sizeFunc func(proto.Message) int 23 sizeFunc func(proto.Message) int
24 } 24 }
25 25
26 func (i *indexBuilder) addLogEntry(le *logpb.LogEntry, offset int64) { 26 func (i *indexBuilder) addLogEntry(le *logpb.LogEntry, offset int64) {
27 // Only calculate the size if we actually use it. 27 // Only calculate the size if we actually use it.
28 if i.ByteRange > 0 { 28 if i.ByteRange > 0 {
29 i.lastBytes += uint64(i.size(le)) 29 i.lastBytes += uint64(i.size(le))
30 } 30 }
31 31
32 // Update our stream properties.
dnj 2016/10/17 22:12:12 (Generate the new protobuf parameters)
33 i.index.LastPrefixIndex = le.PrefixIndex
34 i.index.LastStreamIndex = le.StreamIndex
35 i.index.LogEntryCount++
36
32 // Do we index this LogEntry? 37 // Do we index this LogEntry?
33 if len(i.index.Entries) > 0 { 38 if len(i.index.Entries) > 0 {
34 if !((i.StreamIndexRange > 0 && (le.StreamIndex-i.lastStreamInde x) >= uint64(i.StreamIndexRange)) || 39 if !((i.StreamIndexRange > 0 && (le.StreamIndex-i.lastStreamInde x) >= uint64(i.StreamIndexRange)) ||
35 (i.PrefixIndexRange > 0 && (le.PrefixIndex-i.lastPrefixI ndex) >= uint64(i.PrefixIndexRange)) || 40 (i.PrefixIndexRange > 0 && (le.PrefixIndex-i.lastPrefixI ndex) >= uint64(i.PrefixIndexRange)) ||
36 (i.ByteRange > 0 && i.lastBytes >= uint64(i.ByteRange))) { 41 (i.ByteRange > 0 && i.lastBytes >= uint64(i.ByteRange))) {
37 // Not going to index this entry. 42 // Not going to index this entry.
38 return 43 return
39 } 44 }
40 45
41 i.lastBytes = 0 46 i.lastBytes = 0
(...skipping 23 matching lines...) Expand all
65 } 70 }
66 return nil 71 return nil
67 } 72 }
68 73
69 func (i *indexBuilder) size(pb proto.Message) int { 74 func (i *indexBuilder) size(pb proto.Message) int {
70 if f := i.sizeFunc; f != nil { 75 if f := i.sizeFunc; f != nil {
71 return f(pb) 76 return f(pb)
72 } 77 }
73 return proto.Size(pb) 78 return proto.Size(pb)
74 } 79 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698