dolt/go/libraries/doltcore/row: Remove Format_7_18 references.

This commit is contained in:
Aaron Son
2019-07-03 12:16:22 -07:00
committed by Brian Hendriks
parent 083186e601
commit d0a6487b19
40 changed files with 115 additions and 104 deletions

View File

@@ -18,7 +18,7 @@ type DimRow struct {
}
func NewDimRow(r row.Row, toUntyped, toTyped *rowconv.RowConverter) (*DimRow, error) {
key := r.NomsMapKey(toUntyped.SrcSch).Value(context.Background())
key := r.NomsMapKey(types.Format_7_18, toUntyped.SrcSch).Value(context.Background())
untyped, err := toUntyped.Convert(r)
if err != nil {
@@ -37,7 +37,7 @@ func (dr *DimRow) StoreValue(me *types.MapEditor) *types.MapEditor {
}
typedSch := dr.toTyped.DestSch
key := typed.NomsMapKey(typedSch).Value(context.Background())
key := typed.NomsMapKey(types.Format_7_18, typedSch).Value(context.Background())
if !dr.key.Equals(types.Format_7_18, key) {
me = me.Remove(dr.key)
@@ -47,7 +47,7 @@ func (dr *DimRow) StoreValue(me *types.MapEditor) *types.MapEditor {
dr.dbVals = dr.currentVals
log.Println("stored vals")
return me.Set(key, typed.NomsMapValue(typedSch))
return me.Set(key, typed.NomsMapValue(types.Format_7_18, typedSch))
}
func (dr *DimRow) UpdateVal(tag uint64, str string) error {

View File

@@ -3,13 +3,14 @@ package cli
import (
"context"
"errors"
"os"
"strings"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/row"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/schema"
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/argparser"
"github.com/liquidata-inc/ld/dolt/go/store/types"
"os"
"strings"
)
var ErrEmptyDefTuple = errors.New("empty definition tuple")
@@ -156,7 +157,7 @@ func ParseKeyValues(sch schema.Schema, args []string) ([]types.Value, error) {
taggedVals[k] = val
}
pkVals = append(pkVals, taggedVals.NomsTupleForTags(pkCols.Tags, true).Value(context.TODO()))
pkVals = append(pkVals, taggedVals.NomsTupleForTags(types.Format_7_18, pkCols.Tags, true).Value(context.TODO()))
}
return pkVals, nil

View File

@@ -44,7 +44,7 @@ func TestParseKeyValues(t *testing.T) {
singleKeySch,
[]string{"robertson"},
[]types.Value{
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(singleKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(types.Format_7_18, singleKeyColColl.Tags, true).Value(ctx),
},
false,
},
@@ -53,7 +53,7 @@ func TestParseKeyValues(t *testing.T) {
singleKeySch,
[]string{"last", "robertson"},
[]types.Value{
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(singleKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(types.Format_7_18, singleKeyColColl.Tags, true).Value(ctx),
},
false,
},
@@ -67,7 +67,7 @@ func TestParseKeyValues(t *testing.T) {
singleKeySch,
[]string{"last", "last"},
[]types.Value{
row.TaggedValues{lnColTag: types.String("last")}.NomsTupleForTags(singleKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("last")}.NomsTupleForTags(types.Format_7_18, singleKeyColColl.Tags, true).Value(ctx),
},
false,
},
@@ -75,8 +75,8 @@ func TestParseKeyValues(t *testing.T) {
singleKeySch,
[]string{"last", "robertson", "johnson"},
[]types.Value{
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(singleKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("johnson")}.NomsTupleForTags(singleKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(types.Format_7_18, singleKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("johnson")}.NomsTupleForTags(types.Format_7_18, singleKeyColColl.Tags, true).Value(ctx),
},
false,
},
@@ -91,8 +91,8 @@ func TestParseKeyValues(t *testing.T) {
sch,
[]string{"last", "robertson", "johnson"},
[]types.Value{
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(testKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("johnson")}.NomsTupleForTags(testKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("robertson")}.NomsTupleForTags(types.Format_7_18, testKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("johnson")}.NomsTupleForTags(types.Format_7_18, testKeyColColl.Tags, true).Value(ctx),
},
false,
},
@@ -100,8 +100,8 @@ func TestParseKeyValues(t *testing.T) {
sch,
[]string{"first,last", "robert,robertson", "john,johnson"},
[]types.Value{
row.TaggedValues{lnColTag: types.String("robertson"), fnColTag: types.String("robert")}.NomsTupleForTags(testKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("johnson"), fnColTag: types.String("john")}.NomsTupleForTags(testKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("robertson"), fnColTag: types.String("robert")}.NomsTupleForTags(types.Format_7_18, testKeyColColl.Tags, true).Value(ctx),
row.TaggedValues{lnColTag: types.String("johnson"), fnColTag: types.String("john")}.NomsTupleForTags(types.Format_7_18, testKeyColColl.Tags, true).Value(ctx),
},
false,
},

View File

@@ -23,6 +23,7 @@ import (
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table/untyped/tabular"
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/argparser"
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/iohelp"
"github.com/liquidata-inc/ld/dolt/go/store/types"
"path/filepath"
"strings"
"vitess.io/vitess/go/vt/sqlparser"
@@ -338,7 +339,7 @@ func runPrintingPipeline(p *pipeline.Pipeline, untypedSch schema.Schema) error {
p.SetOutput(cliSink)
p.SetBadRowCallback(func(tff *pipeline.TransformRowFailure) (quit bool) {
cli.PrintErrln(color.RedString("error: failed to transform row %s.", row.Fmt(context.Background(), tff.Row, untypedSch)))
cli.PrintErrln(color.RedString("error: failed to transform row %s.", row.Fmt(context.Background(), types.Format_7_18, tff.Row, untypedSch)))
return true
})

View File

@@ -309,7 +309,7 @@ func TestInsert(t *testing.T) {
for _, expectedid := range test.expectedIds {
table, _ := root.GetTable(context.Background(), tableName)
taggedVals := row.TaggedValues{dtestutils.IdTag: types.UUID(expectedid)}
key := taggedVals.NomsTupleForTags([]uint64{dtestutils.IdTag}, true)
key := taggedVals.NomsTupleForTags(types.Format_7_18, []uint64{dtestutils.IdTag}, true)
_, ok := table.GetRow(context.Background(), key.Value(context.Background()).(types.Tuple), dtestutils.TypedSchema)
assert.True(t, ok, "expected id not found")
}
@@ -381,7 +381,7 @@ func TestUpdate(t *testing.T) {
for i, expectedid := range test.expectedIds {
table, _ := root.GetTable(context.Background(), tableName)
taggedVals := row.TaggedValues{dtestutils.IdTag: types.UUID(expectedid)}
key := taggedVals.NomsTupleForTags([]uint64{dtestutils.IdTag}, true)
key := taggedVals.NomsTupleForTags(types.Format_7_18, []uint64{dtestutils.IdTag}, true)
row, ok := table.GetRow(ctx, key.Value(ctx).(types.Tuple), dtestutils.TypedSchema)
assert.True(t, ok, "expected id not found")
ageVal, _ := row.GetColVal(dtestutils.AgeTag)
@@ -447,7 +447,7 @@ func TestDelete(t *testing.T) {
for _, expectedid := range test.deletedIds {
table, _ := root.GetTable(context.Background(), tableName)
taggedVals := row.TaggedValues{dtestutils.IdTag: types.UUID(expectedid)}
key := taggedVals.NomsTupleForTags([]uint64{dtestutils.IdTag}, true)
key := taggedVals.NomsTupleForTags(types.Format_7_18, []uint64{dtestutils.IdTag}, true)
_, ok := table.GetRow(ctx, key.Value(ctx).(types.Tuple), dtestutils.TypedSchema)
assert.False(t, ok, "row not deleted")
}

View File

@@ -317,7 +317,7 @@ func TestInsert(t *testing.T) {
for _, expectedid := range test.expectedIds {
table, _ := root.GetTable(context.Background(), tableName)
taggedVals := row.TaggedValues{dtestutils.IdTag: types.UUID(expectedid)}
key := taggedVals.NomsTupleForTags([]uint64{dtestutils.IdTag}, true)
key := taggedVals.NomsTupleForTags(types.Format_7_18, []uint64{dtestutils.IdTag}, true)
_, ok := table.GetRow(context.Background(), key.Value(context.Background()).(types.Tuple), dtestutils.TypedSchema)
assert.True(t, ok, "expected id not found")
}
@@ -390,7 +390,7 @@ func TestUpdate(t *testing.T) {
for i, expectedid := range test.expectedIds {
table, _ := root.GetTable(context.Background(), tableName)
taggedVals := row.TaggedValues{dtestutils.IdTag: types.UUID(expectedid)}
key := taggedVals.NomsTupleForTags([]uint64{dtestutils.IdTag}, true)
key := taggedVals.NomsTupleForTags(types.Format_7_18, []uint64{dtestutils.IdTag}, true)
row, ok := table.GetRow(ctx, key.Value(ctx).(types.Tuple), dtestutils.TypedSchema)
assert.True(t, ok, "expected id not found")
ageVal, _ := row.GetColVal(dtestutils.AgeTag)
@@ -457,7 +457,7 @@ func TestDelete(t *testing.T) {
for _, expectedid := range test.deletedIds {
table, _ := root.GetTable(context.Background(), tableName)
taggedVals := row.TaggedValues{dtestutils.IdTag: types.UUID(expectedid)}
key := taggedVals.NomsTupleForTags([]uint64{dtestutils.IdTag}, true)
key := taggedVals.NomsTupleForTags(types.Format_7_18, []uint64{dtestutils.IdTag}, true)
_, ok := table.GetRow(ctx, key.Value(ctx).(types.Tuple), dtestutils.TypedSchema)
assert.False(t, ok, "row not deleted")
}

View File

@@ -238,7 +238,7 @@ func executeMove(dEnv *env.DoltEnv, force bool, mvOpts *mvdata.MoveOptions) int
r := pipeline.GetTransFailureRow(err)
if r != nil {
bdr.AddDetails("Bad Row:" + row.Fmt(context.TODO(), r, mover.Rd.GetSchema()))
bdr.AddDetails("Bad Row:" + row.Fmt(context.TODO(), types.Format_7_18, r, mover.Rd.GetSchema()))
}
details := pipeline.GetTransFailureDetails(err)

View File

@@ -113,7 +113,7 @@ func PutRow(commandStr string, args []string, dEnv *env.DoltEnv) int {
if verr == nil {
me := tbl.GetRowData(context.TODO()).Edit()
updated := me.Set(row.NomsMapKey(sch), row.NomsMapValue(sch)).Map(context.TODO())
updated := me.Set(row.NomsMapKey(types.Format_7_18, sch), row.NomsMapValue(types.Format_7_18, sch)).Map(context.TODO())
tbl = tbl.UpdateRows(context.Background(), updated)
root = root.PutTable(context.Background(), dEnv.DoltDB, prArgs.TableName, tbl)

View File

@@ -3,6 +3,8 @@ package tblcmds
import (
"context"
"errors"
"strings"
"github.com/fatih/color"
"github.com/liquidata-inc/ld/dolt/go/cmd/dolt/cli"
"github.com/liquidata-inc/ld/dolt/go/cmd/dolt/commands"
@@ -23,7 +25,6 @@ import (
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/argparser"
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/iohelp"
"github.com/liquidata-inc/ld/dolt/go/store/types"
"strings"
)
const (
@@ -227,7 +228,7 @@ func createPipeline(tbl *doltdb.Table, tblSch schema.Schema, outSch schema.Schem
wr := tabular.NewTextTableWriter(iohelp.NopWrCloser(cli.CliOut), outSch)
badRowCallback := func(tff *pipeline.TransformRowFailure) (quit bool) {
cli.PrintErrln(color.RedString("error: failed to transform row %s.", row.Fmt(context.TODO(), tff.Row, outSch)))
cli.PrintErrln(color.RedString("error: failed to transform row %s.", row.Fmt(context.TODO(), types.Format_7_18, tff.Row, outSch)))
return true
}
@@ -314,7 +315,7 @@ var noConfLabel = types.String(" ")
func CnfTransformer(inSch, outSch schema.Schema, conflicts types.Map) func(inRow row.Row, props pipeline.ReadableMap) (rowData []*pipeline.TransformedRowResult, badRowDetails string) {
return func(inRow row.Row, props pipeline.ReadableMap) ([]*pipeline.TransformedRowResult, string) {
ctx := context.TODO()
key := inRow.NomsMapKey(inSch)
key := inRow.NomsMapKey(types.Format_7_18, inSch)
var err error
if conflicts.Has(ctx, key.Value(ctx)) {

View File

@@ -37,7 +37,7 @@ func TaggedValueSliceItr(format *types.Format, sch schema.Schema, vals []row.Tag
next++
if current < size {
tpl := vals[current].NomsTupleForTags(pkTags, true)
tpl := vals[current].NomsTupleForTags(format, pkTags, true)
return tpl.Value(context.TODO()).(types.Tuple), true
}

View File

@@ -187,7 +187,7 @@ func (t *Table) HashOf() hash.Hash {
}
func (t *Table) GetRowByPKVals(ctx context.Context, pkVals row.TaggedValues, sch schema.Schema) (row.Row, bool) {
pkTuple := pkVals.NomsTupleForTags(sch.GetPKCols().Tags, true)
pkTuple := pkVals.NomsTupleForTags(t.vrw.Format(), sch.GetPKCols().Tags, true)
return t.GetRow(ctx, pkTuple.Value(ctx).(types.Tuple), sch)
}

View File

@@ -29,7 +29,7 @@ func createTestRowData(vrw types.ValueReadWriter, sch schema.Schema) (types.Map,
ed := types.NewMap(context.Background(), vrw).Edit()
for _, r := range rows {
ed = ed.Set(r.NomsMapKey(sch), r.NomsMapValue(sch))
ed = ed.Set(r.NomsMapKey(types.Format_7_18, sch), r.NomsMapValue(types.Format_7_18, sch))
}
return ed.Map(context.Background()), rows
@@ -71,8 +71,8 @@ func TestTables(t *testing.T) {
if !ok {
t.Error("Could not find row 0 in table")
} else if !row.AreEqual(readRow0, rows[0], tSchema) {
t.Error(row.Fmt(context.Background(), readRow0, tSchema), "!=", row.Fmt(context.Background(), rows[0], tSchema))
} else if !row.AreEqual(types.Format_7_18, readRow0, rows[0], tSchema) {
t.Error(row.Fmt(context.Background(), types.Format_7_18, readRow0, tSchema), "!=", row.Fmt(context.Background(), types.Format_7_18, rows[0], tSchema))
}
_, ok = tbl.GetRowByPKVals(context.Background(), row.TaggedValues{idTag: types.UUID(badUUID)}, tSchema)
@@ -91,8 +91,8 @@ func TestTables(t *testing.T) {
}
for i, r := range rows {
if !row.AreEqual(r, readRows[i], tSchema) {
t.Error(row.Fmt(context.Background(), readRows[i], tSchema), "!=", row.Fmt(context.Background(), r, tSchema))
if !row.AreEqual(types.Format_7_18, r, readRows[i], tSchema) {
t.Error(row.Fmt(context.Background(), types.Format_7_18, readRows[i], tSchema), "!=", row.Fmt(context.Background(), types.Format_7_18, r, tSchema))
}
}
}

View File

@@ -256,7 +256,7 @@ func rowMerge(ctx context.Context, format *types.Format, sch schema.Schema, r, m
return nil, true
}
tpl := resultVals.NomsTupleForTags(sch.GetNonPKCols().SortedTags, false)
tpl := resultVals.NomsTupleForTags(format, sch.GetNonPKCols().SortedTags, false)
return tpl.Value(ctx), false
}

View File

@@ -27,7 +27,7 @@ func ResolveTable(ctx context.Context, vrw types.ValueReadWriter, tbl *doltdb.Ta
tblSchRef := tbl.GetSchemaRef()
tblSchVal := tblSchRef.TargetValue(ctx, vrw)
tblSch, err := encoding.UnmarshalNomsValue(ctx, tblSchVal)
tblSch, err := encoding.UnmarshalNomsValue(ctx, vrw.Format(), tblSchVal)
if err != nil {
return nil, err

View File

@@ -8,13 +8,13 @@ import (
"github.com/liquidata-inc/ld/dolt/go/store/types"
)
type RowFormatFunc func(ctx context.Context, r Row, sch schema.Schema) string
type RowFormatFunc func(ctx context.Context, format *types.Format, r Row, sch schema.Schema) string
var Fmt = FieldSeparatedFmt(':')
var fieldDelim = []byte(" | ")
func FieldSeparatedFmt(delim rune) RowFormatFunc {
return func(ctx context.Context, r Row, sch schema.Schema) string {
return func(ctx context.Context, format *types.Format, r Row, sch schema.Schema) string {
if r == nil {
return "null"
}
@@ -37,7 +37,7 @@ func FieldSeparatedFmt(delim rune) RowFormatFunc {
if ok {
buf.Write([]byte(col.Name))
buf.WriteRune(delim)
types.WriteEncodedValue(ctx, types.Format_7_18, buf, val)
types.WriteEncodedValue(ctx, format, buf, val)
kvps = append(kvps, buf.String())
}

View File

@@ -3,13 +3,14 @@ package row
import (
"context"
"testing"
"github.com/liquidata-inc/ld/dolt/go/store/types"
)
func TestFmt(t *testing.T) {
r := newTestRow()
expected := `first:"rick" | last:"astley" | age:53 | address:"123 Fake St" | title:null_value | `
actual := Fmt(context.Background(), r, sch)
actual := Fmt(context.Background(), types.Format_7_18, r, sch)
if expected != actual {
t.Errorf("expected: '%s', actual: '%s'", expected, actual)
}

View File

@@ -132,10 +132,10 @@ func FromNoms(sch schema.Schema, nomsKey, nomsVal types.Tuple) Row {
return fromTaggedVals(sch, key, val)
}
func (nr nomsRow) NomsMapKey(sch schema.Schema) types.LesserValuable {
return nr.key.NomsTupleForTags(sch.GetPKCols().Tags, true)
func (nr nomsRow) NomsMapKey(format *types.Format, sch schema.Schema) types.LesserValuable {
return nr.key.NomsTupleForTags(format, sch.GetPKCols().Tags, true)
}
func (nr nomsRow) NomsMapValue(sch schema.Schema) types.Valuable {
return nr.value.NomsTupleForTags(sch.GetNonPKCols().SortedTags, false)
func (nr nomsRow) NomsMapValue(format *types.Format, sch schema.Schema) types.Valuable {
return nr.value.NomsTupleForTags(format, sch.GetNonPKCols().SortedTags, false)
}

View File

@@ -255,15 +255,15 @@ func TestConvToAndFromTuple(t *testing.T) {
r := newTestRow()
keyTpl := r.NomsMapKey(sch).(TupleVals)
valTpl := r.NomsMapValue(sch).(TupleVals)
keyTpl := r.NomsMapKey(types.Format_7_18, sch).(TupleVals)
valTpl := r.NomsMapValue(types.Format_7_18, sch).(TupleVals)
r2 := FromNoms(sch, keyTpl.Value(ctx).(types.Tuple), valTpl.Value(ctx).(types.Tuple))
fmt.Println(Fmt(context.Background(), r, sch))
fmt.Println(Fmt(context.Background(), r2, sch))
fmt.Println(Fmt(context.Background(), types.Format_7_18, r, sch))
fmt.Println(Fmt(context.Background(), types.Format_7_18, r2, sch))
if !AreEqual(r, r2, sch) {
if !AreEqual(types.Format_7_18, r, r2, sch) {
t.Error("Failed to convert to a noms tuple, and then convert back to the same row")
}
}

View File

@@ -12,10 +12,10 @@ var ErrRowNotValid = errors.New("invalid row for current schema")
type Row interface {
// Returns the noms map key for this row, using the schema provided.
NomsMapKey(sch schema.Schema) types.LesserValuable
NomsMapKey(format *types.Format, sch schema.Schema) types.LesserValuable
// Returns the noms map value for this row, using the schema provided.
NomsMapValue(sch schema.Schema) types.Valuable
NomsMapValue(format *types.Format, sch schema.Schema) types.Valuable
// Iterates over all the columns in the row. Columns that have no value set will not be visited.
IterCols(cb func(tag uint64, val types.Value) (stop bool)) bool
@@ -107,7 +107,7 @@ func findInvalidCol(r Row, sch schema.Schema) (*schema.Column, schema.ColConstra
return badCol, badCnst
}
func AreEqual(row1, row2 Row, sch schema.Schema) bool {
func AreEqual(format *types.Format, row1, row2 Row, sch schema.Schema) bool {
if row1 == nil && row2 == nil {
return true
} else if row1 == nil || row2 == nil {
@@ -118,7 +118,7 @@ func AreEqual(row1, row2 Row, sch schema.Schema) bool {
val1, _ := row1.GetColVal(tag)
val2, _ := row2.GetColVal(tag)
if !valutil.NilSafeEqCheck(types.Format_7_18, val1, val2) {
if !valutil.NilSafeEqCheck(format, val1, val2) {
return false
}
}

View File

@@ -95,6 +95,6 @@ func TestAreEqual(t *testing.T) {
updatedRow, err := r.SetColVal(lnColTag, types.String("new"), sch)
assert.NoError(t, err)
assert.True(t, AreEqual(r, r, sch))
assert.False(t, AreEqual(r, updatedRow, sch))
assert.True(t, AreEqual(types.Format_7_18, r, r, sch))
assert.False(t, AreEqual(types.Format_7_18, r, updatedRow, sch))
}

View File

@@ -9,33 +9,36 @@ import (
type TaggedValues map[uint64]types.Value
type TupleVals []types.Value
type TupleVals struct {
vs []types.Value
format *types.Format
}
func (tvs TupleVals) Kind() types.NomsKind {
return types.TupleKind
}
func (tvs TupleVals) Value(ctx context.Context) types.Value {
return types.NewTuple(types.Format_7_18, tvs...)
return types.NewTuple(tvs.format, tvs.vs...)
}
func (tvs TupleVals) Less(f *types.Format, other types.LesserValuable) bool {
if other.Kind() == types.TupleKind {
if otherTVs, ok := other.(TupleVals); ok {
for i, val := range tvs {
if i == len(otherTVs) {
for i, val := range tvs.vs {
if i == len(otherTVs.vs) {
// equal up til the end of other. other is shorter, therefore it is less
return false
}
otherVal := otherTVs[i]
otherVal := otherTVs.vs[i]
if !val.Equals(types.Format_7_18, otherVal) {
if !val.Equals(f, otherVal) {
return val.Less(f, otherVal)
}
}
return len(tvs) < len(otherTVs)
return len(tvs.vs) < len(otherTVs.vs)
} else {
panic("not supported")
}
@@ -44,7 +47,7 @@ func (tvs TupleVals) Less(f *types.Format, other types.LesserValuable) bool {
return types.TupleKind < other.Kind()
}
func (tt TaggedValues) NomsTupleForTags(tags []uint64, encodeNulls bool) TupleVals {
func (tt TaggedValues) NomsTupleForTags(format *types.Format, tags []uint64, encodeNulls bool) TupleVals {
numVals := 0
for _, tag := range tags {
val := tt[tag]
@@ -70,7 +73,7 @@ func (tt TaggedValues) NomsTupleForTags(tags []uint64, encodeNulls bool) TupleVa
}
}
return TupleVals(vals)
return TupleVals{vals, format}
}
func (tt TaggedValues) Iter(cb func(tag uint64, val types.Value) (stop bool)) bool {
@@ -135,10 +138,10 @@ func ParseTaggedValues(tpl types.Tuple) TaggedValues {
return taggedTuple
}
func (tt TaggedValues) String() string {
func (tt TaggedValues) String(format *types.Format) string {
str := "{"
for k, v := range tt {
str += fmt.Sprintf("\n\t%d: %s", k, types.EncodedValue(context.Background(), types.Format_7_18, v))
str += fmt.Sprintf("\n\t%d: %s", k, types.EncodedValue(context.Background(), format, v))
}
str += "\n}"

View File

@@ -80,8 +80,8 @@ func TestTupleValsLess(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
ctx := context.Background()
lesserTplVals := test.lesserTVs.NomsTupleForTags(test.tags, true)
greaterTplVals := test.greaterTVs.NomsTupleForTags(test.tags, true)
lesserTplVals := test.lesserTVs.NomsTupleForTags(types.Format_7_18, test.tags, true)
greaterTplVals := test.greaterTVs.NomsTupleForTags(types.Format_7_18, test.tags, true)
// TODO(binformat)
lessLTGreater := lesserTplVals.Less(types.Format_7_18, greaterTplVals)
@@ -125,7 +125,7 @@ func TestTaggedTuple_NomsTupleForTags(t *testing.T) {
//{map[uint64]types.Value{}, []uint64{}, types.NewTuple()},
}
for _, test := range tests {
if got := tt.NomsTupleForTags(test.tags, test.encodeNulls).Value(ctx); !reflect.DeepEqual(got, test.want) {
if got := tt.NomsTupleForTags(types.Format_7_18, test.tags, test.encodeNulls).Value(ctx); !reflect.DeepEqual(got, test.want) {
t.Errorf("TaggedValues.NomsTupleForTags() = %v, want %v", types.EncodedValue(ctx, types.Format_7_18, got), types.EncodedValue(ctx, types.Format_7_18, test.want))
}
}

View File

@@ -56,8 +56,8 @@ func TestRowConverter(t *testing.T) {
6: types.NullValue,
})
if !row.AreEqual(outData, expected, destSch) {
t.Error("\n", row.Fmt(context.Background(), expected, destSch), "!=\n", row.Fmt(context.Background(), outData, destSch))
if !row.AreEqual(types.Format_7_18, outData, expected, destSch) {
t.Error("\n", row.Fmt(context.Background(), types.Format_7_18, expected, destSch), "!=\n", row.Fmt(context.Background(), types.Format_7_18, outData, destSch))
}
}

View File

@@ -2,6 +2,7 @@ package alterschema
import (
"context"
"github.com/liquidata-inc/ld/dolt/go/cmd/dolt/errhand"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/doltdb"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/schema"
@@ -62,7 +63,7 @@ func updateTableWithNewSchema(ctx context.Context, db *doltdb.DoltDB, tbl *doltd
return true
}
me.Set(newRow.NomsMapKey(newSchema), newRow.NomsMapValue(newSchema))
me.Set(newRow.NomsMapKey(vrw.Format(), newSchema), newRow.NomsMapValue(vrw.Format(), newSchema))
return false
})
if updateErr != nil {

View File

@@ -4,11 +4,13 @@ import (
"context"
"errors"
"fmt"
"io"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/doltdb"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/schema"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table/typed/noms"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table/untyped/resultset"
"io"
"github.com/liquidata-inc/ld/dolt/go/store/types"
"vitess.io/vitess/go/vt/sqlparser"
)
@@ -79,7 +81,7 @@ func ExecuteDelete(ctx context.Context, db *doltdb.DoltDB, root *doltdb.RootValu
}
result.NumRowsDeleted++
me.Remove(r.NomsMapKey(tableSch))
me.Remove(r.NomsMapKey(types.Format_7_18, tableSch))
}
table = table.UpdateRows(ctx, me.Map(ctx))

View File

@@ -131,7 +131,7 @@ func TestExecuteDelete(t *testing.T) {
for _, r := range AllPeopleRows {
deletedIdx := FindRowIndex(r, tt.deletedRows)
key := r.NomsMapKey(PeopleTestSchema)
key := r.NomsMapKey(types.Format_7_18, PeopleTestSchema)
_, ok := table.GetRow(ctx, key.Value(ctx).(types.Tuple), PeopleTestSchema)
if deletedIdx >= 0 {
assert.False(t, ok, "Row not deleted: %v", r)

View File

@@ -95,7 +95,7 @@ func ExecuteInsert(ctx context.Context, db *doltdb.DoltDB, root *doltdb.RootValu
}
}
key := r.NomsMapKey(tableSch).Value(ctx)
key := r.NomsMapKey(types.Format_7_18, tableSch).Value(ctx)
rowExists := rowData.Get(ctx, key) != nil
// TODO(binformat)
@@ -111,7 +111,7 @@ func ExecuteInsert(ctx context.Context, db *doltdb.DoltDB, root *doltdb.RootValu
return errInsert("Duplicate primary key: '%v'", getPrimaryKeyString(r, tableSch))
}
}
me.Set(key, r.NomsMapValue(tableSch))
me.Set(key, r.NomsMapValue(types.Format_7_18, tableSch))
// TODO(binformat)
insertedPKHashes[key.Hash(types.Format_7_18)] = struct{}{}

View File

@@ -318,7 +318,7 @@ func TestExecuteInsert(t *testing.T) {
assert.True(t, ok)
for _, expectedRow := range tt.insertedValues {
foundRow, ok := table.GetRow(ctx, expectedRow.NomsMapKey(PeopleTestSchema).Value(ctx).(types.Tuple), PeopleTestSchema)
foundRow, ok := table.GetRow(ctx, expectedRow.NomsMapKey(types.Format_7_18, PeopleTestSchema).Value(ctx).(types.Tuple), PeopleTestSchema)
assert.True(t, ok, "Row not found: %v", expectedRow)
opts := cmp.Options{cmp.AllowUnexported(expectedRow), dtestutils.FloatComparer}
assert.True(t, cmp.Equal(expectedRow, foundRow, opts), "Rows not equals, found diff %v", cmp.Diff(expectedRow, foundRow, opts))

View File

@@ -144,7 +144,7 @@ func ExecuteUpdate(ctx context.Context, db *doltdb.DoltDB, root *doltdb.RootValu
return nil, errFmt(ConstraintFailedFmt, col.Name, constraint)
}
tvs := r.NomsMapKey(tableSch).(row.TupleVals)
tvs := r.NomsMapKey(types.Format_7_18, tableSch).(row.TupleVals)
key := tvs.Value(ctx)
if anyColChanged {
@@ -153,7 +153,7 @@ func ExecuteUpdate(ctx context.Context, db *doltdb.DoltDB, root *doltdb.RootValu
result.NumRowsUnchanged += 1
}
me.Set(key, r.NomsMapValue(tableSch))
me.Set(key, r.NomsMapValue(types.Format_7_18, tableSch))
}
table = table.UpdateRows(ctx, me.Map(ctx))

View File

@@ -347,7 +347,7 @@ func TestExecuteUpdate(t *testing.T) {
expectedRow = tt.updatedRows[updatedIdx]
}
foundRow, ok := table.GetRow(ctx, expectedRow.NomsMapKey(PeopleTestSchema).Value(ctx).(types.Tuple), PeopleTestSchema)
foundRow, ok := table.GetRow(ctx, expectedRow.NomsMapKey(types.Format_7_18, PeopleTestSchema).Value(ctx).(types.Tuple), PeopleTestSchema)
assert.True(t, ok, "Row not found: %v", expectedRow)
opts := cmp.Options{cmp.AllowUnexported(expectedRow), dtestutils.FloatComparer}
assert.True(t, cmp.Equal(expectedRow, foundRow, opts), "Rows not equals, found diff %v", cmp.Diff(expectedRow, foundRow, opts))

View File

@@ -18,7 +18,7 @@ func TestBadRow(t *testing.T) {
t.Error("Should be a bad row error")
}
if !row.AreEqual(GetBadRowRow(err), emptyRow, sch) {
if !row.AreEqual(types.Format_7_18, GetBadRowRow(err), emptyRow, sch) {
t.Error("did not get back expected empty row")
}

View File

@@ -49,8 +49,7 @@ func (imt *InMemTable) AppendRow(r row.Row) error {
sort.Slice(imt.rows, func(i, j int) bool {
iRow := imt.rows[i]
jRow := imt.rows[j]
// TODO(binformat)
return iRow.NomsMapKey(imt.sch).Less(types.Format_7_18, jRow.NomsMapKey(imt.sch))
return iRow.NomsMapKey(types.Format_7_18, imt.sch).Less(types.Format_7_18, jRow.NomsMapKey(types.Format_7_18, imt.sch))
})
return nil

View File

@@ -75,7 +75,7 @@ func TestInMemTable(t *testing.T) {
if err != nil {
t.Error("Unexpected read error")
} else if !row.AreEqual(expectedRow, actualRow, rowSch) {
} else if !row.AreEqual(types.Format_7_18, expectedRow, actualRow, rowSch) {
t.Error("Unexpected row value")
}
}
@@ -117,8 +117,8 @@ func TestPipeRows(t *testing.T) {
t.Fatal("Couldn't Get row.")
}
if !row.AreEqual(r1, r2, rowSch) {
t.Error("Rows should be the same.", row.Fmt(context.Background(), r1, rowSch), "!=", row.Fmt(context.Background(), r2, rowSch))
if !row.AreEqual(types.Format_7_18, r1, r2, rowSch) {
t.Error("Rows should be the same.", row.Fmt(context.Background(), types.Format_7_18, r1, rowSch), "!=", row.Fmt(context.Background(), types.Format_7_18, r2, rowSch))
}
}
}
@@ -148,8 +148,8 @@ func TestReadAllRows(t *testing.T) {
}
for i := 0; i < len(rows); i++ {
if !row.AreEqual(rows[i], results[i], rowSch) {
t.Error(row.Fmt(context.Background(), rows[i], rowSch), "!=", row.Fmt(context.Background(), results[i], rowSch))
if !row.AreEqual(types.Format_7_18, rows[i], results[i], rowSch) {
t.Error(row.Fmt(context.Background(), types.Format_7_18, rows[i], rowSch), "!=", row.Fmt(context.Background(), types.Format_7_18, results[i], rowSch))
}
}
}

View File

@@ -3,6 +3,7 @@ package pipeline
import (
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/row"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table/untyped"
"github.com/liquidata-inc/ld/dolt/go/store/types"
"testing"
)
@@ -24,7 +25,7 @@ func TestTransformRowFailure(t *testing.T) {
fr := GetTransFailureRow(err)
if !row.AreEqual(r, fr, sch) {
if !row.AreEqual(types.Format_7_18, r, fr, sch) {
t.Error("unexpected row")
}

View File

@@ -72,7 +72,7 @@ func TableFromJSON(ctx context.Context, fp string, vrw types.ValueReadWriter, sc
var rowMap types.Map
me := types.NewMap(ctx, vrw).Edit()
for _, row := range tblRows {
me = me.Set(row.NomsMapKey(sch), row.NomsMapValue(sch))
me = me.Set(row.NomsMapKey(vrw.Format(), sch), row.NomsMapValue(vrw.Format(), sch))
}
rowMap = me.Map(ctx)

View File

@@ -52,10 +52,9 @@ func (nmc *NomsMapCreator) WriteRow(ctx context.Context, r row.Row) error {
}
}()
pk := r.NomsMapKey(nmc.sch)
fieldVals := r.NomsMapValue(nmc.sch)
// TODO(binformat)
if nmc.lastPK == nil || nmc.lastPK.Less(types.Format_7_18, pk) {
pk := r.NomsMapKey(nmc.vrw.Format(), nmc.sch)
fieldVals := r.NomsMapValue(nmc.vrw.Format(), nmc.sch)
if nmc.lastPK == nil || nmc.lastPK.Less(nmc.vrw.Format(), pk) {
pkVal := pk.Value(ctx)
nmc.kvsChan <- pkVal

View File

@@ -81,15 +81,15 @@ func (nmu *NomsMapUpdater) WriteRow(ctx context.Context, r row.Row) error {
}
}()
pk := r.NomsMapKey(nmu.sch)
fieldVals := r.NomsMapValue(nmu.sch)
pk := r.NomsMapKey(nmu.vrw.Format(), nmu.sch)
fieldVals := r.NomsMapValue(nmu.vrw.Format(), nmu.sch)
nmu.acc.AddEdit(pk, fieldVals)
nmu.count++
if nmu.count%maxEdits == 0 {
nmu.mapChan <- nmu.acc.FinishedEditing()
nmu.acc = types.CreateEditAccForMapEdits(types.Format_7_18)
nmu.acc = types.CreateEditAccForMapEdits(nmu.vrw.Format())
}
}()

View File

@@ -145,8 +145,8 @@ func testReadAndCompare(t *testing.T, initialMapVal *types.Map, expectedRows []r
}
for i := 0; i < len(expectedRows); i++ {
if !row.AreEqual(actualRows[i], expectedRows[i], sch) {
t.Error(row.Fmt(context.Background(), actualRows[i], sch), "!=", row.Fmt(context.Background(), expectedRows[i], sch))
if !row.AreEqual(types.Format_7_18, actualRows[i], expectedRows[i], sch) {
t.Error(row.Fmt(context.Background(), types.Format_7_18, actualRows[i], sch), "!=", row.Fmt(context.Background(), types.Format_7_18, expectedRows[i], sch))
}
}
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table/untyped"
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/filesys"
"github.com/liquidata-inc/ld/dolt/go/store/types"
"io"
"strings"
"testing"
@@ -93,8 +94,8 @@ func TestReader(t *testing.T) {
} else {
for i, r := range rows {
expectedRow := test.expectedRows[i]
if !row.AreEqual(r, expectedRow, sch) {
t.Error(row.Fmt(context.Background(), r, sch), "!=", row.Fmt(context.Background(), expectedRow, sch))
if !row.AreEqual(types.Format_7_18, r, expectedRow, sch) {
t.Error(row.Fmt(context.Background(), types.Format_7_18, r, sch), "!=", row.Fmt(context.Background(), types.Format_7_18, expectedRow, sch))
}
}
}

View File

@@ -6,6 +6,7 @@ import (
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table"
"github.com/liquidata-inc/ld/dolt/go/libraries/doltcore/table/untyped"
"github.com/liquidata-inc/ld/dolt/go/libraries/utils/filesys"
"github.com/liquidata-inc/ld/dolt/go/store/types"
"io"
"strings"
"testing"
@@ -80,8 +81,8 @@ func TestReader(t *testing.T) {
} else {
for i, r := range rows {
expectedRow := test.expectedRows[i]
if !row.AreEqual(r, expectedRow, sch) {
t.Error(row.Fmt(context.Background(), r, sch), "!=", row.Fmt(context.Background(), expectedRow, sch))
if !row.AreEqual(types.Format_7_18, r, expectedRow, sch) {
t.Error(row.Fmt(context.Background(), types.Format_7_18, r, sch), "!=", row.Fmt(context.Background(), types.Format_7_18, expectedRow, sch))
}
}
}