diff options
author | Andrew Dolgov <[email protected]> | 2017-07-04 23:41:19 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2017-07-04 23:41:19 +0300 |
commit | 1aa0834e6c7847691c4bf0efb876a2410352445c (patch) | |
tree | 053fa8b23c85cb56f3c80e3ddeb30d96d03e6c34 | |
parent | 9eebdaef2291b2af13f85b4981e609a23d91fd62 (diff) |
-rw-r--r-- | Home.md | 30 | ||||
-rw-r--r-- | home.md | 29 |
2 files changed, 29 insertions, 30 deletions
@@ -1 +1,29 @@ -Welcome to Wiki!
\ No newline at end of file +### Known issues + +* On 32-bit systems 64-bit perceptual hash is limited to a 32-bit integer (i.e. only half of the hash is actually stored and used). + +### How to check database contents/hash values easily + +```sql +DROP TABLE IF EXISTS phash_check_setof_type cascade; +CREATE TABLE phash_check_setof_type (created_at timestamp, url text, phash bit(64), owner_uid int, distance int); + +CREATE OR REPLACE FUNCTION phash_check_url(text) RETURNS SETOF phash_check_setof_type AS $$ + SELECT created_at, + url, + phash::bit(64), + owner_uid, + unique_1bits( + (SELECT phash FROM ttrss_plugin_img_phash_urls WHERE url LIKE '%' || + SUBSTRING($1 FROM position('//' IN $1))), + phash) AS distance + FROM ttrss_plugin_img_phash_urls + ORDER BY distance limit 10 +$$ LANGUAGE SQL; +``` + +Use the function like this: + +```sql +select * from phash_check_url('http://example.com/something.jpg'); +```
\ No newline at end of file diff --git a/home.md b/home.md deleted file mode 100644 index 167e978..0000000 --- a/home.md +++ /dev/null @@ -1,29 +0,0 @@ -### Known issues - -* On 32-bit systems 64-bit perceptual hash is limited to a 32-bit integer (i.e. only half of the hash is actually stored and used). - -### How to check database contents/hash values easily - -```sql -DROP TABLE IF EXISTS phash_check_setof_type cascade; -CREATE TABLE phash_check_setof_type (created_at timestamp, url text, phash bit(64), owner_uid int, distance int); - -CREATE OR REPLACE FUNCTION phash_check_url(text) RETURNS SETOF phash_check_setof_type AS $$ - SELECT created_at, - url, - phash::bit(64), - owner_uid, - unique_1bits( - (SELECT phash FROM ttrss_plugin_img_phash_urls WHERE url LIKE '%' || - SUBSTRING($1 FROM position('//' IN $1))), - phash) AS distance - FROM ttrss_plugin_img_phash_urls - ORDER BY distance limit 10 -$$ LANGUAGE SQL; -``` - -Use the function like this: - -```sql -select * from phash_check_url('http://example.com/something.jpg'); -```
\ No newline at end of file |