Skip to content

feat: optimize() resues the first segment if possible#387

Open
JalinWang wants to merge 10 commits into
alibaba:mainfrom
JalinWang:feat/optimize
Open

feat: optimize() resues the first segment if possible#387
JalinWang wants to merge 10 commits into
alibaba:mainfrom
JalinWang:feat/optimize

Conversation

@JalinWang
Copy link
Copy Markdown
Collaborator

No description provided.

@JalinWang JalinWang marked this pull request as draft May 7, 2026 09:31
@JalinWang JalinWang marked this pull request as ready for review May 8, 2026 03:11
@JalinWang JalinWang changed the title feat: optimize() resues the first segment if possible [WIP] feat: optimize() resues the first segment if possible May 8, 2026
@JalinWang JalinWang changed the title [WIP] feat: optimize() resues the first segment if possible [In Progress] feat: optimize() resues the first segment if possible May 8, 2026
@JalinWang JalinWang closed this May 8, 2026
@JalinWang JalinWang reopened this May 8, 2026
@JalinWang JalinWang changed the title [In Progress] feat: optimize() resues the first segment if possible feat: optimize() resues the first segment if possible May 8, 2026
Index::Pointer *result);

//! Move the index's storage file to a new path
int MoveTo(const std::string &new_path);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

MoveTo 没用到吧


//! Merge all indexes into one at output_path, automatically reusing
//! the best source index to avoid rebuilding the graph from scratch.
static int MergeAll(const std::string &output_path,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

函数签名不够直观,建议按照 输入(all_indexes, filter) -> 配置 (options, index_param, storage_type) -> 输出(output_path, result)的顺序

// Current: only reuse the first index (offset math is trivial)
// Must have zero deletions & no builder (IVF has builder, needs full rebuild)
auto first_param = all_indexes[0]->GetParam();
bool can_reuse =
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这个合并策略逻辑放在这里 可能不太合适,目前合并策略强依赖输入indexers是保序的(有个隐含的id递增逻辑),对于core本身接口的使用不具备通用性。

@feihongxu0824
Copy link
Copy Markdown
Collaborator

标题:resues -> reuses

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.

2 participants