summaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-05-09 09:53:36 +0200
committerHenning Baldersheim <balder@oath.com>2018-05-09 09:53:36 +0200
commitc4394d212ae67be6327d5d4b2aa1cefd17ea58f0 (patch)
tree9f7e37d894c13e3fa2b79219aace1faf980ec8ee /searchcore
parent9282c9bacd7b2d09e55552d44f1ec9d8ebceb610 (diff)
Code health
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/fnet_dataset.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp1
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.h36
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.cpp92
-rw-r--r--searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.h15
5 files changed, 56 insertions, 104 deletions
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_dataset.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_dataset.cpp
index f6fb46a67ca..ecb68d3e63c 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_dataset.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_dataset.cpp
@@ -31,18 +31,12 @@ FastS_FNET_DataSet::FastS_FNET_DataSet(FNET_Transport *transport,
}
-FastS_FNET_DataSet::~FastS_FNET_DataSet()
-{
-}
-
+FastS_FNET_DataSet::~FastS_FNET_DataSet() = default;
bool
FastS_FNET_DataSet::AddEngine(FastS_EngineDesc *desc)
{
- FastS_FNET_Engine *engine;
-
- engine = new FastS_FNET_Engine(desc, this);
- FastS_assert(engine != NULL);
+ FastS_FNET_Engine *engine = new FastS_FNET_Engine(desc, this);
InsertEngine(engine);
@@ -57,7 +51,7 @@ namespace {
struct ConnectFNETEngine {
void operator()(FastS_EngineBase* engine) {
FastS_FNET_Engine* fnet_engine = engine->GetFNETEngine();
- FastS_assert(fnet_engine != NULL);
+ FastS_assert(fnet_engine != nullptr);
fnet_engine->ScheduleConnect(0.0);
fnet_engine->StartWarnTimer();
}
@@ -96,9 +90,9 @@ FastS_FNET_DataSet::Free()
_pingTask.Kill();
for (FastS_EngineBase *engine = ExtractEngine();
- engine != NULL; engine = ExtractEngine())
+ engine != nullptr; engine = ExtractEngine())
{
- FastS_assert(engine->GetFNETEngine() != NULL);
+ FastS_assert(engine->GetFNETEngine() != nullptr);
delete engine;
}
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp
index b2082826fe6..e6391cd99d8 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.cpp
@@ -30,7 +30,6 @@ FastS_FNET_SearchNode::FastS_FNET_SearchNode(FastS_FNET_Search *search, uint32_t
: _search(search),
_engine(nullptr),
_channel(nullptr),
- _subds(0),
_partid(partid),
_rowid(0),
_stamp(0),
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.h b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.h
index 755e1a0bca4..7ed8df47789 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.h
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/fnet_search.h
@@ -32,7 +32,6 @@ private:
FastS_FNET_Search *_search; // we are part of this search
FastS_FNET_Engine *_engine; // we use this search engine
FNET_Channel *_channel; // connection with search engine
- uint32_t _subds; // engine sub dataset
uint32_t _partid; // engine partition id
uint32_t _rowid; // engine row id
uint32_t _stamp; // engine timestamp
@@ -62,7 +61,6 @@ public:
uint32_t _docidCnt;
uint32_t _pendingDocsums; // how many docsums pending ?
uint32_t _docsumRow;
- uint32_t _docsumStamp;
uint32_t _docsum_offsets_idx;
double _docsumTime;
@@ -89,7 +87,7 @@ public:
FastS_FNET_SearchNode(const FastS_FNET_SearchNode &) = delete;
FastS_FNET_SearchNode& operator=(const FastS_FNET_SearchNode &) = delete;
- virtual ~FastS_FNET_SearchNode();
+ ~FastS_FNET_SearchNode() override;
// Methods needed by mergehits
bool NT_InitMerge(uint32_t *numDocs, uint64_t *totalHits, search::HitRank *maxRank, uint32_t *sortDataDocs);
@@ -103,7 +101,6 @@ public:
uint32_t getPartID() const { return _partid; }
uint32_t GetRowID() const { return _rowid; }
- uint32_t GetTimeStamp() const { return _stamp; }
FastS_FNET_SearchNode * allocExtraDocsumNode(bool mld, uint32_t rowid, uint32_t rowbits);
@@ -117,13 +114,6 @@ public:
void postGDX(uint32_t *pendingDocsums, uint32_t *pendingDocsumNodes);
vespalib::string toString() const;
- const char *getHostName() const {
- return (_engine == nullptr ? "localhost" : _engine->getHostName());
- }
- int getPortNumber() const {
- return (_engine == nullptr ? 0 : _engine->getPortNumber());
- }
-
void dropCost() {
if (_engine != nullptr && _flags._needSubCost) {
_engine->SubCost();
@@ -152,7 +142,7 @@ public:
return (_channel == nullptr) ? packet->Free(), false : _channel->Send(packet);
}
- virtual HP_RetCode HandlePacket(FNET_Packet *packet, FNET_Context context) override;
+ HP_RetCode HandlePacket(FNET_Packet *packet, FNET_Context context) override;
};
@@ -222,7 +212,7 @@ private:
std::unique_ptr<search::grouping::MergingManager> _groupMerger;
FastS_DataSetCollection *_dsc; // owner keeps this alive
FastS_FNET_DataSet *_dataset;
- bool _datasetActiveCostRef;
+ bool _datasetActiveCostRef;
std::vector<FastS_FNET_SearchNode> _nodes;
bool _nodesConnected;
@@ -306,12 +296,12 @@ public:
// *** API methods -- BEGIN ***
- virtual FastS_SearchInfo *GetSearchInfo() override { return _util.GetSearchInfo(); }
+ FastS_SearchInfo *GetSearchInfo() override { return _util.GetSearchInfo(); }
- virtual RetCode Search(uint32_t searchOffset, uint32_t maxhits, uint32_t minhits = 0) override;
- virtual RetCode ProcessQueryDone() override;
- virtual RetCode GetDocsums(const FastS_hitresult *hits, uint32_t hitcnt) override;
- virtual RetCode ProcessDocsumsDone() override;
+ RetCode Search(uint32_t searchOffset, uint32_t maxhits, uint32_t minhits = 0) override;
+ RetCode ProcessQueryDone() override;
+ RetCode GetDocsums(const FastS_hitresult *hits, uint32_t hitcnt) override;
+ RetCode ProcessDocsumsDone() override;
// *** API methods -- END ***
@@ -351,18 +341,12 @@ public:
uint32_t getDoneQueries() const {
return getRequestedQueries() - getPendingQueries();
}
- uint32_t getBadQueries() const {
- return getDoneQueries() - getGoodQueries();
- }
uint32_t getGoodDocsums() const { return _goodDocsums; }
uint32_t getRequestedDocsums() const { return _requestedDocsums; }
uint32_t getPendingDocsums() const { return _pendingDocsums; }
uint32_t getDoneDocsums() const {
return getRequestedDocsums() - getPendingDocsums();
}
- uint32_t getBadDocsums() const {
- return getDoneDocsums() - getGoodDocsums();
- }
FNET_Packet::UP
setupQueryPacket(uint32_t hitsPerNode, uint32_t qflags,
@@ -385,8 +369,8 @@ public:
{
_search.SetAsyncArgs(this, FastS_SearchContext());
}
- virtual ~FastS_Sync_FNET_Search();
- virtual void Free() override { delete this; }
+ ~FastS_Sync_FNET_Search() override;
+ void Free() override { delete this; }
};
//-----------------------------------------------------------------
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.cpp b/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.cpp
index aa1a783a7be..b48f1abfb51 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.cpp
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.cpp
@@ -18,7 +18,7 @@ static inline int imax(int a, int b) { return (a > b) ? a : b; }
//--------------------------------------------------------------------------
FastS_PartitionMap::Partition::Partition()
- : _engines(NULL),
+ : _engines(nullptr),
_maxnodesNow(0),
_maxnodesSinceReload(0),
_nodes(0),
@@ -31,7 +31,7 @@ FastS_PartitionMap::Partition::Partition()
FastS_PartitionMap::Partition::~Partition()
{
- FastS_assert(_engines == NULL);
+ FastS_assert(_engines == nullptr);
FastS_assert(_nodes == 0);
FastS_assert(_parts == 0);
}
@@ -39,7 +39,7 @@ FastS_PartitionMap::Partition::~Partition()
//--------------------------------------------------------------------------
FastS_PartitionMap::FastS_PartitionMap(FastS_DataSetDesc *desc)
- : _partitions(NULL),
+ : _partitions(nullptr),
_partBits(desc->GetPartBits()),
_rowBits(desc->GetRowBits()),
_num_partitions(desc->GetNumParts()),
@@ -64,13 +64,13 @@ FastS_PartitionMap::FastS_PartitionMap(FastS_DataSetDesc *desc)
if (_num_partitions > 0) {
_partitions = new Partition[_num_partitions];
- FastS_assert(_partitions != NULL);
+ FastS_assert(_partitions != nullptr);
}
- for (FastS_EngineDesc *curr = desc->GetEngineList(); curr != NULL; curr = curr->GetNext()) {
+ for (FastS_EngineDesc *curr = desc->GetEngineList(); curr != nullptr; curr = curr->GetNext()) {
_maxRows = std::max(_maxRows, curr->GetConfRowID());
}
_numPartitions = std::vector<uint32_t>(getNumRows(), 0);
- for (FastS_EngineDesc *curr = desc->GetEngineList(); curr != NULL; curr = curr->GetNext()) {
+ for (FastS_EngineDesc *curr = desc->GetEngineList(); curr != nullptr; curr = curr->GetNext()) {
size_t rowId(curr->GetConfRowID());
_numPartitions[rowId] = std::max(_numPartitions[rowId], curr->GetConfPartID()+1);
}
@@ -89,7 +89,7 @@ FastS_PartitionMap::RecalcPartCnt(uint32_t partid)
uint32_t maxparts = 0;
uint32_t parts = 0;
for (FastS_EngineBase * engine = _partitions[partid]._engines;
- engine != NULL; engine = engine->_nextpart) {
+ engine != nullptr; engine = engine->_nextpart) {
maxparts = imax(engine->_reported._maxParts, maxparts);
parts = imax(engine->_reported._actParts, parts);
}
@@ -112,11 +112,11 @@ FastS_PartitionMap::LinkIn(FastS_EngineBase *engine)
uint32_t partid = engine->_partid - _first_partition;
FastS_assert(partid < GetSize());
- FastS_assert(engine->_nextpart == NULL);
- FastS_assert(engine->_prevpart == NULL);
+ FastS_assert(engine->_nextpart == nullptr);
+ FastS_assert(engine->_prevpart == nullptr);
FastS_PartitionMap::Partition & part = _partitions[partid];
engine->_nextpart = part._engines;
- if (engine->_nextpart != NULL)
+ if (engine->_nextpart != nullptr)
engine->_nextpart->_prevpart = engine;
part._engines = engine;
part._maxnodesNow += engine->_reported._maxNodes;
@@ -144,9 +144,9 @@ FastS_PartitionMap::LinkOut(FastS_EngineBase *engine)
uint32_t partid = engine->_partid - _first_partition;
FastS_assert(partid < GetSize());
- if (engine->_nextpart != NULL)
+ if (engine->_nextpart != nullptr)
engine->_nextpart->_prevpart = engine->_prevpart;
- if (engine->_prevpart != NULL)
+ if (engine->_prevpart != nullptr)
engine->_prevpart->_nextpart = engine->_nextpart;
if (_partitions[partid]._engines == engine)
_partitions[partid]._engines = engine->_nextpart;
@@ -159,8 +159,8 @@ FastS_PartitionMap::LinkOut(FastS_EngineBase *engine)
_partitions[partid]._parts <= engine->_reported._actParts)
RecalcPartCnt(partid);
- engine->_nextpart = NULL;
- engine->_prevpart = NULL;
+ engine->_nextpart = nullptr;
+ engine->_prevpart = nullptr;
}
//--------------------------------------------------------------------------
@@ -188,7 +188,7 @@ FastS_PlainDataSet::ExtractEngine()
_enginesArray.pop_back();
return ret;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -221,7 +221,7 @@ FastS_PlainDataSet::FastS_PlainDataSet(FastS_AppContext *appCtx,
const char *hostname = vespalib::HostName::get().c_str();
unsigned const char *p = reinterpret_cast<unsigned const char *>(hostname);
- if (p != NULL) {
+ if (p != nullptr) {
while (*p != '\0') {
seed = (seed << 7) + *p + (seed >> 25);
p++;
@@ -233,10 +233,7 @@ FastS_PlainDataSet::FastS_PlainDataSet(FastS_AppContext *appCtx,
}
-FastS_PlainDataSet::~FastS_PlainDataSet()
-{
-}
-
+FastS_PlainDataSet::~FastS_PlainDataSet() = default;
void
FastS_PlainDataSet::UpdateMaxHitsPerNodeLog(bool incomplete, bool fuzzy)
@@ -317,11 +314,11 @@ FastS_EngineBase *
FastS_PlainDataSet::getPartition(const std::unique_lock<std::mutex> &dsGuard, uint32_t partindex, uint32_t rowid)
{
(void) dsGuard;
- FastS_EngineBase* ret = NULL;
+ FastS_EngineBase* ret = nullptr;
if (IsValidPartIndex_HasLock(partindex)) {
for (FastS_EngineBase* iter = _partMap._partitions[partindex]._engines;
- iter != NULL && ret == NULL;
+ iter != nullptr && ret == nullptr;
iter = iter->_nextpart) {
// NB: cost race condition
@@ -334,7 +331,7 @@ FastS_PlainDataSet::getPartition(const std::unique_lock<std::mutex> &dsGuard, ui
}
}
- if (ret != NULL) {
+ if (ret != nullptr) {
ret->AddCost();
}
return ret;
@@ -347,7 +344,7 @@ FastS_PlainDataSet::countNodesUpInRow_HasLock(uint32_t rowid)
const size_t numParts = _partMap.GetSize();
for (size_t partindex = 0; partindex < numParts; ++partindex) {
for (FastS_EngineBase* iter = _partMap._partitions[partindex]._engines;
- iter != NULL;
+ iter != nullptr;
iter = iter->_nextpart)
{
if (!iter->IsRealBad() &&
@@ -366,13 +363,13 @@ FastS_EngineBase *
FastS_PlainDataSet::getPartition(const std::unique_lock<std::mutex> &dsGuard, uint32_t partindex)
{
(void) dsGuard;
- FastS_EngineBase* ret = NULL;
+ FastS_EngineBase* ret = nullptr;
unsigned int oldCount = 1;
unsigned int engineCount = 0;
if (IsValidPartIndex_HasLock(partindex)) {
for (FastS_EngineBase* iter = _partMap._partitions[partindex]._engines;
- iter != NULL;
+ iter != nullptr;
iter = iter->_nextpart) {
// NB: cost race condition
@@ -382,16 +379,16 @@ FastS_PlainDataSet::getPartition(const std::unique_lock<std::mutex> &dsGuard, ui
EngineDocStampOK(iter->_reported._docstamp))
{
engineCount++;
- if (ret == NULL || UseNewEngine(ret, iter, &oldCount))
+ if (ret == nullptr || UseNewEngine(ret, iter, &oldCount))
ret = iter;
}
}
}
if (engineCount < getMPP()) {
- ret = NULL;
+ ret = nullptr;
}
- if (ret != NULL) {
+ if (ret != nullptr) {
ret->AddCost();
}
return ret;
@@ -401,18 +398,18 @@ FastS_EngineBase *
FastS_PlainDataSet::getPartitionMLD(const std::unique_lock<std::mutex> &dsGuard, uint32_t partindex, bool mld)
{
(void) dsGuard;
- FastS_EngineBase* ret = NULL;
+ FastS_EngineBase* ret = nullptr;
unsigned int oldCount = 1;
if (partindex < _partMap._num_partitions) {
FastS_EngineBase* iter;
- for (iter = _partMap._partitions[partindex]._engines; iter != NULL; iter = iter->_nextpart) {
+ for (iter = _partMap._partitions[partindex]._engines; iter != nullptr; iter = iter->_nextpart) {
// NB: cost race condition
if (!iter->IsRealBad() &&
iter->_reported._mld == mld &&
(iter->_config._unitrefcost > 0) &&
EngineDocStampOK(iter->_reported._docstamp) &&
- (ret == NULL || UseNewEngine(ret, iter, &oldCount)))
+ (ret == nullptr || UseNewEngine(ret, iter, &oldCount)))
{
ret = iter;
}
@@ -420,7 +417,7 @@ FastS_PlainDataSet::getPartitionMLD(const std::unique_lock<std::mutex> &dsGuard,
} else {
LOG(error, "Couldn't fetch partition data: Partition ID too big, partindex=%x _partMap._num_partitions=%x", partindex, _partMap._num_partitions);
}
- if (ret != NULL) {
+ if (ret != nullptr) {
ret->AddCost();
}
return ret;
@@ -430,18 +427,18 @@ FastS_EngineBase *
FastS_PlainDataSet::getPartitionMLD(const std::unique_lock<std::mutex> &dsGuard, uint32_t partindex, bool mld, uint32_t rowid)
{
(void) dsGuard;
- FastS_EngineBase* ret = NULL;
+ FastS_EngineBase* ret = nullptr;
unsigned int oldCount = 1;
if (partindex < _partMap._num_partitions) {
FastS_EngineBase* iter;
- for (iter = _partMap._partitions[partindex]._engines; iter != NULL; iter = iter->_nextpart) {
+ for (iter = _partMap._partitions[partindex]._engines; iter != nullptr; iter = iter->_nextpart) {
// NB: cost race condition
if (!iter->IsRealBad() &&
(iter->_reported._mld == mld) &&
(iter->_config._confRowID == rowid) &&
EngineDocStampOK(iter->_reported._docstamp) &&
- (ret == NULL || UseNewEngine(ret, iter, &oldCount)))
+ (ret == nullptr || UseNewEngine(ret, iter, &oldCount)))
{
ret = iter;
}
@@ -449,29 +446,12 @@ FastS_PlainDataSet::getPartitionMLD(const std::unique_lock<std::mutex> &dsGuard,
} else {
LOG(error, "Couldn't fetch partition data: Partition ID too big, partindex=%x _partMap._num_partitions=%x", partindex, _partMap._num_partitions);
}
- if (ret != NULL) {
+ if (ret != nullptr) {
ret->AddCost();
}
return ret;
}
-
-std::vector<FastS_EngineBase *>
-FastS_PlainDataSet::getPartEngines(uint32_t partition)
-{
- typedef FastS_EngineBase EB;
- typedef std::vector<EB *> EBV;
- EBV partEngines;
- {
- auto dsGuard(getDsGuard());
- for (FastS_EngineBase *iter = _partMap._partitions[partition]._engines; iter != NULL; iter = iter->_nextpart) {
- partEngines.push_back(iter);
- }
- }
- return partEngines;
-}
-
-
void
FastS_PlainDataSet::LinkInPart_HasLock(FastS_EngineBase *engine)
{
@@ -506,12 +486,12 @@ FastS_PlainDataSet::CalculateQueueLens_HasLock(uint32_t &dispatchnodes)
dispatchnodes = 1;
for (partindex = 0; partindex < _partMap._num_partitions ; partindex++) {
eng = _partMap._partitions[partindex]._engines;
- if (eng != NULL) {
+ if (eng != nullptr) {
pqueueLen = eng->GetQueueLen();
pdispatchnodes = eng->GetDispatchers();
dupnodes = 1;
eng = eng->_nextpart;
- while (eng != NULL) {
+ while (eng != nullptr) {
equeueLen = eng->GetQueueLen();
if (equeueLen < pqueueLen)
pqueueLen = equeueLen;
diff --git a/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.h b/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.h
index ab50efeb40c..8ce6b3adb75 100644
--- a/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.h
+++ b/searchcore/src/vespa/searchcore/fdispatch/search/plain_dataset.h
@@ -138,7 +138,7 @@ protected:
bool IsValidPartIndex_HasLock(uint32_t partindex);
public:
FastS_PlainDataSet(FastS_AppContext *appCtx, FastS_DataSetDesc *desc);
- virtual ~FastS_PlainDataSet();
+ ~FastS_PlainDataSet() override;
bool useFixedRowDistribution() const {
return _queryDistributionMode == FastS_DataSetDesc::QueryDistributionMode::FIXEDROW;
@@ -179,18 +179,15 @@ public:
FastS_EngineBase * getPartitionMLD(const std::unique_lock<std::mutex> &dsGuard, uint32_t partid, bool mld);
FastS_EngineBase * getPartitionMLD(const std::unique_lock<std::mutex> &dsGuard, uint32_t partid, bool mld, uint32_t rowid);
- std::vector<FastS_EngineBase *> getPartEngines(uint32_t partition);
-
void LinkInPart_HasLock(FastS_EngineBase *engine);
void LinkOutPart_HasLock(FastS_EngineBase *engine);
- virtual ChildInfo getChildInfo() const override;
+ ChildInfo getChildInfo() const override;
uint32_t getMPP() const { return _partMap._mpp; }
double getMonitorInterval() const { return _monitorInterval; }
double getHigherCoverageMaxSearchWait() const { return _higherCoverageMaxSearchWait; }
double getHigherCoverageMinSearchWait() const { return _higherCoverageMinSearchWait; }
- double getHigherCoverageBaseSearchWait() const { return _higherCoverageBaseSearchWait; }
double getMinimalSearchCoverage() const { return _minimalSearchCoverage; }
double getHigherCoverageMaxDocSumWait() const { return _higherCoverageMaxDocSumWait; }
double getHigherCoverageMinDocSumWait() const { return _higherCoverageMinDocSumWait; }
@@ -199,13 +196,13 @@ public:
// API
//----
- virtual uint32_t CalculateQueueLens_HasLock(uint32_t &dispatchnodes) override;
- virtual bool AreEnginesReady() override;
+ uint32_t CalculateQueueLens_HasLock(uint32_t &dispatchnodes) override;
+ bool AreEnginesReady() override;
virtual void Ping();
// Downcast
//---------
- virtual FastS_PlainDataSet * GetPlainDataSet() override { return this; }
+ FastS_PlainDataSet * GetPlainDataSet() override { return this; }
template <class FUN>
FUN ForEachEngine(FUN fun) {
@@ -216,6 +213,4 @@ public:
}
static bool EngineDocStampOK(time_t haveDocStamp) { return (haveDocStamp != 0); }
-
- void UseDeterministicQueryDistribution(bool);
};