From e80f6438c22cbaf07a70962f321eb168a303e323 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sun, 11 Sep 2022 13:45:01 -0400 Subject: Containment measures for ugly sql stuff. Also made forgetting return value a sin (should've been the case in the first place) --- signature_db.hpp | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 signature_db.hpp (limited to 'signature_db.hpp') diff --git a/signature_db.hpp b/signature_db.hpp new file mode 100644 index 0000000..f7259bb --- /dev/null +++ b/signature_db.hpp @@ -0,0 +1,60 @@ +//Chris Xiong 2022 +//License: MPL-2.0 +#ifndef SIGNATURE_DB_HPP +#define SIGNATURE_DB_HPP + +#include +#include + +#include "signature.hpp" + +namespace fs = std::filesystem; + +struct subslice_t {size_t id; size_t slice;}; + +struct dupe_t {size_t id1, id2; double distance;}; + +struct signature_db_priv; + +class signature_db +{ +private: + signature_db_priv *p; +public: + signature_db(); + ~signature_db(); + + //insert image signature into database + //id must be unique + void put_signature(size_t id, const fs::path &path, const signature &sig); + //get image signature from database + std::pair get_signature(size_t id); + + //place batch_put_subslice_begin() and batch_end() around a group of + //put_subslice() calls to improve performance + void batch_put_subslice_begin(); + //insert subslice into database + //(id, slice) must be unique + //calling put_subslice_begin() before this is NOT required, but + //will improve performance + void put_subslice(size_t id, size_t slice, const signature &slicesig); + + //same thing as put_subslice_begin() + void batch_find_subslice_begin(); + //find identical subslices from database + std::vector find_subslice(const signature &slicesig); + + //call this to finish a batch + void batch_end(); + + void put_dupe_pair(size_t ida, size_t idb, double dist); + std::vector dupe_pairs(); + + void lock(); + void unlock(); + + bool to_db_file(const fs::path &path); + bool from_db_file(const fs::path &path); +}; + +#endif -- cgit v1.2.3