Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Introduce Codec #557

Closed
wants to merge 18 commits into from
Closed

Conversation

AmoebaProtozoa
Copy link
Contributor

This PR aims unify CodecPDClient and CodecPDClientV2 by introducing a Codec interface.

// EncodeRange encodes key range.
EncodeRange(start, end []byte) ([]byte, []byte)
// DecodeRange decodes key range.
DecodeRange(encodedStart, encodedEnd []byte) ([]byte, []byte)
Copy link
Member

Choose a reason for hiding this comment

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

seem DecodeRange will not be used in the code.

Comment on lines +42 to +48
EncodeRegionKey(key []byte) []byte
// DecodeRegionKey decode region's key
DecodeRegionKey(encodedKey []byte) ([]byte, error)
// EncodeRegionRange encode region's start and end.
EncodeRegionRange(start, end []byte) ([]byte, []byte)
// DecodeRegionRange decode region's start and end.
DecodeRegionRange(encodedStart, encodedEnd []byte) ([]byte, []byte, error)
Copy link
Member

Choose a reason for hiding this comment

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

For PD requests, EncodePDQueryKey and DecodeRegion should be enough.

for _, encodedPair := range encodedPairs {
var err error
p := *encodedPair
if p.Error != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Seem this if could be eliminated.

@iosmanthus iosmanthus mentioned this pull request Aug 3, 2022
4 tasks
@iosmanthus
Copy link
Member

There is a bug that might block this pull request:

if len(reqEndKey) > 0 && len(loc.EndKey) > 0 && bytes.Compare(loc.EndKey, reqEndKey) < 0 {
. We should use to check if we need to proceed the scan:

			if len(reqEndKey) == 0 || (len(loc.EndKey) > 0 && bytes.Compare(loc.EndKey, reqEndKey) < 0) {
				reqEndKey = loc.EndKey
			}

@@ -76,7 +76,9 @@ func (s *apiTestSuite) newRawKVClient(pdCli pd.Client, addrs []string) *rawkv.Cl

func (s *apiTestSuite) wrapPDClient(pdCli pd.Client, addrs []string) pd.Client {
Copy link
Contributor

Choose a reason for hiding this comment

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

addrs not be used?

@iosmanthus iosmanthus marked this pull request as ready for review August 9, 2022 07:01
config/config.go Outdated Show resolved Hide resolved
rawkv/rawkv.go Outdated Show resolved Hide resolved
Signed-off-by: iosmanthus <[email protected]>
@AmoebaProtozoa AmoebaProtozoa deleted the codec branch December 20, 2022 09:23
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