Skip to content

Unmarshal kv log#1

Merged
zier-one merged 12 commits intopingcap:masterfrom
zier-one:marshaler
Sep 9, 2019
Merged

Unmarshal kv log#1
zier-one merged 12 commits intopingcap:masterfrom
zier-one:marshaler

Conversation

@zier-one
Copy link
Contributor

@zier-one zier-one commented Sep 5, 2019

parse binary data of kv change log to structured data

@zier-one zier-one added the WIP label Sep 5, 2019
leoppro added 2 commits September 5, 2019 17:50
# Conflicts:
#	cdc/buffer.go
#	cdc/cdctest/mock_tidb.go
#	cdc/cdctest/mock_tidb_test.go
#	cdc/puller.go
#	cdc/util.go
@zier-one zier-one removed the WIP label Sep 5, 2019
Copy link
Contributor

@july2993 july2993 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to get model.TableInfo before decode sql row.
for pk is handle, get delete primary key from the {record_id -> row data}
for pk is not handle, get delete primary key from {primary index -> record_id}

cdc/codec.go Outdated
}

func hasRecordPrefix(key []byte) bool {
return key[0] == recordPrefix[0] && key[1] == recordPrefix[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use bytes.HasPrefix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because this code is copied from tidb.
https://github.com/pingcap/tidb/blob/master/tablecodec/tablecodec.go#L89

I think it will more efficient.

var recordId int64
if len(raw.Value) > 0 {
buf := bytes.NewBuffer(raw.Value)
err = binary.Read(buf, binary.BigEndian, &recordId)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use int64(binary.BigEndian.Uint64(raw.Value))?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried, it will return a wrong value

@zier-one
Copy link
Contributor Author

zier-one commented Sep 6, 2019

@suzaku @july2993 PTAL again

Copy link
Contributor

@suzaku suzaku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zier-one zier-one merged commit 73399df into pingcap:master Sep 9, 2019
@zier-one zier-one deleted the marshaler branch September 9, 2019 04:53
@zier-one zier-one restored the marshaler branch September 9, 2019 04:55
@zier-one zier-one deleted the marshaler branch September 9, 2019 09:12
5kbpers pushed a commit to 5kbpers/ticdc that referenced this pull request Aug 24, 2020
decode binary data of kv change log
gejibin added a commit to liuzix/ticdc that referenced this pull request Mar 3, 2021
joechenrh added a commit to joechenrh/tiflow that referenced this pull request Mar 18, 2026
…gcap#5)

1. Restore nil-guard on LoadChunk result to prevent panic when
   checkpoint file contains no chunk info.
2. Extract ChecksumCapableSource sub-interface from Source to avoid
   widening the core interface with checksum-only methods. Remove
   dead PreferGlobalChecksum/GetChecksumOnlyIterator from MySQLSources.
3. Rename PreferGlobalChecksum to type-assertion based capability check
   via ChecksumCapableSource, removing the misleading "Prefer" naming.
4. Add log.Warn before break in equalByGlobalChecksum error path so
   operators can see why remaining tables were skipped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
joechenrh added a commit to joechenrh/tiflow that referenced this pull request Mar 18, 2026
…gcap#5)

1. Restore nil-guard on LoadChunk result to prevent panic when
   checkpoint file contains no chunk info.
2. Extract ChecksumCapableSource sub-interface from Source to avoid
   widening the core interface with checksum-only methods. Remove
   dead PreferGlobalChecksum/GetChecksumOnlyIterator from MySQLSources.
3. Rename PreferGlobalChecksum to type-assertion based capability check
   via ChecksumCapableSource, removing the misleading "Prefer" naming.
4. Add log.Warn before break in equalByGlobalChecksum error path so
   operators can see why remaining tables were skipped.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants