66package tests
77
88import (
9+ "cmp"
910 "context"
1011 "fmt"
1112 "math/rand"
1213 "sort"
1314 "strings"
1415 "testing"
1516
16- "github.com/RaduBerinde/btree" // TODO(#144504): switch to the newer btree
1717 "github.com/cockroachdb/cockroach/pkg/base"
1818 "github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
1919 "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
2020 "github.com/cockroachdb/cockroach/pkg/util/leaktest"
2121 "github.com/cockroachdb/cockroach/pkg/util/log"
22+ "github.com/google/btree"
2223 "github.com/stretchr/testify/require"
2324)
2425
@@ -46,17 +47,17 @@ func TestLargeEnums(t *testing.T) {
4647 // have to wait for lots of versions and it would take a very long time.
4748 var createEnumsQuery string
4849 {
49- alreadyInserted := btree .New ( 8 )
50+ alreadyInserted := btree .NewG [ int ]( 8 , cmp . Less [ int ] )
5051 next := func (n int ) (next int , ok bool ) {
51- alreadyInserted .AscendGreaterOrEqual (intItem ( n ) , func (i btree. Item ) (wantMore bool ) {
52- next , ok = int ( i .( intItem )) , true
52+ alreadyInserted .AscendGreaterOrEqual (n , func (i int ) (wantMore bool ) {
53+ next , ok = i , true
5354 return false
5455 })
5556 return next , ok
5657 }
5758 prev := func (n int ) (prev int , ok bool ) {
58- alreadyInserted .DescendLessOrEqual (intItem ( n ) , func (i btree. Item ) (wantMore bool ) {
59- prev , ok = int ( i .( intItem )) , true
59+ alreadyInserted .DescendLessOrEqual (n , func (i int ) (wantMore bool ) {
60+ prev , ok = i , true
6061 return false
6162 })
6263 return prev , ok
@@ -74,7 +75,7 @@ func TestLargeEnums(t *testing.T) {
7475 require .Truef (t , ok , "prev %v %v" , n , order [:i ])
7576 fmt .Fprintf (& buf , " AFTER '%d';\n " , prev )
7677 }
77- alreadyInserted .ReplaceOrInsert (intItem ( n ) )
78+ alreadyInserted .ReplaceOrInsert (n )
7879 }
7980 buf .WriteString ("COMMIT;" )
8081 createEnumsQuery = buf .String ()
@@ -101,12 +102,6 @@ func TestLargeEnums(t *testing.T) {
101102 require .Truef (t , sort .IntsAreSorted (read ), "%v" , read )
102103}
103104
104- type intItem int
105-
106- func (i intItem ) Less (o btree.Item ) bool {
107- return i < o .(intItem )
108- }
109-
110105// TestEnumPlaceholderWithAsOfSystemTime is a regression test for an edge case
111106// with bind where we would not properly deal with leases involving types.
112107func TestEnumPlaceholderWithAsOfSystemTime (t * testing.T ) {
0 commit comments