Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor API so that keys are generic #6

Merged
merged 7 commits into from
Jun 14, 2024
Merged

Refactor API so that keys are generic #6

merged 7 commits into from
Jun 14, 2024

Conversation

ammario
Copy link
Member

@ammario ammario commented May 31, 2024

This is a substantial refactor of the API, removing the "Embedding" concept and instead centering the API around:

type Vector = []float32

// Node is a node in the graph.
type Node[K cmp.Ordered] struct {
	ID  K
	Vec Vector
}

I believe this API is overall better because:

  • The de-virtualization of nodes leads to modest performance improvements
  • Library users don't have to declare a custom "Embeddable" type
  • There remains only one generic parameter, keeping instantiation simple

@ammario ammario mentioned this pull request May 31, 2024
@ammario ammario changed the title Refactor API so that Key is generic Refactor API so that keys are generic May 31, 2024
@josharian
Copy link

API looks nice and simple. Might be nice to say something about how the ordering property of the ID gets used, so folks can reason about it. (I originally assumed it'd be a comparable.) I am heads down on other stuff and then camping, so can't actually try it out until mid- to late-June, I'm afraid...

@ammario
Copy link
Member Author

ammario commented Jun 3, 2024

Might be nice to say something about how the ordering property of the ID gets used, so folks can reason about it.

Will do

I am heads down on other stuff and then camping, so can't actually try it out until mid- to late-June, I'm afraid...

enjoy the the time away!

@ammario ammario merged commit e942b4f into main Jun 14, 2024
2 checks passed
@ammario ammario deleted the generic-key branch June 14, 2024 21:11
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