Use suitable datatype for enum and used and based modulo
#include <vespa/searchlib/query/query_term_ucs4.h>
#include <vespa/searchlib/queryeval/weighted_set_term_search.h>
#include <vespa/vespalib/objects/visit.h>
-#include <vespa/vespalib/stllike/hash_map.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/vespalib/stllike/hash_map.hpp>
+
namespace search {
@@ -36,12 +37,13 @@ public:
class UseStringEnum : public UseAttr
{
public:
+ using TokenT = uint32_t;
UseStringEnum(const IAttributeVector & attr)
: UseAttr(attr) {}
auto mapToken(const ISearchContext &context) const {
return attribute().findFoldedEnums(context.queryTerm()->getTerm());
}
- int64_t getToken(uint32_t docId) const {
+ TokenT getToken(uint32_t docId) const {
return attribute().getEnum(docId);
}
};
@@ -51,6 +53,7 @@ public:
class UseInteger : public UseAttr
{
public:
+ using TokenT = uint64_t;
UseInteger(const IAttributeVector & attr) : UseAttr(attr) {}
std::vector<int64_t> mapToken(const ISearchContext &context) const {
std::vector<int64_t> result;
@@ -60,7 +63,7 @@ public:
}
return result;
}
- int64_t getToken(uint32_t docId) const {
+ TokenT getToken(uint32_t docId) const {
return attribute().getInt(docId);
}
};
@@ -71,8 +74,9 @@ template <typename T>
class AttributeFilter final : public queryeval::SearchIterator
{
private:
- typedef vespalib::hash_map<int64_t, int32_t> Map;
- typedef fef::TermFieldMatchData TFMD;
+ using Key = typename T::TokenT;
+ using Map = vespalib::hash_map<Key, int32_t, vespalib::hash<Key>, std::equal_to<Key>, vespalib::hashtable_base::and_modulator>;
+ using TFMD = fef::TermFieldMatchData;
TFMD &_tfmd;
T _attr;
@@ -93,12 +97,12 @@ public:
}
}
void and_hits_into(BitVector & result,uint32_t begin_id) override {
- Map::iterator end = _map.end();
+ typename Map::iterator end = _map.end();
result.foreach_truebit([&, end](uint32_t key) { if ( _map.find(_attr.getToken(key)) == end) { result.clearBit(key); }}, begin_id);
}
void doSeek(uint32_t docId) override {
- Map::const_iterator pos = _map.find(_attr.getToken(docId));
+ typename Map::const_iterator pos = _map.find(_attr.getToken(docId));
if (pos != _map.end()) {
_weight = pos->second;
setDocId(docId);
