Skip to content

Remove the old log* style constructors - #1278

Draft
xinyuwen2 wants to merge 3 commits into
mainfrom
wxy/issue_1003
Draft

Remove the old log* style constructors#1278
xinyuwen2 wants to merge 3 commits into
mainfrom
wxy/issue_1003

Conversation

@xinyuwen2

Copy link
Copy Markdown
  • Does this PR have a descriptive title that could go in our release notes?
  • Does this PR add any new dependencies?
  • Does this PR modify any existing APIs?
  • Is the change to the API backwards compatible?
  • Should this result in any changes to our documentation, either updating existing docs or adding new ones?

Reference Issues/PRs

Fixes #1003.

What does this implement/fix? Briefly explain your changes.

This change removes the legacy ANNError::log_* constructors and migrates all call sites to the newer ANNError::new(...) or ANNError::from_display(...) paths.
The main goal is to avoid the old eager string-formatting style and preserve more structured error handling where possible. Typed errors are now passed through ANNError::new(ANNErrorKind::..., err), while display-only legacy paths use ANNError::from_display(...) as a transitional wrapper. The legacy API documentation and direct tests for the removed log_* constructors were also cleaned up.

Any other comments?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the legacy ANNError::log_* constructors and migrates call sites across the workspace to the newer ANNError::new(...) and ANNError::from_display(...) paths, aligning error creation with deferred formatting and more structured error propagation.

Changes:

  • Deleted the ANNError::log_* compatibility constructors and updated error docs/tests accordingly.
  • Updated call sites across diskann, diskann-providers, diskann-disk, diskann-bftree, and tools/bench crates to construct ANNError via new(...) (typed errors) or from_display(...) (display-only errors).
  • Introduced an internal display-wrapper to allow carrying display values without eager string formatting.

Reviewed changes

