Repository navigation
refactor: unify naming and style across the library - #193
Merged
Merged
Conversation
Enable clang-format's InsertBraces and reformat first-party sources. About 1270 bodies were already braced and about 50 were not; the formatter now keeps them consistent. Formatting only.
Apply one convention per concept across core, SIMD, FastScan, HNSW, IVF, SymphonyQG, clustering, utils and the bindings, following the role names in docs/development.md. No public API, Python keyword, saved-format or numerical change; object code is unchanged except where internal names or linkage moved. - Role names: internal_id for graph slots, assignments/cluster_id for centroid IDs, num_threads (requested) vs num_workers (resolved), batch_size vs num_points, lookup_table/accumulated_values, estimated_distances/lower_bounds, *_bytes/*_offset. - HNSW: hnswlib-style private names (get_bindata_by_internalid, get_linklist0, datal, ...) renamed; empty-graph sentinel unified on kPidMax; private Candidate replaced by AnnCandidate; link counts use uint16_t/uint32_t with unchanged widths. - Parameter names agree between declarations, definitions and every backend; template parameters are PascalCase; file-local helpers use anonymous namespaces; headers compiled under several ISA flags keep internal linkage. - Error messages read "<Component> <text>". Python-visible text changes: HNSW messages drop the colon after "HNSW", QuantizedGraph messages start with "QuantizedGraph", an unknown metric reports "metric must be 'l2' or 'ip'", SymqgIndex.save reports "must be built or loaded before save", and two IVF messages name IVF. Exception types are unchanged except the untrained k-means error, now std::runtime_error (Python RuntimeError either way). - Detail-header renames (no stability promise): VisitedListPool -> VisitedSetPool with acquire()/release(), clustering RaBitQAssigner -> RaBitQAssignment, pipnn_impl folded into symqg::detail, the unused detail::search_knn adapter removed. - Test suites follow <Module><Area>Test; the CI GoogleTest filters and tests/README.md use the new names.
Extend readability-identifier-naming to functions, methods, types, enums, template parameters, constants, namespaces, public and protected members and macros, list the public spellings kept for compatibility, and make naming findings blocking. Enable Strict for readability-inconsistent-declaration-parameter-name. The tree has no findings under the new rules. docs/development.md gains a library-wide conventions section (identifiers, linkage, namespaces, error messages, comments, tests), records the Python vocabulary kept for compatibility, and names assignments/cluster_id for clustering.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make naming and style consistent across the library and let the tools enforce it. Three commits, best reviewed separately:
style: brace every control statement body: enables clang-format'sInsertBracesand reformats first-party sources. Formatting only (about 1270 bodies were already braced, about 50 were not).refactor: unify naming and style across the library: one convention per concept in core, SIMD, FastScan, HNSW, IVF, SymphonyQG, clustering, utils and the bindings, following the role names indocs/development.md:internal_id,assignments/cluster_id,num_threads(requested) vsnum_workers(resolved),batch_size/num_points,lookup_table/accumulated_values,*_bytes/*_offset;kPidMax), and fixed-width link counts;"<Component> <text>";<Module><Area>Test, with the CI filters andtests/README.mdupdated.chore(tidy): enforce identifier naming and declaration parameter names: extendsreadability-identifier-namingto every identifier kind, lists the public spellings kept for compatibility, makes naming findings blocking, and enablesStrictparameter-name checking.docs/development.mdgains a library-wide conventions section.Compatibility
.clang-tidy.HNSW; QuantizedGraph messages start withQuantizedGraph; an unknown metric reportsmetric must be 'l2' or 'ip';SymqgIndex.savebefore build reports... must be built or loaded before save; two IVF messages name IVF. The untrained k-means error is nowstd::runtime_error(PythonRuntimeErrorbefore and after).VisitedListPool→VisitedSetPoolwithacquire()/release(),rabitqkmeans::detail::RaBitQAssigner→RaBitQAssignment,pipnn_implfolded intosymqg::detail, the unusedhnsw::detail::search_knnadapter removed.Testing
Linux x86-64 (Xeon Gold 6418H), GCC 14.3 and Clang 23,
RABITQ_ENABLE_NATIVE_OPTIMIZATION=OFF.--no-tests=error): 443 passed, 1 skipped (OpenMP placement). The first commit alone: 427 passed.--gtest_filterand-Rpattern still selects tests.main):ex_bits0–8;check-format.sh, fullcheck-tidy.shwith clang-tidy 23 (bindings on; 0 findings under the new rules), ShellCheck,git diff --check.check-python.sh;pytest tests/python812 passed, 2 skipped;tests/test_pyright.pyandtests/test_mypy.pypass.