Skip to content

feat(cmd): support OBJECT ENCODING and OBJECT HELP subcommands - #3638

Open
ReturnKartikey wants to merge 2 commits into
apache:unstablefrom
ReturnKartikey:feat-object-encoding
Open

ReturnKartikey wants to merge 2 commits into
apache:unstablefrom
ReturnKartikey:feat-object-encoding

Conversation

@ReturnKartikey

Copy link
Copy Markdown

Description

This PR implements the Redis-compatible OBJECT ENCODING <key> and OBJECT HELP subcommands in Kvrocks, addressing #595 and contributing to #3516.

Summary of Changes

  • CommandObject:
    • Added Parse() to validate subcommands (dump, encoding, help) and arity.
    • Updated command arity from 3 to -2 and added dynamic Range() key extractor.
    • Implemented OBJECT ENCODING <key> mapping internal types to Redis encodings:
      • String: parses integer format to return int, otherwise raw.
      • List: quicklist.
      • Set / Hash: hashtable.
      • ZSet: skiplist.
      • Stream: stream.
      • JSON: json.
      • Non-existent key: nil.
    • Implemented OBJECT HELP returning subcommand summary.
  • Tests:
    • Added Go integration tests in tests/gocase/unit/introspection/introspection_test.go verifying OBJECT HELP, OBJECT ENCODING across multiple data types, OBJECT DUMP, and error handling for invalid arguments and subcommands.

Closes #595
Relates to #3516

This implements Redis-compatible OBJECT ENCODING <key> and OBJECT HELP subcommands:
- Update CommandObject arity from 3 to -2 and key range to dynamic callback
- Add Parse() to validate subcommands (dump, encoding, help) and arguments
- Support OBJECT ENCODING returning appropriate representation for strings (int/raw), lists (quicklist), hashes/sets (hashtable), zsets (skiplist), streams (stream), JSON (json), and nil when key does not exist
- Support OBJECT HELP summarizing available subcommands
- Add integration tests covering OBJECT HELP, OBJECT ENCODING across data types, and error handling for unknown subcommands or invalid arguments

Closes apache#595
Relates to apache#3516
@github-actions

Copy link
Copy Markdown

Hi @ReturnKartikey,

Thank you for your pull request. Please review our Contributing Guide.

Please make sure you understand your changes and explain your reasoning in this pull request. Low-quality pull requests may be closed.

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.

You can help Kvrocks to support more Redis commands

1 participant