diff options
Diffstat (limited to 'searchsummary')
4 files changed, 9 insertions, 133 deletions
diff --git a/searchsummary/src/tests/docsumformat/docsum-pack.cpp b/searchsummary/src/tests/docsumformat/docsum-pack.cpp index 240abe6bae7..a80c030ef6e 100644 --- a/searchsummary/src/tests/docsumformat/docsum-pack.cpp +++ b/searchsummary/src/tests/docsumformat/docsum-pack.cpp @@ -46,7 +46,6 @@ public: void TestFailShort(); void TestFailOrder(); void TestBasicInplace(); - void TestCompressInplace(); int Main() override; }; @@ -337,60 +336,6 @@ MyApp::TestBasicInplace() delete gres; } - -void -MyApp::TestCompressInplace() -{ - const char *buf; - uint32_t buflen; - - search::RawBuf field1(32_Ki); - search::RawBuf field2(32_Ki); - const ResultClass *resClass; - GeneralResult *gres; - - const char *lstrval = "string string string"; - const char *ldatval = "data data data"; - - RTR(__LINE__, _packer.Init(2)); - RTR(__LINE__, _packer.AddLongString(lstrval, strlen(lstrval))); - RTR(__LINE__, _packer.AddLongData(ldatval, strlen(ldatval))); - RTR(__LINE__, _packer.GetDocsumBlob(&buf, &buflen)); - - resClass = _config.LookupResultClass(_config.GetClassID(buf, buflen)); - if (resClass == nullptr) { - gres = nullptr; - } else { - DocsumStoreValue value(buf, buflen); - gres = new GeneralResult(resClass); - if (!gres->inplaceUnpack(value)) { - delete gres; - gres = nullptr; - } - } - - ResEntry *e1 = (gres == nullptr) ? nullptr : gres->GetEntry("text"); - ResEntry *e2 = (gres == nullptr) ? nullptr : gres->GetEntry("data"); - - if (e1 != nullptr) - e1->_extract_field(&field1); - if (e2 != nullptr) - e2->_extract_field(&field2); - - RTR(__LINE__, gres != nullptr); - RTR(__LINE__, e1 != nullptr); - RTR(__LINE__, e2 != nullptr); - RTR(__LINE__, strcmp(field1.GetDrainPos(), lstrval) == 0); - RTR(__LINE__, strcmp(field2.GetDrainPos(), ldatval) == 0); - RTR(__LINE__, strlen(lstrval) == field1.GetUsedLen()); - RTR(__LINE__, strlen(ldatval) == field2.GetUsedLen()); - RTR(__LINE__, (gres != nullptr && - gres->GetClass()->GetNumEntries() == 2)); - RTR(__LINE__, (gres != nullptr && - gres->GetClass()->GetClassID() == 2)); - delete gres; -} - int MyApp::Main() { @@ -423,7 +368,6 @@ MyApp::Main() TestFailShort(); TestFailOrder(); TestBasicInplace(); - TestCompressInplace(); LOG(info, "CONCLUSION: %s", (_rc) ? "SUCCESS" : "FAIL"); return (_rc ? 0 : 1); diff --git a/searchsummary/src/vespa/searchsummary/docsummary/general_result.cpp b/searchsummary/src/vespa/searchsummary/docsummary/general_result.cpp index ceb358e5859..be6664e41a3 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/general_result.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/general_result.cpp @@ -4,7 +4,6 @@ #include "resultconfig.h" #include <vespa/document/fieldvalue/document.h> #include <vespa/document/datatype/datatype.h> -#include <zlib.h> #include <cassert> #include <vespa/log/log.h> @@ -264,9 +263,13 @@ GeneralResult::unpack(const char *buf, const size_t buflen) memcpy(&flen, p, sizeof(flen)); p += sizeof(flen); lslen = flen & 0x7fffffff; + if (lslen != flen) { + LOG(error, "GeneralResult::_inplace_unpack: compressed data"); + rc = false; + } if (p + lslen <= ebuf) { _entries[i]._stringval = const_cast<char *>(p); - _entries[i]._stringlen = flen; // with compression flag + _entries[i]._stringlen = lslen; _entries[i]._type = RES_STRING; // type normalization p += lslen; } else { diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp index da0106cd7ad..37be8e0a1b2 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.cpp @@ -4,7 +4,6 @@ #include "resultconfig.h" #include <vespa/vespalib/stllike/hashtable.hpp> #include <cassert> -#include <zlib.h> namespace search::docsummary { @@ -45,7 +44,6 @@ ResultClass::AddConfigEntry(const char *name, ResType type) return true; } - void ResultClass::CreateEnumMap() { @@ -59,52 +57,4 @@ ResultClass::CreateEnumMap() } } - -bool -ResEntry::_extract_field(search::RawBuf *target) const -{ - bool rc = true; - target->reset(); - - if (ResultConfig::IsVariableSize(_type)) { - if (_is_compressed()) { // COMPRESSED - - uint32_t len = _get_length(); - uint32_t realLen = 0; - - if (len >= sizeof(uint32_t)) - realLen = _get_real_length(); - else - rc = false; - - if (realLen > 0) { - uLongf rlen = realLen; - char *fillPos = target->GetWritableFillPos(realLen + 1 < 32000 ? - 32000 : realLen + 1); - if ((uncompress((Bytef *)fillPos, &rlen, - (const Bytef *)(_get_compressed()), - len - sizeof(realLen)) == Z_OK) && - rlen == realLen) { - fillPos[realLen] = '\0'; - target->Fill(realLen); - } else { - rc = false; - } - } - } else { // UNCOMPRESSED - uint32_t len = _len; - if (len + 1 < 32000) - target->preAlloc(32000); - else - target->preAlloc(len + 1); - char *fillPos = target->GetWritableFillPos(len + 1 < 32000 ? - 32000 : len + 1); - memcpy(fillPos, _pt, len); - fillPos[len] = '\0'; - target->Fill(len); - } - } - return rc; -} - } diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h index 858fdea2404..547c21d7a3f 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultclass.h @@ -71,10 +71,7 @@ struct ResEntry void *_pt; }; - bool _extract_field(search::RawBuf *target) const; - - uint32_t _get_length() const { return (_len & 0x7fffffff); } - bool _is_compressed() const { return (_len & 0x80000000) != 0; } + uint32_t _get_length() const { return _len; } uint32_t _get_real_length() const { // precond: IsVariableSize(_type) && _len >= sizeof(uint32_t) @@ -83,29 +80,11 @@ struct ResEntry memcpy(&rlen, _pt, sizeof(rlen)); return rlen; } - const void *_get_compressed() const - { - // precond: IsVariableSize(_type) && _len >= sizeof(uint32_t) - - return (const void *)(((const char *) _pt) + sizeof(uint32_t)); - } - void _resolve_field(const char **buf, uint32_t *buflen, - search::RawBuf *target) const + void _resolve_field(const char **buf, uint32_t *buflen, search::RawBuf *) const { // precond: IsVariableSize(_type) - - if (_is_compressed()) { - if (_extract_field(target)) { - *buf = target->GetDrainPos(); - *buflen = target->GetUsedLen(); - } else { - *buf = NULL; - *buflen = 0; - } - } else { - *buf = (char *) _pt; - *buflen = _len; - } + *buf = (char *) _pt; + *buflen = _len; } }; |