This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support for tree truncation when converting to flamebearer (#634)
* wip * fix * switched to a much more performant version of truncation * improvements
- Loading branch information
1 parent
f09f749
commit f90edba
Showing
8 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package querier | ||
|
||
// minHeap is a custom min-heap data structure that stores integers. | ||
type minHeap []int64 | ||
|
||
// Len returns the number of elements in the min-heap. | ||
func (h minHeap) Len() int { return len(h) } | ||
|
||
// Less returns true if the element at index i is less than the element at index j. | ||
// This method is used by the container/heap package to maintain the min-heap property. | ||
func (h minHeap) Less(i, j int) bool { return h[i] < h[j] } | ||
|
||
// Swap exchanges the elements at index i and index j. | ||
// This method is used by the container/heap package to reorganize the min-heap during its operations. | ||
func (h minHeap) Swap(i, j int) { h[i], h[j] = h[j], h[i] } | ||
|
||
// Push adds an element (x) to the min-heap. | ||
// This method is used by the container/heap package to grow the min-heap. | ||
func (h *minHeap) Push(x interface{}) { | ||
*h = append(*h, x.(int64)) | ||
} | ||
|
||
// Pop removes and returns the smallest element (minimum) from the min-heap. | ||
// This method is used by the container/heap package to shrink the min-heap. | ||
func (h *minHeap) Pop() interface{} { | ||
old := *h | ||
n := len(old) | ||
x := old[n-1] | ||
*h = old[0 : n-1] | ||
return x | ||
} |
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