You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: func_json_objectagg_test.go
    path of file: ./repos/tidb/pkg/executor/aggfuncs
    
    the code of the file until where you have to start completion: // Copyright 2020 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package aggfuncs_test

import (
	"testing"

	"github.com/pingcap/errors"
	"github.com/pingcap/tidb/pkg/executor/aggfuncs"
	"github.com/pingcap/tidb/pkg/parser/ast"
	"github.com/pingcap/tidb/pkg/parser/charset"
	"github.com/pingcap/tidb/pkg/parser/mysql"
	"github.com/pingcap/tidb/pkg/planner/util"
	"github.com/pingcap/tidb/pkg/sessionctx"
	"github.com/pingcap/tidb/pkg/types"
	"github.com/pingcap/tidb/pkg/util/chunk"
	"github.com/pingcap/tidb/pkg/util/hack"
	"g
    
func jsonMultiArgsMemDeltaGens(_ sessionctx.Context, srcChk *chunk.Chunk, dataTypes []*types.FieldType, byItems []*util.ByItems) (memDeltas []int64, err error) {
	memDeltas = make([]int64, 0)
	m := make(map[string]bool)
	for i := 0; i < srcChk.NumRows(); i++ {
		row := srcChk.GetRow(i)
		if row.IsNull(0) {
			memDeltas = append(memDeltas, int64(0))
			continue
		}
		datum := row.GetDatum(0, dataTypes[0])
		if datum.IsNull() {
			memDeltas = append(memDeltas, int64(0))
			continue
		}

		memDelta := int64(0)
		key, err := datum.ToString()
		if err != nil {
			return memDeltas, errors.Errorf("fail to get key - %s", key)
		}
		if _, ok := m[key]; ok {
			memDeltas = append(memDeltas, int64(0))
			continue
		}
		m[key] = true
		memDelta += int64(len(key))

		memDelta += aggfuncs.DefInterfaceSize
		switch dataTypes[1].GetType() {
		case mysql.TypeLonglong:
			memDelta += aggfuncs.DefUint64Size
		case mysql.TypeFloat:
			memDelta += aggfuncs.DefFloat64Size
		case mysql.TypeDouble:
			memDelta += aggfuncs.DefFloat64Size
		case mysql.TypeString:
			val := row.GetString(1)
			memDelta += int64(len(val))
		case mysql.TypeJSON:
			val := row.GetJSON(1)
			// +1 for the memory usage of the JSONTypeCode of json
			memDelta += int64(len(val.Value) + 1)
		case mysql.TypeDuration:
			memDelta += aggfuncs.DefDurationSize
		case mysql.TypeDate:
			memDelta += aggfuncs.DefTimeSize
		case mysql.TypeNewDecimal:
			memDelta += aggfuncs.DefFloat64Size
		default:
			return memDeltas, errors.Errorf("unsupported type - %v", dataTypes[1].GetType())
		}
		memDeltas = append(memDeltas, memDelta)
	}
	return memDeltas, nil
}