Repository navigation
[ISSUE-854] feat(ai): add NearestNeighborIndex contract with linear default adapter - #878
Merged
Merged
Conversation
This was referenced Oct 9, 2026
Contributor
Author
Contributor
Author
E2ern1ty
force-pushed
the
issue-854-ann-adapter
branch
from
October 10, 2026 06:24
50b75ac to
b45ec55
Compare
Contributor
Author
|
Branch rebased onto master (includes merged #879) — diff is back to the five ann-package files only. Workflow runs pending approval. |
Contributor
Author
|
The JDK8 build failure was mine: one |
Merged
3 tasks done
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.
What changes were proposed in this pull request?
Implements #854: a minimal nearest-neighbor adapter interface under
geaflow-ai'sindex/annpackage, with the exact linear scan as the default implementation — no new dependencies, no change to any existing code path, no performance claim.Added:
NearestNeighborIndex<T>— the contract.add(id, vector)/search(query, topK)/size(), scored through the existingIVector.match. The javadoc pins the ordering rules the issue asks to be documented:entryVector.match(query), because someIVectorimplementations are not symmetric;topK <= 0throwsIllegalArgumentException;Neighbor<T>— id + score result record.LinearNearestNeighborIndex<T>— the default adapter: scores every entry, sorts score-descending with the insertion ordinal as tie-break key, returns a fresh list. This is the correctness baseline an ANN implementation will be measured against, not an optimization.NearestNeighborIndexContractTest— an abstract suite any adapter runs against (newIndex()factory), split deliberately:IVector.matchverbatim against hand-checked cosine values, full deterministic ordering, bit-for-bit repeat determinism, collinear/zero-vector tie groups in insertion order) — required of adapters claiming exactness. A future ANN adapter extends the suite and excludes the exactness tests while its recall is approximate; that is the concrete form of the acceptance criterion "the linear adapter passes the same contract that an ANN adapter will use".LinearNearestNeighborIndexTest— runs the full contract plus linear-specific checks (null rejection, returned page independent of the index).How was this PR tested?
mvn -pl geaflow-ai test— 66 tests, 0 failures (7 new, no regression; branch is cut from master so it does not include PR [ISSUE-856] test(ai): golden tests for keyword index tokenization, serialization and lifecycle #877's goldens).Production verification
Started
GeaFlowMemoryServerfrom this branch (classpath launch) and drove the HTTP path end to end:/graph/create→/graph/addEntitySchema→/graph/insertEntity× 3 (English + CJK documents) →/query/context→/query/exec→/query/result. Behavior is identical to the master baseline recorded during PR #877's verification: a matching query (alpaca) ranks its document first, a non-matching query (quetzal) still recalls everything through theKeywordVector.toString()wrapper tokens. The newindex/annpackage compiles into the same artifact and leaves the running service's behavior untouched — as intended for a pure contract addition.Notes for reviewers
VectorStoreSPI with model metadata #851/[geaflow/ai-memory] AddEntityVectorIndexwrapper around graph entity embeddings #853's stores settle.