Expose BlockBasedTableOptions::uniform_cv_threshold and BlockSearchType::kAuto in the C API#14775
Conversation
…pe::kAuto in the C API The block-based table format gained an "auto" index-block search mode that selects binary vs interpolation search per index block based on key uniformity (see include/rocksdb/table.h). The C++ surface exposes this as two coupled knobs that the C API only partially covers: 1. BlockSearchType::kAuto = 0x02 selects the per-block adaptive search at read time. The existing C API enum (rocksdb_block_based_table_index_block_search_type_*) only declares values 0 (binary) and 1 (interpolation). The setter rocksdb_block_based_options_set_index_block_search_type already accepts any int via static_cast<BlockSearchType>(v), so kAuto = 2 is reachable today by passing the raw int. Only the named constant was missing. 2. BlockBasedTableOptions::uniform_cv_threshold (default -1, i.e. disabled) is the coefficient-of-variation threshold checked on the write path to set the per-block is_uniform footer bit that kAuto reads. Without a way to set this from C, kAuto degenerates to kBinary because the is_uniform bit is never written. The C API did not expose this field at all. Add: - rocksdb_block_based_table_index_block_search_type_auto = 2 enum constant. - rocksdb_block_based_options_set_uniform_cv_threshold setter, mirroring rocksdb_block_based_options_set_data_block_hash_ratio (the closest sibling — both are doubles tuning the block-based table format). No getter is added: the surrounding rocksdb_block_based_options_set_* functions in c.h do not expose getters either, so adding one only here would be inconsistent with the local style. No change to the C++ API.
✅ clang-tidy: No findings on changed linesCompleted in 56.4s. |
🟡 Codex Code ReviewAuto-triggered after CI passed — reviewing commit 0db9f5d ❌ Codex review failed before producing findings. ℹ️ About this responseGenerated by Codex CLI. Limitations:
Commands:
|
✅ Claude Code ReviewAuto-triggered after CI passed — reviewing commit 0db9f5d SummaryClean, minimal C API addition that correctly follows all established RocksDB C API patterns. The enum value mapping is verified correct ( No high-severity findings. Full review (click to expand)Findings🔴 HIGHNo high-severity findings. 🟡 MEDIUMNo medium-severity findings. 🟢 LOW / NITL1. No input validation for NaN/infinity on
|
| Context | Does code execute? | Assumptions hold? | Action needed? |
|---|---|---|---|
| WritePreparedTxnDB | N/A (config setter) | YES | None |
| ReadOnly DB | N/A (config setter) | YES | None |
| User-defined timestamps | N/A (config setter) | YES | None |
| All compaction styles | N/A (config setter) | YES | None |
This PR only adds C API wrappers around existing C++ configuration fields. No new runtime code paths are introduced. The kAuto feature and uniform_cv_threshold are fully implemented and tested in C++ — this PR merely makes them reachable from C.
Assumption stress test:
- Claim: "Enum value 2 in C maps to kAuto=0x02 in C++." Verified by reading
table.h:289—kAuto = 0x02. Thestatic_cast<BlockSearchType>(2)in the existingset_index_block_search_typeproduceskAuto. Safe. - Claim: "No validation bypass." Verified by reading
BlockBasedTableFactory::ValidateOptions()— no validation exists foruniform_cv_thresholdin C++ either. The C wrapper is consistent.
Positive Observations
- The PR correctly adds both pieces needed for
kAutoto work from C (enum constant AND threshold setter). Without both, the feature would be incomplete. - Placement of the new setter between
set_index_block_search_typeandset_data_block_hash_ratiois logical — it groups related options together. - The release note is well-written and explains the relationship between the two additions clearly.
- The test correctly sets both options together, demonstrating proper usage.
ℹ️ About this response
Generated by Claude Code.
Review methodology: claude_md/code_review.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
Summary
The block-based table format gained an "auto" index-block search mode (table.h) that selects binary vs interpolation search per index block based on key uniformity. The C++ surface exposes this as two coupled knobs:
BlockSearchType::kAuto = 0x02selects the per-block adaptive search at read time.BlockBasedTableOptions::uniform_cv_threshold(default-1, i.e. disabled) is the coefficient-of-variation threshold checked on the write path to set the per-blockis_uniformfooter bit thatkAutoreads.This PR adds the missing C API coverage for both:
rocksdb_block_based_table_index_block_search_type_auto = 2enum constant. The existing setterrocksdb_block_based_options_set_index_block_search_typealready doesstatic_cast<BlockSearchType>(v), sokAuto = 2was reachable today by passing the raw int — only the named constant was missing.rocksdb_block_based_options_set_uniform_cv_threshold(...)setter. The field had no C wrapper, so C/binding users could selectkAutobut theis_uniformbit was never set on the write path, makingkAutodegenerate tokBinary.No getter is added: the surrounding
rocksdb_block_based_options_set_*functions inc.hdo not expose getters either, so adding one only here would be inconsistent with the local style.Motivation
Without both pieces,
kAutois effectively unreachable from C. This matters for binding consumers (Rust, Go, Java-via-JNI shim, etc.) who want to opt index-block search into the per-block adaptive mode.The setter mirrors the existing
rocksdb_block_based_options_set_data_block_hash_ratioshape exactly (same struct, samedoublepayload, same naming pattern), so review surface is minimal.No change to the C++ API.