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

add-image-hash-to-detect-rename-and-optimize-reindexing #143

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

prayas7102
Copy link

@prayas7102 prayas7102 commented Oct 17, 2024

Here's a short note summarizing the changes made to address the issue of re-indexing renamed images:

Changes in db.py:

  • Updated schema with hash column.
  • Updated DB.VERSION to 3
  • Updated ensure_version() with new migration logic and error handling
  • Added get_image_by_hash() method
  • Added update_image_filepath() method
  • Added ensure_hashes() method to compute hashes for existing images
  • Handled the case where the database schema is being upgraded from a version without the hash column in ensure_tables and ensure_version methods.
  • Added error handling for UNIQUE constraint violations in update_image_filepath() method.
  • Modified ensure_tables() to include 'hash' column and index. Also check if 'hash' column exists before creating the index

Changes in main.py:

  • Added _compute_image_hash() method to RClip class
  • Updated _index_files() method to compute and store hashes which implements logic to detect and handle renamed images.
  • In _index_files() added error handling for IntegrityError when updating filepaths. Implemented a fallback to insert a new entry if updating fails.

These changes improve the efficiency of image indexing by avoiding re-indexing of renamed images and allow for faster queries using image hashes.

@prayas7102 prayas7102 marked this pull request as ready for review October 18, 2024 03:50
rclip/db.py Outdated Show resolved Hide resolved
rclip/main.py Outdated Show resolved Hide resolved
@prayas7102 prayas7102 marked this pull request as draft October 19, 2024 05:25
@prayas7102 prayas7102 marked this pull request as ready for review October 20, 2024 14:15
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