-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add search block headers Signed-off-by: Martin Disibio <[email protected]> * nolint Signed-off-by: Martin Disibio <[email protected]> * Fix buffer usage in SearchBlockIterator to prevent data corruption Signed-off-by: Martin Disibio <[email protected]> * Reorganize search iterator and combiner Signed-off-by: Martin Disibio <[email protected]> * changelog Signed-off-by: Martin Disibio <[email protected]> * no nolint Signed-off-by: Martin Disibio <[email protected]> * Add skipped blocks metric to response Signed-off-by: Martin Disibio <[email protected]>
- Loading branch information
Showing
16 changed files
with
529 additions
and
186 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package tempofb | ||
|
||
import flatbuffers "github.com/google/flatbuffers/go" | ||
|
||
type SearchBlockHeaderBuilder struct { | ||
Tags SearchDataMap | ||
MinDur uint64 | ||
MaxDur uint64 | ||
} | ||
|
||
func NewSearchBlockHeaderBuilder() *SearchBlockHeaderBuilder { | ||
return &SearchBlockHeaderBuilder{ | ||
Tags: SearchDataMap{}, | ||
} | ||
} | ||
|
||
func (s *SearchBlockHeaderBuilder) AddEntry(e *SearchEntry) { | ||
|
||
kv := &KeyValues{} //buffer | ||
|
||
// Record all unique keyvalues | ||
for i, ii := 0, e.TagsLength(); i < ii; i++ { | ||
e.Tags(kv, i) | ||
for j, jj := 0, kv.ValueLength(); j < jj; j++ { | ||
s.AddTag(string(kv.Key()), string(kv.Value(j))) | ||
} | ||
} | ||
|
||
// Record min/max durations | ||
dur := e.EndTimeUnixNano() - e.StartTimeUnixNano() | ||
if s.MinDur == 0 || dur < s.MinDur { | ||
s.MinDur = dur | ||
} | ||
if dur > s.MaxDur { | ||
s.MaxDur = dur | ||
} | ||
} | ||
|
||
// AddTag adds the unique tag name and value to the search data. No effect if the pair is already present. | ||
func (s *SearchBlockHeaderBuilder) AddTag(k string, v string) { | ||
s.Tags.Add(k, v) | ||
} | ||
|
||
func (s *SearchBlockHeaderBuilder) ToBytes() []byte { | ||
b := flatbuffers.NewBuilder(1024) | ||
|
||
tags := s.Tags.WriteToBuilder(b) | ||
|
||
SearchBlockHeaderStart(b) | ||
SearchBlockHeaderAddMinDurationNanos(b, s.MinDur) | ||
SearchBlockHeaderAddMaxDurationNanos(b, s.MaxDur) | ||
SearchBlockHeaderAddTags(b, tags) | ||
offset := SearchBlockHeaderEnd(b) | ||
b.Finish(offset) | ||
return b.FinishedBytes() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.