Skip to content

Add rocksdb_slicetransform_create_capped_prefix() to the C API - #15141

Open
dfa1 wants to merge 1 commit into
facebook:mainfrom
dfa1:feat/capped-prefix-slicetransform-c-api
Open

Add rocksdb_slicetransform_create_capped_prefix() to the C API#15141
dfa1 wants to merge 1 commit into
facebook:mainfrom
dfa1:feat/capped-prefix-slicetransform-c-api

Conversation

@dfa1

@dfa1 dfa1 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Adds rocksdb_slicetransform_create_capped_prefix() to the C API, mirroring the existing fixed-prefix function. Verified via a new c_test phase.

@meta-cla meta-cla Bot added the CLA Signed label Aug 23, 2026
@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown

✅ clang-tidy: No findings on changed lines

Completed in 66.3s.

Mirrors the existing fixed-prefix function. Verified via a new c_test
phase.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dfa1
dfa1 force-pushed the feat/capped-prefix-slicetransform-c-api branch from b109538 to c9c7e7c Compare August 23, 2026 20:01
@github-actions

Copy link
Copy Markdown

✅ Claude Code Review

Auto-triggered after CI passed — reviewing commit c9c7e7c


Summary

Clean, well-structured PR that adds rocksdb_slicetransform_create_capped_prefix() to the C API. The implementation exactly follows the established pattern used by rocksdb_slicetransform_create_fixed_prefix() and rocksdb_slicetransform_create_noop(). The test is thorough and correctly exercises the key behavioral difference (short keys being InDomain). All four required locations are updated consistently (c.h, c.cc, c_base.h, c_base.cc).

High-severity findings (0):

No high-severity findings.

Full review (click to expand)

Findings

🔴 HIGH

None.

🟡 MEDIUM

None.

🟢 LOW / NIT

L1. Test iterates entirely in-memtable without flushing — db/c_test.c
  • Issue: The test only exercises the in-memtable path (no rocksdb_flush call). The existing "prefix" phase test also doesn't flush, so this is consistent with the existing pattern, but a flush + SST-read path would provide additional coverage for the capped prefix transform interacting with block-based table prefix bloom filters.
  • Suggested fix: Optional enhancement for future work; not blocking since the underlying CappedPrefixTransform is extensively tested with SST files in C++ tests (db_bloom_filter_test.cc, db_etc2_test.cc, slice_transform_test.cc, etc.).
L2. Test comment is verbose — db/c_test.c:3503-3513
  • Issue: The 8-line block comment explaining the test rationale is more detailed than typical c_test.c comments. While helpful for understanding intent, it could be condensed.
  • Suggested fix: Consider trimming to 2-3 lines, e.g.: // Capped-prefix transform: all keys are InDomain, including those shorter than the cap. Exercise with a key shorter than cap ("ba", 2 bytes, cap 3).

Cross-Component Analysis

Context Applicable? Assessment
WritePreparedTxnDB No C API wrapper only; underlying transform is context-agnostic
ReadOnly DB No Factory function; no DB state dependency
User-defined timestamps No Prefix transform is orthogonal
All other contexts No Thin wrapper delegates entirely to existing, well-tested C++ code

Assumption stress-test:

  • Claim: "follows exact same pattern as fixed_prefix" — Verified. The 6 lines of the new function body are structurally identical to rocksdb_slicetransform_create_fixed_prefix, differing only in the NewCappedPrefixTransform call. Memory ownership via SliceTransformWrapper destructor is correct.
  • Claim: "cap_len=0 is safe" — Verified. CappedPrefixTransform(0) returns empty prefix for all keys, InDomain returns true. Existing unit test at util/slice_transform_test.cc:41-45 confirms this.

Positive Observations

  • Correct pattern adherence: The implementation exactly mirrors the two existing factory functions — no deviation, no missed fields.
  • Thoughtful test design: The test correctly uses fresh options (not the shared options variable modified by the "prefix" phase) to avoid hash-based memtable partitioning, and specifically tests a key shorter than the cap length to exercise the key behavioral difference from fixed-prefix.
  • Complete coverage of code locations: All four required files (c.h, c.cc, c_base.h, c_base.cc) plus the release note are updated.
  • Appropriate release note: Short, one-line, references both the new and existing function — follows CLAUDE.md guidance.

ℹ️ About this response

Generated by Claude Code.
Review methodology: claude_md/ci_review_prompt.md

Limitations:

  • Claude may miss context from files not in the diff
  • Large PRs may be truncated
  • Always apply human judgment to AI suggestions

Commands:

  • /claude-review [context] — Request a code review
  • /claude-query <question> — Ask about the PR or codebase

@dfa1

dfa1 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@pdillinger hello! can you please have a look? thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant