blob: 3fe2424b97dd5e470a42ffbb9ffdfcba91252c1a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include "multinumericattribute.h"
namespace search {
typedef MultiValueNumericAttribute< IntegerAttributeTemplate<int8_t>, multivalue::Value<int8_t> > FlagBaseImpl;
typedef MultiValueNumericAttribute< IntegerAttributeTemplate<int8_t>, multivalue::Value<int8_t> > HugeFlagBaseImpl;
template <typename B>
class FlagAttributeT : public B {
public:
FlagAttributeT(const vespalib::string & baseFileName, const AttributeVector::Config & cfg);
private:
typedef AttributeVector::DocId DocId;
typedef FlagBaseImpl::ArraySearchContext BaseSC;
class SearchContext : public BaseSC {
public:
typedef FlagAttributeT<B> Attribute;
SearchContext(std::unique_ptr<QueryTermSimple> qTerm, const FlagAttributeT<B> & toBeSearched);
std::unique_ptr<queryeval::SearchIterator>
createIterator(fef::TermFieldMatchData * matchData, bool strict) override;
private:
bool _zeroHits;
template <class SC> friend class FlagAttributeIteratorT;
template <class SC> friend class FlagAttributeIteratorStrict;
};
bool onLoad() override;
bool onLoadEnumerated(ReaderBase &attrReader) override;
AttributeVector::SearchContext::UP
getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams & params) const override;
void clearOldValues(DocId doc) override;
void setNewValues(DocId doc, const std::vector<typename B::WType> & values) override;
public:
void setNewBVValue(DocId doc, typename B::WType::ValueType value);
private:
bool onAddDoc(DocId doc) override;
void onAddDocs(DocId docIdLimit) override;
void ensureGuardBit(BitVector & bv);
void ensureGuardBit();
void clearGuardBit(DocId doc);
void resizeBitVectors(uint32_t neededSize);
void removeOldGenerations(vespalib::GenerationHandler::generation_t firstUsed) override;
uint32_t getOffset(int8_t value) const { return value + 128; }
BitVector * getBitVector(typename B::BaseType value) const {
return _bitVectors[value + 128];
}
vespalib::GenerationHolder _bitVectorHolder;
std::vector<std::shared_ptr<BitVector> > _bitVectorStore;
std::vector<BitVector *> _bitVectors;
uint32_t _bitVectorSize;
template <class SC> friend class FlagAttributeIteratorT;
template <class SC> friend class FlagAttributeIteratorStrict;
};
typedef FlagAttributeT<FlagBaseImpl> FlagAttribute;
typedef FlagAttributeT<HugeFlagBaseImpl> HugeFlagAttribute;
} // namespace search
|