aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2018-12-18 11:06:10 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2018-12-18 11:06:10 +0000
commitdecb935acf29d72c447d4179dc03b149fe613ba3 (patch)
tree550604b13ec1c53805235353494188c4706b86d6 /searchlib
parent94a80f1c8e036b28dd84b98cae21465824b365ce (diff)
Return information if a buffer is held.
Use std::make_unique. Minor unifying cleanup.
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/common/bitvector/bitvector_test.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/integerbase.h4
-rw-r--r--searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h11
-rw-r--r--searchlib/src/vespa/searchlib/attribute/primitivereader.h1
-rw-r--r--searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp5
-rw-r--r--searchlib/src/vespa/searchlib/common/growablebitvector.cpp22
-rw-r--r--searchlib/src/vespa/searchlib/common/growablebitvector.h14
7 files changed, 33 insertions, 36 deletions
diff --git a/searchlib/src/tests/common/bitvector/bitvector_test.cpp b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
index c1170869c26..ea70806aec2 100644
--- a/searchlib/src/tests/common/bitvector/bitvector_test.cpp
+++ b/searchlib/src/tests/common/bitvector/bitvector_test.cpp
@@ -555,33 +555,33 @@ TEST("requireThatGrowWorks")
v.invalidateCachedCount();
EXPECT_TRUE(assertBV("[7,39,71,103]", v));
EXPECT_EQUAL(4u, v.countTrueBits());
- v.reserve(204);
+ EXPECT_TRUE(v.reserve(204));
EXPECT_EQUAL(200u, v.size());
EXPECT_EQUAL(204u, v.capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v));
EXPECT_EQUAL(4u, v.countTrueBits());
- v.extend(202);
+ EXPECT_FALSE(v.extend(202));
EXPECT_EQUAL(202u, v.size());
EXPECT_EQUAL(204u, v.capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v));
EXPECT_EQUAL(4u, v.countTrueBits());
- v.shrink(200);
+ EXPECT_FALSE(v.shrink(200));
EXPECT_EQUAL(200u, v.size());
EXPECT_EQUAL(204u, v.capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v));
EXPECT_EQUAL(4u, v.countTrueBits());
- v.reserve(204);
+ EXPECT_FALSE(v.reserve(204));
EXPECT_EQUAL(200u, v.size());
EXPECT_EQUAL(204u, v.capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v));
EXPECT_EQUAL(4u, v.countTrueBits());
- v.shrink(202);
+ EXPECT_FALSE(v.shrink(202));
EXPECT_EQUAL(202u, v.size());
EXPECT_EQUAL(204u, v.capacity());
EXPECT_TRUE(assertBV("[7,39,71,103]", v));
EXPECT_EQUAL(4u, v.countTrueBits());
- v.shrink(100);
+ EXPECT_FALSE(v.shrink(100));
EXPECT_EQUAL(100u, v.size());
EXPECT_EQUAL(204u, v.capacity());
EXPECT_TRUE(assertBV("[7,39,71]", v));
diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.h b/searchlib/src/vespa/searchlib/attribute/integerbase.h
index c3299d9fdf7..0ee2672f744 100644
--- a/searchlib/src/vespa/searchlib/attribute/integerbase.h
+++ b/searchlib/src/vespa/searchlib/attribute/integerbase.h
@@ -78,9 +78,7 @@ protected:
{
assert(c.basicType() == BasicType::fromType(T()));
}
- IntegerAttributeTemplate(const vespalib::string & name,
- const Config & c,
- const BasicType &realType)
+ IntegerAttributeTemplate(const vespalib::string & name, const Config & c, const BasicType &realType)
: IntegerAttribute(name, c),
_defaultValue(ChangeBase::UPDATE, 0, 0u)
{
diff --git a/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h
index e779e41bb90..097cc35d8cb 100644
--- a/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h
+++ b/searchlib/src/vespa/searchlib/attribute/ipostinglistsearchcontext.h
@@ -4,12 +4,10 @@
#include <memory>
-namespace search {
+namespace search::queryeval { class SearchIterator; }
+namespace search::fef { class TermFieldMatchData; }
-namespace queryeval { class SearchIterator; }
-namespace fef { class TermFieldMatchData; }
-
-namespace attribute {
+namespace search::attribute {
/**
@@ -32,5 +30,4 @@ public:
virtual unsigned int approximateHits() const = 0;
};
-} // namespace attribute
-} // namespace search
+}
diff --git a/searchlib/src/vespa/searchlib/attribute/primitivereader.h b/searchlib/src/vespa/searchlib/attribute/primitivereader.h
index 97a29494623..cf8821526d0 100644
--- a/searchlib/src/vespa/searchlib/attribute/primitivereader.h
+++ b/searchlib/src/vespa/searchlib/attribute/primitivereader.h
@@ -19,6 +19,7 @@ namespace search {
virtual ~PrimitiveReader() { }
T getNextData() { return _datReader.readHostOrder(); }
size_t getDataCount() const { return getDataCountHelper(sizeof(T)); }
+ FileReader<T> & getReader() { return _datReader; }
private:
FileReader<T> _datReader;
};
diff --git a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
index 4f028e1a478..0842d91c174 100644
--- a/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/singlestringattribute.hpp
@@ -25,7 +25,7 @@ SingleValueStringAttributeT(const vespalib::string &name,
{ }
template <typename B>
-SingleValueStringAttributeT<B>::~SingleValueStringAttributeT() { }
+SingleValueStringAttributeT<B>::~SingleValueStringAttributeT() = default;
template <typename B>
void
@@ -39,8 +39,7 @@ AttributeVector::SearchContext::UP
SingleValueStringAttributeT<B>::getSearch(QueryTermSimpleUP qTerm,
const attribute::SearchContextParams &) const
{
- return std::unique_ptr<AttributeVector::SearchContext>
- (new StringTemplSearchContext(std::move(qTerm), *this));
+ return std::make_unique<StringTemplSearchContext>(std::move(qTerm), *this);
}
template <typename B>
diff --git a/searchlib/src/vespa/searchlib/common/growablebitvector.cpp b/searchlib/src/vespa/searchlib/common/growablebitvector.cpp
index 41c99a41ce9..5062bb78e79 100644
--- a/searchlib/src/vespa/searchlib/common/growablebitvector.cpp
+++ b/searchlib/src/vespa/searchlib/common/growablebitvector.cpp
@@ -8,8 +8,7 @@ namespace search {
using vespalib::GenerationHeldBase;
using vespalib::GenerationHolder;
-GrowableBitVector::GrowableBitVector(Index newSize,
- Index newCapacity,
+GrowableBitVector::GrowableBitVector(Index newSize, Index newCapacity,
GenerationHolder &generationHolder)
: AllocatedBitVector(newSize, newCapacity, nullptr, 0),
_generationHolder(generationHolder)
@@ -17,36 +16,39 @@ GrowableBitVector::GrowableBitVector(Index newSize,
assert(newSize <= newCapacity);
}
-void
+bool
GrowableBitVector::reserve(Index newCapacity)
{
Index oldCapacity = capacity();
assert(newCapacity >= oldCapacity);
if (newCapacity == oldCapacity)
- return;
- hold(grow(size(), newCapacity));
+ return false;
+ return hold(grow(size(), newCapacity));
}
-void GrowableBitVector::hold(GenerationHeldBase::UP v)
+bool
+GrowableBitVector::hold(GenerationHeldBase::UP v)
{
if (v) {
_generationHolder.hold(std::move(v));
+ return true;
}
+ return false;
}
-void
+bool
GrowableBitVector::shrink(Index newCapacity)
{
Index oldCapacity = capacity();
assert(newCapacity <= oldCapacity);
(void) oldCapacity;
- hold(grow(newCapacity, std::max(capacity(), newCapacity)));
+ return hold(grow(newCapacity, std::max(capacity(), newCapacity)));
}
-void
+bool
GrowableBitVector::extend(Index newCapacity)
{
- hold(grow(newCapacity, std::max(capacity(), newCapacity)));
+ return hold(grow(newCapacity, std::max(capacity(), newCapacity)));
}
} // namespace search
diff --git a/searchlib/src/vespa/searchlib/common/growablebitvector.h b/searchlib/src/vespa/searchlib/common/growablebitvector.h
index 1c5cd31b235..ff5d878063d 100644
--- a/searchlib/src/vespa/searchlib/common/growablebitvector.h
+++ b/searchlib/src/vespa/searchlib/common/growablebitvector.h
@@ -2,22 +2,22 @@
#pragma once
-#include <vespa/searchlib/common/allocatedbitvector.h>
+#include "allocatedbitvector.h"
namespace search {
class GrowableBitVector : public AllocatedBitVector
{
public:
- GrowableBitVector(Index newSize,
- Index newCapacity,
+ GrowableBitVector(Index newSize, Index newCapacity,
GenerationHolder &generationHolder);
- void reserve(Index newCapacity);
- void shrink(Index newCapacity);
- void extend(Index newCapacity);
+ /** Will return true if a a buffer is held */
+ bool reserve(Index newCapacity);
+ bool shrink(Index newCapacity);
+ bool extend(Index newCapacity);
private:
- VESPA_DLL_LOCAL void hold(GenerationHeldBase::UP v);
+ VESPA_DLL_LOCAL bool hold(GenerationHeldBase::UP v);
GenerationHolder &_generationHolder;
};