diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-02-19 21:24:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-19 21:24:25 +0100 |
commit | 91525f0e94bc150ef9e9879699c158ff93ddb628 (patch) | |
tree | e7c141380834a210337d96b75361a0c5eae3bf3b /searchlib | |
parent | 8f72e63785af529ea5877e7a7bbcc683cb9a92da (diff) | |
parent | 7059a097c51a313ff9a7ef7e16894ce7832e0edc (diff) |
Merge pull request #30316 from vespa-engine/balder/use-highlight-termsv8.307.19
Balder/use highlight terms
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/vespa/searchlib/common/packets.cpp | 23 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/common/packets.h | 19 |
2 files changed, 26 insertions, 16 deletions
diff --git a/searchlib/src/vespa/searchlib/common/packets.cpp b/searchlib/src/vespa/searchlib/common/packets.cpp index 3f2b5750631..af5dc5fc110 100644 --- a/searchlib/src/vespa/searchlib/common/packets.cpp +++ b/searchlib/src/vespa/searchlib/common/packets.cpp @@ -35,14 +35,14 @@ FS4Properties::FS4Properties() _backing() { } -FS4Properties::FS4Properties(FS4Properties && rhs) +FS4Properties::FS4Properties(FS4Properties && rhs) noexcept : _entries(std::move(rhs._entries)), _name(std::move(rhs._name)), _backing(std::move(rhs._backing)) { } FS4Properties & -FS4Properties::operator=(FS4Properties && rhs) +FS4Properties::operator=(FS4Properties && rhs) noexcept { _entries = std::move(rhs._entries); _name = std::move(rhs._name); @@ -72,14 +72,25 @@ FS4Properties::setValue(uint32_t entry, const char *value, uint32_t valueSize) } uint32_t -FS4Properties::getLength() +FS4Properties::getLength() const noexcept { - uint32_t len = sizeof(uint32_t) * 2 + getNameLen(); + uint32_t len = sizeof(uint32_t) * 2 + name().size(); len += _backing.size(); len += _entries.size() * sizeof(uint32_t) * 2; return len; } +vespalib::stringref +FS4Properties::key(uint32_t entry) const noexcept { + auto pair = _entries[entry].first; + return {c_str(pair.first), pair.second}; +} +vespalib::stringref +FS4Properties::value(uint32_t entry) const noexcept { + auto pair = _entries[entry].second; + return {c_str(pair.first), pair.second}; +} + vespalib::string FS4Properties::toString(uint32_t indent) const { @@ -90,8 +101,8 @@ FS4Properties::toString(uint32_t indent) const s += "\n"; for (uint32_t i = 0; i < size(); ++i) { s += make_string("%*s Entry[%d] {\n", indent, "", i); - s += make_string("%*s key : %s\n", indent, "", vespalib::string(getKey(i), getKeyLen(i)).c_str()); - s += make_string("%*s value: %s\n", indent, "", vespalib::string(getValue(i), getValueLen(i)).c_str()); + s += make_string("%*s key : %s\n", indent, "", string(key(i)).c_str()); + s += make_string("%*s value: %s\n", indent, "", string(value(i)).c_str()); s += make_string("%*s }\n", indent, ""); } s += make_string("%*s}\n", indent, ""); diff --git a/searchlib/src/vespa/searchlib/common/packets.h b/searchlib/src/vespa/searchlib/common/packets.h index b04e1fb44d0..fbdae8b51ec 100644 --- a/searchlib/src/vespa/searchlib/common/packets.h +++ b/searchlib/src/vespa/searchlib/common/packets.h @@ -50,8 +50,10 @@ private: void set(StringRef & e, vespalib::stringref s); void allocEntries(uint32_t cnt); public: - FS4Properties(FS4Properties &&); - FS4Properties &operator=(FS4Properties &&); + FS4Properties(FS4Properties &&) noexcept; + FS4Properties &operator=(FS4Properties &&) noexcept; + FS4Properties(const FS4Properties &) = delete; + FS4Properties &operator=(const FS4Properties &) = delete; FS4Properties(); ~FS4Properties(); @@ -67,16 +69,13 @@ public: void setValue(uint32_t entry, vespalib::stringref val) { setValue(entry, val.data(), val.size()); } - uint32_t size() const { return _entries.size(); } - const char *getName() const { return _name.c_str(); } - uint32_t getNameLen() const { return _name.size(); } - const char *getKey(uint32_t entry) const { return c_str(_entries[entry].first.first); } - uint32_t getKeyLen(uint32_t entry) const { return _entries[entry].first.second; } - const char *getValue(uint32_t entry) const { return c_str(_entries[entry].second.first); } - uint32_t getValueLen(uint32_t entry) const { return _entries[entry].second.second; } + uint32_t size() const noexcept { return _entries.size(); } + const vespalib::string & name() const noexcept { return _name; } + vespalib::stringref key(uint32_t entry) const noexcept; + vespalib::stringref value(uint32_t entry) const noexcept; // sub-packet methods below - uint32_t getLength(); + uint32_t getLength() const noexcept; void encode(FNET_DataBuffer &dst); bool decode(FNET_DataBuffer &src, uint32_t &len); |