Copilot reviewed 60 out of 60 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
diskann/src/utils/vector_repr.rs Convert log_index_error(...) usage to ANNError::new(ANNErrorKind::IndexError, err) for typed error propagation.
diskann/src/utils/async_tools.rs Replace legacy async error constructor with ANNError::new(ANNErrorKind::AsyncError, err).
diskann/src/graph/search/paged.rs Replace paged-search parameter validation errors with ANNError::from_display(...).
diskann/src/graph/index.rs Migrate async task/mutex error creation away from log_* constructors.
diskann/src/error/ranked.rs Update tests and conversions to use ANNError::new(...) / from_display(...) instead of legacy constructors.
diskann/src/error/ann_error.rs Remove log_* constructors; add from_display(...) helper and DisplayError wrapper.
diskann-tools/src/utils/search_index_utils.rs Replace log_index_error(format_args!(...)) patterns with from_display(..., format!(...)).
diskann-providers/src/utils/sampling.rs Replace invalid format / bounds errors with from_display(...).
diskann-providers/src/utils/rayon_util.rs Convert thread-pool build errors to from_display(...).
diskann-providers/src/utils/medoid.rs Replace legacy index errors (dimension, empty iterators, missing medoid) with from_display(...).
diskann-providers/src/utils/file_util.rs Update vector-length validation errors to from_display(...).
diskann-providers/src/storage/pq_storage.rs Replace PQ/index config errors with from_display(...) and preserve existing message structure.
diskann-providers/src/storage/index_storage.rs Convert index save precondition failures to from_display(...).
diskann-providers/src/storage/bin.rs Update metadata/vector dimension validation errors to from_display(...).
diskann-providers/src/model/pq/views.rs Convert PQ view bridging errors to ANNError::new(PQError, ...) for typed errors.
diskann-providers/src/model/pq/strided.rs Convert PQ strided bridging errors to ANNError::new(PQError, ...) for typed errors.
diskann-providers/src/model/pq/pq_construction.rs Replace PQ parameter validation and quantization formatting errors with from_display(...).
diskann-providers/src/model/pq/generate_pivot_arguments.rs Migrate pivot-argument errors to from_display(...).
diskann-providers/src/model/pq/fixed_chunk_pq_table.rs Replace PQ table construction/validation errors with from_display(...).
diskann-providers/src/model/pq/distance/dynamic.rs Replace dimension mismatch error creation with from_display(...).
diskann-providers/src/model/graph/provider/async_/simple_neighbor_provider.rs Update index error construction for start-point validation to from_display(...).
diskann-providers/src/model/graph/provider/async_/memory_vector_provider.rs Replace bounds/dimension validation errors with from_display(...).
diskann-providers/src/model/graph/provider/async_/memory_quant_vector_provider.rs Replace bounds/dimension validation errors with from_display(...).
diskann-providers/src/model/graph/provider/async_/inmem/spherical.rs Replace SQ error construction with ANNError::new(SQError, err) for typed errors.
diskann-providers/src/model/graph/provider/async_/inmem/scalar.rs Replace SQ error construction with ANNError::new(SQError, err) for typed errors.
diskann-providers/src/model/graph/provider/async_/inmem/provider.rs Replace async index/start-point validation errors with from_display(...).
diskann-providers/src/model/graph/provider/async_/fast_memory_vector_provider.rs Replace bounds/dimension validation errors with from_display(...).
diskann-providers/src/model/graph/provider/async_/fast_memory_quant_vector_provider.rs Replace bounds/dimension validation errors with from_display(...).
diskann-providers/src/model/graph/provider/async_/experimental/multi_pq_async.rs Replace multiple legacy errors (table build, bounds, poison) with from_display(...).
diskann-providers/src/model/graph/provider/async_/common.rs Replace legacy index/async errors with from_display(...).
diskann-providers/src/common/minmax_repr.rs Replace MinMax conversion error formatting with from_display(...).
diskann-disk/src/utils/partition.rs Replace dimension mismatch error with from_display(...).
diskann-disk/src/utils/math_util.rs Replace various validation/overflow errors with from_display(...).
diskann-disk/src/utils/kmeans.rs Replace PQ/KMeans cancellation/validation errors with from_display(...).
diskann-disk/src/storage/quant/pq/pq_generation.rs Replace PQ compressor/table errors with from_display(...).
diskann-disk/src/storage/quant/pq/pq_dataset.rs Replace PQ dataset construction/bounds errors with from_display(...).
diskann-disk/src/storage/quant/generator.rs Replace PQ generator precondition failures with from_display(...).
diskann-disk/src/storage/disk_index_writer.rs Replace index config/reader validation errors with from_display(...).
diskann-disk/src/storage/cached_reader.rs Replace EOF/bounds read errors with from_display(...).
diskann-disk/src/search/provider/disk_vertex_provider.rs Replace vertex-data/serde errors with from_display(...) (and keep existing message structure).
diskann-disk/src/search/provider/disk_vertex_provider_factory.rs Replace allocation/strategy validation errors with new(...) / from_display(...).
diskann-disk/src/search/provider/disk_sector_graph.rs Replace allocation/validation errors with new(...) / from_display(...).
diskann-disk/src/search/provider/aligned_file_reader/reader/windows.rs Replace IO error creation with ANNError::new(IOError, err).
diskann-disk/src/search/provider/aligned_file_reader/reader/linux.rs Replace IO/push errors with ANNError::new(..., err).
diskann-disk/src/search/provider/aligned_file_reader/aligned_read.rs Replace alignment errors with from_display(...).
diskann-disk/src/search/pq/pq_scratch.rs Replace allocation and dimension mismatch errors with new(...) / from_display(...).
diskann-disk/src/data_model/graph_metadata.rs Replace parse-slice error creation with from_display(...) using legacy-equivalent formatting.
diskann-disk/src/data_model/graph_layout_version.rs Replace parse-slice error creation with from_display(...) using legacy-equivalent formatting.
diskann-disk/src/data_model/graph_header.rs Replace header error conversion with from_display(...).
diskann-disk/src/data_model/cache.rs Replace cache validation errors with from_display(...).
diskann-disk/src/build/configuration/disk_index_build_parameter.rs Replace index config parameter errors with from_display(...) preserving message semantics.
diskann-disk/src/build/builder/tokio.rs Replace tokio runtime build failures with from_display(...).
diskann-disk/src/build/builder/quantizer.rs Replace invalid SQ config error with from_display(...) preserving prior message structure.
diskann-disk/src/build/builder/build.rs Replace thread-count / join / poison errors with from_display(...).
diskann-bftree/src/vectors.rs Replace index errors in BF-tree vector provider with from_display(...).
diskann-bftree/src/quant.rs Replace SQ/index errors with new(...) / from_display(...).
diskann-bftree/src/provider.rs Replace multiple async/index errors (start points, params serde, metric parse) with from_display(...).
diskann-bftree/src/neighbors.rs Replace BF-tree neighbor provider validation errors with from_display(...).
diskann-bftree/src/lib.rs Replace transient escalation formatting with from_display(...).
diskann-benchmark/src/inputs/save_and_load.rs Replace index config error with from_display(...) and preserve prior message semantics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 155 to 159
if num_nodes_to_cache == 0 {
ANNError::log_index_error(
ANNError::from_display(diskann::ANNErrorKind::IndexError,
"num_nodes_to_cache should be greater than 0 for StaticCacheWithBfsNodes caching strategy",
);
}
struct LocalError(tokio::task::JoinError);

ANNError::log_async_error(LocalError(err))
ANNError::from_display(crate::ANNErrorKind::AsyncError, LocalError(err))
Comment on lines +20 to +26
pub struct DisplayError<D>(D);

impl<D> DisplayError<D> {
pub fn new(display: D) -> Self {
Self(display)
}
}
@codecov-commenter

codecov-commenter commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 50.06974% with 358 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.32%. Comparing base (6caca35) to head (ddff863).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
diskann-providers/src/storage/pq_storage.rs 25.28% 65 Missing ⚠️
diskann-bftree/src/provider.rs 12.50% 49 Missing ⚠️
...ann-providers/src/model/pq/fixed_chunk_pq_table.rs 36.66% 38 Missing ⚠️
diskann-providers/src/model/pq/pq_construction.rs 18.60% 35 Missing ⚠️
diskann-tools/src/utils/search_index_utils.rs 0.00% 14 Missing ⚠️
.../src/model/graph/provider/async_/inmem/provider.rs 0.00% 13 Missing ⚠️
...n-disk/src/search/provider/disk_vertex_provider.rs 0.00% 11 Missing ⚠️
diskann-disk/src/build/builder/build.rs 28.57% 10 Missing ⚠️
...aph/provider/async_/experimental/multi_pq_async.rs 37.50% 10 Missing ⚠️
diskann-bftree/src/neighbors.rs 18.18% 9 Missing ⚠️
... and 31 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1278      +/-   ##
==========================================
- Coverage   91.50%   90.32%   -1.18%     
==========================================
  Files         498      497       -1     
  Lines       95522    95527       +5     
==========================================
- Hits        87407    86286    -1121     
- Misses       8115     9241    +1126     
Flag Coverage Δ
miri 90.32% <50.06%> (-1.18%) ⬇️
unittests 89.99% <50.06%> (-1.48%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-disk/src/build/builder/quantizer.rs 92.85% <100.00%> (ø)
diskann-disk/src/data_model/cache.rs 100.00% <100.00%> (ø)
diskann-disk/src/data_model/graph_header.rs 100.00% <100.00%> (ø)
...iskann-disk/src/data_model/graph_layout_version.rs 95.83% <100.00%> (-4.17%) ⬇️
diskann-disk/src/data_model/graph_metadata.rs 100.00% <100.00%> (ø)
diskann-disk/src/search/pq/pq_scratch.rs 100.00% <100.00%> (ø)
...earch/provider/aligned_file_reader/aligned_read.rs 100.00% <100.00%> (ø)
diskann-disk/src/storage/cached_reader.rs 99.16% <100.00%> (ø)
diskann-disk/src/storage/quant/generator.rs 97.23% <100.00%> (+0.03%) ⬆️
diskann-providers/src/common/minmax_repr.rs 97.90% <100.00%> (ø)
... and 49 more

... and 43 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xinyuwen2 xinyuwen2 changed the title ANNError: Remove the old log* style constructors Remove the old log* style constructors Jul 28, 2026
@xinyuwen2
xinyuwen2 marked this pull request as draft July 28, 2026 06:45
@hildebrandmw

Copy link
Copy Markdown
Contributor

We had an unfortunate situation where I was working on a similar PR simultaneously in #1282 😢.

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.

ANNError: Remove the old log* style constructors

4 participants