Skip to content

Commit

Permalink
avoid NewEmptyIndex when table does not exist (#7879)
Browse files Browse the repository at this point in the history
  • Loading branch information
jycor authored May 20, 2024
1 parent 26e1d5b commit 68db779
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
31 changes: 23 additions & 8 deletions go/libraries/doltcore/diff/diff_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,39 @@ func diffProllyTrees(ctx context.Context, ch chan DiffStatProgress, keyless bool
return err
}

f := durable.ProllyMapFromIndex(from)
t := durable.ProllyMapFromIndex(to)
var f, t prolly.Map
if from != nil {
f = durable.ProllyMapFromIndex(from)
}
if to != nil {
t = durable.ProllyMapFromIndex(to)

}

_, fVD := f.Descriptors()
_, tVD := t.Descriptors()

var rpr prollyReporter
if keyless {
rpr = reportKeylessChanges
} else {
fc, err := from.Count()
if err != nil {
return err
var fc uint64
if from != nil {
fc, err = from.Count()
if err != nil {
return err
}
}

cfc := uint64(len(fromSch.GetAllCols().GetColumns())) * fc
tc, err := to.Count()
if err != nil {
return err
var tc uint64
if to != nil {
tc, err = to.Count()
if err != nil {
return err
}
}

ctc := uint64(len(toSch.GetAllCols().GetColumns())) * tc
rpr = reportPkChanges
ch <- DiffStatProgress{
Expand Down
10 changes: 2 additions & 8 deletions go/libraries/doltcore/diff/table_deltas.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,21 +600,15 @@ func (td TableDelta) GetRowData(ctx context.Context) (from, to durable.Index, er
if td.FromTable != nil {
from, err = td.FromTable.GetRowData(ctx)
if err != nil {
return from, to, err
return nil, nil, err
}
} else {
// If there is no |FromTable| use the |ToTable|'s schema to make the index.
from, _ = durable.NewEmptyIndex(ctx, td.FromVRW, td.FromNodeStore, td.ToSch)
}

if td.ToTable != nil {
to, err = td.ToTable.GetRowData(ctx)
if err != nil {
return from, to, err
return nil, nil, err
}
} else {
// If there is no |ToTable| use the |FromTable|'s schema to make the index.
to, _ = durable.NewEmptyIndex(ctx, td.ToVRW, td.ToNodeStore, td.FromSch)
}

return from, to, nil
Expand Down

0 comments on commit 68db779

Please sign in to comment.