mirror of
https://github.com/dolthub/dolt.git
synced 2026-01-09 00:39:54 -06:00
[writer] skip more deserialization steps in getTableWriter (#7922)
* skip more deserialization steps in getTableWriter * [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh --------- Co-authored-by: max-hoffman <max-hoffman@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d95b391b51
commit
cfaeff4e09
@@ -32,6 +32,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/store/prolly/shim"
|
||||
"github.com/dolthub/dolt/go/store/prolly/tree"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
"github.com/dolthub/dolt/go/store/val"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -71,8 +72,10 @@ type Table interface {
|
||||
// SetSchema sets this table's schema.
|
||||
SetSchema(ctx context.Context, sch schema.Schema) (Table, error)
|
||||
|
||||
// GetTableRows returns this tables rows.
|
||||
// GetTableRows returns this table's rows.
|
||||
GetTableRows(ctx context.Context) (Index, error)
|
||||
// GetTableRowsWithDescriptors returns this table's rows with fewer deserialization calls
|
||||
GetTableRowsWithDescriptors(ctx context.Context, kd, vd val.TupleDesc) (Index, error)
|
||||
// SetTableRows sets this table's rows.
|
||||
SetTableRows(ctx context.Context, rows Index) (Table, error)
|
||||
|
||||
@@ -327,6 +330,10 @@ func (t nomsTable) GetTableRows(ctx context.Context) (Index, error) {
|
||||
return indexFromRef(ctx, t.vrw, t.ns, sch, val.(types.Ref))
|
||||
}
|
||||
|
||||
func (t nomsTable) GetTableRowsWithDescriptors(ctx context.Context, kd, vd val.TupleDesc) (Index, error) {
|
||||
return nil, fmt.Errorf("nomsTable does not implement GetTableRowsWithDescriptors")
|
||||
}
|
||||
|
||||
// GetIndexes implements Table.
|
||||
func (t nomsTable) GetIndexes(ctx context.Context) (IndexSet, error) {
|
||||
iv, ok, err := t.tableStruct.MaybeGet(indexesKey)
|
||||
@@ -850,6 +857,15 @@ func (t doltDevTable) GetTableRows(ctx context.Context) (Index, error) {
|
||||
return IndexFromProllyMap(m), nil
|
||||
}
|
||||
|
||||
func (t doltDevTable) GetTableRowsWithDescriptors(ctx context.Context, kd, vd val.TupleDesc) (Index, error) {
|
||||
rowbytes := t.msg.PrimaryIndexBytes()
|
||||
m, err := shim.MapFromValueWithDescriptors(types.SerialMessage(rowbytes), kd, vd, t.ns)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return IndexFromProllyMap(m), nil
|
||||
}
|
||||
|
||||
func (t doltDevTable) SetTableRows(ctx context.Context, rows Index) (Table, error) {
|
||||
rowsbytes, err := rows.bytes()
|
||||
if err != nil {
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/store/hash"
|
||||
"github.com/dolthub/dolt/go/store/prolly/tree"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
"github.com/dolthub/dolt/go/store/val"
|
||||
)
|
||||
|
||||
var ErrNoConflictsResolved = errors.New("no conflicts resolved")
|
||||
@@ -490,6 +491,10 @@ func (t *Table) GetRowData(ctx context.Context) (durable.Index, error) {
|
||||
return t.table.GetTableRows(ctx)
|
||||
}
|
||||
|
||||
func (t *Table) GetRowDataWithDescriptors(ctx context.Context, kd, vd val.TupleDesc) (durable.Index, error) {
|
||||
return t.table.GetTableRowsWithDescriptors(ctx, kd, vd)
|
||||
}
|
||||
|
||||
// GetRowDataHash returns the hash.Hash of the row data index.
|
||||
func (t *Table) GetRowDataHash(ctx context.Context) (hash.Hash, error) {
|
||||
idx, err := t.table.GetTableRows(ctx)
|
||||
|
||||
@@ -67,6 +67,8 @@ type WriteSessionFlusher interface {
|
||||
// is the same.
|
||||
type WriterState struct {
|
||||
DoltSchema schema.Schema
|
||||
PkKeyDesc val.TupleDesc
|
||||
PkValDesc val.TupleDesc
|
||||
PkSchema sql.PrimaryKeySchema
|
||||
PriIndex IndexState
|
||||
SecIndexes []IndexState
|
||||
|
||||
@@ -30,7 +30,7 @@ import (
|
||||
)
|
||||
|
||||
func getPrimaryProllyWriter(ctx context.Context, t *doltdb.Table, schState *dsess.WriterState) (prollyIndexWriter, error) {
|
||||
idx, err := t.GetRowData(ctx)
|
||||
idx, err := t.GetRowDataWithDescriptors(ctx, schState.PkKeyDesc, schState.PkValDesc)
|
||||
if err != nil {
|
||||
return prollyIndexWriter{}, err
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ func getSecondaryProllyIndexWriters(ctx context.Context, t *doltdb.Table, schSta
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
pkDesc, _ := schState.DoltSchema.GetMapDescriptors()
|
||||
|
||||
// check session cache based on schema hash argument
|
||||
// we want to get or save the
|
||||
@@ -92,7 +91,7 @@ func getSecondaryProllyIndexWriters(ctx context.Context, t *doltdb.Table, schSta
|
||||
keyMap: def.KeyMapping,
|
||||
keyBld: val.NewTupleBuilder(keyDesc),
|
||||
pkMap: def.PkMapping,
|
||||
pkBld: val.NewTupleBuilder(pkDesc),
|
||||
pkBld: val.NewTupleBuilder(schState.PkKeyDesc),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ func newWriterSchema(ctx *sql.Context, t *doltdb.Table, tableName string, dbName
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
schState.PkKeyDesc, schState.PkValDesc = schState.DoltSchema.GetMapDescriptors()
|
||||
schState.PkSchema, err = sqlutil.FromDoltSchema(dbName, tableName, schState.DoltSchema)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
"github.com/dolthub/dolt/go/store/prolly"
|
||||
"github.com/dolthub/dolt/go/store/prolly/tree"
|
||||
"github.com/dolthub/dolt/go/store/types"
|
||||
"github.com/dolthub/dolt/go/store/val"
|
||||
)
|
||||
|
||||
func NodeFromValue(v types.Value) (tree.Node, error) {
|
||||
@@ -42,3 +43,11 @@ func MapFromValue(v types.Value, sch schema.Schema, ns tree.NodeStore) (prolly.M
|
||||
vd := sch.GetValueDescriptor()
|
||||
return prolly.NewMap(root, ns, kd, vd), nil
|
||||
}
|
||||
|
||||
func MapFromValueWithDescriptors(v types.Value, kd, vd val.TupleDesc, ns tree.NodeStore) (prolly.Map, error) {
|
||||
root, err := NodeFromValue(v)
|
||||
if err != nil {
|
||||
return prolly.Map{}, err
|
||||
}
|
||||
return prolly.NewMap(root, ns, kd, vd), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user