summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--searchlib/src/tests/memoryindex/datastore/word_store_test.cpp9
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_inverter.cpp17
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_inverter.h2
-rw-r--r--vespalib/src/vespa/vespalib/datastore/buffer_type.cpp21
4 files changed, 47 insertions, 2 deletions
diff --git a/searchlib/src/tests/memoryindex/datastore/word_store_test.cpp b/searchlib/src/tests/memoryindex/datastore/word_store_test.cpp
index 1de7b4a3efd..5c2bf0d634f 100644
--- a/searchlib/src/tests/memoryindex/datastore/word_store_test.cpp
+++ b/searchlib/src/tests/memoryindex/datastore/word_store_test.cpp
@@ -1,6 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/searchlib/memoryindex/word_store.h>
#include <vespa/vespalib/gtest/gtest.h>
+#include <vespa/vespalib/util/exceptions.h>
+#include <vespa/vespalib/util/size_literals.h>
#include <vespa/log/log.h>
LOG_SETUP("word_store_test");
@@ -64,6 +66,13 @@ TEST(WordStoreTest, add_word_triggers_change_of_buffer)
EXPECT_EQ(4u, lastId);
}
+TEST(WordStoreTest, long_word_triggers_exception)
+{
+ WordStore ws;
+ vespalib::string word(16_Mi + 1_Ki, 'z');
+ EXPECT_THROW(ws.addWord(word), vespalib::OverflowException);
+}
+
}
GTEST_MAIN_RUN_ALL_TESTS()
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.cpp b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.cpp
index a05b39a74a9..25aff06b5ef 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.cpp
@@ -18,7 +18,9 @@
#include <vespa/searchlib/util/url.h>
#include <vespa/vespalib/datastore/aligner.h>
#include <vespa/vespalib/text/utf8.h>
+#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/stringfmt.h>
+#include <vespa/vespalib/stllike/asciistream.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <stdexcept>
@@ -519,7 +521,7 @@ FieldInverter::applyRemoves()
}
void
-FieldInverter::pushDocuments()
+FieldInverter::push_documents_internal()
{
trimAbortedDocs();
@@ -605,5 +607,18 @@ FieldInverter::pushDocuments()
reset();
}
+void
+FieldInverter::pushDocuments()
+{
+ try {
+ push_documents_internal();
+ } catch (vespalib::OverflowException &e) {
+ const Schema::IndexField &field = _schema.getIndexField(_fieldId);
+ vespalib::asciistream s;
+ s << "FieldInverter::pushDocuments(), caught exception for field " << field.getName();
+ throw vespalib::OverflowException(s.c_str(), e);
+ }
+}
+
}
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h
index 7995dc56de8..1a582bf8099 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h
@@ -248,6 +248,8 @@ public:
VESPA_DLL_LOCAL void
processAnnotations(const document::StringFieldValue &value);
+ void push_documents_internal();
+
private:
void processNormalDocTextField(const document::StringFieldValue &field);
void processNormalDocArrayTextField(const document::ArrayFieldValue &field);
diff --git a/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp b/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp
index d1b16e7ae7a..4a9ba2d33a8 100644
--- a/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp
+++ b/vespalib/src/vespa/vespalib/datastore/buffer_type.cpp
@@ -1,6 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "buffer_type.hpp"
+#include <vespa/vespalib/stllike/asciistream.h>
+#include <vespa/vespalib/util/exceptions.h>
#include <algorithm>
#include <cassert>
#include <cmath>
@@ -150,7 +152,24 @@ BufferTypeBase::calcArraysToAlloc(uint32_t bufferId, ElemCount elemsNeeded, bool
if (result > _maxArrays) {
result = _maxArrays;
}
- assert(result >= neededArrays);
+ if (result < neededArrays) {
+ vespalib::asciistream s;
+ s << "BufferTypeBase::calcArraysToAlloc(" <<
+ "bufferId=" << bufferId <<
+ ",elemsNeeeded=" << elemsNeeded <<
+ ",resizing=" << (resizing ? "true" : "false") << ")" <<
+ " wantedArrays=" << wantedArrays <<
+ ", _arraySize=" << _arraySize <<
+ ", _maxArrays=" << _maxArrays <<
+ ", reservedElems=" << reservedElems <<
+ ", liveArrays=" << liveArrays <<
+ ", growArrays=" << growArrays <<
+ ", usedArrays=" << usedArrays <<
+ ", typeid(*this).name=\"" << typeid(*this).name() << "\"" <<
+ ", newArrays=" << result <<
+ " < neededArrays=" << neededArrays;;
+ throw vespalib::OverflowException(s.c_str());
+ }
return result;
}