aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-05-23 17:09:11 +0200
committerGitHub <noreply@github.com>2023-05-23 17:09:11 +0200
commit5113dccbb084ef043d867e1b219f9593ea5fe579 (patch)
treed9ac4e3f235646dfba3b8a13418a55d8c65554a1 /searchlib
parentdeb431d5e0d1b4ce0799137bdb6e98f6e920f059 (diff)
parent3df6866688b9dd446dafd06e954c660b714a2e09 (diff)
Merge pull request #27185 from vespa-engine/balder/inline-small-frequently-called-methods
Balder/inline small frequently called methods
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp11
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp12
-rw-r--r--searchlib/src/vespa/searchlib/attribute/enumcomparator.h8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp24
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h19
-rw-r--r--searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp5
-rw-r--r--searchlib/src/vespa/searchlib/attribute/search_context.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/attribute/search_context.h7
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_index.cpp2
-rw-r--r--searchlib/src/vespa/searchlib/util/rawbuf.cpp60
-rw-r--r--searchlib/src/vespa/searchlib/util/rawbuf.h39
11 files changed, 66 insertions, 129 deletions
diff --git a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp
index 75e0a82ff1d..4b8916273e7 100644
--- a/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/bitvector_search_cache.cpp
@@ -8,15 +8,8 @@ namespace search::attribute {
using BitVectorSP = BitVectorSearchCache::BitVectorSP;
-BitVectorSearchCache::BitVectorSearchCache()
- : _mutex(),
- _cache()
-{
-}
-
-BitVectorSearchCache::~BitVectorSearchCache()
-{
-}
+BitVectorSearchCache::BitVectorSearchCache() = default;
+BitVectorSearchCache::~BitVectorSearchCache() = default;
void
BitVectorSearchCache::insert(const vespalib::string &term, Entry::SP entry)
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
index 0f52b64ede0..5a5702f50e8 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.cpp
@@ -6,18 +6,6 @@
namespace search {
template <typename EntryT>
-EnumStoreComparator<EntryT>::EnumStoreComparator(const DataStoreType& data_store, const EntryT& fallback_value)
- : ParentType(data_store, fallback_value)
-{
-}
-
-template <typename EntryT>
-EnumStoreComparator<EntryT>::EnumStoreComparator(const DataStoreType& data_store)
- : ParentType(data_store)
-{
-}
-
-template <typename EntryT>
bool
EnumStoreComparator<EntryT>::equal_helper(const EntryT& lhs, const EntryT& rhs)
{
diff --git a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
index 5df85cd1c57..546ac82e389 100644
--- a/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
+++ b/searchlib/src/vespa/searchlib/attribute/enumcomparator.h
@@ -18,8 +18,12 @@ public:
using ParentType = vespalib::datastore::UniqueStoreComparator<EntryT, IEnumStore::InternalIndex>;
using DataStoreType = typename ParentType::DataStoreType;
- EnumStoreComparator(const DataStoreType& data_store, const EntryT& fallback_value);
- EnumStoreComparator(const DataStoreType& data_store);
+ EnumStoreComparator(const DataStoreType& data_store, const EntryT& fallback_value)
+ : ParentType(data_store, fallback_value)
+ {}
+ EnumStoreComparator(const DataStoreType& data_store)
+ : ParentType(data_store)
+ {}
static bool equal_helper(const EntryT& lhs, const EntryT& rhs);
};
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
index 0c34ae6e330..12c887eb407 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.cpp
@@ -10,28 +10,24 @@ namespace search::attribute {
using vespalib::btree::BTreeNode;
PostingListSearchContext::
-PostingListSearchContext(const IEnumStoreDictionary& dictionary,
- uint32_t docIdLimit,
- uint64_t numValues,
- bool hasWeight,
- bool useBitVector,
- const ISearchContext &baseSearchCtx)
+PostingListSearchContext(const IEnumStoreDictionary& dictionary, bool has_btree_dictionary, uint32_t docIdLimit,
+ uint64_t numValues, bool hasWeight, bool useBitVector, const ISearchContext &baseSearchCtx)
: _dictionary(dictionary),
- _frozenDictionary(_dictionary.get_has_btree_dictionary() ? _dictionary.get_posting_dictionary().getFrozenView() : FrozenDictionary()),
- _lowerDictItr(_dictionary.get_has_btree_dictionary() ? DictionaryConstIterator(BTreeNode::Ref(), _frozenDictionary.getAllocator()) : DictionaryConstIterator()),
- _upperDictItr(_dictionary.get_has_btree_dictionary() ? DictionaryConstIterator(BTreeNode::Ref(), _frozenDictionary.getAllocator()) : DictionaryConstIterator()),
+ _baseSearchCtx(baseSearchCtx),
+ _bv(nullptr),
+ _frozenDictionary(has_btree_dictionary ? _dictionary.get_posting_dictionary().getFrozenView() : FrozenDictionary()),
+ _lowerDictItr(has_btree_dictionary ? DictionaryConstIterator(BTreeNode::Ref(), _frozenDictionary.getAllocator()) : DictionaryConstIterator()),
+ _upperDictItr(has_btree_dictionary ? DictionaryConstIterator(BTreeNode::Ref(), _frozenDictionary.getAllocator()) : DictionaryConstIterator()),
+ _numValues(numValues),
_uniqueValues(0u),
_docIdLimit(docIdLimit),
_dictSize(_frozenDictionary.size()),
- _numValues(numValues),
- _hasWeight(hasWeight),
- _useBitVector(useBitVector),
_pidx(),
_frozenRoot(),
_FSTC(0.0),
_PLSTC(0.0),
- _bv(nullptr),
- _baseSearchCtx(baseSearchCtx)
+ _hasWeight(hasWeight),
+ _useBitVector(useBitVector)
{
}
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
index d0a8958f615..107abd24069 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.h
@@ -32,26 +32,25 @@ protected:
using FrozenDictionary = Dictionary::FrozenView;
using EnumIndex = IEnumStore::Index;
- const IEnumStoreDictionary& _dictionary;
- const FrozenDictionary _frozenDictionary;
+ const IEnumStoreDictionary & _dictionary;
+ const ISearchContext &_baseSearchCtx;
+ const BitVector *_bv; // bitvector if _useBitVector has been set
+ const FrozenDictionary _frozenDictionary;
DictionaryConstIterator _lowerDictItr;
DictionaryConstIterator _upperDictItr;
+ uint64_t _numValues; // attr.getStatus().getNumValues();
uint32_t _uniqueValues;
uint32_t _docIdLimit;
uint32_t _dictSize;
- uint64_t _numValues; // attr.getStatus().getNumValues();
- bool _hasWeight;
- bool _useBitVector;
vespalib::datastore::EntryRef _pidx;
vespalib::datastore::EntryRef _frozenRoot; // Posting list in tree form
float _FSTC; // Filtering Search Time Constant
float _PLSTC; // Posting List Search Time Constant
- const BitVector *_bv; // bitvector if _useBitVector has been set
- const ISearchContext &_baseSearchCtx;
-
+ bool _hasWeight;
+ bool _useBitVector;
- PostingListSearchContext(const IEnumStoreDictionary& dictionary, uint32_t docIdLimit, uint64_t numValues, bool hasWeight,
- bool useBitVector, const ISearchContext &baseSearchCtx);
+ PostingListSearchContext(const IEnumStoreDictionary& dictionary, bool has_btree_dictionary, uint32_t docIdLimit,
+ uint64_t numValues, bool hasWeight, bool useBitVector, const ISearchContext &baseSearchCtx);
~PostingListSearchContext() override;
diff --git a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
index 98f89f9080f..d32d8cde7ea 100644
--- a/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
+++ b/searchlib/src/vespa/searchlib/attribute/postinglistsearchcontext.hpp
@@ -22,9 +22,8 @@ namespace search::attribute {
template <typename DataT>
PostingListSearchContextT<DataT>::
PostingListSearchContextT(const IEnumStoreDictionary& dictionary, uint32_t docIdLimit, uint64_t numValues, bool hasWeight,
- const PostingList &postingList,
- bool useBitVector, const ISearchContext &searchContext)
- : PostingListSearchContext(dictionary, docIdLimit, numValues, hasWeight, useBitVector, searchContext),
+ const PostingList &postingList, bool useBitVector, const ISearchContext &searchContext)
+ : PostingListSearchContext(dictionary, dictionary.get_has_btree_dictionary(), docIdLimit, numValues, hasWeight, useBitVector, searchContext),
_postingList(postingList),
_merger(docIdLimit)
{
diff --git a/searchlib/src/vespa/searchlib/attribute/search_context.cpp b/searchlib/src/vespa/searchlib/attribute/search_context.cpp
index a0345ddce70..a0208ab787e 100644
--- a/searchlib/src/vespa/searchlib/attribute/search_context.cpp
+++ b/searchlib/src/vespa/searchlib/attribute/search_context.cpp
@@ -10,14 +10,6 @@ using search::queryeval::SearchIterator;
namespace search::attribute {
-SearchContext::SearchContext(const AttributeVector &attr) noexcept
- : _attr(attr),
- _plsc(nullptr)
-{
-}
-
-SearchContext::~SearchContext() = default;
-
unsigned int
SearchContext::approximateHits() const
{
diff --git a/searchlib/src/vespa/searchlib/attribute/search_context.h b/searchlib/src/vespa/searchlib/attribute/search_context.h
index 025b0fdf113..cc55beee216 100644
--- a/searchlib/src/vespa/searchlib/attribute/search_context.h
+++ b/searchlib/src/vespa/searchlib/attribute/search_context.h
@@ -30,7 +30,7 @@ public:
SearchContext(SearchContext&&) noexcept = default;
SearchContext& operator=(const SearchContext&) = delete;
SearchContext& operator=(SearchContext&&) noexcept = delete;
- ~SearchContext() override;
+ ~SearchContext() override = default;
unsigned int approximateHits() const override;
std::unique_ptr<queryeval::SearchIterator> createIterator(fef::TermFieldMatchData* matchData, bool strict) override;
@@ -47,7 +47,10 @@ public:
const AttributeVector& attribute() const { return _attr; }
protected:
- SearchContext(const AttributeVector& attr) noexcept;
+ SearchContext(const AttributeVector& attr) noexcept
+ : _attr(attr),
+ _plsc(nullptr)
+ {}
const AttributeVector& _attr;
attribute::IPostingListSearchContext* _plsc;
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp
index 093052608c5..199e9a4b8a0 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_index.cpp
@@ -97,7 +97,7 @@ FieldIndex<interleaved_features>::findFrozen(const vespalib::stringref word) con
if (itr.valid()) {
return _postingListStore.beginFrozen(itr.getData().load_acquire());
}
- return typename PostingList::Iterator();
+ return typename PostingList::ConstIterator();
}
template <bool interleaved_features>
diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.cpp b/searchlib/src/vespa/searchlib/util/rawbuf.cpp
index 04d69544047..3af29d7eed5 100644
--- a/searchlib/src/vespa/searchlib/util/rawbuf.cpp
+++ b/searchlib/src/vespa/searchlib/util/rawbuf.cpp
@@ -1,32 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "rawbuf.h"
-#include <vespa/vespalib/util/compress.h>
#include <cassert>
-#include <cstring>
#include <cstdlib>
namespace search {
-RawBuf::RawBuf(size_t size)
- : _bufStart(nullptr),
- _bufEnd(nullptr),
- _bufFillPos(nullptr),
- _bufDrainPos(nullptr)
-{
- if (size > 0) {
- _bufStart = static_cast<char *>(malloc(size));
- }
- _bufEnd = _bufStart + size;
- _bufDrainPos = _bufFillPos = _bufStart;
-}
-
-RawBuf::~RawBuf()
-{
- free(_bufStart);
-}
-
-
/**
* Allocate a new buffer at least as large as the parameter value,
* move any content to the new and delete the old buffer.
@@ -50,45 +29,6 @@ RawBuf::expandBuf(size_t needlen)
_bufEnd = _bufStart + size;
}
-
-/**
- * Put 'data' of 'len'gth into the buffer. If insufficient room,
- * make the buffer larger.
- */
-void
-RawBuf::append(const void *data, size_t len)
-{
- if (__builtin_expect(len != 0, true)) {
- ensureSize(len);
- memcpy(_bufFillPos, data, len);
- _bufFillPos += len;
- }
-}
-
-void
-RawBuf::append(uint8_t byte)
-{
- ensureSize(1);
- *_bufFillPos++ = byte;
-}
-
-void
-RawBuf::appendCompressedPositiveNumber(uint64_t n)
-{
- size_t len(vespalib::compress::Integer::compressedPositiveLength(n));
- ensureSize(len);
- _bufFillPos += vespalib::compress::Integer::compressPositive(n, _bufFillPos);
-}
-
-void
-RawBuf::appendCompressedNumber(int64_t n)
-{
- size_t len(vespalib::compress::Integer::compressedLength(n));
- ensureSize(len);
- _bufFillPos += vespalib::compress::Integer::compress(n, _bufFillPos);
-}
-
-
/**
* Compact any free space from the beginning of the buffer, by
* copying the contents to the start of the buffer.
diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.h b/searchlib/src/vespa/searchlib/util/rawbuf.h
index 30018cb45c2..9ecfbc23c24 100644
--- a/searchlib/src/vespa/searchlib/util/rawbuf.h
+++ b/searchlib/src/vespa/searchlib/util/rawbuf.h
@@ -2,8 +2,9 @@
#pragma once
-#include <cstdint>
-#include <cstddef>
+#include <vespa/vespalib/util/compress.h>
+#include <cstring>
+#include <cstdlib>
namespace search {
/**
@@ -45,13 +46,35 @@ private:
public:
RawBuf(const RawBuf &) = delete;
RawBuf& operator=(const RawBuf &) = delete;
- explicit RawBuf(size_t size); // malloc-s given size, assigns to _bufStart
- ~RawBuf(); // Frees _bufStart, i.e. the char[].
+ explicit RawBuf(size_t size)
+ : _bufStart(static_cast<char *>(malloc(size))),
+ _bufEnd(_bufStart + size),
+ _bufFillPos(_bufStart),
+ _bufDrainPos(_bufStart)
+ { }
+ ~RawBuf() {
+ free(_bufStart);
+ } // Frees _bufStart, i.e. the char[].
- void append(const void *data, size_t len);
- void append(uint8_t byte);
- void appendCompressedPositiveNumber(uint64_t n);
- void appendCompressedNumber(int64_t n);
+ void append(const void *data, size_t len) {
+ if (__builtin_expect(len != 0, true)) {
+ ensureSize(len);
+ memcpy(_bufFillPos, data, len);
+ _bufFillPos += len;
+ }
+ }
+ void append(uint8_t byte) {
+ ensureSize(1);
+ *_bufFillPos++ = byte;
+ }
+ void appendCompressedPositiveNumber(uint64_t n) {
+ ensureSize(vespalib::compress::Integer::compressedPositiveLength(n));
+ _bufFillPos += vespalib::compress::Integer::compressPositive(n, _bufFillPos);
+ }
+ void appendCompressedNumber(int64_t n) {
+ ensureSize(vespalib::compress::Integer::compressedLength(n));
+ _bufFillPos += vespalib::compress::Integer::compress(n, _bufFillPos);
+ }
size_t GetFreeLen() const { return _bufEnd - _bufFillPos; }
const char *GetDrainPos() const { return _bufDrainPos; }
char * GetWritableFillPos(size_t len) { preAlloc(len); return _bufFillPos; }