diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-16 21:49:34 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-11-16 21:49:34 +0000 |
commit | e1b6fa45cdafbebc62e81a317c1da11378d9154b (patch) | |
tree | 90e93076cc6959cf6b189746a786a87358852a0c | |
parent | c11bd88ab54edd6e2c370ed7e82094707de19726 (diff) |
GC unused code as tld is gone.
16 files changed, 12 insertions, 750 deletions
diff --git a/searchlib/CMakeLists.txt b/searchlib/CMakeLists.txt index b78f4fc89ac..e81d83ddefa 100644 --- a/searchlib/CMakeLists.txt +++ b/searchlib/CMakeLists.txt @@ -206,7 +206,6 @@ vespa_define_module( src/tests/sort src/tests/sortresults src/tests/sortspec - src/tests/stackdumpiterator src/tests/stringenum src/tests/tensor/dense_tensor_store src/tests/transactionlog diff --git a/searchlib/src/tests/stackdumpiterator/.gitignore b/searchlib/src/tests/stackdumpiterator/.gitignore deleted file mode 100644 index 6f8239c6cc1..00000000000 --- a/searchlib/src/tests/stackdumpiterator/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.core -.depend -Makefile -core -core.* -stackdumpiteratortest -searchlib_stackdumpiteratortest_app diff --git a/searchlib/src/tests/stackdumpiterator/CMakeLists.txt b/searchlib/src/tests/stackdumpiterator/CMakeLists.txt deleted file mode 100644 index 124373406f5..00000000000 --- a/searchlib/src/tests/stackdumpiterator/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchlib_stackdumpiteratortest_app TEST - SOURCES - stackdumpiteratortest.cpp - DEPENDS - searchlib -) -vespa_add_test(NAME searchlib_stackdumpiteratortest_app COMMAND searchlib_stackdumpiteratortest_app - *1000) diff --git a/searchlib/src/tests/stackdumpiterator/stackdumpiteratortest.cpp b/searchlib/src/tests/stackdumpiterator/stackdumpiteratortest.cpp deleted file mode 100644 index 479ec67813d..00000000000 --- a/searchlib/src/tests/stackdumpiterator/stackdumpiteratortest.cpp +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include "stackdumpiteratortest.h" -#include <vespa/searchlib/parsequery/simplequerystack.h> -#include <vespa/searchlib/parsequery/stackdumpiterator.h> -#include <vespa/fastos/time.h> - -#define NUMTESTS 6 - -int -StackDumpIteratorTest::Main() -{ - int doTest[NUMTESTS]; - int low, high, accnum, num; - int indicator; - bool verify = false; - int multiplier = 1; - bool failed = false; - - if (_argc == 1) { - Usage(_argv[0]); - return 1; - } - - // default initialize to not run any tests. - for (int n = 0; n < NUMTESTS; n++) - doTest[n] = 0; - - // parse the command line arguments - for (int i = 1; i < _argc; i++) { - low = 0; - high = NUMTESTS - 1; - char *p = _argv[i]; - - // Check if a multiplier is specified - if (*p == '*') { - p++; - accnum = 0; - while (*p != '\0') { - num = *p - '0'; - accnum = accnum * 10 + num; - p++; - } - multiplier = accnum; - continue; - } - - // Default is to run the tests specified, unless the first char is '/' - indicator = 1; - if (*p == '/') { - p++; - indicator = 0; - } - - // Find the first number - accnum = 0; - while (*p != '-' && *p != '\0') { - num = *p - '0'; - accnum = accnum * 10 + num; - p++; - } - if (accnum >= NUMTESTS) - continue; - low = accnum; - // Check for range operator - if (*p == '-') { - p++; - // Find the second number - accnum = 0; - while (*p != '\0') { - num = *p - '0'; - accnum = accnum * 10 + num; - p++; - } - if (accnum > 0) - high = accnum < NUMTESTS ? accnum : NUMTESTS-1; - } else - high = low; - - // Indicate the runrequest for the desired range. - for (int j = low; j <= high; j++) - doTest[j] = indicator; - } - - // Remove unused tests. - // doTest[1] = 0; - - // Remember time - if (multiplier > 1) { - printf("Running all tests %d times.\n", multiplier); - verify = false; - } else { - verify = true; - } - - int testCnt = 0; - - FastOS_Time timer; - timer.SetNow(); - - // Actually run the tests that we wanted. - for (int j = 0; j < multiplier; j++) - for (int k = 0; k < NUMTESTS; k++) - if (doTest[k] == 1) { - if (!RunTest(k, verify)) - failed = true; - testCnt++; - } - - // Print time taken - double timeTaken = timer.MilliSecsToNow(); - - printf("Time taken : %f ms\n", timeTaken); - printf("Number of tests run: %d\n", testCnt); - double avgTestPrMSec = static_cast<double>(testCnt) / timeTaken; - printf("Tests pr Sec: %f\n", avgTestPrMSec * 1000.0); - - return failed ? 1 : 0; -} - -#define ITERATOR_NOERROR 0x0 -#define ITERATOR_ERROR_WRONG_NUM 0x1 -#define ITERATOR_ERROR_WRONG_TYPE 0x2 -#define ITERATOR_ERROR_WRONG_ARITY 0x4 -#define ITERATOR_ERROR_WRONG_INDEX 0x10 -#define ITERATOR_ERROR_WRONG_TERM 0x20 -#define ITERATOR_ERROR_WRONG_GETINDEX 0x40 -#define ITERATOR_ERROR_WRONG_GETTERM 0x80 -#define ITERATOR_ERROR_WRONG_SIZE 0x100 - -bool -StackDumpIteratorTest::ShowResult(int testNo, - search::SimpleQueryStackDumpIterator &actual, - search::SimpleQueryStack &correct, - unsigned int expected) -{ - if (expected == ITERATOR_NOERROR) { - vespalib::string query = search::SimpleQueryStack::StackbufToString(actual.getStack()); - printf("query = %s\n", query.c_str()); - } - unsigned int results = 0; - - int num = 0; - - search::ParseItem *item; - - printf("%03d: ", testNo); - - while (actual.next()) { - vespalib::stringref idx = actual.getIndexName(); - vespalib::stringref term = actual.getTerm(); - -#if 0 - printf("StackItem #%d: %d %d '%.*s:%.*s'\n", - actual.getNum(), - actual.getType(), - actual.getArity(), - idx.size(), idx.c_str(), - term.size(), term.c_str()); -#endif - - item = correct.Pop(); - - if (num++ != actual.getNum()) { - results |= ITERATOR_ERROR_WRONG_NUM; - delete item; - break; - } - if (item->Type() != actual.getType()) { - results |= ITERATOR_ERROR_WRONG_TYPE; - delete item; - break; - } - if (item->_arity != actual.getArity()) { - results |= ITERATOR_ERROR_WRONG_ARITY; - delete item; - break; - } - if (strncmp(item->_indexName.c_str(), idx.data(), idx.size()) != 0) { - results |= ITERATOR_ERROR_WRONG_INDEX; - delete item; - break; - } - if (strncmp(item->_term.c_str(), term.data(), term.size()) != 0) { - results |= ITERATOR_ERROR_WRONG_TERM; - delete item; - break; - } - - delete item; - } - if (correct.GetSize() != 0) results |= ITERATOR_ERROR_WRONG_SIZE; - - if (results == expected) - printf("ok\n"); - else - printf("fail. exp: %x, result: %x\n", expected, results); - - return results == expected; -} - -/** - * - * @param testno The test to run. - * @param verify Verify the result of the test. - */ -bool -StackDumpIteratorTest::RunTest(int testno, bool verify) -{ - search::SimpleQueryStack stack; - search::RawBuf buf(32768); - - switch (testno) { - case 0: - { - // Simple term query - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foobar")); - - stack.AppendBuffer(&buf); - search::SimpleQueryStackDumpIterator si(vespalib::stringref(buf.GetDrainPos(), buf.GetUsedLen())); - - if (verify) - return ShowResult(testno, si, stack, ITERATOR_NOERROR); - break; - } - - case 1: - { - // multi term query - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo", "foobar")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo", "xyzzy")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "bar", "baz")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_OR, 2)); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_AND, 2)); - - stack.AppendBuffer(&buf); - search::SimpleQueryStackDumpIterator si(vespalib::stringref(buf.GetDrainPos(), buf.GetUsedLen())); - - if (verify) - return ShowResult(testno, si, stack, ITERATOR_NOERROR); - break; - } - - case 2: - { - // all stack items - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo", "foobar")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_NUMTERM, "foo", "[0;22]")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_PREFIXTERM, "bar", "baz")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_PHRASE, 3, "bar")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_SAME_ELEMENT, 3, "bar")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_OR, 2)); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_AND, 3)); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_RANK, 5)); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_NOT, 3)); - - stack.AppendBuffer(&buf); - search::SimpleQueryStackDumpIterator si(vespalib::stringref(buf.GetDrainPos(), buf.GetUsedLen())); - - if (verify) - return ShowResult(testno, si, stack, ITERATOR_NOERROR); - break; - } - - case 3: - { - // malicous type in buffer - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo", "foobar")); - stack.AppendBuffer(&buf); - *buf.GetWritableDrainPos(0) = 0x1e; - search::SimpleQueryStackDumpIterator si(vespalib::stringref(buf.GetDrainPos(), buf.GetUsedLen())); - if (verify) - return ShowResult(testno, si, stack, ITERATOR_ERROR_WRONG_SIZE); - break; - } - - case 4: - { - // malicous length in buffer - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo", "foobar")); - stack.AppendBuffer(&buf); - *buf.GetWritableDrainPos(1) = 0xba; - search::SimpleQueryStackDumpIterator si(vespalib::stringref(buf.GetDrainPos(), buf.GetUsedLen())); - if (verify) - return ShowResult(testno, si, stack, ITERATOR_ERROR_WRONG_SIZE); - break; - } - - case 5: { - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo", "foobar")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo1", "foobar1")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_TERM, "foo2", "foobar2")); - stack.Push(new search::ParseItem(search::ParseItem::ITEM_WORD_ALTERNATIVES, 3, "wa")); - - stack.AppendBuffer(&buf); - search::SimpleQueryStackDumpIterator si(vespalib::stringref(buf.GetDrainPos(), buf.GetUsedLen())); - - if (verify) - return ShowResult(testno, si, stack, ITERATOR_NOERROR); - break; - } - - - default: - { - printf("%03d: no such test\n", testno); - } - } - - return true; -} - -void -StackDumpIteratorTest::Usage(char *progname) -{ - printf("%s {testnospec}+\n\ - Where testnospec is:\n\ - num: single test\n\ - num-num: inclusive range (open range permitted)\n",progname); - printf("There are tests from %d to %d\n\n", 0, NUMTESTS-1); -} - -int -main(int argc, char** argv) -{ - StackDumpIteratorTest tester; - return tester.Entry(argc, argv); -} - diff --git a/searchlib/src/tests/stackdumpiterator/stackdumpiteratortest.h b/searchlib/src/tests/stackdumpiterator/stackdumpiteratortest.h deleted file mode 100644 index bca1dd45893..00000000000 --- a/searchlib/src/tests/stackdumpiterator/stackdumpiteratortest.h +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#pragma once - -#include <vespa/searchlib/parsequery/stackdumpiterator.h> -#include <vespa/fastos/app.h> - -namespace search { class SimpleQueryStack; } - -class StackDumpIteratorTest : public FastOS_Application -{ - int Main() override; - void Usage(char *progname); - bool ShowResult(int testNo, search::SimpleQueryStackDumpIterator &actual, search::SimpleQueryStack &correct, unsigned int expected); - bool RunTest(int i, bool verify); -}; diff --git a/searchlib/src/vespa/searchlib/parsequery/parse.cpp b/searchlib/src/vespa/searchlib/parsequery/parse.cpp index 0911459655c..c8fcce037ae 100644 --- a/searchlib/src/vespa/searchlib/parsequery/parse.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/parse.cpp @@ -58,15 +58,6 @@ void assert_type(ParseItem::ItemType type) } -ParseItem::ParseItem(ItemType type, vespalib::stringref idx, const char *term) - : PARSEITEM_DEFAULT_CONSTRUCTOR_LIST -{ - assert_type(type); - SetType(type); - SetIndex(idx.data()); - SetTerm(term); -} - ParseItem::ParseItem(ItemType type, const char *term) : PARSEITEM_DEFAULT_CONSTRUCTOR_LIST { diff --git a/searchlib/src/vespa/searchlib/parsequery/parse.h b/searchlib/src/vespa/searchlib/parsequery/parse.h index 15fb0e316e8..9c0e76d2441 100644 --- a/searchlib/src/vespa/searchlib/parsequery/parse.h +++ b/searchlib/src/vespa/searchlib/parsequery/parse.h @@ -72,23 +72,19 @@ public: * (juniper/src/query.h) */ enum ItemCreator { - CREA_ORIG = 0, // Original user query - CREA_FILTER // Automatically applied filter (no specific type) + CREA_ORIG = 0 // Original user query }; enum ItemFeatures { - IF_MASK = 0xE0, // mask for item features IF_WEIGHT = 0x20, // item has rank weight IF_UNIQUEID = 0x40, // item has unique id IF_FLAGS = 0x80, // item has extra flags - IF_SUPPORTED_MASK = 0xE0 // mask for supported item features }; enum ItemFlags { IFLAG_NORANK = 0x00000001, // this term should not be ranked (not exposed to rank framework) IFLAG_SPECIALTOKEN = 0x00000002, IFLAG_NOPOSITIONDATA = 0x00000004, // we should not use position data when ranking this term - IFLAG_FILTER = 0x00000008 }; private: @@ -160,15 +156,6 @@ public: ParseItem(ItemType type, int arity, const char *index); /** - * Overloaded constructor for ParseItem. Used for TERMs. - * - * @param type The type of the ParseItem. - * @param idx The name of the index of the ParseItem. - * @param term The actual term string of the ParseItem. - */ - ParseItem(ItemType type, vespalib::stringref index, const char *term); - -/** * Overloaded constructor for ParseItem. Used for TERMs without index. * * @param type The type of the ParseItem. @@ -215,8 +202,6 @@ public: * @param buf Pointer to a buffer containing the encoded contents. */ void AppendBuffer(RawBuf *buf) const; - - size_t GetBufferLen() const; }; } diff --git a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp index dac446df7d5..0908132aa87 100644 --- a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.cpp @@ -14,8 +14,7 @@ namespace search { SimpleQueryStack::SimpleQueryStack() : _numItems(0), - _stack(nullptr), - _FP_queryOK(true) + _stack(nullptr) { } @@ -27,31 +26,12 @@ SimpleQueryStack::~SimpleQueryStack() void SimpleQueryStack::Push(ParseItem *item) { - // Check if query OK for FirstPage - _FP_queryOK &= - ( item->Type() != ParseItem::ITEM_UNDEF - && item->Type() != ParseItem::ITEM_PAREN - ); - - item->_next = _stack; _stack = item; _numItems++; } -ParseItem * -SimpleQueryStack::Pop() -{ - ParseItem *item = _stack; - if (_stack != nullptr) { - _numItems--; - _stack = _stack->_next; - item->_next = nullptr; - } - return item; -} - void SimpleQueryStack::AppendBuffer(RawBuf *buf) const { @@ -67,289 +47,4 @@ SimpleQueryStack::GetSize() return _numItems; } -bool -SimpleQueryStack::_FP_isAllowed() -{ - return _FP_queryOK; -} - -class ItemName { -public: - ItemName() { - memset(_name, 'X', sizeof(_name)); - _name[ParseItem::ITEM_OR] = '|'; - _name[ParseItem::ITEM_WEAK_AND] = 'w'; - _name[ParseItem::ITEM_EQUIV] = 'E'; - _name[ParseItem::ITEM_AND] = '&'; - _name[ParseItem::ITEM_NOT] = '-'; - _name[ParseItem::ITEM_ANY] = '?'; - _name[ParseItem::ITEM_RANK] = '%'; - _name[ParseItem::ITEM_NEAR] = 'N'; - _name[ParseItem::ITEM_ONEAR] = 'O'; - _name[ParseItem::ITEM_NUMTERM] = '#'; - _name[ParseItem::ITEM_TERM] = 't'; - _name[ParseItem::ITEM_PURE_WEIGHTED_STRING] = 'T'; - _name[ParseItem::ITEM_PURE_WEIGHTED_LONG] = 'L'; - _name[ParseItem::ITEM_PREFIXTERM] = '*'; - _name[ParseItem::ITEM_SUBSTRINGTERM] = 's'; - _name[ParseItem::ITEM_EXACTSTRINGTERM] = 'e'; - _name[ParseItem::ITEM_SUFFIXTERM] = 'S'; - _name[ParseItem::ITEM_PHRASE] = '"'; - _name[ParseItem::ITEM_SAME_ELEMENT] = 'M'; - _name[ParseItem::ITEM_WEIGHTED_SET] = 'W'; - _name[ParseItem::ITEM_DOT_PRODUCT] = 'D'; - _name[ParseItem::ITEM_WAND] = 'A'; - _name[ParseItem::ITEM_PREDICATE_QUERY] = 'P'; - _name[ParseItem::ITEM_REGEXP] = '^'; - _name[ParseItem::ITEM_WORD_ALTERNATIVES] = 'a'; - } - char operator[] (ParseItem::ItemType i) const { return _name[i]; } - char operator[] (size_t i) const { return _name[i]; } -private: - char _name[ParseItem::ITEM_MAX]; -}; - -static ItemName _G_ItemName; - -vespalib::string -SimpleQueryStack::StackbufToString(vespalib::stringref theBuf) -{ - vespalib::string result; - - /* - * This is a slightly bogus estimate of the size required. It should - * be enough in most cases, but it is possible to break it in rare and - * artificial circumstances. - * - * The simple operators use 8 bytes in the buffer. - * The string representation has 3 overhead chars, leaving 5 chars - * for the printed representation of the arity, i.e. < 10^5. - * - * The phrase operator uses 12 bytes + the length of the index string. - * The string representation has 5 overhead chars, leaving 7 chars - * for the total printed representation of the length of the index. - * If the index is 0, then the arity may use 6 chars, i.e. < 10^6. - * - * The term operator uses 12 bytes + the length of the index and term string. - * The string representation has 6 overhead chars, leaving 6 chars - * for the total printed representation of the index and term lengths. - * If for instance the index is 0, then the term must be shorter - * than 10^5 characters. - */ - - uint8_t rawtype = 0; - uint32_t type = 0, arity = 0, arg1 = 0; - const char *idxRef; - const char *termRef; - uint32_t idxRefLen; - uint32_t termRefLen; - - const char *p = theBuf.begin(); - const char *ep = theBuf.end(); - uint64_t tmp(0); - int64_t tmpI64(0); - uint8_t flags(0); - while (p < ep) { - vespalib::string metaStr; - rawtype = *p++; - type = ParseItem::GetType(rawtype); - if (ParseItem::GetFeature_Weight(rawtype)) { - int64_t tmpLong(0); - p += vespalib::compress::Integer::decompress(tmpLong, p); - metaStr.append("(w:"); - metaStr.append(make_string("%" PRId64, tmpLong)); - metaStr.append(")"); - } - if (ParseItem::getFeature_UniqueId(rawtype)) { - p += vespalib::compress::Integer::decompressPositive(tmp, p); - metaStr.append("(u:"); - metaStr.append(make_string("%" PRIu64, tmp)); - metaStr.append(")"); - } - if (ParseItem::getFeature_Flags(rawtype)) { - flags = *p++; - metaStr.append("(f:"); - metaStr.append(make_string("%d", flags)); - metaStr.append(")"); - } - if (ParseItem::GetCreator(flags) != ParseItem::CREA_ORIG) { - metaStr.append("(c:"); - metaStr.append(make_string("%d", ParseItem::GetCreator(flags))); - metaStr.append(")"); - } - - metaStr.append('/'); - result.append(metaStr); - - switch (type) { - case ParseItem::ITEM_OR: - case ParseItem::ITEM_AND: - case ParseItem::ITEM_EQUIV: - case ParseItem::ITEM_NOT: - case ParseItem::ITEM_RANK: - case ParseItem::ITEM_ANY: - p += vespalib::compress::Integer::decompressPositive(tmp, p); - arity = tmp; - result.append(make_string("%c/%d~", _G_ItemName[type], arity)); - break; - case ParseItem::ITEM_NEAR: - case ParseItem::ITEM_ONEAR: - p += vespalib::compress::Integer::decompressPositive(tmp, p); - arity = tmp; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - arg1 = tmp; - result.append(make_string("%c/%d/%d~", _G_ItemName[type], arity, arg1)); - break; - case ParseItem::ITEM_WEAK_AND: - p += vespalib::compress::Integer::decompressPositive(tmp, p); - arity = tmp; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - arg1 = tmp; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - idxRefLen = tmp; - idxRef = p; - p += idxRefLen; - result.append( - make_string("%c/%d/%d/%d:%.*s~", _G_ItemName[type], arity, arg1, idxRefLen, idxRefLen, idxRef)); - break; - case ParseItem::ITEM_SAME_ELEMENT: - p += vespalib::compress::Integer::decompressPositive(tmp, p); - arity = tmp; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - idxRefLen = tmp; - idxRef = p; - p += idxRefLen; - result.append(make_string("%c/%d/%d:%.*s~", _G_ItemName[type], arity, idxRefLen, idxRefLen, idxRef)); - break; - - case ParseItem::ITEM_NUMTERM: - case ParseItem::ITEM_TERM: - case ParseItem::ITEM_PREFIXTERM: - case ParseItem::ITEM_SUBSTRINGTERM: - case ParseItem::ITEM_EXACTSTRINGTERM: - case ParseItem::ITEM_SUFFIXTERM: - case ParseItem::ITEM_REGEXP: - p += vespalib::compress::Integer::decompressPositive(tmp, p); - idxRefLen = tmp; - idxRef = p; - p += idxRefLen; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - termRefLen = tmp; - termRef = p; - p += termRefLen; - result.append(make_string("%c/%d:%.*s/%d:%.*s~", _G_ItemName[type], - idxRefLen, idxRefLen, idxRef, termRefLen, termRefLen, termRef)); - break; - case ParseItem::ITEM_PURE_WEIGHTED_STRING: - p += vespalib::compress::Integer::decompressPositive(tmp, p); - termRefLen = tmp; - termRef = p; - p += termRefLen; - result.append(make_string("%c/%d:%.*s~", _G_ItemName[type], termRefLen, termRefLen, termRef)); - break; - - case ParseItem::ITEM_PURE_WEIGHTED_LONG: - tmpI64 = vespalib::nbo::n2h(*reinterpret_cast<const int64_t *>(p)); - p += sizeof(uint64_t); - result.append(make_string("%c/%" PRId64, _G_ItemName[type], tmpI64)); - break; - - case ParseItem::ITEM_PHRASE: - case ParseItem::ITEM_WEIGHTED_SET: - case ParseItem::ITEM_DOT_PRODUCT: - case ParseItem::ITEM_WAND: - p += vespalib::compress::Integer::decompressPositive(tmp, p); - arity = tmp; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - idxRefLen = tmp; - idxRef = p; - p += idxRefLen; - if (type == ParseItem::ITEM_WAND) { - p += vespalib::compress::Integer::decompressPositive(tmp, p); - uint32_t targetNumHits = tmp; - double scoreThreshold = vespalib::nbo::n2h(*reinterpret_cast<const double *>(p)); - p += sizeof(double); - double thresholdBoostFactor = vespalib::nbo::n2h(*reinterpret_cast<const double *>(p)); - p += sizeof(double); - result.append(make_string("%c/%d/%d:%.*s(%u,%f,%f)~", _G_ItemName[type], arity, idxRefLen, - idxRefLen, idxRef, targetNumHits, scoreThreshold, thresholdBoostFactor)); - } else { - result.append( - make_string("%c/%d/%d:%.*s~", _G_ItemName[type], arity, idxRefLen, idxRefLen, idxRef)); - } - break; - - case ParseItem::ITEM_PREDICATE_QUERY: { - idxRefLen = static_cast<uint32_t>(ReadCompressedPositiveInt(p)); - idxRef = p; - p += idxRefLen; - size_t feature_count = ReadCompressedPositiveInt(p); - result.append( - make_string("%c/%d:%.*s/%zu(", _G_ItemName[type], idxRefLen, idxRefLen, idxRef, feature_count)); - for (size_t i = 0; i < feature_count; ++i) { - vespalib::string key = ReadString(p); - vespalib::string value = ReadString(p); - uint64_t sub_queries = ReadUint64(p); - result.append(make_string("%s:%s:%" PRIx64, key.c_str(), value.c_str(), sub_queries)); - if (i < feature_count - 1) { - result.append(','); - } - } - - size_t range_feature_count = ReadCompressedPositiveInt(p); - result.append(make_string(")/%zu(", range_feature_count)); - for (size_t i = 0; i < range_feature_count; ++i) { - vespalib::string key = ReadString(p); - uint64_t value = ReadUint64(p); - uint64_t sub_queries = ReadUint64(p); - result.append(make_string("%s:%" PRIu64 ":%" PRIx64, key.c_str(), value, sub_queries)); - if (i < range_feature_count - 1) { - result.append(','); - } - } - result.append(")~"); - break; - } - case ParseItem::ITEM_WORD_ALTERNATIVES: { - idxRefLen = static_cast<uint32_t>(ReadCompressedPositiveInt(p)); - idxRef = p; - p += idxRefLen; - arity = ReadCompressedPositiveInt(p); - result.append(make_string("%c/%d:%.*s/%d(", _G_ItemName[type], idxRefLen, idxRefLen, idxRef, arity)); - break; - } - default: - LOG(error, "Unhandled type %d", type); - LOG_ABORT("should not be reached"); - } - } - return result; -} - -vespalib::string -SimpleQueryStack::ReadString(const char *&p) -{ - uint64_t tmp; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - vespalib::string s(p, tmp); - p += s.size(); - return s; -} - -uint64_t -SimpleQueryStack::ReadUint64(const char *&p) -{ - uint64_t l = static_cast<uint64_t>(vespalib::nbo::n2h(*(const uint64_t *)(const void *)p)); - p += sizeof(uint64_t); - return l; -} - -uint64_t -SimpleQueryStack::ReadCompressedPositiveInt(const char *&p) -{ - uint64_t tmp; - p += vespalib::compress::Integer::decompressPositive(tmp, p); - return tmp; -} - } // namespace search diff --git a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h index 27e85821cf1..3fff9103b2b 100644 --- a/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h +++ b/searchlib/src/vespa/searchlib/parsequery/simplequerystack.h @@ -17,15 +17,7 @@ namespace search { */ class SimpleQueryStack { - private: - SimpleQueryStack(const SimpleQueryStack &); - SimpleQueryStack& operator=(const SimpleQueryStack &); - - static vespalib::string ReadString(const char *&p); - static uint64_t ReadUint64(const char *&p); - static uint64_t ReadCompressedPositiveInt(const char *&p); - /** The number of items on the stack. */ uint32_t _numItems; @@ -35,10 +27,9 @@ private: */ search::ParseItem *_stack; - /** Is this query OK for FirstPage? */ - bool _FP_queryOK; - public: + SimpleQueryStack(const SimpleQueryStack &) = delete; + SimpleQueryStack& operator=(const SimpleQueryStack &) = delete; /** * Constructor for SimpleQueryStack. */ @@ -52,16 +43,7 @@ public: * @param item The search::ParseItem to push. */ void Push(search::ParseItem *item); - /** - * Pop an item of the stack. - * @return Pointer to the search::ParseItem poped, or NULL if stack is empty. - */ - search::ParseItem *Pop(); - /** - * Top node of the stack. - * @return Pointer to the top search::ParseItem, or NULL if stack is empty. - */ - search::ParseItem *Top() { return _stack; } + /** * Encode the contents of the stack in a binary buffer. @@ -81,18 +63,6 @@ public: * @param numItems The number of items on the stack. */ void SetSize(uint32_t numItems) { _numItems = numItems; } - - /** - * Is it possible to run this query on FirstPage? - * @return true if ok - */ - bool _FP_isAllowed(); - /** - * Make a string representation of the search::RawBuf representing a querystack. - * @param theBuf The querystack encoded buffer. - * @return a fresh string - */ - static vespalib::string StackbufToString(vespalib::stringref theBuf); }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp index 2f59bb30847..18cb2025425 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.cpp @@ -29,8 +29,7 @@ SimpleQueryStackDumpIterator::SimpleQueryStackDumpIterator(vespalib::stringref b _currIndexNameLen(0), _currTerm(nullptr), _currTermLen(0), - _generatedTerm(), - _currNum(-1) + _generatedTerm() { } @@ -288,9 +287,7 @@ SimpleQueryStackDumpIterator::next() default: // Unknown item, so report that no more are available return false; - break; } - _currNum++; _currEnd = p; // We should not have passed the buffer diff --git a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h index c1049aabc55..82e99b786d7 100644 --- a/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h +++ b/searchlib/src/vespa/searchlib/parsequery/stackdumpiterator.h @@ -60,9 +60,6 @@ private: size_t _currTermLen; vespalib::asciistream _generatedTerm; - /** The number of the current item */ - int _currNum; - vespalib::string readString(const char *&p); uint64_t readUint64(const char *&p); uint64_t readCompressedPositiveInt(const char *&p); @@ -90,13 +87,6 @@ public: bool next(); /** - * Get the number of the current item. - * - * @return The ordinal of the current item. -1 if at the start. - */ - int getNum() const { return _currNum; } - - /** * Get the type of the current item. * @return the type. */ diff --git a/searchlib/src/vespa/searchlib/query/query.cpp b/searchlib/src/vespa/searchlib/query/query.cpp index 5887ba395eb..73ad9b5f458 100644 --- a/searchlib/src/vespa/searchlib/query/query.cpp +++ b/searchlib/src/vespa/searchlib/query/query.cpp @@ -1,5 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "query.h" +#include <vespa/searchlib/parsequery/stackdumpiterator.h> #include <vespa/vespalib/objects/visit.hpp> namespace search { diff --git a/searchlib/src/vespa/searchlib/query/query.h b/searchlib/src/vespa/searchlib/query/query.h index b9bcd76d869..f86e7861d06 100644 --- a/searchlib/src/vespa/searchlib/query/query.h +++ b/searchlib/src/vespa/searchlib/query/query.h @@ -3,7 +3,7 @@ #include "queryterm.h" #include "base.h" -#include <vespa/searchlib/parsequery/stackdumpiterator.h> +#include <vespa/searchlib/parsequery/parse.h> namespace search { diff --git a/searchlib/src/vespa/searchlib/query/querynode.cpp b/searchlib/src/vespa/searchlib/query/querynode.cpp index fcc539658d0..234e64b2718 100644 --- a/searchlib/src/vespa/searchlib/query/querynode.cpp +++ b/searchlib/src/vespa/searchlib/query/querynode.cpp @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "query.h" +#include <vespa/searchlib/parsequery/stackdumpiterator.h> #include <vespa/log/log.h> LOG_SETUP(".vsm.querynode"); diff --git a/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h b/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h index a208ae357fa..dfb0c75a695 100644 --- a/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h +++ b/searchlib/src/vespa/searchlib/query/tree/stackdumpquerycreator.h @@ -42,10 +42,6 @@ public: LOG(error, "Unable to create query tree from stack dump. Failed at position %ld out of %ld bytes %s", queryStack.getPosition(), stack.size(), builder.error().c_str()); LOG(error, "Raw QueryStack = %s", vespalib::HexDump(stack.data(), stack.size()).toString().c_str()); - if (LOG_WOULD_LOG(debug)) { - vespalib::string query = SimpleQueryStack::StackbufToString(stack); - LOG(error, "Error = %s, QueryStack = %s", builder.error().c_str(), query.c_str()); - } } return builder.build(); } diff --git a/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp b/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp index 8bb047beb24..e56df354d2a 100644 --- a/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp +++ b/vsm/src/vespa/vsm/vsm/fieldsearchspec.cpp @@ -10,6 +10,7 @@ #include <vespa/vsm/searcher/intfieldsearcher.h> #include <vespa/vsm/searcher/boolfieldsearcher.h> #include <vespa/vsm/searcher/floatfieldsearcher.h> +#include <vespa/vespalib/stllike/asciistream.h> #include <regex> #include <vespa/log/log.h> @@ -148,13 +149,9 @@ vespalib::asciistream & operator <<(vespalib::asciistream & os, const FieldSearc return os; } -FieldSearchSpecMap::FieldSearchSpecMap() : - _specMap(), - _documentTypeMap(), - _nameIdMap() -{ } +FieldSearchSpecMap::FieldSearchSpecMap() = default; -FieldSearchSpecMap::~FieldSearchSpecMap() {} +FieldSearchSpecMap::~FieldSearchSpecMap() = default; namespace { const std::string _G_empty(""); |