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

refactor: Extract kvapi::KeyCodec trait from kvapi::Key #15262

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Apr 18, 2024

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

refactor: Extract kvapi::KeyCodec trait from kvapi::Key

The kvapi::Key trait encompasses various key behaviors, including
prefix, parent, and value type. The key codec functionality,
responsible for encoding and decoding components of a key, operates
independently of these behaviors. This is evident in scenarios like a
database identifier (tenant, db_name), where db_name requires its
own distinct codec logic independent of the overarching key structure.

This commit introduces the kvapi::KeyCodec trait, which abstracts the
codec functionality with two primary methods: encode_key() and
decode_key(). This separation enhances modularity and aligns with
single responsibility principles, allowing for more targeted
implementations and testing of key encoding and decoding behaviors.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Refactoring

Related Issues


This change is Reviewable

@github-actions github-actions bot added the pr-refactor this PR changes the code base without new features or bugfix label Apr 18, 2024
@drmingdrmer drmingdrmer force-pushed the 49-remove-string-as-key branch from 7524d40 to 1f4adc1 Compare April 19, 2024 02:33
@drmingdrmer drmingdrmer marked this pull request as ready for review April 19, 2024 02:34
@drmingdrmer drmingdrmer requested review from lichuang and zhyass April 19, 2024 02:34
@drmingdrmer drmingdrmer force-pushed the 49-remove-string-as-key branch from 1f4adc1 to 3b43633 Compare April 19, 2024 11:58
The `kvapi::Key` trait encompasses various key behaviors, including
prefix, parent, and value type. The key codec functionality,
responsible for encoding and decoding components of a key, operates
independently of these behaviors. This is evident in scenarios like a
database identifier `(tenant, db_name)`, where `db_name` requires its
own distinct codec logic independent of the overarching key structure.

This commit introduces the `kvapi::KeyCodec` trait, which abstracts the
codec functionality with two primary methods: `encode_key()` and
`decode_key()`. This separation enhances modularity and aligns with
single responsibility principles, allowing for more targeted
implementations and testing of key encoding and decoding behaviors.
@drmingdrmer drmingdrmer force-pushed the 49-remove-string-as-key branch from 3b43633 to 9f4f9d3 Compare April 19, 2024 14:01
@BohuTANG BohuTANG merged commit d440030 into databendlabs:main Apr 19, 2024
72 checks passed
@drmingdrmer drmingdrmer deleted the 49-remove-string-as-key branch April 20, 2024 00:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-refactor this PR changes the code base without new features or bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants