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

feat: add key prefix count assertions to transactions #17053

Merged
merged 2 commits into from
Dec 16, 2024

Conversation

drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Dec 16, 2024

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

Summary

feat: add key prefix count assertions to transactions

Enable transaction conditions based on the number of keys matching a prefix.
Example:

let txn = TxnRequest {
    condition: vec![ TxnCondition::match_keys_with_prefix("key/", Eq, 3) ],
    //...
}

This allows transactions to proceed only when a prefix matches an expected
number of keys, providing atomic prefix-based cardinality checks.

This commit involves a databend-meta server side change:

  • Add txn_condition::Target::KeysWithPrefix.

To provide compatibility, any change to the client that uses this
feature must update the compatibility doc and upgrade the databend-meta
cluster first.

MM src/meta/kvapi/src/kvapi/test_suite.rs

Tests

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

Type of change

  • New Feature (non-breaking change which adds functionality)

Related Issues


This change is Reviewable

@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Dec 16, 2024
Copy link

what-the-diff bot commented Dec 16, 2024

PR Summary

  • Enhanced Documentation: The documentation within our codebase, specifically in lib.rs, has been revised and updated, providing a clearer understanding of our latest features and changes.
  • New Feature for Checking Key Quantity: We've integrated a new method kv_transaction_condition_keys_with_prefix, which will allow us to identify the number of keys that correlate to a specific prefix.
  • Enhancements in Handling Conditions: We've modified the internal structure of TxnCondition to now offer support in comparing the count of keys using a given prefix.
  • Improved Condition Assessment: The evaluation process for conditions in applier.rs has been simplified, enabling different kinds of conditions to be assessed using a singular function.
  • Comprehensive Test Adjustments: We updated the test cases to validate the new capabilities of the key count conditions, ensuring a full coverage for the new feature.
  • Refinement in Byte Conversion: We've transitioned the conversion method of bytes to a broader application, now accepting any type convertible into a string.

@drmingdrmer drmingdrmer marked this pull request as ready for review December 16, 2024 05:33
Enable transaction conditions based on the number of keys matching a prefix.
Example:
```rust
let txn = TxnRequest {
    condition: vec![ TxnCondition::match_keys_with_prefix("key/", Eq, 3) ],
    //...
}
```

This allows transactions to proceed only when a prefix matches an expected
number of keys, providing atomic prefix-based cardinality checks.

This commit involves a databend-meta server side change:
- Add `txn_condition::Target::KeysWithPrefix`.

To provide compatibility, any change to the client that uses this
feature must update the compatibility doc and upgrade the databend-meta
cluster first.
@drmingdrmer drmingdrmer merged commit d577e76 into databendlabs:main Dec 16, 2024
72 of 73 checks passed
@drmingdrmer drmingdrmer deleted the 183-txn-prefix branch December 16, 2024 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants