MCPcopy Create free account
hub / github.com/pingcap/tidb / Encode

Method Encode

pkg/util/rowcodec/encoder.go:46–58  ·  view source on GitHub ↗

Encode encodes a row from a datums slice. `buf` is not truncated before encoding. This function may return both a valid encoded bytes and an error (actually `"pingcap/errors".ErrorGroup`). If the caller expects to handle these errors according to `SQL_MODE` or other configuration, please refer to `p

(loc *time.Location, colIDs []int64, values []types.Datum, checksum Checksum, buf []byte)

Source from the content-addressed store, hash-verified

44// expects to handle these errors according to `SQL_MODE` or other configuration, please refer to `pkg/errctx`.
45// the caller needs to ensure the key is not nil if checksum is required.
46func (encoder *Encoder) Encode(loc *time.Location, colIDs []int64, values []types.Datum, checksum Checksum, buf []byte) ([]byte, error) {
47 encoder.reset()
48 encoder.appendColVals(colIDs, values)
49 numCols, notNullIdx := encoder.reformatCols()
50 err := encoder.encodeRowCols(loc, numCols, notNullIdx)
51 if err != nil {
52 return nil, err
53 }
54 if checksum == nil {
55 checksum = NoChecksum{}
56 }
57 return checksum.encode(encoder, buf)
58}
59
60func (encoder *Encoder) reset() {
61 encoder.flags = 0

Callers 15

JSONToStringFunction · 0.95
EncodeJSONCommonFunction · 0.95
SlowLogFormatMethod · 0.95
encodeFromOldRowFunction · 0.95
dumpOneDebugTraceFunction · 0.95
genIndexValueVersion0Function · 0.95
vecEvalStringMethod · 0.95

Implementers 6

MockEncoderbr/pkg/mock/encode.go
MockEncoderMockRecorderbr/pkg/mock/encode.go
TableKVEncoderpkg/executor/importer/kv_encode.go
tableKVEncoderpkg/lightning/backend/kv/sql2kv.go
tidbEncoderpkg/lightning/backend/tidb/tidb.go
mockEncoderlightning/pkg/importer/chunk_process_t

Calls 5

resetMethod · 0.95
appendColValsMethod · 0.95
reformatColsMethod · 0.95
encodeRowColsMethod · 0.95
encodeMethod · 0.65

Tested by 15

TestOptimizerDebugTraceFunction · 0.76
TestDecodeRowWithHandleFunction · 0.76
TestEncodeKindNullDatumFunction · 0.76
TestTypesNewRowCodecFunction · 0.76
TestNilAndDefaultFunction · 0.76
TestVarintCompatibilityFunction · 0.76
Test65535BugFunction · 0.76
TestDecodeWithCommitTSFunction · 0.76