Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2013-04-25 22:42:30 +0400
committerKenneth Heafield <github@kheafield.com>2013-04-25 22:42:30 +0400
commitf1d366381033c0caae18f8d15305ded38734bdbf (patch)
tree22b0cbd3acc337a995701629bf9facbe179f5618 /moses/FactorCollection.h
parent8a1e944bb428a0af9f6c82c26e5633361ce4052c (diff)
Back FactorCollection with a memory pool. Less memory for large vocabularies.
Diffstat (limited to 'moses/FactorCollection.h')
-rw-r--r--moses/FactorCollection.h15
1 files changed, 4 insertions, 11 deletions
diff --git a/moses/FactorCollection.h b/moses/FactorCollection.h
index 9a01766f4..e7749244f 100644
--- a/moses/FactorCollection.h
+++ b/moses/FactorCollection.h
@@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <string>
#include "util/string_piece.hh"
+#include "util/pool.hh"
#include "Factor.h"
namespace Moses
@@ -62,27 +63,20 @@ class FactorCollection
friend std::ostream& operator<<(std::ostream&, const FactorCollection&);
struct HashFactor : public std::unary_function<const FactorFriend &, std::size_t> {
- std::size_t operator()(const StringPiece &str) const {
- return util::MurmurHashNative(str.data(), str.size());
- }
std::size_t operator()(const FactorFriend &factor) const {
- return (*this)(factor.in.GetString());
+ return util::MurmurHashNative(factor.in.m_string.data(), factor.in.m_string.size());
}
};
struct EqualsFactor : public std::binary_function<const FactorFriend &, const FactorFriend &, bool> {
bool operator()(const FactorFriend &left, const FactorFriend &right) const {
return left.in.GetString() == right.in.GetString();
}
- bool operator()(const FactorFriend &left, const StringPiece &right) const {
- return left.in.GetString() == right;
- }
- bool operator()(const StringPiece &left, const FactorFriend &right) const {
- return left == right.in.GetString();
- }
};
typedef boost::unordered_set<FactorFriend, HashFactor, EqualsFactor> Set;
Set m_set;
+ util::Pool m_string_backing;
+
static FactorCollection s_instance;
#ifdef WITH_THREADS
//reader-writer lock
@@ -117,6 +111,5 @@ public:
};
-
}
#endif