mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-17 23:56:33 -05:00
go/store/types: Thread context in Compare.
This commit is contained in:
@@ -434,6 +434,8 @@ func TestReadReplica(t *testing.T) {
|
||||
}
|
||||
defer os.Chdir(cwd)
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
multiSetup := testcommands.NewMultiRepoTestSetup(t.Fatal)
|
||||
defer multiSetup.Close()
|
||||
defer os.RemoveAll(multiSetup.Root)
|
||||
@@ -471,7 +473,7 @@ func TestReadReplica(t *testing.T) {
|
||||
defer sc.StopServer()
|
||||
|
||||
replicatedTable := "new_table"
|
||||
multiSetup.CreateTable(sourceDbName, replicatedTable)
|
||||
multiSetup.CreateTable(ctx, sourceDbName, replicatedTable)
|
||||
multiSetup.StageAll(sourceDbName)
|
||||
_ = multiSetup.CommitWithWorkingSet(sourceDbName)
|
||||
multiSetup.PushToRemote(sourceDbName, "remote1", "main")
|
||||
|
||||
@@ -298,10 +298,10 @@ func createTestDataTable(ctx context.Context, ddb *doltdb.DoltDB) (*table.InMemT
|
||||
return imt, sch
|
||||
}
|
||||
|
||||
func (mr *MultiRepoTestSetup) CreateTable(dbName, tblName string) {
|
||||
func (mr *MultiRepoTestSetup) CreateTable(ctx context.Context, dbName, tblName string) {
|
||||
dEnv := mr.envs[dbName]
|
||||
|
||||
imt, sch := createTestDataTable(context.TODO(), dEnv.DoltDB)
|
||||
imt, sch := createTestDataTable(ctx, dEnv.DoltDB)
|
||||
rows := make([]row.Row, imt.NumRows())
|
||||
for i := 0; i < imt.NumRows(); i++ {
|
||||
r, err := imt.GetRow(i)
|
||||
|
||||
@@ -38,7 +38,7 @@ func NewStash(ctx context.Context, nbf *types.NomsBinFormat, vrw types.ValueRead
|
||||
return hash.Hash{}, types.Ref{}, err
|
||||
}
|
||||
|
||||
isCommit, err := IsCommit(headCommit)
|
||||
isCommit, err := IsCommit(ctx, headCommit)
|
||||
if err != nil {
|
||||
return hash.Hash{}, types.Ref{}, err
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ func NewEmptyBlob(vrw ValueReadWriter) (Blob, error) {
|
||||
|
||||
// Less implements the LesserValuable interface.
|
||||
func (b Blob) Less(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (bool, error) {
|
||||
res, err := b.Compare(nbf, other)
|
||||
res, err := b.Compare(ctx, nbf, other)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
@@ -64,10 +64,9 @@ func (b Blob) Less(ctx context.Context, nbf *NomsBinFormat, other LesserValuable
|
||||
return res < 0, nil
|
||||
}
|
||||
|
||||
func (b Blob) Compare(nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
func (b Blob) Compare(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
if b2, ok := other.(Blob); ok {
|
||||
// Blobs can have an arbitrary length, so we compare in chunks rather than loading it entirely
|
||||
ctx := context.Background()
|
||||
b1Length := b.Len()
|
||||
b2Length := b2.Len()
|
||||
b1Reader := b.Reader(ctx)
|
||||
|
||||
@@ -159,7 +159,7 @@ func (fep *EPMerger) ReachedEOF() bool {
|
||||
}
|
||||
|
||||
type comparableValue interface {
|
||||
Compare(ctx context.Context, vr types.ValueReader, other types.LesserValuable) (int, error)
|
||||
Compare(ctx context.Context, nbf *types.NomsBinFormat, other types.LesserValuable) (int, error)
|
||||
}
|
||||
|
||||
// search does a binary search or a sorted []entry and returns an integer representing the insertion index where the
|
||||
@@ -174,7 +174,7 @@ func search(ctx context.Context, vr types.ValueReader, readerIdx int, key types.
|
||||
}
|
||||
|
||||
var res int
|
||||
res, err = comparable.Compare(ctx, vr, vals[i].key)
|
||||
res, err = comparable.Compare(ctx, vr.Format(), vals[i].key)
|
||||
if err != nil {
|
||||
return false
|
||||
} else if res < 0 {
|
||||
|
||||
@@ -562,7 +562,7 @@ func (mes mapEntrySequence) Less(ctx context.Context, nbf *NomsBinFormat, other
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
func (mes mapEntrySequence) Compare(nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
func (mes mapEntrySequence) Compare(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
panic("not implemented")
|
||||
}
|
||||
|
||||
|
||||
@@ -653,7 +653,7 @@ func (es emptySequence) Less(ctx context.Context, nbf *NomsBinFormat, other Less
|
||||
panic("empty sequence")
|
||||
}
|
||||
|
||||
func (es emptySequence) Compare(nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
func (es emptySequence) Compare(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
panic("empty sequence")
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ type sequence interface {
|
||||
Kind() NomsKind
|
||||
Len() uint64
|
||||
Less(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (bool, error)
|
||||
Compare(nbf *NomsBinFormat, other LesserValuable) (int, error)
|
||||
Compare(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (int, error)
|
||||
numLeaves() uint64
|
||||
seqLen() int
|
||||
treeLevel() uint64
|
||||
|
||||
@@ -112,7 +112,7 @@ func (ts testSequence) Less(ctx context.Context, nbf *NomsBinFormat, other Lesse
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
func (ts testSequence) Compare(nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
func (ts testSequence) Compare(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
panic("not reached")
|
||||
}
|
||||
|
||||
|
||||
@@ -824,7 +824,7 @@ func (t Tuple) TupleCompare(ctx context.Context, nbf *NomsBinFormat, otherTuple
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
res, err = blob.Compare(nbf, otherBlob)
|
||||
res, err = blob.Compare(ctx, nbf, otherBlob)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ func (v valueImpl) Less(ctx context.Context, nbf *NomsBinFormat, other LesserVal
|
||||
return isLess, nil
|
||||
}
|
||||
|
||||
func (v valueImpl) Compare(nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
func (v valueImpl) Compare(ctx context.Context, nbf *NomsBinFormat, other LesserValuable) (int, error) {
|
||||
return valueCompare(nbf, v, other.(Value))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user