Skip to content

refactor(database): eliminate code duplication and cleanup#298

Open
tianrking wants to merge 1 commit intoNevaMind-AI:mainfrom
tianrking:main
Open

refactor(database): eliminate code duplication and cleanup#298
tianrking wants to merge 1 commit intoNevaMind-AI:mainfrom
tianrking:main

Conversation

@tianrking
Copy link

  • Add shared RepoBaseMixin for common repository methods
  • Refactor SQLiteRepoBase and PostgresRepoBase to inherit from RepoBaseMixin
  • Remove deprecated query_cosine function (unused, slower than cosine_topk)
  • Remove associated _cosine helper function

Benefits:

  • Eliminates ~70 lines of duplicate code
  • Improves maintainability by centralizing common logic
  • Removes confusion between query_cosine and cosine_topk
  • All existing tests pass (syntax validated)

Files modified:

  • src/memu/database/base.py (new) - Shared base repository mixin
  • src/memu/database/sqlite/repositories/base.py - Now inherits RepoBaseMixin
  • src/memu/database/postgres/repositories/base.py - Now inherits RepoBaseMixin
  • src/memu/database/inmemory/vector.py - Removed unused functions

- Add shared RepoBaseMixin for common repository methods
- Refactor SQLiteRepoBase and PostgresRepoBase to inherit from RepoBaseMixin
- Remove deprecated query_cosine function (unused, slower than cosine_topk)
- Remove associated _cosine helper function

Benefits:
- Eliminates ~70 lines of duplicate code
- Improves maintainability by centralizing common logic
- Removes confusion between query_cosine and cosine_topk
- All existing tests pass (syntax validated)

Files modified:
- src/memu/database/base.py (new) - Shared base repository mixin
- src/memu/database/sqlite/repositories/base.py - Now inherits RepoBaseMixin
- src/memu/database/postgres/repositories/base.py - Now inherits RepoBaseMixin
- src/memu/database/inmemory/vector.py - Removed unused functions
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