summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-12-19 08:56:04 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2018-12-19 12:09:41 +0000
commit443ccdff7143a659761b0e295e8f2f2ad60715e2 (patch)
treeeba7e9194541c0de50d23e3336564db62223e3a7 /searchlib
parent6b079a1349eb8bdb3768de25cd7ae163642d7035 (diff)
Use a bitvector for the single bit numeric attribute.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/queryeval/queryeval.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/CMakeLists.txt1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/changevector.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp3
-rw-r--r--searchlib/src/vespa/searchlib/attribute/integerbase.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/multinumericattribute.h2
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp252
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singleboolattribute.h102
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.h4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp69
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h24
12 files changed, 392 insertions, 76 deletions
diff --git a/searchlib/src/tests/queryeval/queryeval.cpp b/searchlib/src/tests/queryeval/queryeval.cpp
index 28cc17a3e52..bd8252521f8 100644
--- a/searchlib/src/tests/queryeval/queryeval.cpp
+++ b/searchlib/src/tests/queryeval/queryeval.cpp
@@ -16,6 +16,7 @@
#include <vespa/searchlib/queryeval/leaf_blueprints.h>
#include <vespa/searchlib/queryeval/intermediate_blueprints.h>
#include <vespa/searchlib/attribute/singlenumericattribute.hpp>
+#include <vespa/searchlib/attribute/singleboolattribute.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/searchlib/queryeval/isourceselector.h>
#include <vespa/searchlib/fef/fef.h>
@@ -347,7 +348,7 @@ public:
return _sc->createIterator(&_tfmd, strict);
}
private:
- search::SingleValueBitNumericAttribute _a;
+ search::SingleBoolAttribute _a;
search::AttributeVector::SearchContext::UP _sc;
mutable TermFieldMatchData _tfmd;
};
diff --git a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt
index 0916ff7186d..0c2e4e49b56 100644
--- a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt
+++ b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt
@@ -93,6 +93,7 @@ vespa_add_library(searchlib_attribute OBJECT
singlenumericattributesaver.cpp
singlenumericenumattribute.cpp
singlenumericpostattribute.cpp
+ singleboolattribute.cpp
singlesmallnumericattribute.cpp
singlestringattribute.cpp
singlestringpostattribute.cpp
diff --git a/searchlib/src/vespa/searchlib/attribute/changevector.h b/searchlib/src/vespa/searchlib/attribute/changevector.h
index 91a04a2d8bd..e28f230b49a 100644
--- a/searchlib/src/vespa/searchlib/attribute/changevector.h
+++ b/searchlib/src/vespa/searchlib/attribute/changevector.h
@@ -167,6 +167,7 @@ public:
const T & back() const { return _v.back(); }
T & back() { return _v.back(); }
size_t size() const { return _v.size(); }
+ bool empty() const { return _v.empty(); }
void clear();
const_iterator begin() const { return const_iterator(_v, 0); }
const_iterator end() const { return const_iterator(_v, size()); }
diff --git a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp
index 8ea41a9dab0..7bd96b5cbb2 100644
--- a/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/createsinglestd.cpp
@@ -7,6 +7,7 @@
#include "attributevector.hpp"
#include "singlenumericattribute.hpp"
#include "singlestringattribute.h"
+#include "singleboolattribute.h"
#include <vespa/searchlib/tensor/generic_tensor_attribute.h>
#include <vespa/searchlib/tensor/dense_tensor_attribute.h>
@@ -24,7 +25,7 @@ AttributeFactory::createSingleStd(stringref name, const Config & info)
AttributeVector::SP ret;
switch(info.basicType().type()) {
case BasicType::BOOL:
- ret.reset(new SingleValueBitNumericAttribute(name, info.getGrowStrategy()));
+ ret.reset(new SingleBoolAttribute(name, info.getGrowStrategy()));
break;
case BasicType::UINT2:
ret.reset(new SingleValueSemiNibbleNumericAttribute(name, info.getGrowStrategy()));
diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.h b/searchlib/src/vespa/searchlib/attribute/integerbase.h
index 0ee2672f744..9bc1c88bc22 100644
--- a/searchlib/src/vespa/searchlib/attribute/integerbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/integerbase.h
@@ -39,7 +39,7 @@ protected:
typedef ChangeVectorT< Change > ChangeVector;
ChangeVector _changes;
- virtual MemoryUsage getChangeVectorMemoryUsage() const override;
+ MemoryUsage getChangeVectorMemoryUsage() const override;
private:
const char * getString(DocId doc, char * s, size_t sz) const override;
uint32_t get(DocId doc, vespalib::string * v, uint32_t sz) const override;
diff --git a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h
index 4b951fd7ceb..3c76e6bac46 100644
--- a/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/multinumericattribute.h
@@ -54,7 +54,7 @@ protected:
}
public:
- virtual uint32_t getRawValues(DocId doc, const WType * & values) const final override {
+ uint32_t getRawValues(DocId doc, const WType * & values) const final override {
return get(doc, values);
}
/*
diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
new file mode 100644
index 00000000000..1fa322b712e
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.cpp
@@ -0,0 +1,252 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#include "singleboolattribute.h"
+#include "attributevector.hpp"
+#include "primitivereader.h"
+#include "iattributesavetarget.h"
+#include "ipostinglistsearchcontext.h"
+#include <vespa/searchlib/query/queryterm.h>
+#include <vespa/searchlib/queryeval/emptysearch.h>
+#include <vespa/searchlib/common/bitvectoriterator.h>
+
+namespace search {
+
+using attribute::Config;
+
+SingleBoolAttribute::
+SingleBoolAttribute(const vespalib::string &baseFileName, const GrowStrategy & grow)
+ : IntegerAttributeTemplate<int8_t>(baseFileName, Config(BasicType::BOOL, CollectionType::SINGLE).setGrowStrategy(grow), BasicType::BOOL),
+ _bv(0, 0, getGenerationHolder())
+{
+}
+
+SingleBoolAttribute::~SingleBoolAttribute()
+{
+ getGenerationHolder().clearHoldLists();
+}
+
+bool
+SingleBoolAttribute::addDoc(DocId & doc) {
+ bool incGen = _bv.extend(getNumDocs() + 1);
+ incNumDocs();
+ doc = getNumDocs() - 1;
+ updateUncommittedDocIdLimit(doc);
+ if (incGen) {
+ incGeneration();
+ } else {
+ removeAllOldGenerations();
+ }
+ return true;
+}
+
+void
+SingleBoolAttribute::onCommit() {
+ checkSetMaxValueCount(1);
+
+ if ( ! _changes.empty()) {
+ // apply updates
+ ValueModifier valueGuard(getValueModifier());
+ for (const auto & change : _changes) {
+ if (change._type == ChangeBase::UPDATE) {
+ std::atomic_thread_fence(std::memory_order_release);
+ if (change._data == 0) {
+ _bv.clearBit(change._doc);
+ } else {
+ _bv.setBit(change._doc);
+ }
+ } else if ((change._type >= ChangeBase::ADD) && (change._type <= ChangeBase::DIV)) {
+ std::atomic_thread_fence(std::memory_order_release);
+ int8_t val = applyArithmetic(getFast(change._doc), change);
+ if (val == 0) {
+ _bv.clearBit(change._doc);
+ } else {
+ _bv.setBit(change._doc);
+ }
+ } else if (change._type == ChangeBase::CLEARDOC) {
+ std::atomic_thread_fence(std::memory_order_release);
+ _bv.clearBit(change._doc);
+ }
+ }
+ _bv.invalidateCachedCount();
+ }
+
+ std::atomic_thread_fence(std::memory_order_release);
+ removeAllOldGenerations();
+
+ _changes.clear();
+}
+
+void
+SingleBoolAttribute::onAddDocs(DocId docIdLimit) {
+ _bv.reserve(docIdLimit);
+}
+
+void
+SingleBoolAttribute::onUpdateStat() {
+ MemoryUsage usage;
+ usage.setAllocatedBytes(_bv.extraByteSize());
+ usage.setUsedBytes(_bv.sizeBytes());
+ usage.mergeGenerationHeldBytes(getGenerationHolder().getHeldBytes());
+ usage.merge(this->getChangeVectorMemoryUsage());
+ this->updateStatistics(_bv.size(), _bv.size(), usage.allocatedBytes(), usage.usedBytes(),
+ usage.deadBytes(), usage.allocatedBytesOnHold());
+}
+
+namespace {
+
+class BitVectorSearchContext : public AttributeVector::SearchContext, public attribute::IPostingListSearchContext
+{
+private:
+ const BitVector & _bv;
+ bool _invert;
+ bool _valid;
+ bool valid() const override { return _valid; }
+ int32_t onFind(DocId , int32_t , int32_t & ) const override {
+ assert(false);
+ return -1;
+ }
+
+ int32_t onFind(DocId , int32_t ) const override {
+ assert(false);
+ return -1;
+ }
+
+public:
+ BitVectorSearchContext(std::unique_ptr<QueryTermSimple> qTerm, const SingleBoolAttribute & bv);
+
+ std::unique_ptr<queryeval::SearchIterator>
+ createFilterIterator(fef::TermFieldMatchData * matchData, bool strict) override;
+ void fetchPostings(bool strict) override;
+ std::unique_ptr<queryeval::SearchIterator> createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) override;
+ unsigned int approximateHits() const override;
+};
+
+BitVectorSearchContext::BitVectorSearchContext(std::unique_ptr<QueryTermSimple> qTerm, const SingleBoolAttribute & attr)
+ : SearchContext(attr),
+ _bv(attr.getBitVector()),
+ _invert(false),
+ _valid(qTerm->isValid())
+{
+ if ((strcmp("1", qTerm->getTerm()) == 0) || (strcasecmp("true", qTerm->getTerm()) == 0)) {
+ } else if ((strcmp("0", qTerm->getTerm()) == 0) || (strcasecmp("false", qTerm->getTerm()) == 0)) {
+ _invert = true;
+ } else {
+ _valid = false;
+ }
+ _plsc = this;
+}
+
+std::unique_ptr<queryeval::SearchIterator>
+BitVectorSearchContext::createFilterIterator(fef::TermFieldMatchData * matchData, bool strict)
+{
+ if (!valid()) {
+ return std::make_unique<queryeval::EmptySearch>();
+ }
+ return BitVectorIterator::create(&_bv, _attr.getCommittedDocIdLimit(), *matchData, strict, _invert);
+}
+
+void
+BitVectorSearchContext::fetchPostings(bool strict) {
+ (void) strict;
+}
+
+std::unique_ptr<queryeval::SearchIterator>
+BitVectorSearchContext::createPostingIterator(fef::TermFieldMatchData *matchData, bool strict) {
+ return createFilterIterator(matchData, strict);
+}
+
+unsigned int
+BitVectorSearchContext::approximateHits() const {
+ return valid()
+ ? (_invert) ? (_bv.size() - _bv.countTrueBits()) : _bv.countTrueBits()
+ : 0;
+}
+
+}
+
+AttributeVector::SearchContext::UP
+SingleBoolAttribute::getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams &) const {
+ return std::make_unique<BitVectorSearchContext>(std::move(term), *this);
+}
+
+bool
+SingleBoolAttribute::onLoad()
+{
+ PrimitiveReader<uint32_t> attrReader(*this);
+ bool ok(attrReader.hasData());
+ if (ok) {
+ setCreateSerialNum(attrReader.getCreateSerialNum());
+ getGenerationHolder().clearHoldLists();
+ _bv.clear();
+ uint32_t numDocs = attrReader.getNextData();
+ _bv.extend(numDocs);
+ ssize_t bytesRead = attrReader.getReader().read(_bv.getStart(), _bv.sizeBytes());
+ assert(bytesRead == _bv.sizeBytes());
+ setNumDocs(numDocs);
+ setCommittedDocIdLimit(numDocs);
+ }
+
+ return ok;
+}
+
+void
+SingleBoolAttribute::onSave(IAttributeSaveTarget &saveTarget)
+{
+ assert(!saveTarget.getEnumerated());
+ const size_t numDocs(getCommittedDocIdLimit());
+ const size_t sz(sizeof(uint32_t) + _bv.sizeBytes());
+ IAttributeSaveTarget::Buffer buf(saveTarget.datWriter().allocBuf(sz));
+
+ char *p = buf->getFree();
+ const char *e = p + sz;
+ uint32_t numDocs2 = numDocs;
+ memcpy(p, &numDocs2, sizeof(uint32_t));
+ p += sizeof(uint32_t);
+ memcpy(p, _bv.getStart(), _bv.sizeBytes());
+ p += _bv.sizeBytes();
+ assert(p == e);
+ (void) e;
+ buf->moveFreeToData(sz);
+ saveTarget.datWriter().writeBuf(std::move(buf));
+ assert(numDocs == getCommittedDocIdLimit());
+}
+
+void
+SingleBoolAttribute::clearDocs(DocId lidLow, DocId lidLimit)
+{
+ assert(lidLow <= lidLimit);
+ assert(lidLimit <= getNumDocs());
+ for (DocId lid = lidLow; lid < lidLimit; ++lid) {
+ if (getFast(lid) != 0) {
+ clearDoc(lid);
+ }
+ }
+}
+
+void
+SingleBoolAttribute::onShrinkLidSpace()
+{
+ uint32_t committedDocIdLimit = getCommittedDocIdLimit();
+ assert(committedDocIdLimit < getNumDocs());
+ _bv.shrink(committedDocIdLimit);
+ setNumDocs(committedDocIdLimit);
+}
+
+uint64_t
+SingleBoolAttribute::getEstimatedSaveByteSize() const
+{
+ constexpr uint64_t headerSize = 4096 + sizeof(uint32_t);
+ return headerSize + _bv.sizeBytes();
+}
+
+void
+SingleBoolAttribute::removeOldGenerations(generation_t firstUsed) {
+ getGenerationHolder().trimHoldLists(firstUsed);
+}
+
+void
+SingleBoolAttribute::onGenerationChange(generation_t generation) {
+ getGenerationHolder().transferHoldLists(generation - 1);
+}
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h
new file mode 100644
index 00000000000..bb819e4bd0e
--- /dev/null
+++ b/searchlib/src/vespa/searchlib/attribute/singleboolattribute.h
@@ -0,0 +1,102 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+
+#pragma once
+
+#include "integerbase.h"
+#include <vespa/searchlib/common/growablebitvector.h>
+#include <limits>
+
+namespace search {
+
+class SingleBoolAttribute : public IntegerAttributeTemplate<int8_t>
+{
+public:
+ SingleBoolAttribute(const vespalib::string & baseFileName, const search::GrowStrategy & grow);
+ ~SingleBoolAttribute() override;
+
+ void onCommit() override;
+ bool addDoc(DocId & doc) override;
+ void onAddDocs(DocId docIdLimit) override;
+ void onUpdateStat() override;
+ bool onLoad() override;
+ void onSave(IAttributeSaveTarget &saveTarget) override;
+ void clearDocs(DocId lidLow, DocId lidLimit) override;
+ void onShrinkLidSpace() override;
+ void removeOldGenerations(generation_t firstUsed) override;
+ void onGenerationChange(generation_t generation) override;
+ uint64_t getEstimatedSaveByteSize() const override;
+
+ SearchContext::UP
+ getSearch(std::unique_ptr<QueryTermSimple> term, const attribute::SearchContextParams & params) const override;
+
+ uint32_t getValueCount(DocId doc) const override {
+ return (doc >= _bv.size()) ? 0 : 1;
+ }
+ largeint_t getInt(DocId doc) const override {
+ return static_cast<largeint_t>(getFast(doc));
+ }
+ double getFloat(DocId doc) const override {
+ return static_cast<double>(getFast(doc));
+ }
+ uint32_t getEnum(DocId) const override {
+ return std::numeric_limits<uint32_t>::max(); // does not have enum
+ }
+ uint32_t getAll(DocId doc, int8_t * v, uint32_t sz) const override {
+ if (sz > 0) {
+ v[0] = getFast(doc);
+ }
+ return 1;
+ }
+ uint32_t get(DocId doc, largeint_t * v, uint32_t sz) const override {
+ if (sz > 0) {
+ v[0] = static_cast<largeint_t>(getFast(doc));
+ }
+ return 1;
+ }
+ uint32_t get(DocId doc, double * v, uint32_t sz) const override {
+ if (sz > 0) {
+ v[0] = static_cast<double>(getFast(doc));
+ }
+ return 1;
+ }
+ uint32_t get(DocId doc, EnumHandle * e, uint32_t sz) const override {
+ if (sz > 0) {
+ e[0] = getEnum(doc);
+ }
+ return 1;
+ }
+ uint32_t getAll(DocId, Weighted *, uint32_t) const override { return 0; }
+ uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override {
+ if (sz > 0) {
+ v[0] = WeightedInt(static_cast<largeint_t>(getFast(doc)));
+ }
+ return 1;
+ }
+ uint32_t get(DocId doc, WeightedFloat * v, uint32_t sz) const override {
+ if (sz > 0) {
+ v[0] = WeightedFloat(static_cast<double>(getFast(doc)));
+ }
+ return 1;
+ }
+ uint32_t get(DocId, WeightedEnum *, uint32_t) const override {
+ return 0;
+ }
+ int8_t get(DocId doc) const override {
+ return getFast(doc);
+ }
+ const BitVector & getBitVector() const { return _bv; }
+protected:
+ bool findEnum(int8_t, EnumHandle &) const override {
+ return false;
+ }
+private:
+ int8_t getFromEnum(EnumHandle) const override {
+ return 0;
+ }
+ int8_t getFast(DocId doc) const {
+ return _bv.testBit(doc) ? 1 : 0;
+ }
+ GrowableBitVector _bv;
+};
+
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp
index 92b2dc1dde1..db8636f47c3 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.cpp
@@ -30,9 +30,8 @@ SingleValueNumericAttributeSaver(const attribute::AttributeHeader &header,
}
-SingleValueNumericAttributeSaver::~SingleValueNumericAttributeSaver()
-{
-}
+SingleValueNumericAttributeSaver::~SingleValueNumericAttributeSaver() = default;
+
bool
diff --git a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.h b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.h
index 4ccc6595454..3205f88b1eb 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlenumericattributesaver.h
@@ -20,12 +20,12 @@ private:
Buffer _buf;
using BufferBuf = IAttributeFileWriter::BufferBuf;
- virtual bool onSave(IAttributeSaveTarget &saveTarget) override;
+ bool onSave(IAttributeSaveTarget &saveTarget) override;
public:
SingleValueNumericAttributeSaver(const attribute::AttributeHeader &header,
const void *data, size_t size);
- virtual ~SingleValueNumericAttributeSaver();
+ ~SingleValueNumericAttributeSaver() override;
};
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
index 2d6e1e57806..96c4565657a 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.cpp
@@ -4,11 +4,8 @@
#include "attributevector.hpp"
#include "primitivereader.h"
#include "attributeiterators.hpp"
-#include <vespa/searchlib/queryeval/emptysearch.h>
#include "iattributesavetarget.h"
-
-#include <vespa/log/log.h>
-LOG_SETUP(".searchlib.attribute.single_small_numeric_attribute");
+#include <vespa/searchlib/queryeval/emptysearch.h>
namespace search {
@@ -30,8 +27,7 @@ SingleValueSmallNumericAttribute(const vespalib::string & baseFileName,
getGenerationHolder())
{
assert(_valueMask + 1 == (1u << (1u << valueShiftShift)));
- assert((_valueShiftMask + 1) * (1u << valueShiftShift) ==
- 8 * sizeof(Word));
+ assert((_valueShiftMask + 1) * (1u << valueShiftShift) == 8 * sizeof(Word));
assert(_valueShiftMask + 1 == (1u << wordShift));
}
@@ -58,8 +54,7 @@ SingleValueSmallNumericAttribute::onCommit()
if (change._type == ChangeBase::UPDATE) {
std::atomic_thread_fence(std::memory_order_release);
set(change._doc, change._data);
- } else if (change._type >= ChangeBase::ADD &&
- change._type <= ChangeBase::DIV) {
+ } else if (change._type >= ChangeBase::ADD && change._type <= ChangeBase::DIV) {
std::atomic_thread_fence(std::memory_order_release);
set(change._doc, applyArithmetic(getFast(change._doc), change));
} else if (change._type == ChangeBase::CLEARDOC) {
@@ -169,16 +164,13 @@ SingleValueSmallNumericAttribute::onSave(IAttributeSaveTarget &saveTarget)
assert(numDocs == getCommittedDocIdLimit());
}
-
AttributeVector::SearchContext::UP
SingleValueSmallNumericAttribute::getSearch(std::unique_ptr<QueryTermSimple> qTerm,
- const attribute::SearchContextParams & params) const
+ const attribute::SearchContextParams &) const
{
- (void) params;
- return SearchContext::UP(new SingleSearchContext(std::move(qTerm), *this));
+ return std::make_unique<SingleSearchContext>(std::move(qTerm), *this);
}
-
void
SingleValueSmallNumericAttribute::clearDocs(DocId lidLow, DocId lidLimit)
{
@@ -191,7 +183,6 @@ SingleValueSmallNumericAttribute::clearDocs(DocId lidLow, DocId lidLimit)
}
}
-
void
SingleValueSmallNumericAttribute::onShrinkLidSpace()
{
@@ -203,7 +194,6 @@ SingleValueSmallNumericAttribute::onShrinkLidSpace()
setNumDocs(committedDocIdLimit);
}
-
uint64_t
SingleValueSmallNumericAttribute::getEstimatedSaveByteSize() const
{
@@ -218,13 +208,13 @@ bool SingleValueSmallNumericAttribute::SingleSearchContext::valid() const { retu
SingleValueSmallNumericAttribute::SingleSearchContext::SingleSearchContext(std::unique_ptr<QueryTermSimple> qTerm,
- const NumericAttribute & toBeSearched)
+ const SingleValueSmallNumericAttribute & toBeSearched)
: NumericAttribute::Range<T>(*qTerm),
- SearchContext(toBeSearched), _wordData(&static_cast<const SingleValueSmallNumericAttribute &>(toBeSearched)._wordData[0]),
- _valueMask(static_cast<const SingleValueSmallNumericAttribute &>(toBeSearched)._valueMask),
- _valueShiftShift(static_cast<const SingleValueSmallNumericAttribute &>(toBeSearched)._valueShiftShift),
- _valueShiftMask(static_cast<const SingleValueSmallNumericAttribute &>(toBeSearched)._valueShiftMask),
- _wordShift(static_cast<const SingleValueSmallNumericAttribute &>(toBeSearched)._wordShift)
+ SearchContext(toBeSearched), _wordData(&toBeSearched._wordData[0]),
+ _valueMask(toBeSearched._valueMask),
+ _valueShiftShift(toBeSearched._valueShiftShift),
+ _valueShiftMask(toBeSearched._valueShiftMask),
+ _wordShift(toBeSearched._wordShift)
{ }
Int64Range
@@ -233,26 +223,22 @@ SingleValueSmallNumericAttribute::SingleSearchContext::getAsIntegerTerm() const
}
std::unique_ptr<queryeval::SearchIterator>
-SingleValueSmallNumericAttribute::SingleSearchContext::createFilterIterator(fef::TermFieldMatchData * matchData,
- bool strict)
+SingleValueSmallNumericAttribute::SingleSearchContext::createFilterIterator(fef::TermFieldMatchData * matchData, bool strict)
{
if (!valid()) {
- return queryeval::SearchIterator::UP(new queryeval::EmptySearch());
+ return std::make_unique<queryeval::EmptySearch>();
}
if (getIsFilter()) {
- return queryeval::SearchIterator::UP
- (strict
- ? new FilterAttributeIteratorStrict<SingleSearchContext>(*this, matchData)
- : new FilterAttributeIteratorT<SingleSearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<FilterAttributeIteratorStrict<SingleSearchContext>>(*this, matchData)
+ : std::make_unique<FilterAttributeIteratorT<SingleSearchContext>>(*this, matchData);
}
- return queryeval::SearchIterator::UP
- (strict
- ? new AttributeIteratorStrict<SingleSearchContext>(*this, matchData)
- : new AttributeIteratorT<SingleSearchContext>(*this, matchData));
+ return strict
+ ? std::make_unique<AttributeIteratorStrict<SingleSearchContext>>(*this, matchData)
+ : std::make_unique<AttributeIteratorT<SingleSearchContext>>(*this, matchData);
}
-namespace
-{
+namespace {
template <typename TT>
uint32_t
@@ -281,18 +267,6 @@ createConfig(BasicType bt, CollectionType ct, const GrowStrategy & grow) {
}
-SingleValueBitNumericAttribute::
-SingleValueBitNumericAttribute(const vespalib::string &baseFileName, const GrowStrategy & grow)
- : SingleValueSmallNumericAttribute(baseFileName,
- createConfig(BasicType::BOOL, CollectionType::SINGLE, grow),
- 0x01u /* valueMask */,
- 0x00u /* valueShiftShift */,
- 8 * sizeof(Word) - 1 /* valueShiftMask */,
- log2bits<Word>() /* wordShift */)
-{
-}
-
-
SingleValueSemiNibbleNumericAttribute::
SingleValueSemiNibbleNumericAttribute(const vespalib::string &baseFileName, const search::GrowStrategy & grow)
: SingleValueSmallNumericAttribute(baseFileName,
@@ -308,7 +282,7 @@ SingleValueSemiNibbleNumericAttribute(const vespalib::string &baseFileName, cons
SingleValueNibbleNumericAttribute::
SingleValueNibbleNumericAttribute(const vespalib::string &baseFileName, const search::GrowStrategy & grow)
: SingleValueSmallNumericAttribute(baseFileName,
- createConfig(BasicType::BOOL, CollectionType::SINGLE, grow),
+ createConfig(BasicType::UINT4, CollectionType::SINGLE, grow),
0x0fu /* valueMask */,
0x02u /* valueShiftShift */,
2 * sizeof(Word) - 1 /* valueShiftMask */,
@@ -316,5 +290,4 @@ SingleValueNibbleNumericAttribute(const vespalib::string &baseFileName, const se
{
}
-
}
diff --git a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h
index d5b65da08fa..5029a632ea1 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h
+++ b/searchlib/src/vespa/searchlib/attribute/singlesmallnumericattribute.h
@@ -35,14 +35,12 @@ private:
typedef search::attribute::RcuVectorBase<Word> DataVector;
DataVector _wordData;
- T getFromEnum(EnumHandle e) const override {
- (void) e;
+ T getFromEnum(EnumHandle) const override {
return T();
}
protected:
- bool findEnum(T value, EnumHandle & e) const override {
- (void) value; (void) e;
+ bool findEnum(T, EnumHandle &) const override {
return false;
}
@@ -78,7 +76,7 @@ public:
bool valid() const override;
public:
- SingleSearchContext(std::unique_ptr<QueryTermSimple> qTerm, const NumericAttribute & toBeSearched);
+ SingleSearchContext(std::unique_ptr<QueryTermSimple> qTerm, const SingleValueSmallNumericAttribute & toBeSearched);
int32_t find(DocId docId, int32_t elemId, int32_t & weight) const {
if ( elemId != 0) return -1;
@@ -144,8 +142,7 @@ public:
double getFloat(DocId doc) const override {
return static_cast<double>(getFast(doc));
}
- uint32_t getEnum(DocId doc) const override {
- (void) doc;
+ uint32_t getEnum(DocId) const override {
return std::numeric_limits<uint32_t>::max(); // does not have enum
}
uint32_t getAll(DocId doc, T * v, uint32_t sz) const override {
@@ -172,10 +169,7 @@ public:
}
return 1;
}
- uint32_t getAll(DocId doc, Weighted * v, uint32_t sz) const override {
- (void) doc; (void) v; (void) sz;
- return 0;
- }
+ uint32_t getAll(DocId, Weighted *, uint32_t) const override { return 0; }
uint32_t get(DocId doc, WeightedInt * v, uint32_t sz) const override {
if (sz > 0) {
v[0] = WeightedInt(static_cast<largeint_t>(getFast(doc)));
@@ -198,14 +192,6 @@ public:
uint64_t getEstimatedSaveByteSize() const override;
};
-
-class SingleValueBitNumericAttribute : public SingleValueSmallNumericAttribute
-{
-public:
- SingleValueBitNumericAttribute(const vespalib::string & baseFileName, const search::GrowStrategy & grow);
-};
-
-
class SingleValueSemiNibbleNumericAttribute : public SingleValueSmallNumericAttribute
{
public: