diff --git a/go/vt/vtgate/engine/cached_size.go b/go/vt/vtgate/engine/cached_size.go index 0ad0330f5f8..d176b99a839 100644 --- a/go/vt/vtgate/engine/cached_size.go +++ b/go/vt/vtgate/engine/cached_size.go @@ -603,49 +603,6 @@ func (cached *Join) CachedSize(alloc bool) int64 { } return size } - -//go:nocheckptr -func (cached *JoinValues) CachedSize(alloc bool) int64 { - if cached == nil { - return int64(0) - } - size := int64(0) - if alloc { - size += int64(80) - } - // field Left vitess.io/vitess/go/vt/vtgate/engine.Primitive - if cc, ok := cached.Left.(cachedObject); ok { - size += cc.CachedSize(true) - } - // field Right vitess.io/vitess/go/vt/vtgate/engine.Primitive - if cc, ok := cached.Right.(cachedObject); ok { - size += cc.CachedSize(true) - } - // field Vars map[string]int - if cached.Vars != nil { - size += int64(48) - hmap := reflect.ValueOf(cached.Vars) - numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9))))))) - numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10)))) - size += hack.RuntimeAllocSize(int64(numOldBuckets * 208)) - if len(cached.Vars) > 0 || numBuckets > 1 { - size += hack.RuntimeAllocSize(int64(numBuckets * 208)) - } - for k := range cached.Vars { - size += hack.RuntimeAllocSize(int64(len(k))) - } - } - // field Columns []string - { - size += hack.RuntimeAllocSize(int64(cap(cached.Columns)) * int64(16)) - for _, elem := range cached.Columns { - size += hack.RuntimeAllocSize(int64(len(elem))) - } - } - // field RowConstructorArg string - size += hack.RuntimeAllocSize(int64(len(cached.RowConstructorArg))) - return size -} func (cached *Limit) CachedSize(alloc bool) int64 { if cached == nil { return int64(0) @@ -1518,6 +1475,49 @@ func (cached *VStream) CachedSize(alloc bool) int64 { size += hack.RuntimeAllocSize(int64(len(cached.Position))) return size } + +//go:nocheckptr +func (cached *ValuesJoin) CachedSize(alloc bool) int64 { + if cached == nil { + return int64(0) + } + size := int64(0) + if alloc { + size += int64(80) + } + // field Left vitess.io/vitess/go/vt/vtgate/engine.Primitive + if cc, ok := cached.Left.(cachedObject); ok { + size += cc.CachedSize(true) + } + // field Right vitess.io/vitess/go/vt/vtgate/engine.Primitive + if cc, ok := cached.Right.(cachedObject); ok { + size += cc.CachedSize(true) + } + // field Vars map[string]int + if cached.Vars != nil { + size += int64(48) + hmap := reflect.ValueOf(cached.Vars) + numBuckets := int(math.Pow(2, float64((*(*uint8)(unsafe.Pointer(hmap.Pointer() + uintptr(9))))))) + numOldBuckets := (*(*uint16)(unsafe.Pointer(hmap.Pointer() + uintptr(10)))) + size += hack.RuntimeAllocSize(int64(numOldBuckets * 208)) + if len(cached.Vars) > 0 || numBuckets > 1 { + size += hack.RuntimeAllocSize(int64(numBuckets * 208)) + } + for k := range cached.Vars { + size += hack.RuntimeAllocSize(int64(len(k))) + } + } + // field Columns []string + { + size += hack.RuntimeAllocSize(int64(cap(cached.Columns)) * int64(16)) + for _, elem := range cached.Columns { + size += hack.RuntimeAllocSize(int64(len(elem))) + } + } + // field RowConstructorArg string + size += hack.RuntimeAllocSize(int64(len(cached.RowConstructorArg))) + return size +} func (cached *Verify) CachedSize(alloc bool) int64 { if cached == nil { return int64(0) diff --git a/go/vt/vtgate/engine/join_values.go b/go/vt/vtgate/engine/join_values.go index 1d5b835e349..e35addd8c09 100644 --- a/go/vt/vtgate/engine/join_values.go +++ b/go/vt/vtgate/engine/join_values.go @@ -23,11 +23,12 @@ import ( querypb "vitess.io/vitess/go/vt/proto/query" ) -var _ Primitive = (*JoinValues)(nil) +var _ Primitive = (*ValuesJoin)(nil) -// JoinValues is a primitive that joins two primitives by constructing a table from the rows of the LHS primitive. +// ValuesJoin is a primitive that joins two primitives by constructing a table from the rows of the LHS primitive. // The table is passed in as a bind variable to the RHS primitive. -type JoinValues struct { +// It's called ValuesJoin because the LHS of the join is sent to the RHS as a VALUES clause. +type ValuesJoin struct { // Left and Right are the LHS and RHS primitives // of the Join. They can be any primitive. Left, Right Primitive @@ -38,7 +39,7 @@ type JoinValues struct { } // TryExecute performs a non-streaming exec. -func (jv *JoinValues) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { +func (jv *ValuesJoin) TryExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool) (*sqltypes.Result, error) { lresult, err := vcursor.ExecutePrimitive(ctx, jv.Left, bindVars, wantfields) if err != nil { return nil, err @@ -69,27 +70,27 @@ func (jv *JoinValues) TryExecute(ctx context.Context, vcursor VCursor, bindVars } // TryStreamExecute performs a streaming exec. -func (jv *JoinValues) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { +func (jv *ValuesJoin) TryStreamExecute(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable, wantfields bool, callback func(*sqltypes.Result) error) error { panic("implement me") } // GetFields fetches the field info. -func (jv *JoinValues) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { +func (jv *ValuesJoin) GetFields(ctx context.Context, vcursor VCursor, bindVars map[string]*querypb.BindVariable) (*sqltypes.Result, error) { return jv.Right.GetFields(ctx, vcursor, bindVars) } // Inputs returns the input primitives for this join -func (jv *JoinValues) Inputs() ([]Primitive, []map[string]any) { +func (jv *ValuesJoin) Inputs() ([]Primitive, []map[string]any) { return []Primitive{jv.Left, jv.Right}, nil } // RouteType returns a description of the query routing type used by the primitive -func (jv *JoinValues) RouteType() string { - return "JoinValues" +func (jv *ValuesJoin) RouteType() string { + return "ValuesJoin" } // GetKeyspaceName specifies the Keyspace that this primitive routes to. -func (jv *JoinValues) GetKeyspaceName() string { +func (jv *ValuesJoin) GetKeyspaceName() string { if jv.Left.GetKeyspaceName() == jv.Right.GetKeyspaceName() { return jv.Left.GetKeyspaceName() } @@ -97,16 +98,16 @@ func (jv *JoinValues) GetKeyspaceName() string { } // GetTableName specifies the table that this primitive routes to. -func (jv *JoinValues) GetTableName() string { +func (jv *ValuesJoin) GetTableName() string { return jv.Left.GetTableName() + "_" + jv.Right.GetTableName() } // NeedsTransaction implements the Primitive interface -func (jv *JoinValues) NeedsTransaction() bool { +func (jv *ValuesJoin) NeedsTransaction() bool { return jv.Right.NeedsTransaction() || jv.Left.NeedsTransaction() } -func (jv *JoinValues) description() PrimitiveDescription { +func (jv *ValuesJoin) description() PrimitiveDescription { return PrimitiveDescription{ OperatorType: "Join", Variant: "Values", diff --git a/go/vt/vtgate/planbuilder/operator_transformers.go b/go/vt/vtgate/planbuilder/operator_transformers.go index 8fabc2e20d2..2436b565cde 100644 --- a/go/vt/vtgate/planbuilder/operator_transformers.go +++ b/go/vt/vtgate/planbuilder/operator_transformers.go @@ -96,7 +96,7 @@ func transformValuesJoin(ctx *plancontext.PlanningContext, op *operators.ValuesJ return nil, err } - return &engine.JoinValues{ + return &engine.ValuesJoin{ Left: lhs, Right: rhs, Vars: op.Vars,