mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-23 21:59:01 -05:00
PR feedback, added an assertion method
This commit is contained in:
@@ -102,11 +102,7 @@ func StatForTableDelta(ctx context.Context, ch chan DiffStatProgress, td TableDe
|
||||
return err
|
||||
}
|
||||
|
||||
if types.IsFormat_DOLT(td.Format()) {
|
||||
return diffProllyTrees(ctx, ch, keyless, fromRows, toRows, fromSch, toSch)
|
||||
}
|
||||
|
||||
panic("Unsupported format: " + td.Format().VersionString())
|
||||
return diffProllyTrees(ctx, ch, keyless, fromRows, toRows, fromSch, toSch)
|
||||
}
|
||||
|
||||
func diffProllyTrees(ctx context.Context, ch chan DiffStatProgress, keyless bool, from, to durable.Index, fromSch, toSch schema.Schema) error {
|
||||
|
||||
@@ -658,11 +658,6 @@ func (td TableDelta) GetSchemas(ctx context.Context) (from, to schema.Schema, er
|
||||
return td.FromSch, td.ToSch, nil
|
||||
}
|
||||
|
||||
// Format returns the format of the tables in this delta.
|
||||
func (td TableDelta) Format() *types.NomsBinFormat {
|
||||
return types.Format_DOLT
|
||||
}
|
||||
|
||||
func (td TableDelta) IsKeyless(ctx context.Context) (bool, error) {
|
||||
f, t, err := td.GetSchemas(ctx)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,7 +30,6 @@ import (
|
||||
type ArtifactIndex interface {
|
||||
HashOf() (hash.Hash, error)
|
||||
Count() (uint64, error)
|
||||
Format() *types.NomsBinFormat
|
||||
HasConflicts(ctx context.Context) (bool, error)
|
||||
// ConflictCount returns the number of conflicts
|
||||
ConflictCount(ctx context.Context) (uint64, error)
|
||||
@@ -43,17 +42,8 @@ type ArtifactIndex interface {
|
||||
|
||||
// RefFromArtifactIndex persists |idx| and returns the types.Ref targeting it.
|
||||
func RefFromArtifactIndex(ctx context.Context, vrw types.ValueReadWriter, idx ArtifactIndex) (types.Ref, error) {
|
||||
switch idx.Format() {
|
||||
case types.Format_LD_1:
|
||||
panic("Unsupported format " + idx.Format().VersionString())
|
||||
|
||||
case types.Format_DOLT:
|
||||
b := shim.ValueFromMap(idx.(prollyArtifactIndex).index)
|
||||
return vrw.WriteValue(ctx, b)
|
||||
|
||||
default:
|
||||
return types.Ref{}, errNbfUnknown
|
||||
}
|
||||
b := shim.ValueFromMap(idx.(prollyArtifactIndex).index)
|
||||
return vrw.WriteValue(ctx, b)
|
||||
}
|
||||
|
||||
// NewEmptyArtifactIndex returns an ArtifactIndex with no artifacts.
|
||||
@@ -85,10 +75,6 @@ func ProllyMapFromArtifactIndex(i ArtifactIndex) prolly.ArtifactMap {
|
||||
return i.(prollyArtifactIndex).index
|
||||
}
|
||||
|
||||
func artifactIndexFromRef(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeStore, tableSch schema.Schema, r types.Ref) (ArtifactIndex, error) {
|
||||
return artifactIndexFromAddr(ctx, vrw, ns, tableSch, r.TargetHash())
|
||||
}
|
||||
|
||||
func artifactIndexFromAddr(ctx context.Context, vrw types.ValueReadWriter, ns tree.NodeStore, tableSch schema.Schema, addr hash.Hash) (ArtifactIndex, error) {
|
||||
v, err := vrw.MustReadValue(ctx, addr)
|
||||
if err != nil {
|
||||
@@ -129,10 +115,6 @@ func (i prollyArtifactIndex) Count() (uint64, error) {
|
||||
return uint64(c), err
|
||||
}
|
||||
|
||||
func (i prollyArtifactIndex) Format() *types.NomsBinFormat {
|
||||
return i.index.Format()
|
||||
}
|
||||
|
||||
func (i prollyArtifactIndex) HasConflicts(ctx context.Context) (bool, error) {
|
||||
return i.index.HasArtifactOfType(ctx, prolly.ArtifactTypeConflict)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package types
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/dolthub/dolt/go/store/constants"
|
||||
@@ -58,6 +59,13 @@ func IsFormat_DOLT(nbf *NomsBinFormat) bool {
|
||||
return nbf.tag == formatTag_DOLT
|
||||
}
|
||||
|
||||
// AssertFormat_DOLT panics if the provided NomsBinFormat is not compatible with the DOLT format.
|
||||
func AssertFormat_DOLT(nbf *NomsBinFormat) {
|
||||
if !IsFormat_DOLT(nbf) {
|
||||
panic(fmt.Sprintf("Unsupported binary format %s, please migrate database to newer format", nbf.VersionString()))
|
||||
}
|
||||
}
|
||||
|
||||
func IsFormat_LD(nbf *NomsBinFormat) bool {
|
||||
return nbf.tag == formatTag_LD_1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user