summaryrefslogtreecommitdiffstats
path: root/vsm
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-07-26 15:24:39 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2017-07-31 17:04:18 +0200
commitc53f75542efbbe5e737744fe1104f7b8c56eb3b8 (patch)
treedf98d7f1206b60623594a43e23794d05485f1203 /vsm
parent5f54fb77ef1e354f9919e92da7b22cbe68ee7fbd (diff)
Unify error handling to using exceptions only, not in combination with nullptr.
Diffstat (limited to 'vsm')
-rw-r--r--vsm/src/tests/docsum/docsum.cpp24
-rw-r--r--vsm/src/tests/document/document.cpp8
-rw-r--r--vsm/src/vespa/vsm/common/documenttypemapping.cpp13
3 files changed, 30 insertions, 15 deletions
diff --git a/vsm/src/tests/docsum/docsum.cpp b/vsm/src/tests/docsum/docsum.cpp
index 52baefbfc0e..a3c8cba14b5 100644
--- a/vsm/src/tests/docsum/docsum.cpp
+++ b/vsm/src/tests/docsum/docsum.cpp
@@ -195,8 +195,16 @@ DocsumTest::testSlimeFieldWriter()
{ // select a subset and then all
SlimeFieldWriter sfw;
DocsumFieldSpec::FieldIdentifierVector fields;
- fields.push_back(DocsumFieldSpec::FieldIdentifier(0, *type.buildFieldPath("a")));
- fields.push_back(DocsumFieldSpec::FieldIdentifier(0, *type.buildFieldPath("c.e")));
+ {
+ FieldPath path;
+ type.buildFieldPath(path, "a");
+ fields.push_back(DocsumFieldSpec::FieldIdentifier(0, path));
+ }
+ {
+ FieldPath path;
+ type.buildFieldPath(path, "c.e");
+ fields.push_back(DocsumFieldSpec::FieldIdentifier(0, path));
+ }
sfw.setInputFields(fields);
TEST_DO(assertSlimeFieldWriter(sfw, value, "{\"a\":\"foo\",\"c\":{\"e\":\"qux\"}}"));
sfw.clear();
@@ -240,10 +248,18 @@ DocsumTest::requireThatSlimeFieldWriterHandlesMap()
{ // select a subset and then all
SlimeFieldWriter sfw;
DocsumFieldSpec::FieldIdentifierVector fields;
- fields.push_back(DocsumFieldSpec::FieldIdentifier(0, *mapType.buildFieldPath("value.b")));
+ {
+ FieldPath path;
+ mapType.buildFieldPath(path, "value.b");
+ fields.push_back(DocsumFieldSpec::FieldIdentifier(0, path));
+ }
sfw.setInputFields(fields);
TEST_DO(assertSlimeFieldWriter(sfw, mapfv, "[{\"key\":\"k1\",\"value\":{\"b\":\"bar\"}}]"));
- fields[0] = DocsumFieldSpec::FieldIdentifier(0, *mapType.buildFieldPath("{k1}.a"));
+ {
+ FieldPath path;
+ mapType.buildFieldPath(path, "{k1}.a");
+ fields[0] = DocsumFieldSpec::FieldIdentifier(0, path);
+ }
sfw.clear();
sfw.setInputFields(fields);
TEST_DO(assertSlimeFieldWriter(sfw, mapfv, "[{\"key\":\"k1\",\"value\":{\"a\":\"foo\"}}]"));
diff --git a/vsm/src/tests/document/document.cpp b/vsm/src/tests/document/document.cpp
index 599b761ea0b..d6e3f507034 100644
--- a/vsm/src/tests/document/document.cpp
+++ b/vsm/src/tests/document/document.cpp
@@ -34,9 +34,11 @@ DocumentTest::testStorageDocument()
doc->setValue(fb, StringFieldValue("bar"));
SharedFieldPathMap fpmap(new FieldPathMapT());
- fpmap->push_back(*dt.buildFieldPath("a"));
- fpmap->push_back(*dt.buildFieldPath("b"));
- fpmap->push_back(FieldPath());
+ fpmap->emplace_back();
+ dt.buildFieldPath(fpmap->back(),"a");
+ fpmap->emplace_back();
+ dt.buildFieldPath(fpmap->back(), "b");
+ fpmap->emplace_back();
ASSERT_TRUE((*fpmap)[0].size() == 1);
ASSERT_TRUE((*fpmap)[1].size() == 1);
ASSERT_TRUE((*fpmap)[2].size() == 0);
diff --git a/vsm/src/vespa/vsm/common/documenttypemapping.cpp b/vsm/src/vespa/vsm/common/documenttypemapping.cpp
index 4c87f9e186f..679f3d968bd 100644
--- a/vsm/src/vespa/vsm/common/documenttypemapping.cpp
+++ b/vsm/src/vespa/vsm/common/documenttypemapping.cpp
@@ -78,14 +78,11 @@ void DocumentTypeMapping::buildFieldMap(
LOG(debug, "Handling %s -> %d", fname.c_str(), it->second);
try {
if ((it->first[0] != '[') && (it->first != "summaryfeatures") && (it->first != "rankfeatures") && (it->first != "ranklog") && (it->first != "sddocname") && (it->first != "documentid")) {
- FieldPath::UP fieldPath = docType.buildFieldPath(fname);
- if (fieldPath.get()) {
- fieldMap[it->second] = *fieldPath;
- validCount++;
- LOG(spam, "Found %s -> %d in document", fname.c_str(), it->second);
- } else {
- LOG(debug, "Failed to find %s -> %d in document", fname.c_str(), it->second);
- }
+ FieldPath fieldPath;
+ docType.buildFieldPath(fieldPath, fname);
+ fieldMap[it->second] = std::move(fieldPath);
+ validCount++;
+ LOG(spam, "Found %s -> %d in document", fname.c_str(), it->second);
}
} catch (const std::exception & e) {
LOG(debug, "Could not get field info for '%s' in documenttype '%s' (id = '%s') : %s",