Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Commit

Permalink
chore: PipelineID -> GroupID
Browse files Browse the repository at this point in the history
Signed-off-by: Valery Piashchynski <piashchynski.valery@gmail.com>
  • Loading branch information
rustatian committed Jun 20, 2023
1 parent a4247fd commit 06f89ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions priority_queue/binary_heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
type Item interface {
// Priority returns the Item's priority to sort
Priority() int64
// PipelineID represents the pipeline ID (name)
PipelineID() string
// GroupID represents the Item's group, used to delete all Items with the same GroupID
GroupID() string
}

type BinHeap[T Item] struct {
Expand Down Expand Up @@ -80,14 +80,14 @@ func (bh *BinHeap[T]) fixDown(curr, end int) {
}

// Remove removes all elements with the provided ID and returns the slice with them
func (bh *BinHeap[T]) Remove(pipeID string) []T {
func (bh *BinHeap[T]) Remove(groupID string) []T {
bh.cond.L.Lock()
defer bh.cond.L.Unlock()

out := make([]T, 0, 10)

for i := 0; i < len(bh.items); i++ {
if bh.items[i].PipelineID() == pipeID {
if bh.items[i].GroupID() == groupID {
out = append(out, bh.items[i])
bh.st.add(i)
}
Expand Down
4 changes: 2 additions & 2 deletions priority_queue/binary_heap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (t Test) Context() ([]byte, error) {
return nil, nil
}

func (t Test) PipelineID() string {
func (t Test) GroupID() string {
return t.id
}

Expand Down Expand Up @@ -334,7 +334,7 @@ func TestBinHeap_Remove(t *testing.T) {
}

for i := 0; i < len(out); i++ {
if out[i].PipelineID() != "1" {
if out[i].GroupID() != "1" {
t.Fatal("id is not 1")
}
}
Expand Down

0 comments on commit 06f89ad

Please sign in to comment.