diff --git a/pkg/registry/core/service/allocator/bitmap.go b/pkg/registry/core/service/allocator/bitmap.go index 84c09eadfcb..c5dad0467f0 100644 --- a/pkg/registry/core/service/allocator/bitmap.go +++ b/pkg/registry/core/service/allocator/bitmap.go @@ -72,18 +72,6 @@ func NewAllocationMap(max int, rangeSpec string) *AllocationBitmap { return &a } -// NewContiguousAllocationMap creates an allocation bitmap using the contiguous scan strategy. -func NewContiguousAllocationMap(max int, rangeSpec string) *AllocationBitmap { - a := AllocationBitmap{ - strategy: contiguousScanStrategy{}, - allocated: big.NewInt(0), - count: 0, - max: max, - rangeSpec: rangeSpec, - } - return &a -} - // Allocate attempts to reserve the provided item. // Returns true if it was allocated, false if it was already in use func (r *AllocationBitmap) Allocate(offset int) (bool, error) { @@ -217,20 +205,3 @@ func (rss randomScanStrategy) AllocateBit(allocated *big.Int, max, count int) (i } var _ bitAllocator = randomScanStrategy{} - -// contiguousScanStrategy tries to allocate starting at 0 and filling in any gaps -type contiguousScanStrategy struct{} - -func (contiguousScanStrategy) AllocateBit(allocated *big.Int, max, count int) (int, bool) { - if count >= max { - return 0, false - } - for i := 0; i < max; i++ { - if allocated.Bit(i) == 0 { - return i, true - } - } - return 0, false -} - -var _ bitAllocator = contiguousScanStrategy{} diff --git a/pkg/registry/core/service/allocator/bitmap_test.go b/pkg/registry/core/service/allocator/bitmap_test.go index 8aa434950f8..b5eacc114e5 100644 --- a/pkg/registry/core/service/allocator/bitmap_test.go +++ b/pkg/registry/core/service/allocator/bitmap_test.go @@ -136,22 +136,3 @@ func TestSnapshotAndRestore(t *testing.T) { t.Errorf("expect offset %v allocated", offset) } } - -func TestContiguousAllocation(t *testing.T) { - max := 10 - m := NewContiguousAllocationMap(max, "test") - - for i := 0; i < max; i++ { - next, ok, _ := m.AllocateNext() - if !ok { - t.Fatalf("unexpected error") - } - if next != i { - t.Fatalf("expect next to %d, but got %d", i, next) - } - } - - if _, ok, _ := m.AllocateNext(); ok { - t.Errorf("unexpected success") - } -}