func WrapEvent(outputFormat string, key string, bd []byte, seqno uint64) ([]byte, error) {
	akey := make([]interface{}, 1)
	akey[0] = []byte(key)
	cfw := types.CommonFormatEvent{
		Type:      outputFormat,
		Key:       akey,
		SeqNo:     seqno,
		Timestamp: time.Now().UnixNano(),
		Fields:    nil,
	}
	cfb, err := Internal.CommonFormat(&cfw)
	if err != nil {
		return nil, err
	}
	buf := bytes.NewBuffer(cfb)
	_, err = buf.Write(bd)
	if err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
WrapEvent prepend provided payload with CommonFormat like event
package encoder
import (
	"bytes"
	"fmt"
	"strings"
	"time"
	"github.com/uber/storagetapper/types"
)
type encoderConstructor func(service, db, table, input string, output string, version int) (Encoder, error)
var encoders map[string]encoderConstructor
var Internal Encoder
func registerPlugin(name string, init encoderConstructor) {
	if encoders == nil {
		encoders = make(map[string]encoderConstructor)
	}
	encoders[name] = init
}
type Encoder interface {
	Row(tp int, row *[]interface{}, seqNo uint64, ts time.Time) ([]byte, error)
	CommonFormat(cf *types.CommonFormatEvent) ([]byte, error)
	EncodeSchema(seqNo uint64) ([]byte, error)
	UpdateCodec() error
	Type() string
	Schema() *types.TableSchema
	UnwrapEvent(data []byte, cfEvent *types.CommonFormatEvent) (payload []byte, err error)
	DecodeEvent(b []byte) (*types.CommonFormatEvent, error)
}
func Encoders() []string {
	r := make([]string, len(encoders))
	i := 0
	for k := range encoders {
		r[i] = k
		i++
	}
	return r
}
func InitEncoder(encType, svc, sdb, tbl, input string, output string, version int) (Encoder, error) {
	init := encoders[strings.ToLower(encType)]
	if init == nil {
		return nil, fmt.Errorf("unsupported encoder: %s", strings.ToLower(encType))
	}
	enc, err := init(svc, sdb, tbl, input, output, version)
	if err != nil {
		return nil, err
	}
	return enc, nil
}
func Create(encType, svc, sdb, tbl, input string, output string, version int) (Encoder, error) {
	enc, err := InitEncoder(encType, svc, sdb, tbl, input, output, version)
	if err != nil {
		return nil, err
	}
	return enc, enc.UpdateCodec()
}
func GetRowKey(s *types.TableSchema, row *[]interface{}) string {
	var key string
	for i := 0; i < len(s.Columns); i++ {
		if s.Columns[i].Key == "PRI" {
			if row == nil {
				k := fmt.Sprintf("%v", s.Columns[i].Name)
				key += fmt.Sprintf("%v%v", len(k), k)
			} else {
				k := fmt.Sprintf("%v", (*row)[i])
				key += fmt.Sprintf("%v%v", len(k), k)
			}
		}
	}
	return key
}
func GetCommonFormatKey(cf *types.CommonFormatEvent) string {
	var key string
	for _, v := range cf.Key {
		s := fmt.Sprintf("%v", v)
		key += fmt.Sprintf("%v%v", len(s), s)
	}
	return key
}
func filteredField(filter []int, i int, j *int) bool {
	if *j < len(filter) && filter[*j] == i {
		(*j)++
		return true
	}
	return false
}