Skip to content

feat(vamana): Add relabelVector, a data-preserving external-ID rename - #383

Open
nonirosenfeldredis wants to merge 1 commit into
intel:mainfrom
nonirosenfeldredis:sharon-relabel-support
Open

feat(vamana): Add relabelVector, a data-preserving external-ID rename#383
nonirosenfeldredis wants to merge 1 commit into
intel:mainfrom
nonirosenfeldredis:sharon-relabel-support

Conversation

@nonirosenfeldredis

Copy link
Copy Markdown

Summary

MutableVamanaIndex::delete_entries + add_points was the only existing way to change a
vector's external label -- and that path re-reads and re-inserts the vector's data, and
re-links its graph adjacency, even when the caller only wants a new label for data that
hasn't changed. That's exactly the situation a downstream index-update path faces after a
document update turns out not to have touched the vector: nothing about the stored vector or
its graph position needs to change, only the external ID it's known by.

  • IDTranslator::remap_external_id(from, to): the missing symmetric counterpart to the
    existing remap_internal_id (used internally by compact()) -- a pure O(1) hash-map key
    swap on the external ID, checked by default the same way insert/delete_* are.
  • MutableVamanaIndex::relabelVector(old_id, new_id): exposes this at the index level,
    alongside the existing translate_external_id/has_id/get_datum methods it's meant to be
    used with. Touches neither the dataset nor the graph.

Testing

  • New "Rename External" section (plus two error-path sections) in
    tests/svs/core/translation.cpp.
  • New "MutableVamana Index Relabel" test case in tests/svs/index/vamana/dynamic_index.cpp,
    verifying the internal id, stored data, and every other id are unaffected by the rename.
  • Verified both error-path sections actually exercise the check (not just happen to pass) by
    temporarily disabling it and confirming all four throw-assertions fail as expected, then
    restoring it.

MutableVamanaIndex::delete_entries + add_points is the only existing way to
change a vector's external label -- and that path re-reads and re-inserts
the vector's data, and re-links its graph adjacency, even when the caller
only wants a new label for data that hasn't changed. That's the situation
a downstream index-update path faces after a document update turns out not
to have touched the vector: nothing about the stored vector or its graph
position needs to change, only the external ID it's known by.

Adds IDTranslator::remap_external_id(from, to), the missing symmetric
counterpart to the existing remap_internal_id (used internally by
compact()): a pure O(1) hash-map key swap on the external ID, validated
the same way insert/delete_* are (checked by default, throws ANNException
and leaves the table unmodified on a bad from/to, matching every other
public mutator on this class).

MutableVamanaIndex::relabelVector(old_id, new_id) exposes this at the index
level, alongside the existing translate_external_id/has_id/get_datum
methods it's meant to be used with. It does not touch the dataset or graph
at all.

Tested: a new "Rename External" section (plus two error-path sections) in
tests/svs/core/translation.cpp, and a new "MutableVamana Index Relabel"
test case in tests/svs/index/vamana/dynamic_index.cpp verifying the internal
id, stored data, and every other id are unaffected by the rename. Verified
both error-path sections actually exercise the check (not just happen to
pass) by temporarily disabling it and confirming all four throw-assertions
fail as expected, then restoring it.
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.

1 participant