Mercurial > dedupe
diff EditDistance.hpp @ 58:7b7e84356b39
Introduce API for fine tuning inserts.
Reduce the amount of rebuilds.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Fri, 14 Sep 2012 00:04:24 +0200 |
| parents | 4c283daa42c7 |
| children | e5fa379d4030 |
line wrap: on
line diff
--- a/EditDistance.hpp Thu Sep 13 23:53:35 2012 +0200 +++ b/EditDistance.hpp Fri Sep 14 00:04:24 2012 +0200 @@ -10,18 +10,37 @@ #include <QtCore/QMap> #include <QtCore/QString> +template<typename Value> +struct InsertRegulator<OrderedPair<UniqueString>, Value > +{ + uint n; + void start() + { + n = 0; + HuffmanString::getSet().setAutoRebuild(false); + } + + static void finish() + { + HuffmanString::getSet().rebuild(); + HuffmanString::getSet().setAutoRebuild(true); + } + + void next() + { + if (++n == 2048) + HuffmanString::getSet().rebuild(); + } +}; + class EditDistance { protected: - //typedef ThreadSafeLookup<OrderedPair<QString>, int> cacheType; typedef DBCache<OrderedPair<UniqueString>, int, true> cacheType; - //typedef QMap<OrderedPair<QString>, int> cacheType; - //typedef QHash<OrderedPair<QString>, int> cacheType; public: static int Compute(QString a, QString b, bool removeDiacritics = false); static void removeDiacriticsNoCopy(QString& in); static QString removeDiacritics(const QString& in); - //static cacheType cache; static cacheType* cache; };
