summaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorJon Bratseth <jonbratseth@yahoo.com>2018-02-07 13:55:26 +0100
committerGitHub <noreply@github.com>2018-02-07 13:55:26 +0100
commit4edbbfb6c3e9be923137b7ea9cf039bf7a19c8a4 (patch)
tree2aa84005557c96f48a40323827750f194598a30c /searchlib
parent521be18377a117c5d02c1dd104017457c375f25b (diff)
parent553575a45c8697b247036c5a4a6b2e9e9fb862ee (diff)
Merge pull request #4949 from vespa-engine/balder/cleanup-softtimeout
Balder/cleanup softtimeout
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/common/packets/packets_test.cpp24
-rw-r--r--searchlib/src/vespa/searchlib/common/packets.cpp63
-rw-r--r--searchlib/src/vespa/searchlib/common/packets.h11
-rw-r--r--searchlib/src/vespa/searchlib/common/transport.h2
-rw-r--r--searchlib/src/vespa/searchlib/engine/packetconverter.cpp8
-rw-r--r--searchlib/src/vespa/searchlib/engine/searchreply.h13
6 files changed, 67 insertions, 54 deletions
diff --git a/searchlib/src/tests/common/packets/packets_test.cpp b/searchlib/src/tests/common/packets/packets_test.cpp
index c4da5ca4873..ad4cf02f4e8 100644
--- a/searchlib/src/tests/common/packets/packets_test.cpp
+++ b/searchlib/src/tests/common/packets/packets_test.cpp
@@ -2,7 +2,6 @@
#include <vespa/searchlib/common/mapnames.h>
#include <vespa/searchlib/common/packets.h>
-#include <vector>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <vespa/fnet/controlpacket.h>
@@ -10,15 +9,6 @@
using namespace search::fs4transport;
using vespalib::compression::CompressionConfig;
-
-// ----------------------------------------------------------------------------
-//
-// Utilities
-//
-// ----------------------------------------------------------------------------
-
-#define QRF_RANKTYPE QRF_RANKTYPE_DOUBLE
-
#define PCODE_BEGIN PCODE_EOL
#define PCODE_END PCODE_LastCode
@@ -59,7 +49,7 @@ testEncodeDecode(FS4PersistentPacketStreamer &streamer, FNET_Packet &packet)
EXPECT_EQUAL(myStreamer.getChannelId(pcode, 1u), chid);
FNET_Packet *ret = streamer.Decode(&buf, plen, pcode, ctx);
- ASSERT_TRUE(ret);
+ assert(ret);
if (ret->GetPCODE() == (pcode & PCODE_MASK)) {
FNET_DataBuffer rhs;
streamer.Encode(ret, 1u, &rhs);
@@ -325,6 +315,10 @@ TEST("testQueryResultX") {
src->setDistributionKey(4u);
src->_coverageDocs = 6u;
src->_activeDocs = 7u;
+ src->_soonActiveDocs = 8;
+ src->_coverageDegradeReason = 0x17;
+ src->setNodesQueried(12);
+ src->setNodesReplied(11);
uint32_t sortIndex[3] = { 0u, 1u, 3u /* size of data */}; // numDocs + 1
src->SetSortDataRef(2, sortIndex, "foo");
src->SetGroupDataRef("baz", 3u);
@@ -358,8 +352,12 @@ TEST("testQueryResultX") {
EXPECT_EQUAL(2u, ptr->_totNumDocs);
EXPECT_EQUAL((search::HitRank)3, ptr->_maxRank);
EXPECT_EQUAL(4u, ptr->getDistributionKey());
- EXPECT_EQUAL(ptr->_features & QRF_COVERAGE ? 6u : 0u, ptr->_coverageDocs);
- EXPECT_EQUAL(ptr->_features & QRF_COVERAGE ? 7u : 0u, ptr->_activeDocs);
+ EXPECT_EQUAL(ptr->_features & QRF_COVERAGE_NODES ? 12 : 0u, ptr->getNodesQueried());
+ EXPECT_EQUAL(ptr->_features & QRF_COVERAGE_NODES ? 11 : 0u, ptr->getNodesReplied());
+ EXPECT_EQUAL(6u, ptr->_coverageDocs);
+ EXPECT_EQUAL(7u, ptr->_activeDocs);
+ EXPECT_EQUAL(8u, ptr->_soonActiveDocs);
+ EXPECT_EQUAL(0x17u, ptr->_coverageDegradeReason);
if (ptr->_features & QRF_SORTDATA) {
EXPECT_EQUAL(0u, ptr->_sortIndex[0]);
EXPECT_EQUAL(1u, ptr->_sortIndex[1]);
diff --git a/searchlib/src/vespa/searchlib/common/packets.cpp b/searchlib/src/vespa/searchlib/common/packets.cpp
index 281d0c1541e..04da47aa76b 100644
--- a/searchlib/src/vespa/searchlib/common/packets.cpp
+++ b/searchlib/src/vespa/searchlib/common/packets.cpp
@@ -906,6 +906,8 @@ FS4Packet_QUERYRESULTX::AllocateHits(uint32_t cnt)
FS4Packet_QUERYRESULTX::FS4Packet_QUERYRESULTX()
: FS4Packet(),
_distributionKey(0),
+ _nodesQueried(0),
+ _nodesReplied(0),
_features(0),
_offset(0),
_numDocs(0),
@@ -942,22 +944,14 @@ FS4Packet_QUERYRESULTX::GetLength()
_numDocs * (sizeof(document::GlobalId) + sizeof(search::HitRank));
plen += sizeof(uint32_t);
-
- if ((_features & QRF_MLD) != 0)
- plen += _numDocs * 2 * sizeof(uint32_t);
+ plen += (_features & QRF_COVERAGE_NODES) ? 2 * sizeof(uint16_t) : 0;
+ plen += (_features & QRF_MLD) ? _numDocs * 2 * sizeof(uint32_t) : 0;
+ plen += (_features & QRF_GROUPDATA) ? sizeof(uint32_t) + _groupDataLen : 0;
+ plen += 3 * sizeof(uint64_t) + sizeof(uint32_t);
if (((_features & QRF_SORTDATA) != 0) && (_numDocs > 0))
plen += _numDocs * sizeof(uint32_t) + (_sortIndex[_numDocs] - _sortIndex[0]);
- if ((_features & QRF_GROUPDATA) != 0)
- plen += sizeof(uint32_t) + _groupDataLen;
-
- if ((_features & QRF_COVERAGE) != 0)
- plen += 2 * sizeof(uint64_t);
-
- if ((_features & QRF_EXTENDED_COVERAGE) != 0)
- plen += sizeof(uint64_t) + sizeof(uint32_t);
-
if ((_features & QRF_PROPERTIES) != 0) {
plen += sizeof(uint32_t);
for (uint32_t i = 0; i < _propsVector.size(); ++i) {
@@ -981,6 +975,11 @@ FS4Packet_QUERYRESULTX::Encode(FNET_DataBuffer *dst)
dst->WriteInt64Fast(mrval.INT64);
dst->WriteInt32Fast(_distributionKey);
+ if (_features & QRF_COVERAGE_NODES) {
+ dst->WriteInt16Fast(_nodesQueried);
+ dst->WriteInt16Fast(_nodesReplied);
+ }
+
if (((_features & QRF_SORTDATA) != 0) &&
(_numDocs > 0))
{
@@ -998,14 +997,11 @@ FS4Packet_QUERYRESULTX::Encode(FNET_DataBuffer *dst)
dst->WriteBytesFast(_groupData, _groupDataLen);
}
- if ((_features & QRF_COVERAGE) != 0) {
- dst->WriteInt64Fast(_coverageDocs);
- dst->WriteInt64Fast(_activeDocs);
- }
- if ((_features & QRF_EXTENDED_COVERAGE) != 0) {
- dst->WriteInt64Fast(_soonActiveDocs);
- dst->WriteInt32Fast(_coverageDegradeReason);
- }
+ dst->WriteInt64Fast(_coverageDocs);
+ dst->WriteInt64Fast(_activeDocs);
+ dst->WriteInt64Fast(_soonActiveDocs);
+ dst->WriteInt32Fast(_coverageDegradeReason);
+
for (uint32_t i = 0; i < _numDocs; i++) {
dst->WriteBytesFast(_hits[i]._gid.get(), document::GlobalId::LENGTH);
@@ -1051,8 +1047,13 @@ FS4Packet_QUERYRESULTX::Decode(FNET_DataBuffer *src, uint32_t len)
_distributionKey = src->ReadInt32();
len -= 3 * sizeof(uint32_t) + sizeof(uint64_t) + sizeof(search::HitRank);
- if (((_features & QRF_SORTDATA) != 0) &&
- (_numDocs > 0)) {
+ if (_features & QRF_COVERAGE_NODES) {
+ if (len < 2* sizeof(uint16_t)) goto error;
+ _nodesQueried = src->ReadInt16();
+ _nodesReplied = src->ReadInt16();
+ len -= 2*sizeof(uint16_t);
+ }
+ if (((_features & QRF_SORTDATA) != 0) && (_numDocs > 0)) {
if (len < _numDocs * sizeof(uint32_t)) goto error;
AllocateSortIndex(_numDocs);
_sortIndex[0] = 0; // implicit
@@ -1079,19 +1080,13 @@ FS4Packet_QUERYRESULTX::Decode(FNET_DataBuffer *src, uint32_t len)
len -= _groupDataLen;
}
- if ((_features & QRF_COVERAGE) != 0) {
- if (len < 2 * sizeof(uint64_t)) goto error;
- _coverageDocs = src->ReadInt64();
- _activeDocs = src->ReadInt64();
- len -= 2 * sizeof(uint64_t);
- }
- if ((_features & QRF_EXTENDED_COVERAGE) != 0) {
- if (len < sizeof(uint64_t) + sizeof(uint32_t)) goto error;
- _soonActiveDocs = src->ReadInt64();
- _coverageDegradeReason = src->ReadInt32();
+ if (len < 3 * sizeof(uint64_t) + sizeof(uint32_t)) goto error;
+ _coverageDocs = src->ReadInt64();
+ _activeDocs = src->ReadInt64();
+ _soonActiveDocs = src->ReadInt64();
+ _coverageDegradeReason = src->ReadInt32();
- len -= sizeof(uint64_t) + sizeof(uint32_t);
- }
+ len -= 3*sizeof(uint64_t) + sizeof(uint32_t);
if ((_features & QRF_MLD) != 0) {
hitSize += 2 * sizeof(uint32_t);
diff --git a/searchlib/src/vespa/searchlib/common/packets.h b/searchlib/src/vespa/searchlib/common/packets.h
index 52130c57374..a876400e503 100644
--- a/searchlib/src/vespa/searchlib/common/packets.h
+++ b/searchlib/src/vespa/searchlib/common/packets.h
@@ -21,6 +21,7 @@ using vespalib::string;
enum fnet_feature_masks {
FNET_QRF_SUPPORTED_MASK = (QRF_MLD |
QRF_SORTDATA |
+ QRF_COVERAGE_NODES |
QRF_EXTENDED_COVERAGE |
QRF_COVERAGE |
QRF_GROUPDATA |
@@ -65,8 +66,7 @@ private:
uint32_t _used;
public:
- PacketArray(FNET_Packet **arr = NULL,
- uint32_t size = 0)
+ PacketArray(FNET_Packet **arr = nullptr, uint32_t size = 0)
: _extArray(arr),
_array(arr),
_size(size),
@@ -374,6 +374,8 @@ private:
FS4Packet_QUERYRESULTX& operator=(const FS4Packet_QUERYRESULTX &);
uint32_t _distributionKey;
+ uint16_t _nodesQueried;
+ uint16_t _nodesReplied;
public:
uint32_t _features; // see queryresult_features
@@ -425,8 +427,11 @@ public:
vespalib::string toString(uint32_t indent) const override ;
uint32_t getDistributionKey() const { return _distributionKey; }
void setDistributionKey(uint32_t key) { _distributionKey = key; }
+ uint16_t getNodesQueried() const { return _nodesQueried; }
+ void setNodesQueried(uint16_t key) { _nodesQueried = key; }
+ uint16_t getNodesReplied() const { return _nodesReplied; }
+ void setNodesReplied(uint16_t key) { _nodesReplied = key; }
};
-
//==========================================================================
class FS4Packet_QUERYX : public FS4Packet
diff --git a/searchlib/src/vespa/searchlib/common/transport.h b/searchlib/src/vespa/searchlib/common/transport.h
index 454c8404163..b6a925240c9 100644
--- a/searchlib/src/vespa/searchlib/common/transport.h
+++ b/searchlib/src/vespa/searchlib/common/transport.h
@@ -25,6 +25,7 @@ namespace search::fs4transport {
**/
enum queryflags {
QFLAG_EXTENDED_COVERAGE = 0x00000001,
+ QFLAG_COVERAGE_NODES = 0x00000002,
QFLAG_ESTIMATE = 0x00000080,
QFLAG_DROP_SORTDATA = 0x00004000,
QFLAG_NO_RESULTCACHE = 0x00010000,
@@ -46,6 +47,7 @@ enum queryflags {
**/
enum queryresult_features {
QRF_MLD = 0x00000001,
+ QRF_COVERAGE_NODES = 0x00000002,
QRF_SORTDATA = 0x00000010,
QRF_EXTENDED_COVERAGE = 0x00000020,
QRF_COVERAGE = 0x00000040,
diff --git a/searchlib/src/vespa/searchlib/engine/packetconverter.cpp b/searchlib/src/vespa/searchlib/engine/packetconverter.cpp
index 0697c4631ba..5b7b6ef8265 100644
--- a/searchlib/src/vespa/searchlib/engine/packetconverter.cpp
+++ b/searchlib/src/vespa/searchlib/engine/packetconverter.cpp
@@ -117,13 +117,15 @@ PacketConverter::fromSearchReply(const SearchReply &reply, QUERYRESULTX &packet)
packet.AllocateGroupData(reply.groupResult.size());
memcpy(packet._groupData, &(reply.groupResult[0]), reply.groupResult.size());
}
- packet._features |= QRF_COVERAGE;
+ packet._features |= QRF_COVERAGE | QRF_EXTENDED_COVERAGE;
packet._coverageDocs = reply.coverage.getCovered();
packet._activeDocs = reply.coverage.getActive();
packet._soonActiveDocs = reply.coverage.getSoonActive();
packet._coverageDegradeReason = reply.coverage.getDegradeReason();
- if (reply.request && (reply.request->queryFlags & QFLAG_EXTENDED_COVERAGE)) {
- packet._features |= QRF_EXTENDED_COVERAGE;
+ packet.setNodesQueried(reply.coverage.getNodesQueried());
+ packet.setNodesReplied(reply.coverage.getNodesReplied());
+ if (reply.request && (reply.request->queryFlags & QFLAG_COVERAGE_NODES)) {
+ packet._features |= QRF_COVERAGE_NODES;
}
if (reply.useWideHits) {
packet._features |= QRF_MLD;
diff --git a/searchlib/src/vespa/searchlib/engine/searchreply.h b/searchlib/src/vespa/searchlib/engine/searchreply.h
index b1c55fea874..9135866a7f7 100644
--- a/searchlib/src/vespa/searchlib/engine/searchreply.h
+++ b/searchlib/src/vespa/searchlib/engine/searchreply.h
@@ -32,15 +32,24 @@ public:
public:
Coverage() : Coverage(0) { }
Coverage(uint64_t active) : Coverage(active, active) { }
- Coverage(uint64_t active, uint64_t covered) : _covered(covered), _active(active), _soonActive(active), _degradeReason(0) { }
+ Coverage(uint64_t active, uint64_t covered)
+ : _covered(covered), _active(active), _soonActive(active),
+ _degradeReason(0), _nodesQueried(1), _nodesReplied(1)
+ { }
uint64_t getCovered() const { return _covered; }
uint64_t getActive() const { return _active; }
uint64_t getSoonActive() const { return _soonActive; }
uint32_t getDegradeReason() const { return _degradeReason; }
+ uint16_t getNodesQueried() const { return _nodesQueried; }
+ uint16_t getNodesReplied() const { return _nodesReplied; }
+
Coverage & setCovered(uint64_t v) { _covered = v; return *this; }
Coverage & setActive(uint64_t v) { _active = v; return *this; }
Coverage & setSoonActive(uint64_t v) { _soonActive = v; return *this; }
Coverage & setDegradeReason(uint32_t v) { _degradeReason = v; return *this; }
+ Coverage & setNodesQueried(uint16_t v) { _nodesQueried = v; return *this; }
+ Coverage & setNodesReplied(uint16_t v) { _nodesReplied = v; return *this; }
+
Coverage & degradeMatchPhase() { _degradeReason |= MATCH_PHASE; return *this; }
Coverage & degradeTimeout() { _degradeReason |= TIMEOUT; return *this; }
Coverage & degradeAdaptiveTimeout() { _degradeReason |= ADAPTIVE_TIMEOUT; return *this; }
@@ -50,6 +59,8 @@ public:
uint64_t _active;
uint64_t _soonActive;
uint32_t _degradeReason;
+ uint16_t _nodesQueried;
+ uint16_t _nodesReplied;
};
// set to false to indicate 'talk to the hand' behavior