rowcodec: make rowcodec can be used for mocktikv & unistore#13774
Merged
Conversation
Contributor
Author
|
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #13774 +/- ##
===========================================
Coverage 80.2253% 80.2253%
===========================================
Files 481 481
Lines 120791 120791
===========================================
Hits 96905 96905
Misses 16171 16171
Partials 7715 7715 |
coocood
reviewed
Nov 27, 2019
coocood
reviewed
Nov 27, 2019
coocood
reviewed
Nov 27, 2019
jackysp
reviewed
Nov 28, 2019
jackysp
reviewed
Nov 28, 2019
jackysp
reviewed
Nov 28, 2019
coocood
reviewed
Nov 28, 2019
coocood
reviewed
Nov 28, 2019
coocood
reviewed
Nov 28, 2019
Contributor
Author
|
@jackysp @coocood I have make some refactor: mainly split Decoder into DatumMapDecoder/ChunkDecoder/BytesDecoder, after refactor:
PTAL if free |
coocood
reviewed
Dec 2, 2019
|
|
||
| // Decoder decodes the row to chunk.Chunk. | ||
| // Decoder contains base util for decode row. | ||
| type Decoder struct { |
coocood
reviewed
Dec 2, 2019
| func (decoder *Decoder) decodeColData(colIdx int, colData []byte, chk *chunk.Chunk) error { | ||
| ft := decoder.requestTypes[colIdx] | ||
| switch ft.Tp { | ||
| func (decoder *ChunkDecoder) decodeColChunk(colIdx int, col *ColInfo, colData []byte, chk *chunk.Chunk) error { |
coocood
reviewed
Dec 2, 2019
| } | ||
|
|
||
| // NewByteDecoder creates a BytesDecoder. | ||
| func NewByteDecoder(columns []ColInfo, handleColID int64, defBytes []func() ([]byte, error), loc *time.Location) *BytesDecoder { |
Member
There was a problem hiding this comment.
We need comments about the defBytes argument.
coocood
reviewed
Dec 3, 2019
| // BytesDecoder decodes the row to old datums bytes. | ||
| type BytesDecoder struct { | ||
| decoder | ||
| defBytes []func() ([]byte, error) |
Member
There was a problem hiding this comment.
If we make the defBytes accept an i argument, then we only need to implement one function.
Member
|
LGTM |
Contributor
Author
|
PTAL @jackysp 😄 |
Contributor
Author
|
PTAL @jackysp |
Contributor
|
/run-all-tests |
XiaTianliang
pushed a commit
to XiaTianliang/tidb
that referenced
this pull request
Dec 21, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
first part of split PRs of #12634 (there are too many lines but almost them are test)
in #7597, we add rowcodec lib, but after see real-world usage old code need some change, and in this PR add much Unit Test to cover normal code path.
rowcodec provide:
Encode: datumn array into row bytes, pay attention this method will flatten type and make int/unit as non-varint encode.DecodeToDatumMap: decode row into datum map, mainly used in ddl operation in TiDBDecodeToChunk: decode row into chunk, mainly used in unistore executor and batch-get/point executorDecodeToBytes: decode row into old datum bytes, mainly used in TiDB memtable reader and mocktikv executorDecodeToBytescan force varin viaWithVarintoption to decode int value as varint(in col value, pk value and default value), this will be used in mocktikv analyze columns executor to build table reader .What is changed and how it works?
Check List
Tests
Code changes
Side effects
Related changes
Release note
This change is