summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java2
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java14
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/parser/InheritanceResolver.java24
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocument.java22
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocumentSummary.java7
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSchema.java12
-rw-r--r--config-model/src/main/javacc/IntermediateParser.jj7
-rw-r--r--config-model/src/test/examples/multiplesummaries.sd5
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java6
-rwxr-xr-xconfig-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java1
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java12
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java10
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java44
-rw-r--r--config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java9
-rw-r--r--document/src/tests/arrayfieldvaluetest.cpp18
-rw-r--r--document/src/tests/documentselectparsertest.cpp20
-rw-r--r--document/src/tests/documenttestcase.cpp36
-rw-r--r--document/src/tests/documentupdatetestcase.cpp4
-rw-r--r--document/src/tests/fieldvalue/fieldvalue_test.cpp14
-rw-r--r--document/src/tests/primitivefieldvaluetest.cpp55
-rw-r--r--document/src/vespa/document/datatype/primitivedatatype.cpp18
-rw-r--r--document/src/vespa/document/fieldvalue/arrayfieldvalue.h4
-rw-r--r--document/src/vespa/document/fieldvalue/boolfieldvalue.cpp20
-rw-r--r--document/src/vespa/document/fieldvalue/boolfieldvalue.h6
-rw-r--r--document/src/vespa/document/fieldvalue/bytefieldvalue.h5
-rw-r--r--document/src/vespa/document/fieldvalue/doublefieldvalue.h4
-rw-r--r--document/src/vespa/document/fieldvalue/fieldvalue.cpp24
-rw-r--r--document/src/vespa/document/fieldvalue/fieldvalue.h10
-rw-r--r--document/src/vespa/document/fieldvalue/floatfieldvalue.h4
-rw-r--r--document/src/vespa/document/fieldvalue/intfieldvalue.h3
-rw-r--r--document/src/vespa/document/fieldvalue/literalfieldvalue.cpp44
-rw-r--r--document/src/vespa/document/fieldvalue/literalfieldvalue.h8
-rw-r--r--document/src/vespa/document/fieldvalue/longfieldvalue.h3
-rw-r--r--document/src/vespa/document/fieldvalue/numericfieldvalue.h4
-rw-r--r--document/src/vespa/document/fieldvalue/numericfieldvalue.hpp36
-rw-r--r--document/src/vespa/document/fieldvalue/shortfieldvalue.h3
-rw-r--r--document/src/vespa/document/fieldvalue/stringfieldvalue.h4
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.cpp19
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.h3
-rw-r--r--document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp14
-rw-r--r--document/src/vespa/document/fieldvalue/structuredfieldvalue.h13
-rw-r--r--document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp16
-rw-r--r--document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp6
-rw-r--r--document/src/vespa/document/test/fieldvalue_helpers.h59
-rw-r--r--documentapi/src/tests/messages/messages60test.cpp1
-rw-r--r--documentapi/src/tests/policies/policies_test.cpp2
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp1
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/messages/visitor.h17
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp1
-rw-r--r--documentapi/src/vespa/documentapi/messagebus/routablefactories60.cpp1
-rw-r--r--eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp4
-rw-r--r--eval/src/tests/apps/analyze_onnx_model/analyze_onnx_model_test.cpp10
-rw-r--r--persistence/src/vespa/persistence/spi/persistenceprovider.h1
-rw-r--r--searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp3
-rw-r--r--searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp8
-rw-r--r--searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp90
-rw-r--r--searchcore/src/tests/proton/server/documentretriever_test.cpp16
-rw-r--r--searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp2
-rw-r--r--searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp40
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp7
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h3
-rw-r--r--searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp1
-rw-r--r--searchlib/src/apps/tests/memoryindexstress_test.cpp2
-rw-r--r--searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp8
-rw-r--r--searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp6
-rw-r--r--searchlib/src/tests/grouping/grouping_serialization_test.cpp1
-rw-r--r--searchlib/src/vespa/searchlib/expression/documentaccessornode.h10
-rw-r--r--searchlib/src/vespa/searchlib/expression/documentfieldnode.h1
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/field_inverter.h9
-rw-r--r--searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp1
-rw-r--r--searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp2
-rw-r--r--storage/src/tests/storageserver/documentapiconvertertest.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/CMakeLists.txt1
-rw-r--r--storage/src/vespa/storage/persistence/asynchandler.h5
-rw-r--r--storage/src/vespa/storage/persistence/merge_bucket_info_syncer.h2
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.cpp15
-rw-r--r--storage/src/vespa/storage/persistence/mergehandler.h23
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/persistenceutil.h7
-rw-r--r--storage/src/vespa/storage/persistence/processallhandler.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/provider_error_wrapper.cpp1
-rw-r--r--storage/src/vespa/storage/persistence/types.cpp10
-rw-r--r--storage/src/vespa/storage/persistence/types.h7
-rw-r--r--storage/src/vespa/storage/storageserver/documentapiconverter.cpp1
-rw-r--r--storage/src/vespa/storage/visiting/recoveryvisitor.cpp2
86 files changed, 422 insertions, 556 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java
index e9939a53fc5..67d8d679275 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/ApplicationBuilder.java
@@ -426,7 +426,7 @@ public class ApplicationBuilder {
}
/**
- * Convenience factory methdd to create a SearchBuilder from multiple SD files. Only for testing.
+ * Convenience factory methods to create a SearchBuilder from multiple SD files. Only for testing.
*/
public static ApplicationBuilder createFromFiles(Collection<String> fileNames) throws IOException, ParseException {
return createFromFiles(fileNames, new BaseDeployLogger());
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java
index ad2dff46ee3..e67c1ac8275 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java
@@ -58,8 +58,6 @@ public class ConvertParsedTypes {
var doc = schema.getDocument();
for (var struct : doc.getStructs()) {
String structId = doc.name() + "->" + struct.name();
- // int id = new StructDataType(structId).getId();
- // var dt = new StructDataType(id, struct.name());
var dt = new StructDataType(struct.name());
structsFromSchemas.put(structId, dt);
}
@@ -190,18 +188,6 @@ public class ConvertParsedTypes {
throw new IllegalArgumentException("conflicting values for struct " + name + " in " +doc);
}
}
- if (found == null) {
- // TODO: be more restrictive here, but we need something
- // for imported fields. For now, fall back to looking for
- // struct in any schema.
- for (var schema : orderedInput) {
- for (var struct : schema.getDocument().getStructs()) {
- if (struct.name().equals(name)) {
- return struct;
- }
- }
- }
- }
return found;
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/InheritanceResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/InheritanceResolver.java
index d9132d3aa24..4d011c1b596 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/InheritanceResolver.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/InheritanceResolver.java
@@ -15,6 +15,7 @@ public class InheritanceResolver {
private final Map<String, ParsedSchema> parsedSchemas;
private final Map<String, ParsedDocument> parsedDocs = new HashMap<>();
+ private final Map<String, ParsedSchema> schemaForDocs = new HashMap<>();
public InheritanceResolver(Map<String, ParsedSchema> parsedSchemas) {
this.parsedSchemas = parsedSchemas;
@@ -24,7 +25,7 @@ public class InheritanceResolver {
String name = schema.name();
if (seen.contains(name)) {
seen.add(name);
- throw new IllegalArgumentException("Inheritance cycle for schemas: " +
+ throw new IllegalArgumentException("Inheritance/reference cycle for schemas: " +
String.join(" -> ", seen));
}
seen.add(name);
@@ -64,9 +65,13 @@ public class InheritanceResolver {
if (old != null) {
throw new IllegalArgumentException("duplicate document declaration for " + doc.name());
}
+ schemaForDocs.put(doc.name(), schema);
for (String docInherit : doc.getInherited()) {
schema.inheritByDocument(docInherit);
}
+ for (String docReferenced : doc.getReferencedDocuments()) {
+ schema.inheritByDocument(docReferenced);
+ }
}
for (ParsedDocument doc : parsedDocs.values()) {
for (String inherit : doc.getInherited()) {
@@ -76,13 +81,20 @@ public class InheritanceResolver {
}
doc.resolveInherit(inherit, parentDoc);
}
+ for (String docRefName : doc.getReferencedDocuments()) {
+ var refDoc = parsedDocs.get(docRefName);
+ if (refDoc == null) {
+ throw new IllegalArgumentException("document " + doc.name() + " references unavailable document " + docRefName);
+ }
+ doc.resolveReferenced(refDoc);
+ }
}
for (ParsedSchema schema : parsedSchemas.values()) {
- for (String inherit : schema.getInheritedByDocument()) {
- var parent = parsedSchemas.get(inherit);
+ for (String docName : schema.getInheritedByDocument()) {
+ var parent = schemaForDocs.get(docName);
assert(parent.hasDocument());
- assert(parent.getDocument().name().equals(inherit));
- schema.resolveInheritByDocument(inherit, parent);
+ assert(parent.getDocument().name().equals(docName));
+ schema.resolveInheritByDocument(docName, parent);
}
}
}
@@ -91,7 +103,7 @@ public class InheritanceResolver {
String name = document.name();
if (seen.contains(name)) {
seen.add(name);
- throw new IllegalArgumentException("Inheritance cycle for documents: " +
+ throw new IllegalArgumentException("Inheritance/reference cycle for documents: " +
String.join(" -> ", seen));
}
seen.add(name);
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocument.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocument.java
index 065b66e22b1..ed975238067 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocument.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocument.java
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.parser;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
@@ -34,6 +33,19 @@ public class ParsedDocument extends ParsedBlock {
ParsedStruct getStruct(String name) { return docStructs.get(name); }
ParsedAnnotation getAnnotation(String name) { return docAnnotations.get(name); }
+ List<String> getReferencedDocuments() {
+ var result = new ArrayList<String>();
+ for (var field : docFields.values()) {
+ var type = field.getType();
+ if (type.getVariant() == ParsedType.Variant.DOC_REFERENCE) {
+ var docType = type.getReferencedDocumentType();
+ assert(docType.getVariant() == ParsedType.Variant.DOCUMENT);
+ result.add(docType.name());
+ }
+ }
+ return result;
+ }
+
void inherit(String other) { inherited.add(other); }
void addField(ParsedField field) {
@@ -54,6 +66,7 @@ public class ParsedDocument extends ParsedBlock {
verifyThat(! docAnnotations.containsKey(annName), "already has annotation", annName);
docAnnotations.put(annName, annotation);
annotation.tagOwner(name());
+ annotation.getStruct().ifPresent(s -> s.tagOwner(name()));
}
public String toString() { return "document " + name(); }
@@ -64,5 +77,12 @@ public class ParsedDocument extends ParsedBlock {
verifyThat(! resolvedInherits.containsKey(name), "double resolveInherit for", name);
resolvedInherits.put(name, parsed);
}
+
+ void resolveReferenced(ParsedDocument parsed) {
+ // TODO - not really inheritance:
+ var old = resolvedInherits.put(parsed.name(), parsed);
+ assert(old == null || old == parsed);
+ }
+
}
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocumentSummary.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocumentSummary.java
index 08f4946a218..25adc6f134f 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocumentSummary.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedDocumentSummary.java
@@ -28,10 +28,11 @@ class ParsedDocumentSummary extends ParsedBlock {
List<ParsedSummaryField> getSummaryFields() { return List.copyOf(fields.values()); }
List<String> getInherited() { return List.copyOf(inherited); }
- void addField(ParsedSummaryField field) {
+ ParsedSummaryField addField(ParsedSummaryField field) {
String fieldName = field.name();
- verifyThat(! fields.containsKey(fieldName), "already has field", fieldName);
- fields.put(fieldName, field);
+ // TODO disallow this on Vespa 8
+ // verifyThat(! fields.containsKey(fieldName), "already has field", fieldName);
+ return fields.put(fieldName, field);
}
void setFromDisk(boolean value) {
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSchema.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSchema.java
index bcbf14d9398..0004094e1c2 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSchema.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ParsedSchema.java
@@ -82,8 +82,9 @@ public class ParsedSchema extends ParsedBlock {
void addDocument(ParsedDocument document) {
verifyThat(myDocument == null,
"already has", myDocument, "so cannot add", document);
- verifyThat(name().equals(document.name()),
- "schema " + name() + "can only contain document named " + name() + ", was: "+ document.name());
+ // TODO - disallow?
+ // verifyThat(name().equals(document.name()),
+ // "schema " + name() + " can only contain document named " + name() + ", was: "+ document.name());
this.myDocument = document;
}
@@ -156,16 +157,15 @@ public class ParsedSchema extends ParsedBlock {
verifyThat(name.equals(parsed.name()), "resolveInherit name mismatch for", name);
verifyThat(! resolvedInherits.containsKey(name), "double resolveInherit for", name);
resolvedInherits.put(name, parsed);
- var old = allResolvedInherits.put(name, parsed);
+ var old = allResolvedInherits.put("schema " + name, parsed);
verifyThat(old == null || old == parsed, "conflicting resolveInherit for", name);
}
void resolveInheritByDocument(String name, ParsedSchema parsed) {
verifyThat(inheritedByDocument.contains(name),
"resolveInheritByDocument for non-inherited name", name);
- verifyThat(name.equals(parsed.name()), "resolveInheritByDocument name mismatch for", name);
- var old = allResolvedInherits.put(name, parsed);
- verifyThat(old == null || old == parsed, "conflicting resolveInherit for", name);
+ var old = allResolvedInherits.put("document " + name, parsed);
+ verifyThat(old == null || old == parsed, "conflicting resolveInheritByDocument for", name);
}
}
diff --git a/config-model/src/main/javacc/IntermediateParser.jj b/config-model/src/main/javacc/IntermediateParser.jj
index b57719ec72d..7447eee5cec 100644
--- a/config-model/src/main/javacc/IntermediateParser.jj
+++ b/config-model/src/main/javacc/IntermediateParser.jj
@@ -1161,7 +1161,12 @@ void summaryInDocument(ParsedDocumentSummary docsum) :
}
lbrace() (summaryItem(psf) (<NL>)*)* <RBRACE>
{
- docsum.addField(psf);
+ var old = docsum.addField(psf);
+ if (old != null) {
+ deployLogger.logApplicationPackage(Level.WARNING, "Summary field '" + psf.name()
+ + "' is defined twice in document-summary '"
+ + docsum.name() + "'");
+ }
}
}
diff --git a/config-model/src/test/examples/multiplesummaries.sd b/config-model/src/test/examples/multiplesummaries.sd
index 07ab3c5a104..83e817718aa 100644
--- a/config-model/src/test/examples/multiplesummaries.sd
+++ b/config-model/src/test/examples/multiplesummaries.sd
@@ -28,6 +28,11 @@ search multiplesummaries {
summary field3 type array<int> {
}
+ # TODO disallow duplicates
+ summary field1 type weightedset<string> {
+ source: field1
+ }
+
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java
index 0fcc6e09b02..1bf07aff9d5 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/MultipleSummariesTestCase.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
+import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -12,8 +13,11 @@ import java.io.IOException;
* @author bratseth
*/
public class MultipleSummariesTestCase extends AbstractSchemaTestCase {
+
@Test
public void testArrayImporting() throws IOException, ParseException {
- ApplicationBuilder.buildFromFile("src/test/examples/multiplesummaries.sd");
+ var builder = new ApplicationBuilder(new TestProperties().setExperimentalSdParsing(true));
+ builder.addSchemaFile("src/test/examples/multiplesummaries.sd");
+ builder.build(true);
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
index 2ce88e2148d..231881114b5 100755
--- a/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/StructTestCase.java
@@ -1,3 +1,4 @@
+
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition;
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java
index 456efdb08ae..ad4ff4be4b3 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/AbstractExportingTestCase.java
@@ -100,6 +100,7 @@ public abstract class AbstractExportingTestCase extends AbstractSchemaTestCase {
DeployLogger logger) throws IOException, ParseException {
return assertCorrectDeriving(dirName, searchDefinitionName, new TestProperties(), logger);
}
+
protected DerivedConfiguration assertCorrectDeriving(String dirName,
TestProperties properties) throws IOException, ParseException
{
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java
index 34354612d04..5dcb9e4ca01 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/ImportedFieldsTestCase.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;
+import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -18,7 +19,16 @@ public class ImportedFieldsTestCase extends AbstractExportingTestCase {
@Test
public void configs_for_imported_struct_fields_are_derived() throws IOException, ParseException {
- assertCorrectDeriving("imported_struct_fields", "child", new TestableDeployLogger());
+ assertCorrectDeriving("imported_struct_fields", "child",
+ new TestProperties().setExperimentalSdParsing(false),
+ new TestableDeployLogger());
+ }
+
+ @Test
+ public void configs_for_imported_struct_fields_are_derived_new() throws IOException, ParseException {
+ assertCorrectDeriving("imported_struct_fields", "child",
+ new TestProperties().setExperimentalSdParsing(true),
+ new TestableDeployLogger());
}
@Test
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java
index 0e6d7b8442f..b13e88f5f1f 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/MultipleSummariesTestCase.java
@@ -1,6 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.derived;
+import com.yahoo.config.model.deploy.TestProperties;
import com.yahoo.searchdefinition.parser.ParseException;
import org.junit.Test;
@@ -14,6 +15,13 @@ import java.io.IOException;
public class MultipleSummariesTestCase extends AbstractExportingTestCase {
@Test
public void testMultipleSummaries() throws IOException, ParseException {
- assertCorrectDeriving("multiplesummaries");
+ assertCorrectDeriving("multiplesummaries",
+ new TestProperties().setExperimentalSdParsing(false));
+ }
+
+ @Test
+ public void testMultipleSummariesNew() throws IOException, ParseException {
+ assertCorrectDeriving("multiplesummaries",
+ new TestProperties().setExperimentalSdParsing(true));
}
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java
index 10f45e6c17b..e29e4833856 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateCollectionTestCase.java
@@ -36,6 +36,20 @@ public class IntermediateCollectionTestCase {
}
@Test
+ public void names_may_differ() throws Exception {
+ String input = joinLines
+ ("schema foo_search {",
+ " document foo {",
+ " }",
+ "}");
+ var collection = new IntermediateCollection();
+ ParsedSchema schema = collection.addSchemaFromString(input);
+ assertEquals("foo_search", schema.name());
+ assertTrue(schema.hasDocument());
+ assertEquals("foo", schema.getDocument().name());
+ }
+
+ @Test
public void can_add_schema_files() throws Exception {
var collection = new IntermediateCollection();
collection.addSchemaFromFile("src/test/derived/deriver/child.sd");
@@ -167,7 +181,7 @@ public class IntermediateCollectionTestCase {
assertEquals(collection.getParsedSchemas().size(), 3);
var ex = assertThrows(IllegalArgumentException.class, () ->
collection.resolveInternalConnections());
- assertTrue(ex.getMessage().startsWith("Inheritance cycle for schemas: "));
+ assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for schemas: "));
}
@Test
@@ -180,7 +194,7 @@ public class IntermediateCollectionTestCase {
var ex = assertThrows(IllegalArgumentException.class, () ->
collection.resolveInternalConnections());
System.err.println("ex: "+ex.getMessage());
- assertTrue(ex.getMessage().startsWith("Inheritance cycle for documents: "));
+ assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for documents: "));
}
@Test
@@ -194,4 +208,30 @@ public class IntermediateCollectionTestCase {
assertEquals("document foo inherits from unavailable document bar", ex.getMessage());
}
+ @Test
+ public void can_detect_document_reference_cycle() throws Exception {
+ var collection = new IntermediateCollection();
+ collection.addSchemaFromString("schema foo { document foo { field oneref type reference<bar> {} } }");
+ collection.addSchemaFromString("schema bar { document bar { field tworef type reference<foo> {} } }");
+ assertEquals(collection.getParsedSchemas().size(), 2);
+ var ex = assertThrows(IllegalArgumentException.class, () ->
+ collection.resolveInternalConnections());
+ System.err.println("ex: "+ex.getMessage());
+ assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for documents: "));
+ }
+
+ @Test
+ public void can_detect_cycles_with_reference() throws Exception {
+ var collection = new IntermediateCollection();
+ collection.addSchemaFromString("schema foo { document foodoc inherits bardoc {} }");
+ collection.addSchemaFromString("schema bar { document bardoc { field myref type reference<qux> { } } }");
+ collection.addSchemaFromString("schema qux inherits foo { document qux inherits foodoc {} }");
+ assertEquals(collection.getParsedSchemas().size(), 3);
+ var ex = assertThrows(IllegalArgumentException.class, () ->
+ collection.resolveInternalConnections());
+ System.err.println("ex: "+ex.getMessage());
+ assertTrue(ex.getMessage().startsWith("Inheritance/reference cycle for documents: "));
+ }
+
+
}
diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java
index 9d93dedb709..190a8fc0a19 100644
--- a/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java
+++ b/config-model/src/test/java/com/yahoo/searchdefinition/parser/IntermediateParserTestCase.java
@@ -22,8 +22,12 @@ public class IntermediateParserTestCase {
var deployLogger = new BaseDeployLogger();
var modelProperties = new TestProperties();
var stream = new SimpleCharStream(input);
- var parser = new IntermediateParser(stream, deployLogger, modelProperties);
- return parser.schema();
+ try {
+ var parser = new IntermediateParser(stream, deployLogger, modelProperties);
+ return parser.schema();
+ } catch (ParseException pe) {
+ throw new ParseException(stream.formatException(pe.getMessage()));
+ }
}
ParsedSchema parseFile(String fileName) throws Exception {
@@ -208,6 +212,7 @@ public class IntermediateParserTestCase {
checkFileParses("src/test/derived/uri_wset/uri_wset.sd");
checkFileParses("src/test/examples/arrays.sd");
checkFileParses("src/test/examples/arraysweightedsets.sd");
+ checkFileParses("src/test/examples/attributeposition.sd");
checkFileParses("src/test/examples/attributesettings.sd");
checkFileParses("src/test/examples/attributesexactmatch.sd");
checkFileParses("src/test/examples/casing.sd");
diff --git a/document/src/tests/arrayfieldvaluetest.cpp b/document/src/tests/arrayfieldvaluetest.cpp
index a8ca9d22916..375ce05a4e6 100644
--- a/document/src/tests/arrayfieldvaluetest.cpp
+++ b/document/src/tests/arrayfieldvaluetest.cpp
@@ -3,7 +3,6 @@
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/document/util/bytebuffer.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <gtest/gtest.h>
#include <gmock/gmock.h>
@@ -103,21 +102,14 @@ TEST(ArrayFieldValueTest, testArray)
ArrayFieldValue::UP valuePtr(value2.clone());
EXPECT_EQ(value, *valuePtr);
- // Iterating
+ // Iterating
const ArrayFieldValue& constVal(value);
- for(ArrayFieldValue::const_iterator it = constVal.begin();
- it != constVal.end(); ++it)
- {
- const FieldValue& fval1(*it);
- (void) fval1;
- EXPECT_EQ((uint32_t) IntFieldValue::classId,
- it->getClass().id());
+ for(const FieldValue & fval1 : constVal) {
+ EXPECT_EQ((uint32_t) IntFieldValue::classId, fval1.getClass().id());
}
value2 = value;
- for(ArrayFieldValue::iterator it = value2.begin(); it != value2.end(); ++it)
- {
- (*it).assign(IntFieldValue(7));
- it->assign(IntFieldValue(7));
+ for(size_t i(0); i < value2.size(); i++) {
+ value2[i].assign(IntFieldValue(7));
}
EXPECT_TRUE(value != value2);
EXPECT_TRUE(value2.contains(IntFieldValue(7)));
diff --git a/document/src/tests/documentselectparsertest.cpp b/document/src/tests/documentselectparsertest.cpp
index 8308c3bc693..d2fa969daa9 100644
--- a/document/src/tests/documentselectparsertest.cpp
+++ b/document/src/tests/documentselectparsertest.cpp
@@ -153,18 +153,18 @@ DocumentSelectParserTest::createDocs()
// Add some arrays and structs to doc 1
{
StructFieldValue sval(_doc.back()->getField("mystruct").getDataType());
- sval.set("key", 14);
- sval.set("value", "structval");
+ sval.setValue("key", IntFieldValue::make(14));
+ sval.setValue("value", StringFieldValue::make("structval"));
_doc.back()->setValue("mystruct", sval);
ArrayFieldValue
aval(_doc.back()->getField("structarray").getDataType());
{
StructFieldValue sval1(aval.getNestedType());
- sval1.set("key", 15);
- sval1.set("value", "structval1");
+ sval1.setValue("key", IntFieldValue::make(15));
+ sval1.setValue("value", StringFieldValue::make("structval1"));
StructFieldValue sval2(aval.getNestedType());
- sval2.set("key", 16);
- sval2.set("value", "structval2");
+ sval2.setValue("key", IntFieldValue::make(16));
+ sval2.setValue("value", StringFieldValue::make("structval2"));
aval.add(sval1);
aval.add(sval2);
}
@@ -182,11 +182,11 @@ DocumentSelectParserTest::createDocs()
ArrayFieldValue abval(_doc.back()->getField("structarray").getDataType());
{
StructFieldValue sval1(aval.getNestedType());
- sval1.set("key", 17);
- sval1.set("value", "structval3");
+ sval1.setValue("key", IntFieldValue::make(17));
+ sval1.setValue("value", StringFieldValue::make("structval3"));
StructFieldValue sval2(aval.getNestedType());
- sval2.set("key", 18);
- sval2.set("value", "structval4");
+ sval2.setValue("key", IntFieldValue::make(18));
+ sval2.setValue("value", StringFieldValue::make("structval4"));
abval.add(sval1);
abval.add(sval2);
}
diff --git a/document/src/tests/documenttestcase.cpp b/document/src/tests/documenttestcase.cpp
index bcf0cbad5fe..c852e219faa 100644
--- a/document/src/tests/documenttestcase.cpp
+++ b/document/src/tests/documenttestcase.cpp
@@ -707,15 +707,15 @@ TEST(DocumentTest,testReadSerializedAllVersions)
// Create a memory instance of document
{
Document doc(*docType, DocumentId("id:ns:serializetest::http://test.doc.id/"));
- doc.set("intfield", 5);
- doc.set("floatfield", -9.23);
- doc.set("stringfield", "This is a string.");
- doc.set("longfield", static_cast<int64_t>(398420092938472983LL));
- doc.set("doublefield", 98374532.398820);
- doc.set("bytefield", -2);
- doc.setValue("rawfield", RawFieldValue("RAW DATA", 8));
+ doc.setValue("intfield", IntFieldValue::make(5));
+ doc.setValue("floatfield", FloatFieldValue::make(-9.23));
+ doc.setValue("stringfield", StringFieldValue::make("This is a string."));
+ doc.setValue("longfield", LongFieldValue::make(static_cast<int64_t>(398420092938472983LL)));
+ doc.setValue("doublefield", DoubleFieldValue::make(98374532.398820));
+ doc.setValue("bytefield", ByteFieldValue::make(-2));
+ doc.setValue("rawfield", std::make_unique<RawFieldValue>("RAW DATA", 8));
Document docInDoc(*docInDocType, DocumentId("id:ns:docindoc::http://doc.in.doc/"));
- docInDoc.set("stringindocfield", "Elvis is dead");
+ docInDoc.setValue("stringindocfield", StringFieldValue::make("Elvis is dead"));
doc.setValue("docfield", docInDoc);
ArrayFieldValue floatArray(*arrayOfFloatDataType);
CollectionHelper(floatArray).add(1.0);
@@ -830,14 +830,14 @@ TEST(DocumentTest, testGenerateSerializedFile)
DocumentTypeRepo repo(readDocumenttypesConfig(file_name));
Document doc(*repo.getDocumentType("serializetest"), DocumentId("id:ns:serializetest::http://test.doc.id/"));
- doc.set("intfield", 5);
- doc.set("floatfield", -9.23);
- doc.set("stringfield", "This is a string.");
- doc.set("longfield", (int64_t) 398420092938472983ll);
- doc.set("doublefield", 98374532.398820);
- doc.set("urifield", "http://this.is.a.test/");
- doc.set("bytefield", -2);
- doc.set("rawfield", "RAW DATA");
+ doc.setValue("intfield", IntFieldValue::make(5));
+ doc.setValue("floatfield", FloatFieldValue::make(-9.23));
+ doc.setValue("stringfield", StringFieldValue::make("This is a string."));
+ doc.setValue("longfield", LongFieldValue::make((int64_t) 398420092938472983ll));
+ doc.setValue("doublefield", DoubleFieldValue::make(98374532.398820));
+ doc.setValue("urifield", StringFieldValue::make("http://this.is.a.test/"));
+ doc.setValue("bytefield", ByteFieldValue::make(-2));
+ doc.setValue("rawfield", std::make_unique<RawFieldValue>("RAW DATA"));
const DocumentType *docindoc_type = repo.getDocumentType("docindoc");
EXPECT_TRUE(docindoc_type);
@@ -951,7 +951,7 @@ TEST(DocumentTest, testHasChanged)
Document doc2(test_repo.getTypeRepo(), buf);
EXPECT_TRUE(!doc2.hasChanged());
- doc2.set("headerval", 13);
+ doc2.setValue("headerval", IntFieldValue::make(13));
EXPECT_TRUE(doc2.hasChanged());
}
// Overwriting a value in doc tags us changed.
@@ -959,7 +959,7 @@ TEST(DocumentTest, testHasChanged)
buf.rp(0);
Document doc2(test_repo.getTypeRepo(), buf);
- doc2.set("hstringval", "bla bla bla bla bla");
+ doc2.setValue("hstringval", StringFieldValue::make("bla bla bla bla bla"));
EXPECT_TRUE(doc2.hasChanged());
}
// Clearing value tags us changed.
diff --git a/document/src/tests/documentupdatetestcase.cpp b/document/src/tests/documentupdatetestcase.cpp
index d5905d63455..26819699db4 100644
--- a/document/src/tests/documentupdatetestcase.cpp
+++ b/document/src/tests/documentupdatetestcase.cpp
@@ -139,8 +139,8 @@ TEST(DocumentUpdateTest, testSimpleUsage)
// Create a test document
Document doc(*docType, DocumentId("id:ns:test::1"));
- doc.set("bytef", 0);
- doc.set("intf", 5);
+ doc.setValue("bytef", ByteFieldValue::make(0));
+ doc.setValue("intf", IntFieldValue::make(5));
ArrayFieldValue array(*arrayType);
array.add(IntFieldValue(3));
array.add(IntFieldValue(7));
diff --git a/document/src/tests/fieldvalue/fieldvalue_test.cpp b/document/src/tests/fieldvalue/fieldvalue_test.cpp
index b70fd0d18a8..d8712768000 100644
--- a/document/src/tests/fieldvalue/fieldvalue_test.cpp
+++ b/document/src/tests/fieldvalue/fieldvalue_test.cpp
@@ -1,15 +1,15 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
// Unit tests for fieldvalue.
-#include <vespa/log/log.h>
-LOG_SETUP("fieldvalue_test");
-
#include <vespa/document/fieldvalue/stringfieldvalue.h>
#include <vespa/document/fieldvalue/longfieldvalue.h>
#include <vespa/document/fieldvalue/intfieldvalue.h>
#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/log/log.h>
+LOG_SETUP("fieldvalue_test");
+
using namespace document;
namespace {
@@ -18,14 +18,6 @@ TEST("require that StringFieldValue can be assigned primitives") {
StringFieldValue val;
val = "foo";
EXPECT_EQUAL("foo", val.getValue());
- val = 1;
- EXPECT_EQUAL("1", val.getValue());
- val = static_cast<int64_t>(2);
- EXPECT_EQUAL("2", val.getValue());
- val = 3.0f;
- EXPECT_EQUAL("3", val.getValue());
- val = 4.0;
- EXPECT_EQUAL("4", val.getValue());
}
TEST("require that FieldValues does not change their storage size.") {
diff --git a/document/src/tests/primitivefieldvaluetest.cpp b/document/src/tests/primitivefieldvaluetest.cpp
index 7c734544f27..ea78baa4ee6 100644
--- a/document/src/tests/primitivefieldvaluetest.cpp
+++ b/document/src/tests/primitivefieldvaluetest.cpp
@@ -3,7 +3,6 @@
#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/document/serialization/vespadocumentdeserializer.h>
#include <vespa/vespalib/objects/nbostream.h>
-#include <vespa/document/util/bytebuffer.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <limits>
#include <gtest/gtest.h>
@@ -32,7 +31,7 @@ void deserialize(nbostream & stream, T &value) {
const Type& medium2, const Type& largest)
{
try{
- // Less
+ // Less
EXPECT_TRUE(!(smallest < smallest));
EXPECT_TRUE(smallest < medium1);
EXPECT_TRUE(smallest < medium2);
@@ -203,31 +202,6 @@ TEST(PrimitiveFieldValueTest, testRaw)
value.getValueRef().size()) == 0);
}
-#define ASSERT_FAILED_CONV(getter, totype, floating) \
-{ \
- totype toType; \
- FieldValue::UP copy(value.clone()); \
- try{ \
- getter; \
- std::ostringstream ost; \
- ost << "Conversion unexpectedly worked from max value of " \
- << *value.getDataType() << " to " << *toType.getDataType(); \
- FAIL() << ost.str(); \
- } catch (std::exception& e) { \
- EXPECT_EQ( \
- std::string("bad numeric conversion: positive overflow"), \
- std::string(e.what())); \
- } \
- /* Verify that we can convert to smaller type if value is within \
- range. Only tests integer to integer. No floating point. */ \
- if (!floating) { \
- totype::Number maxV = std::numeric_limits<totype::Number>::max(); \
- value.setValue((Number) maxV); \
- getter; \
- } \
- value.assign(*copy); \
-}
-
namespace {
template<typename Numeric>
@@ -258,25 +232,21 @@ namespace {
// representation can keep the value.
if (floatingPoint || sizeof(Number) > sizeof(unsigned char)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsByte(), ByteFieldValue, floatingPoint);
} else {
EXPECT_EQ((char) maxValue, value.getAsByte());
}
if (floatingPoint || sizeof(Number) > sizeof(int32_t)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsInt(), IntFieldValue, floatingPoint);
} else {
EXPECT_EQ((int32_t) maxValue, value.getAsInt());
}
if (floatingPoint || sizeof(Number) > sizeof(int64_t)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsLong(), LongFieldValue, floatingPoint);
} else {
EXPECT_EQ((int64_t) maxValue, value.getAsLong());
}
if (floatingPoint && sizeof(Number) > sizeof(float)) {
// No longer throws. This is guarded on the perimeter by java code.
- // ASSERT_FAILED_CONV(value.getAsFloat(), FloatFieldValue, true);
} else {
EXPECT_EQ((float) maxValue, value.getAsFloat());
}
@@ -303,30 +273,15 @@ TEST(PrimitiveFieldValueTest, testBool)
v = BoolFieldValue(true);
EXPECT_TRUE(v.getValue());
- v = 0;
- EXPECT_TRUE( ! v.getValue());
- v = 1;
- EXPECT_TRUE(v.getValue());
-
- v = INT64_C(0);
- EXPECT_TRUE( ! v.getValue());
- v = INT64_C(1);
- EXPECT_TRUE(v.getValue());
-
- v = 0.0f;
- EXPECT_TRUE( ! v.getValue());
- v = 1.0f;
- EXPECT_TRUE(v.getValue());
-
- v = 0.0;
- EXPECT_TRUE( ! v.getValue());
- v = 1.0;
+ v.setValue(false);
+ EXPECT_FALSE(v.getValue());
+ v.setValue(true);
EXPECT_TRUE(v.getValue());
v = vespalib::stringref("true");
EXPECT_TRUE(v.getValue());
v = vespalib::stringref("something not true");
- EXPECT_TRUE( ! v.getValue());
+ EXPECT_FALSE(v.getValue());
}
TEST(PrimitiveFieldValueTest, testNumerics)
diff --git a/document/src/vespa/document/datatype/primitivedatatype.cpp b/document/src/vespa/document/datatype/primitivedatatype.cpp
index 08e873c7de2..d5af0ca6885 100644
--- a/document/src/vespa/document/datatype/primitivedatatype.cpp
+++ b/document/src/vespa/document/datatype/primitivedatatype.cpp
@@ -56,16 +56,16 @@ FieldValue::UP
PrimitiveDataType::createFieldValue() const
{
switch (getId()) {
- case T_INT: return std::make_unique<IntFieldValue>();
- case T_SHORT: return std::make_unique<ShortFieldValue>();
- case T_FLOAT: return std::make_unique<FloatFieldValue>();
- case T_URI: return std::make_unique<StringFieldValue>();
- case T_STRING: return std::make_unique<StringFieldValue>();
+ case T_INT: return IntFieldValue::make();
+ case T_SHORT: return ShortFieldValue::make();
+ case T_FLOAT: return FloatFieldValue::make();
+ case T_URI: return StringFieldValue::make();
+ case T_STRING: return StringFieldValue::make();
case T_RAW: return std::make_unique<RawFieldValue>();
- case T_LONG: return std::make_unique<LongFieldValue>();
- case T_DOUBLE: return std::make_unique<DoubleFieldValue>();
- case T_BOOL: return std::make_unique<BoolFieldValue>();
- case T_BYTE: return std::make_unique<ByteFieldValue>();
+ case T_LONG: return LongFieldValue::make();
+ case T_DOUBLE: return DoubleFieldValue::make();
+ case T_BOOL: return BoolFieldValue::make();
+ case T_BYTE: return ByteFieldValue::make();
case T_PREDICATE: return std::make_unique<PredicateFieldValue>();
}
LOG_ABORT("getId() returned value out of range");
diff --git a/document/src/vespa/document/fieldvalue/arrayfieldvalue.h b/document/src/vespa/document/fieldvalue/arrayfieldvalue.h
index b37049f207a..c4f879f7348 100644
--- a/document/src/vespa/document/fieldvalue/arrayfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/arrayfieldvalue.h
@@ -74,11 +74,11 @@ public:
// Iterator functionality
const_iterator begin() const { return array().begin(); }
const_iterator end() const { return array().end(); }
- iterator begin() { return array().begin(); }
- iterator end() { return array().end(); }
DECLARE_IDENTIFIABLE_ABSTRACT(ArrayFieldValue);
private:
+ iterator begin() { return array().begin(); }
+ iterator end() { return array().end(); }
const IArray & array() const { return *_array; }
IArray & array() { return *_array; }
};
diff --git a/document/src/vespa/document/fieldvalue/boolfieldvalue.cpp b/document/src/vespa/document/fieldvalue/boolfieldvalue.cpp
index c542936825d..1c5261877fd 100644
--- a/document/src/vespa/document/fieldvalue/boolfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/boolfieldvalue.cpp
@@ -87,25 +87,5 @@ BoolFieldValue::operator=(vespalib::stringref v) {
_value = (v == "true");
return *this;
}
-BoolFieldValue&
-BoolFieldValue::operator=(int32_t v) {
- _value = (v != 0);
- return *this;
-}
-BoolFieldValue&
-BoolFieldValue::operator=(int64_t v) {
- _value = (v != 0);
- return *this;
-}
-BoolFieldValue&
-BoolFieldValue::operator=(float v) {
- _value = (v != 0);
- return *this;
-}
-BoolFieldValue&
-BoolFieldValue::operator=(double v) {
- _value = (v != 0);
- return *this;
-}
} // namespace document
diff --git a/document/src/vespa/document/fieldvalue/boolfieldvalue.h b/document/src/vespa/document/fieldvalue/boolfieldvalue.h
index d03ded5c9f1..01cfcf2cd48 100644
--- a/document/src/vespa/document/fieldvalue/boolfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/boolfieldvalue.h
@@ -42,12 +42,8 @@ public:
vespalib::string getAsString() const override;
BoolFieldValue& operator=(vespalib::stringref) override;
- BoolFieldValue& operator=(int32_t) override;
- BoolFieldValue& operator=(int64_t) override;
- BoolFieldValue& operator=(float) override;
- BoolFieldValue& operator=(double) override;
-
DECLARE_IDENTIFIABLE(BoolFieldValue);
+ static std::unique_ptr<BoolFieldValue> make(bool value=false) { return std::make_unique<BoolFieldValue>(value); }
};
}
diff --git a/document/src/vespa/document/fieldvalue/bytefieldvalue.h b/document/src/vespa/document/fieldvalue/bytefieldvalue.h
index 7f6bc429b69..2cccf483c84 100644
--- a/document/src/vespa/document/fieldvalue/bytefieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/bytefieldvalue.h
@@ -14,7 +14,6 @@ namespace document {
class ByteFieldValue : public NumericFieldValue<int8_t> {
public:
- typedef std::unique_ptr<ByteFieldValue> UP;
typedef int8_t Number;
ByteFieldValue(Number value = 0)
@@ -24,10 +23,10 @@ public:
void accept(ConstFieldValueVisitor &visitor) const override { visitor.visit(*this); }
const DataType *getDataType() const override { return DataType::BYTE; }
ByteFieldValue* clone() const override { return new ByteFieldValue(*this); }
- using NumericFieldValue<Number>::operator=;
+ using NumericFieldValue<Number>::operator=;
DECLARE_IDENTIFIABLE(ByteFieldValue);
-
+ static std::unique_ptr<ByteFieldValue> make(Number value=0) { return std::make_unique<ByteFieldValue>(value); }
};
} // document
diff --git a/document/src/vespa/document/fieldvalue/doublefieldvalue.h b/document/src/vespa/document/fieldvalue/doublefieldvalue.h
index feb15e52223..b9b20bbd24a 100644
--- a/document/src/vespa/document/fieldvalue/doublefieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/doublefieldvalue.h
@@ -14,7 +14,6 @@ namespace document {
class DoubleFieldValue : public NumericFieldValue<double> {
public:
- typedef std::unique_ptr<DoubleFieldValue> UP;
typedef double Number;
DoubleFieldValue(Number value = 0) : NumericFieldValue<Number>(value) {}
@@ -26,9 +25,8 @@ public:
DoubleFieldValue* clone() const override { return new DoubleFieldValue(*this); }
using NumericFieldValue<Number>::operator=;
-
DECLARE_IDENTIFIABLE(DoubleFieldValue);
-
+ static std::unique_ptr<DoubleFieldValue> make(Number value=0) { return std::make_unique<DoubleFieldValue>(value); }
};
} // document
diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.cpp b/document/src/vespa/document/fieldvalue/fieldvalue.cpp
index 8a678ddf968..c69b7169aa0 100644
--- a/document/src/vespa/document/fieldvalue/fieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/fieldvalue.cpp
@@ -95,30 +95,6 @@ FieldValue::operator=(vespalib::stringref)
throw IllegalArgumentException("Cannot assign string to datatype " + getDataType()->toString(), VESPA_STRLOC);
}
-FieldValue&
-FieldValue::operator=(int32_t)
-{
- throw IllegalArgumentException("Cannot assign int to datatype " + getDataType()->toString(), VESPA_STRLOC);
-}
-
-FieldValue&
-FieldValue::operator=(int64_t)
-{
- throw IllegalArgumentException("Cannot assign long to datatype " + getDataType()->toString(), VESPA_STRLOC);
-}
-
-FieldValue&
-FieldValue::operator=(float)
-{
- throw IllegalArgumentException("Cannot assign float to datatype " + getDataType()->toString(), VESPA_STRLOC);
-}
-
-FieldValue&
-FieldValue::operator=(double)
-{
- throw IllegalArgumentException("Cannot assign double to datatype " + getDataType()->toString(), VESPA_STRLOC);
-}
-
char
FieldValue::getAsByte() const
{
diff --git a/document/src/vespa/document/fieldvalue/fieldvalue.h b/document/src/vespa/document/fieldvalue/fieldvalue.h
index b0507a6c251..fedb0141391 100644
--- a/document/src/vespa/document/fieldvalue/fieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/fieldvalue.h
@@ -24,7 +24,6 @@ namespace document {
namespace fieldvalue { class IteratorHandler; }
-class ByteBuffer;
class DataType;
class FieldValue : public vespalib::Identifiable
@@ -108,13 +107,6 @@ public:
/** Override toXml from XmlSerializable to add start/stop tags. */
virtual std::string toXml(const std::string& indent = "") const;
- // Utility functions to set commonly used value types.
- virtual FieldValue& operator=(vespalib::stringref);
- virtual FieldValue& operator=(int32_t);
- virtual FieldValue& operator=(int64_t);
- virtual FieldValue& operator=(float);
- virtual FieldValue& operator=(double);
-
// Utility functions to unwrap field values if you know the type.
/**
@@ -187,6 +179,8 @@ public:
std::string toString(bool verbose=false, const std::string& indent="") const;
virtual void printXml(XmlOutputStream& out) const = 0;
+ // Utility functions to set commonly used value types.
+ virtual FieldValue& operator=(vespalib::stringref);
private:
fieldvalue::ModificationStatus
iterateNested(FieldPath::const_iterator start, FieldPath::const_iterator end, fieldvalue::IteratorHandler & handler) const {
diff --git a/document/src/vespa/document/fieldvalue/floatfieldvalue.h b/document/src/vespa/document/fieldvalue/floatfieldvalue.h
index f33939d8d67..f662c400633 100644
--- a/document/src/vespa/document/fieldvalue/floatfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/floatfieldvalue.h
@@ -14,7 +14,6 @@ namespace document {
class FloatFieldValue : public NumericFieldValue<float> {
public:
- typedef std::unique_ptr<FloatFieldValue> UP;
typedef float Number;
FloatFieldValue(Number value = 0) : NumericFieldValue<Number>(value) {}
@@ -26,9 +25,8 @@ public:
FloatFieldValue* clone() const override { return new FloatFieldValue(*this); }
using NumericFieldValue<Number>::operator=;
-
DECLARE_IDENTIFIABLE(FloatFieldValue);
-
+ static std::unique_ptr<FloatFieldValue> make(Number value = 0) { return std::make_unique<FloatFieldValue>(value); }
};
} // document
diff --git a/document/src/vespa/document/fieldvalue/intfieldvalue.h b/document/src/vespa/document/fieldvalue/intfieldvalue.h
index dbe419379a1..d365e34779e 100644
--- a/document/src/vespa/document/fieldvalue/intfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/intfieldvalue.h
@@ -14,7 +14,6 @@ namespace document {
class IntFieldValue : public NumericFieldValue<int32_t> {
public:
- typedef std::unique_ptr<IntFieldValue> UP;
typedef int32_t Number;
IntFieldValue(Number value = 0) : NumericFieldValue<Number>(value) {}
@@ -27,7 +26,7 @@ public:
using NumericFieldValue<Number>::operator=;
DECLARE_IDENTIFIABLE(IntFieldValue);
-
+ static std::unique_ptr<IntFieldValue> make(Number value=0) { return std::make_unique<IntFieldValue>(value); }
};
} // document
diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp
index 9b648400533..7ba537d9cc2 100644
--- a/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.cpp
@@ -1,10 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include "literalfieldvalue.h"
#include "literalfieldvalue.hpp"
#include <vespa/document/util/stringutil.h>
#include <vespa/vespalib/util/xmlstream.h>
-#include <sstream>
using namespace vespalib::xml;
@@ -21,7 +19,7 @@ LiteralFieldValueB::LiteralFieldValueB() :
_value = _backing;
}
-LiteralFieldValueB::~LiteralFieldValueB() { }
+LiteralFieldValueB::~LiteralFieldValueB() = default;
LiteralFieldValueB::LiteralFieldValueB(const LiteralFieldValueB& other)
: FieldValue(other),
@@ -32,7 +30,7 @@ LiteralFieldValueB::LiteralFieldValueB(const LiteralFieldValueB& other)
_value = _backing;
}
-LiteralFieldValueB::LiteralFieldValueB(const string& value)
+LiteralFieldValueB::LiteralFieldValueB(const stringref & value)
: FieldValue(),
_value(),
_backing(value),
@@ -117,44 +115,6 @@ LiteralFieldValueB::syncBacking() const
_value = _backing;
}
-
-namespace {
-template <typename T>
-std::string valueToString(T value) {
- std::ostringstream ost;
- ost << value;
- return ost.str();
-}
-} // namespace
-
-FieldValue&
-LiteralFieldValueB::operator=(int32_t value)
-{
- setValue(valueToString(value));
- return *this;
-}
-
-FieldValue&
-LiteralFieldValueB::operator=(int64_t value)
-{
- setValue(valueToString(value));
- return *this;
-}
-
-FieldValue&
-LiteralFieldValueB::operator=(float value)
-{
- setValue(valueToString(value));
- return *this;
-}
-
-FieldValue&
-LiteralFieldValueB::operator=(double value)
-{
- setValue(valueToString(value));
- return *this;
-}
-
template class LiteralFieldValue<RawFieldValue, DataType::T_RAW, false>;
template class LiteralFieldValue<StringFieldValue, DataType::T_STRING, true>;
diff --git a/document/src/vespa/document/fieldvalue/literalfieldvalue.h b/document/src/vespa/document/fieldvalue/literalfieldvalue.h
index e84f0c529c7..6e3f0223b20 100644
--- a/document/src/vespa/document/fieldvalue/literalfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/literalfieldvalue.h
@@ -32,7 +32,7 @@ public:
~LiteralFieldValueB();
LiteralFieldValueB(const LiteralFieldValueB &);
- LiteralFieldValueB(const string& value);
+ LiteralFieldValueB(const stringref & value);
const value_type & getValue() const { sync(); return _backing; }
/**
@@ -69,10 +69,6 @@ public:
bool hasChanged() const override{ return _altered; }
FieldValue& operator=(vespalib::stringref) override;
- FieldValue& operator=(int32_t) override;
- FieldValue& operator=(int64_t) override;
- FieldValue& operator=(float) override;
- FieldValue& operator=(double) override;
protected:
void syncBacking() const __attribute__((noinline));
void sync() const {
@@ -95,7 +91,7 @@ public:
typedef std::unique_ptr<SubClass> UP;
LiteralFieldValue() : LiteralFieldValueB() { }
- LiteralFieldValue(const string& value) : LiteralFieldValueB(value) { }
+ LiteralFieldValue(const stringref& value) : LiteralFieldValueB(value) { }
const DataType *getDataType() const override;
};
diff --git a/document/src/vespa/document/fieldvalue/longfieldvalue.h b/document/src/vespa/document/fieldvalue/longfieldvalue.h
index 12a0615e0ad..64ab4332cef 100644
--- a/document/src/vespa/document/fieldvalue/longfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/longfieldvalue.h
@@ -14,7 +14,6 @@ namespace document {
class LongFieldValue : public NumericFieldValue<int64_t> {
public:
- typedef std::unique_ptr<LongFieldValue> UP;
typedef int64_t Number;
LongFieldValue(Number value = 0) : NumericFieldValue<Number>(value) {}
@@ -26,8 +25,8 @@ public:
LongFieldValue* clone() const override { return new LongFieldValue(*this); }
using NumericFieldValue<Number>::operator=;
-
DECLARE_IDENTIFIABLE(LongFieldValue);
+ static std::unique_ptr<LongFieldValue> make(Number value=0) { return std::make_unique<LongFieldValue>(value); }
};
diff --git a/document/src/vespa/document/fieldvalue/numericfieldvalue.h b/document/src/vespa/document/fieldvalue/numericfieldvalue.h
index c094cf0689c..0a557af93d9 100644
--- a/document/src/vespa/document/fieldvalue/numericfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/numericfieldvalue.h
@@ -41,10 +41,6 @@ public:
int fastCompare(const FieldValue& other) const override final;
FieldValue& operator=(vespalib::stringref) override;
- FieldValue& operator=(int32_t) override;
- FieldValue& operator=(int64_t) override;
- FieldValue& operator=(float) override;
- FieldValue& operator=(double) override;
size_t hash() const override final { return vespalib::hash<Number>()(_value); }
char getAsByte() const override;
diff --git a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp
index c4f1fdf13a1..f1bbce5450d 100644
--- a/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp
+++ b/document/src/vespa/document/fieldvalue/numericfieldvalue.hpp
@@ -123,42 +123,6 @@ NumericFieldValue<Number>::operator=(vespalib::stringref value)
}
template<typename Number>
-FieldValue&
-NumericFieldValue<Number>::operator=(int32_t value)
-{
- _value = static_cast<Number>(value);
- _altered = true;
- return *this;
-}
-
-template<typename Number>
-FieldValue&
-NumericFieldValue<Number>::operator=(int64_t value)
-{
- _value = static_cast<Number>(value);
- _altered = true;
- return *this;
-}
-
-template<typename Number>
-FieldValue&
-NumericFieldValue<Number>::operator=(float value)
-{
- _value = static_cast<Number>(value);
- _altered = true;
- return *this;
-}
-
-template<typename Number>
-FieldValue&
-NumericFieldValue<Number>::operator=(double value)
-{
- _value = static_cast<Number>(value);
- _altered = true;
- return *this;
-}
-
-template<typename Number>
char
NumericFieldValue<Number>::getAsByte() const
{
diff --git a/document/src/vespa/document/fieldvalue/shortfieldvalue.h b/document/src/vespa/document/fieldvalue/shortfieldvalue.h
index f2047d1a521..fa61c37c4eb 100644
--- a/document/src/vespa/document/fieldvalue/shortfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/shortfieldvalue.h
@@ -27,9 +27,8 @@ public:
ShortFieldValue* clone() const override { return new ShortFieldValue(*this); }
using NumericFieldValue<Number>::operator=;
-
DECLARE_IDENTIFIABLE(ShortFieldValue);
-
+ static std::unique_ptr<ShortFieldValue> make(int16_t value = 0) { return std::make_unique<ShortFieldValue>(value); }
};
} // document
diff --git a/document/src/vespa/document/fieldvalue/stringfieldvalue.h b/document/src/vespa/document/fieldvalue/stringfieldvalue.h
index 15aeeccd0de..17a0302f6f9 100644
--- a/document/src/vespa/document/fieldvalue/stringfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/stringfieldvalue.h
@@ -24,7 +24,7 @@ public:
typedef std::vector<SpanTree::UP> SpanTrees;
StringFieldValue() : Parent(), _annotationData() { }
- StringFieldValue(const string &value)
+ StringFieldValue(const vespalib::stringref &value)
: Parent(value), _annotationData() { }
StringFieldValue(const StringFieldValue &rhs);
@@ -57,6 +57,8 @@ public:
using LiteralFieldValueB::operator=;
DECLARE_IDENTIFIABLE(StringFieldValue);
+ static std::unique_ptr<StringFieldValue> make(vespalib::stringref value) { return std::make_unique<StringFieldValue>(value); }
+ static std::unique_ptr<StringFieldValue> make() { return StringFieldValue::make(""); }
private:
void doClearSpanTrees();
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
index 555964d8b34..fbe6dadb320 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
@@ -79,14 +79,16 @@ bool StructFieldValue::serializeField(int field_id, uint16_t version, FieldValue
}
}
-void StructFieldValue::getRawFieldIds(vector<int> &raw_ids) const {
- raw_ids.clear();
+vector<int>
+StructFieldValue::getRawFieldIds() const {
+ vector<int> raw_ids;
raw_ids.reserve(_fields.getEntries().size());
for (const SerializableArray::Entry & entry : _fields.getEntries()) {
raw_ids.emplace_back(entry.id());
}
sort(raw_ids.begin(), raw_ids.end());
raw_ids.erase(unique(raw_ids.begin(), raw_ids.end()), raw_ids.end());
+ return raw_ids;
}
void
@@ -242,10 +244,8 @@ StructFieldValue::compare(const FieldValue& otherOrg) const
}
const auto & other = static_cast<const StructFieldValue&>(otherOrg);
- std::vector<int> a;
- getRawFieldIds(a);
- std::vector<int> b;
- other.getRawFieldIds(b);
+ std::vector<int> a = getRawFieldIds();
+ std::vector<int> b = other.getRawFieldIds();
for (size_t i(0); i < std::min(a.size(), b.size()); i++) {
if (a[i] != b[i]) {
@@ -337,12 +337,9 @@ struct StructFieldValue::FieldIterator : public StructuredIterator {
explicit FieldIterator(const StructFieldValue& s)
: _struct(s),
- _ids(),
+ _ids(s.getRawFieldIds()),
_cur(_ids.begin())
- {
- s.getRawFieldIds(_ids);
- _cur = _ids.begin();
- }
+ { }
void skipTo(int fieldId) {
while (_cur != _ids.end() && fieldId != *_cur) {
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.h b/document/src/vespa/document/fieldvalue/structfieldvalue.h
index ab35dc04421..24e143ddc27 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.h
@@ -54,7 +54,7 @@ public:
uint16_t getVersion() const { return _version; }
// raw_ids may contain ids for elements not in the struct's datatype.
- void getRawFieldIds(std::vector<int> &raw_ids) const;
+ std::vector<int> getRawFieldIds() const;
void getRawFieldIds(std::vector<int> &raw_ids, const FieldSet& fieldSet) const;
void accept(FieldValueVisitor &visitor) override { visitor.visit(*this); }
@@ -98,7 +98,6 @@ private:
VESPA_DLL_LOCAL const StructDataType & getStructType() const;
struct FieldIterator;
- friend struct FieldIterator;
StructuredIterator::UP getIterator(const Field* toFind) const override;
diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp
index becdfdabb5f..53f75cb2e73 100644
--- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp
@@ -172,20 +172,6 @@ StructuredFieldValue::onIterateNested(PathRange nested, IteratorHandler & handle
}
}
-using ConstCharP = const char *;
-template void StructuredFieldValue::set(const Field& field, int32_t value);
-template void StructuredFieldValue::set(const Field& field, int64_t value);
-template void StructuredFieldValue::set(const Field& field, double value);
-template void StructuredFieldValue::set(const Field& field, ConstCharP value);
-template void StructuredFieldValue::set(const Field& field, vespalib::stringref value);
-template void StructuredFieldValue::set(const Field& field, vespalib::string value);
-template void StructuredFieldValue::set(vespalib::stringref field, int32_t value);
-template void StructuredFieldValue::set(vespalib::stringref field, int64_t value);
-template void StructuredFieldValue::set(vespalib::stringref field, double value);
-template void StructuredFieldValue::set(vespalib::stringref field, ConstCharP value);
-template void StructuredFieldValue::set(vespalib::stringref field, vespalib::stringref value);
-template void StructuredFieldValue::set(vespalib::stringref field, vespalib::string value);
-
template std::unique_ptr<MapFieldValue> StructuredFieldValue::getAs<MapFieldValue>(const Field &field) const;
template std::unique_ptr<ArrayFieldValue> StructuredFieldValue::getAs<ArrayFieldValue>(const Field &field) const;
template std::unique_ptr<WeightedSetFieldValue> StructuredFieldValue::getAs<WeightedSetFieldValue>(const Field &field) const;
diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.h b/document/src/vespa/document/fieldvalue/structuredfieldvalue.h
index b1b88323a3b..9d79b6279a4 100644
--- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.h
@@ -152,6 +152,12 @@ public:
void setValue(const Field& field, FieldValue::UP value) {
setFieldValue(field, std::move(value));
}
+ void setValue(vespalib::stringref fieldName, const FieldValue& value) {
+ setFieldValue(getField(fieldName), value);
+ }
+ void setValue(vespalib::stringref fieldName, FieldValue::UP value) {
+ setFieldValue(getField(fieldName), std::move(value));
+ }
/** Remove the value of given field if it is set. */
//These are affected by the begin/commitTanasaction
@@ -166,13 +172,6 @@ public:
void remove(vespalib::stringref fieldName) {
removeFieldValue(getField(fieldName));
}
- void setValue(vespalib::stringref fieldName, const FieldValue& value) {
- setFieldValue(getField(fieldName), value);
- }
- template<typename PrimitiveType>
- void set(const Field& field, PrimitiveType value);
- template<typename PrimitiveType>
- void set(vespalib::stringref fieldName, PrimitiveType value);
size_t getSetFieldCount() const {
size_t count = 0;
diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp
index df02506c076..4b347d7cc07 100644
--- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp
+++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.hpp
@@ -20,20 +20,4 @@ StructuredFieldValue::getAs(const Field &field) const {
return std::unique_ptr<T>(t);
}
-template<typename PrimitiveType>
-void
-StructuredFieldValue::set(const Field& field, PrimitiveType value)
-{
- FieldValue::UP fval(field.getDataType().createFieldValue());
- *fval = value;
- setFieldValue(field, std::move(fval));
-}
-
-template<typename PrimitiveType>
-void
-StructuredFieldValue::set(vespalib::stringref fieldName, PrimitiveType value)
-{
- set(getField(fieldName), value);
-}
-
} // document
diff --git a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp
index 6b80ceb1f6e..2a3726095df 100644
--- a/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/weightedsetfieldvalue.cpp
@@ -59,7 +59,7 @@ WeightedSetFieldValue::add(const FieldValue& key, int weight)
_map.erase(key);
return false;
}
- return _map.insert(FieldValue::UP(key.clone()), std::make_unique<IntFieldValue>(weight));
+ return _map.insert(FieldValue::UP(key.clone()), IntFieldValue::make(weight));
}
bool
@@ -67,14 +67,14 @@ WeightedSetFieldValue::addIgnoreZeroWeight(const FieldValue& key, int32_t weight
{
verifyKey(key);
_altered = true;
- return _map.insert(FieldValue::UP(key.clone()), std::make_unique<IntFieldValue>(weight));
+ return _map.insert(FieldValue::UP(key.clone()), IntFieldValue::make(weight));
}
void
WeightedSetFieldValue::push_back(FieldValue::UP key, int weight)
{
_altered = true;
- _map.push_back(std::move(key), std::make_unique<IntFieldValue>(weight));
+ _map.push_back(std::move(key), IntFieldValue::make(weight));
}
void
diff --git a/document/src/vespa/document/test/fieldvalue_helpers.h b/document/src/vespa/document/test/fieldvalue_helpers.h
index 539ee50d2ab..a7d899b385f 100644
--- a/document/src/vespa/document/test/fieldvalue_helpers.h
+++ b/document/src/vespa/document/test/fieldvalue_helpers.h
@@ -4,6 +4,9 @@
#include <vespa/document/fieldvalue/collectionfieldvalue.h>
#include <vespa/document/fieldvalue/weightedsetfieldvalue.h>
+#include <vespa/document/fieldvalue/longfieldvalue.h>
+#include <vespa/document/fieldvalue/floatfieldvalue.h>
+#include <vespa/document/fieldvalue/doublefieldvalue.h>
namespace document {
@@ -13,22 +16,22 @@ public:
// Convenience functions for using primitives directly
bool add(vespalib::stringref val) { return _cfv.add(*_cfv.createNested() = val); }
- bool add(int32_t val) { return _cfv.add(*_cfv.createNested() = val); }
- bool add(int64_t val) { return _cfv.add(*_cfv.createNested() = val); }
- bool add(float val) { return _cfv.add(*_cfv.createNested() = val); }
- bool add(double val) { return _cfv.add(*_cfv.createNested() = val); }
+ bool add(int32_t val) { return _cfv.add(_cfv.createNested()->assign(IntFieldValue(val))); }
+ bool add(int64_t val) { return _cfv.add(_cfv.createNested()->assign(LongFieldValue(val))); }
+ bool add(float val) { return _cfv.add(_cfv.createNested()->assign(FloatFieldValue(val))); }
+ bool add(double val) { return _cfv.add(_cfv.createNested()->assign(DoubleFieldValue(val))); }
bool contains(vespalib::stringref val) { return _cfv.contains(*_cfv.createNested() = val); }
- bool contains(int32_t val) { return _cfv.contains(*_cfv.createNested() = val); }
- bool contains(int64_t val) { return _cfv.contains(*_cfv.createNested() = val); }
- bool contains(float val) { return _cfv.contains(*_cfv.createNested() = val); }
- bool contains(double val) { return _cfv.contains(*_cfv.createNested() = val); }
+ bool contains(int32_t val) { return _cfv.contains(_cfv.createNested()->assign(IntFieldValue(val))); }
+ bool contains(int64_t val) { return _cfv.contains(_cfv.createNested()->assign(LongFieldValue(val))); }
+ bool contains(float val) { return _cfv.contains(_cfv.createNested()->assign(FloatFieldValue(val))); }
+ bool contains(double val) { return _cfv.contains(_cfv.createNested()->assign(DoubleFieldValue(val))); }
bool remove(vespalib::stringref val) { return _cfv.remove(*_cfv.createNested() = val); }
- bool remove(int32_t val) { return _cfv.remove(*_cfv.createNested() = val); }
- bool remove(int64_t val) { return _cfv.remove(*_cfv.createNested() = val); }
- bool remove(float val) { return _cfv.remove(*_cfv.createNested() = val); }
- bool remove(double val) { return _cfv.remove(*_cfv.createNested() = val); }
+ bool remove(int32_t val) { return _cfv.remove(_cfv.createNested()->assign(IntFieldValue(val))); }
+ bool remove(int64_t val) { return _cfv.remove(_cfv.createNested()->assign(LongFieldValue(val))); }
+ bool remove(float val) { return _cfv.remove(_cfv.createNested()->assign(FloatFieldValue(val))); }
+ bool remove(double val) { return _cfv.remove(_cfv.createNested()->assign(DoubleFieldValue(val))); }
private:
CollectionFieldValue & _cfv;
};
@@ -40,28 +43,28 @@ public:
// Utility functions for easy use of weighted sets of primitives
bool add(vespalib::stringref val, int32_t weight = 1) { return _ws.add(*_ws.createNested() = val, weight); }
- bool add(int32_t val, int32_t weight = 1) { return _ws.add(*_ws.createNested() = val, weight); }
- bool add(int64_t val, int32_t weight = 1) { return _ws.add(*_ws.createNested() = val, weight); }
- bool add(float val, int32_t weight = 1) { return _ws.add(*_ws.createNested() = val, weight); }
- bool add(double val, int32_t weight = 1) { return _ws.add(*_ws.createNested() = val, weight); }
+ bool add(int32_t val, int32_t weight = 1) { return _ws.add(_ws.createNested()->assign(IntFieldValue(val)), weight); }
+ bool add(int64_t val, int32_t weight = 1) { return _ws.add(_ws.createNested()->assign(LongFieldValue(val)), weight); }
+ bool add(float val, int32_t weight = 1) { return _ws.add(_ws.createNested()->assign(FloatFieldValue(val)), weight); }
+ bool add(double val, int32_t weight = 1) { return _ws.add(_ws.createNested()->assign(DoubleFieldValue(val)), weight); }
int32_t get(vespalib::stringref val) const { return _ws.get(*_ws.createNested() = val); }
- int32_t get(int32_t val) const { return _ws.get(*_ws.createNested() = val); }
- int32_t get(int64_t val) const { return _ws.get(*_ws.createNested() = val); }
- int32_t get(float val) const { return _ws.get(*_ws.createNested() = val); }
- int32_t get(double val) const { return _ws.get(*_ws.createNested() = val); }
+ int32_t get(int32_t val) const { return _ws.get(_ws.createNested()->assign(IntFieldValue(val))); }
+ int32_t get(int64_t val) const { return _ws.get(_ws.createNested()->assign(LongFieldValue(val))); }
+ int32_t get(float val) const { return _ws.get(_ws.createNested()->assign(FloatFieldValue(val))); }
+ int32_t get(double val) const { return _ws.get(_ws.createNested()->assign(DoubleFieldValue(val))); }
void increment(vespalib::stringref val, int32_t weight = 1) { _ws.increment(*_ws.createNested() = val, weight); }
- void increment(int32_t val, int32_t weight = 1) { _ws.increment(*_ws.createNested() = val, weight); }
- void increment(int64_t val, int32_t weight = 1) { _ws.increment(*_ws.createNested() = val, weight); }
- void increment(float val, int32_t weight = 1) { _ws.increment(*_ws.createNested() = val, weight); }
- void increment(double val, int32_t weight = 1) { _ws.increment(*_ws.createNested() = val, weight); }
+ void increment(int32_t val, int32_t weight = 1) { _ws.increment(_ws.createNested()->assign(IntFieldValue(val)), weight); }
+ void increment(int64_t val, int32_t weight = 1) { _ws.increment(_ws.createNested()->assign(LongFieldValue(val)), weight); }
+ void increment(float val, int32_t weight = 1) { _ws.increment(_ws.createNested()->assign(FloatFieldValue(val)), weight); }
+ void increment(double val, int32_t weight = 1) { _ws.increment(_ws.createNested()->assign(DoubleFieldValue(val)), weight); }
void decrement(vespalib::stringref val, int32_t weight = 1) { _ws.decrement(*_ws.createNested() = val, weight); }
- void decrement(int32_t val, int32_t weight = 1) { _ws.decrement(*_ws.createNested() = val, weight); }
- void decrement(int64_t val, int32_t weight = 1) { _ws.decrement(*_ws.createNested() = val, weight); }
- void decrement(float val, int32_t weight = 1) { _ws.decrement(*_ws.createNested() = val, weight); }
- void decrement(double val, int32_t weight = 1) { _ws.decrement(*_ws.createNested() = val, weight); }
+ void decrement(int32_t val, int32_t weight = 1) { _ws.decrement(_ws.createNested()->assign(IntFieldValue(val)), weight); }
+ void decrement(int64_t val, int32_t weight = 1) { _ws.decrement(_ws.createNested()->assign(LongFieldValue(val)), weight); }
+ void decrement(float val, int32_t weight = 1) { _ws.decrement(_ws.createNested()->assign(FloatFieldValue(val)), weight); }
+ void decrement(double val, int32_t weight = 1) { _ws.decrement(_ws.createNested()->assign(DoubleFieldValue(val)), weight); }
private:
WeightedSetFieldValue & _ws;
};
diff --git a/documentapi/src/tests/messages/messages60test.cpp b/documentapi/src/tests/messages/messages60test.cpp
index c0bdb71fb25..a7604888c69 100644
--- a/documentapi/src/tests/messages/messages60test.cpp
+++ b/documentapi/src/tests/messages/messages60test.cpp
@@ -10,6 +10,7 @@
#include <vespa/document/update/fieldpathupdates.h>
#include <vespa/documentapi/documentapi.h>
#include <vespa/document/bucket/fixed_bucket_spaces.h>
+#include <vespa/document/fieldvalue/document.h>
using document::DataType;
using document::DocumentTypeRepo;
diff --git a/documentapi/src/tests/policies/policies_test.cpp b/documentapi/src/tests/policies/policies_test.cpp
index 61716e4ed6b..dfa9cbb581e 100644
--- a/documentapi/src/tests/policies/policies_test.cpp
+++ b/documentapi/src/tests/policies/policies_test.cpp
@@ -18,11 +18,11 @@
#include <vespa/messagebus/testlib/testserver.h>
#include <vespa/vdslib/state/clusterstate.h>
#include <vespa/document/base/testdocrepo.h>
-#include <vespa/document/config/documenttypes_config_fwd.h>
#include <vespa/document/fieldvalue/longfieldvalue.h>
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/update/documentupdate.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/vespalib/testkit/testapp.h>
#include <vespa/vespalib/util/stringfmt.h>
#include <thread>
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp
index 534a4c62efc..1717b687322 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.cpp
@@ -6,6 +6,7 @@
#include <vespa/vespalib/util/growablebytebuffer.h>
#include <vespa/document/util/bytebuffer.h>
#include <vespa/document/fieldset/fieldsets.h>
+#include <vespa/document/fieldvalue/document.h>
#include <climits>
using document::FixedBucketSpaces;
diff --git a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h
index 48fece57064..0b43b37c0b7 100644
--- a/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h
+++ b/documentapi/src/vespa/documentapi/messagebus/messages/visitor.h
@@ -9,9 +9,8 @@
#include <vespa/vdslib/container/visitorstatistics.h>
#include <vespa/document/bucket/bucketid.h>
#include <vespa/documentapi/messagebus/documentprotocol.h>
-#include <vespa/document/fieldvalue/document.h>
-
+namespace document { class Document; }
namespace documentapi {
typedef uint64_t Timestamp;
@@ -237,25 +236,25 @@ public:
*/
class DocumentListMessage : public VisitorMessage {
public:
- typedef std::unique_ptr<DocumentListMessage> UP;
+ using UP = std::unique_ptr<DocumentListMessage>;
+ using DocumentSP = std::shared_ptr<document::Document>;
class Entry {
public:
Entry();
- Entry(int64_t timestamp, document::Document::SP doc, bool removeEntry);
+ Entry(int64_t timestamp, DocumentSP doc, bool removeEntry);
Entry(const Entry& other);
Entry(const document::DocumentTypeRepo &repo, document::ByteBuffer& buf);
int64_t getTimestamp() { return _timestamp; }
- const document::Document::SP& getDocument() { return _document; }
+ const DocumentSP & getDocument() { return _document; }
bool isRemoveEntry() { return _removeEntry; }
void serialize(vespalib::GrowableByteBuffer& buf) const;
- uint32_t getSerializedSize() const;
private:
- int64_t _timestamp;
- document::Document::SP _document;
- bool _removeEntry;
+ int64_t _timestamp;
+ DocumentSP _document;
+ bool _removeEntry;
};
private:
diff --git a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
index 5fded6a6266..ae4041732a7 100644
--- a/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/policies/contentpolicy.cpp
@@ -3,6 +3,7 @@
#include "contentpolicy.h"
#include <vespa/document/base/documentid.h>
#include <vespa/document/update/documentupdate.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/messagebus/emptyreply.h>
#include <vespa/messagebus/error.h>
#include <vespa/documentapi/documentapi.h>
diff --git a/documentapi/src/vespa/documentapi/messagebus/routablefactories60.cpp b/documentapi/src/vespa/documentapi/messagebus/routablefactories60.cpp
index 8b7c56117b1..ad32a5b4fa7 100644
--- a/documentapi/src/vespa/documentapi/messagebus/routablefactories60.cpp
+++ b/documentapi/src/vespa/documentapi/messagebus/routablefactories60.cpp
@@ -6,6 +6,7 @@
#include <vespa/document/bucket/fixed_bucket_spaces.h>
#include <vespa/document/select/parser.h>
#include <vespa/document/update/documentupdate.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/documentapi/documentapi.h>
#include <vespa/vespalib/objects/nbostream.h>
diff --git a/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp b/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp
index 868e9d036f1..a3aa7cbb32f 100644
--- a/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp
+++ b/eval/src/apps/analyze_onnx_model/analyze_onnx_model.cpp
@@ -299,10 +299,10 @@ int main(int argc, char **argv) {
try {
return my_main(argc, argv);
} catch (const MyError &err) {
- fprintf(stderr, "error: %s\n", err.msg.c_str());
+ fprintf(stdout, "error: %s\n", err.msg.c_str());
return 3;
} catch (const std::exception &ex) {
- fprintf(stderr, "got exception: %s\n", ex.what());
+ fprintf(stdout, "got exception: %s\n", ex.what());
return 2;
}
}
diff --git a/eval/src/tests/apps/analyze_onnx_model/analyze_onnx_model_test.cpp b/eval/src/tests/apps/analyze_onnx_model/analyze_onnx_model_test.cpp
index dc4527dd5c8..68d9ed69f80 100644
--- a/eval/src/tests/apps/analyze_onnx_model/analyze_onnx_model_test.cpp
+++ b/eval/src/tests/apps/analyze_onnx_model/analyze_onnx_model_test.cpp
@@ -39,13 +39,13 @@ TEST_F("require that output types can be probed", ServerCmd(probe_cmd)) {
//-----------------------------------------------------------------------------
-TEST_F("test error: invalid json", ServerCmd(probe_cmd, ServerCmd::capture_stderr_tag())) {
+TEST_F("test error: invalid json", ServerCmd(probe_cmd)) {
auto out = f1.write_then_read_all("this is not valid json...\n");
EXPECT_TRUE(out.find("invalid json") < out.size());
EXPECT_EQUAL(f1.shutdown(), 3);
}
-TEST_F("test error: missing input type", ServerCmd(probe_cmd, ServerCmd::capture_stderr_tag())) {
+TEST_F("test error: missing input type", ServerCmd(probe_cmd)) {
Slime params;
params.setObject();
params.get().setString("model", simple_model);
@@ -55,7 +55,7 @@ TEST_F("test error: missing input type", ServerCmd(probe_cmd, ServerCmd::capture
EXPECT_EQUAL(f1.shutdown(), 3);
}
-TEST_F("test error: invalid input type", ServerCmd(probe_cmd, ServerCmd::capture_stderr_tag())) {
+TEST_F("test error: invalid input type", ServerCmd(probe_cmd)) {
Slime params;
params.setObject();
params.get().setString("model", simple_model);
@@ -68,7 +68,7 @@ TEST_F("test error: invalid input type", ServerCmd(probe_cmd, ServerCmd::capture
EXPECT_EQUAL(f1.shutdown(), 3);
}
-TEST_F("test error: incompatible input type", ServerCmd(probe_cmd, ServerCmd::capture_stderr_tag())) {
+TEST_F("test error: incompatible input type", ServerCmd(probe_cmd)) {
Slime params;
params.setObject();
params.get().setString("model", simple_model);
@@ -81,7 +81,7 @@ TEST_F("test error: incompatible input type", ServerCmd(probe_cmd, ServerCmd::ca
EXPECT_EQUAL(f1.shutdown(), 3);
}
-TEST_F("test error: symbolic size mismatch", ServerCmd(probe_cmd, ServerCmd::capture_stderr_tag())) {
+TEST_F("test error: symbolic size mismatch", ServerCmd(probe_cmd)) {
Slime params;
params.setObject();
params.get().setString("model", dynamic_model);
diff --git a/persistence/src/vespa/persistence/spi/persistenceprovider.h b/persistence/src/vespa/persistence/spi/persistenceprovider.h
index 8c62e691daf..38c86454255 100644
--- a/persistence/src/vespa/persistence/spi/persistenceprovider.h
+++ b/persistence/src/vespa/persistence/spi/persistenceprovider.h
@@ -8,6 +8,7 @@
#include "selection.h"
#include "clusterstate.h"
#include "operationcomplete.h"
+#include <vespa/document/base/documentid.h>
namespace document { class FieldSet; }
namespace vespalib { class IDestructorCallback; }
diff --git a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp
index 133912548b1..85c39226998 100644
--- a/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp
+++ b/searchcore/src/apps/vespa-dump-feed/vespa-dump-feed.cpp
@@ -3,6 +3,7 @@
#include <vespa/config/print/fileconfigwriter.h>
#include <vespa/document/config/config-documenttypes.h>
#include <vespa/document/repo/documenttyperepo.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/documentapi/documentapi.h>
#include <vespa/messagebus/destinationsession.h>
#include <vespa/messagebus/rpcmessagebus.h>
@@ -16,8 +17,6 @@
#include <vespa/config/helper/configgetter.hpp>
#include <vespa/fastos/app.h>
-#include <iostream>
-
typedef vespalib::SignalHandler SIG;
//-----------------------------------------------------------------------------
diff --git a/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp b/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp
index 65d17d207ec..903b4d89696 100644
--- a/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp
+++ b/searchcore/src/tests/proton/attribute/document_field_extractor/document_field_extractor_test.cpp
@@ -50,7 +50,7 @@ makeIntArray(const std::vector<int32_t> &array)
{
auto result = std::make_unique<ArrayFieldValue>(arrayTypeInt);
for (const auto &elem : array) {
- result->append(std::make_unique<IntFieldValue>(elem));
+ result->append(IntFieldValue::make(elem));
}
return result;
}
@@ -60,7 +60,7 @@ makeStringArray(const std::vector<vespalib::string> &array)
{
auto result = std::make_unique<ArrayFieldValue>(arrayTypeString);
for (const auto &elem : array) {
- result->append(std::make_unique<StringFieldValue>(elem));
+ result->append(StringFieldValue::make(elem));
}
return result;
}
@@ -160,8 +160,8 @@ TEST_F("require that simple fields give simple values", SimpleFixture)
auto doc = f.makeDoc();
doc->setValue(f.weightField, IntFieldValue(200));
doc->setValue(f.nameField, StringFieldValue("name200b"));
- TEST_DO(f.assertExtracted("weight", std::make_unique<IntFieldValue>(200)));
- TEST_DO(f.assertExtracted("name", std::make_unique<StringFieldValue>("name200b")));
+ TEST_DO(f.assertExtracted("weight", IntFieldValue::make(200)));
+ TEST_DO(f.assertExtracted("name", StringFieldValue::make("name200b")));
}
struct ArrayFixture : public FixtureBase
diff --git a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
index 82eac88a53e..a460c65fbb2 100644
--- a/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
+++ b/searchcore/src/tests/proton/document_iterator/document_iterator_test.cpp
@@ -338,8 +338,8 @@ const DocumentType &getAttrDocType() {
IDocumentRetriever::SP doc_with_fields(const std::string &id, Timestamp t, Bucket b) {
auto d = std::make_unique<Document>(getDocType(), DocumentId(id));
- d->set("header", "foo");
- d->set("body", "bar");
+ d->setValue("header", StringFieldValue::make("foo"));
+ d->setValue("body", StringFieldValue::make("bar"));
return std::make_shared<UnitDR>(getDocType(), std::move(d), t, b, false);
}
@@ -355,12 +355,12 @@ IDocumentRetriever::SP doc_with_attr_fields(const vespalib::string &id,
const vespalib::string &attr_ss)
{
auto d = std::make_unique<Document>(getAttrDocType(), DocumentId(id));
- d->set("header", "foo");
- d->set("body", "bar");
- d->set("aa", aa);
- d->set("ab", ab);
- d->set("dd", dd);
- d->set("ss", ss);
+ d->setValue("header", StringFieldValue::make("foo"));
+ d->setValue("body", StringFieldValue::make("bar"));
+ d->setValue("aa", IntFieldValue::make(aa));
+ d->setValue("ab", IntFieldValue::make(ab));
+ d->setValue("dd", DoubleFieldValue::make(dd));
+ d->setValue("ss", StringFieldValue::make(ss));
return std::make_shared<AttrUnitDR>(std::move(d), t, b, false, attr_aa, attr_dd, attr_ss);
}
@@ -782,7 +782,7 @@ TEST("require that fieldset limits fields returned") {
EXPECT_TRUE(res.isCompleted());
EXPECT_EQUAL(1u, res.getEntries().size());
Document expected(getDocType(), DocumentId("id:ns:foo::xxx1"));
- expected.set("header", "foo");
+ expected.setValue("header", StringFieldValue::make("foo"));
TEST_DO(checkEntry(res, 0, expected, Timestamp(1)));
}
@@ -838,19 +838,19 @@ TEST("require that attributes are used")
EXPECT_TRUE(res.isCompleted());
EXPECT_EQUAL(2u, res.getEntries().size());
Document expected1(getAttrDocType(), DocumentId("id:ns:foo::xx2"));
- expected1.set("header", "foo");
- expected1.set("body", "bar");
- expected1.set("aa", 27);
- expected1.set("ab", 28);
- expected1.set("dd", 2.7);
- expected1.set("ss", "x27");
+ expected1.setValue("header", StringFieldValue::make("foo"));
+ expected1.setValue("body", StringFieldValue::make("bar"));
+ expected1.setValue("aa", IntFieldValue::make(27));
+ expected1.setValue("ab", IntFieldValue::make(28));
+ expected1.setValue("dd", DoubleFieldValue::make(2.7));
+ expected1.setValue("ss", StringFieldValue::make("x27"));
Document expected2(getAttrDocType(), DocumentId("id:ns:foo::xx4"));
- expected2.set("header", "foo");
- expected2.set("body", "bar");
- expected2.set("aa", 45);
- expected2.set("ab", 46);
- expected2.set("dd", 4.5);
- expected2.set("ss", "x45");
+ expected2.setValue("header", StringFieldValue::make("foo"));
+ expected2.setValue("body", StringFieldValue::make("bar"));
+ expected2.setValue("aa", IntFieldValue::make(45));
+ expected2.setValue("ab", IntFieldValue::make(46));
+ expected2.setValue("dd", DoubleFieldValue::make(4.5));
+ expected2.setValue("ss", StringFieldValue::make("x45"));
TEST_DO(checkEntry(res, 0, expected1, Timestamp(2)));
TEST_DO(checkEntry(res, 1, expected2, Timestamp(4)));
@@ -868,19 +868,19 @@ TEST("require that attributes are used")
EXPECT_TRUE(res2.isCompleted());
EXPECT_EQUAL(2u, res2.getEntries().size());
Document expected3(getAttrDocType(), DocumentId("id:ns:foo::xx6"));
- expected3.set("header", "foo");
- expected3.set("body", "bar");
- expected3.set("aa", 27);
- expected3.set("ab", 28);
- expected3.set("dd", 2.7);
- expected3.set("ss", "x27");
+ expected3.setValue("header", StringFieldValue::make("foo"));
+ expected3.setValue("body", StringFieldValue::make("bar"));
+ expected3.setValue("aa", IntFieldValue::make(27));
+ expected3.setValue("ab", IntFieldValue::make(28));
+ expected3.setValue("dd", DoubleFieldValue::make(2.7));
+ expected3.setValue("ss", StringFieldValue::make("x27"));
Document expected4(getAttrDocType(), DocumentId("id:ns:foo::xx8"));
- expected4.set("header", "foo");
- expected4.set("body", "bar");
- expected4.set("aa", 45);
- expected4.set("ab", 46);
- expected4.set("dd", 4.5);
- expected4.set("ss", "x45");
+ expected4.setValue("header", StringFieldValue::make("foo"));
+ expected4.setValue("body", StringFieldValue::make("bar"));
+ expected4.setValue("aa", IntFieldValue::make(45));
+ expected4.setValue("ab", IntFieldValue::make(46));
+ expected4.setValue("dd", DoubleFieldValue::make(4.5));
+ expected4.setValue("ss", StringFieldValue::make("x45"));
TEST_DO(checkEntry(res2, 0, expected3, Timestamp(6)));
TEST_DO(checkEntry(res2, 1, expected4, Timestamp(8)));
@@ -898,19 +898,19 @@ TEST("require that attributes are used")
EXPECT_TRUE(res3.isCompleted());
EXPECT_EQUAL(2u, res3.getEntries().size());
Document expected5(getAttrDocType(), DocumentId("id:ns:foo::xx10"));
- expected5.set("header", "foo");
- expected5.set("body", "bar");
- expected5.set("aa", 27);
- expected5.set("ab", 28);
- expected5.set("dd", 2.7);
- expected5.set("ss", "x27");
+ expected5.setValue("header", StringFieldValue::make("foo"));
+ expected5.setValue("body", StringFieldValue::make("bar"));
+ expected5.setValue("aa", IntFieldValue::make(27));
+ expected5.setValue("ab", IntFieldValue::make(28));
+ expected5.setValue("dd", DoubleFieldValue::make(2.7));
+ expected5.setValue("ss", StringFieldValue::make("x27"));
Document expected6(getAttrDocType(), DocumentId("id:ns:foo::xx12"));
- expected6.set("header", "foo");
- expected6.set("body", "bar");
- expected6.set("aa", 45);
- expected6.set("ab", 46);
- expected6.set("dd", 4.5);
- expected6.set("ss", "x45");
+ expected6.setValue("header", StringFieldValue::make("foo"));
+ expected6.setValue("body", StringFieldValue::make("bar"));
+ expected6.setValue("aa", IntFieldValue::make(45));
+ expected6.setValue("ab", IntFieldValue::make(46));
+ expected6.setValue("dd", DoubleFieldValue::make(4.5));
+ expected6.setValue("ss", StringFieldValue::make("x45"));
TEST_DO(checkEntry(res3, 0, expected5, Timestamp(10)));
TEST_DO(checkEntry(res3, 1, expected6, Timestamp(12)));
}
diff --git a/searchcore/src/tests/proton/server/documentretriever_test.cpp b/searchcore/src/tests/proton/server/documentretriever_test.cpp
index bf0d2881675..b4236ba4e3e 100644
--- a/searchcore/src/tests/proton/server/documentretriever_test.cpp
+++ b/searchcore/src/tests/proton/server/documentretriever_test.cpp
@@ -162,12 +162,12 @@ struct MyDocumentStore : proton::test::DummyDocumentStore {
const DocumentType *doc_type = r.getDocumentType(doc_type_name);
auto doc = std::make_unique<Document>(*doc_type, doc_id);
ASSERT_TRUE(doc);
- doc->set(static_field, static_value);
- doc->set(dyn_field_i, static_value);
- doc->set(dyn_field_s, static_value_s);
- doc->set(dyn_field_nai, static_value);
- doc->set(dyn_field_nas, static_value_s);
- doc->set(zcurve_field, static_zcurve_value);
+ doc->setValue(static_field, IntFieldValue::make(static_value));
+ doc->setValue(dyn_field_i, IntFieldValue::make(static_value));
+ doc->setValue(dyn_field_s, StringFieldValue::make(static_value_s));
+ doc->setValue(dyn_field_nai, IntFieldValue::make(static_value));
+ doc->setValue(dyn_field_nas, StringFieldValue::make(static_value_s));
+ doc->setValue(zcurve_field, LongFieldValue::make(static_zcurve_value));
doc->setValue(dyn_field_p, static_value_p);
TensorFieldValue tensorFieldValue(tensorDataType);
tensorFieldValue = SimpleValue::from_value(*static_tensor);
@@ -175,8 +175,8 @@ struct MyDocumentStore : proton::test::DummyDocumentStore {
if (_set_position_struct_field) {
FieldValue::UP fv = PositionDataType::getInstance().createFieldValue();
auto &pos = dynamic_cast<StructFieldValue &>(*fv);
- pos.set(PositionDataType::FIELD_X, 42);
- pos.set(PositionDataType::FIELD_Y, 21);
+ pos.setValue(PositionDataType::FIELD_X, IntFieldValue::make(42));
+ pos.setValue(PositionDataType::FIELD_Y, IntFieldValue::make(21));
doc->setValue(doc->getField(position_field), *fv);
}
diff --git a/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp b/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp
index 49d1bb1c0a8..56cea8db741 100644
--- a/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp
+++ b/searchcore/src/vespa/searchcore/bmcluster/bm_feed.cpp
@@ -65,7 +65,7 @@ BmFeed::make_document(uint32_t n, uint32_t i) const
auto id = make_document_id(n, i);
auto document = std::make_unique<Document>(*_document_type, id);
document->setRepo(*_repo);
- document->setFieldValue(_field, std::make_unique<IntFieldValue>(i));
+ document->setFieldValue(_field, IntFieldValue::make(i));
return document;
}
diff --git a/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp b/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp
index 4a220c790c9..00d84e795c7 100644
--- a/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp
+++ b/searchcore/src/vespa/searchcore/proton/attribute/document_field_retriever.cpp
@@ -1,9 +1,7 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "document_field_retriever.h"
-#include <vespa/document/fieldvalue/arrayfieldvalue.h>
-#include <vespa/document/fieldvalue/weightedsetfieldvalue.h>
-#include <vespa/document/fieldvalue/tensorfieldvalue.h>
+#include <vespa/document/fieldvalue/fieldvalues.h>
#include <vespa/searchcommon/attribute/attributecontent.h>
#include <vespa/searchlib/tensor/tensor_attribute.h>
#include <vespa/eval/eval/value.h>
@@ -31,12 +29,13 @@ namespace proton {
namespace {
-template <typename T>
+template <typename T, typename FT>
void
-setValue(DocumentIdT lid,
- Document &doc,
- const document::Field & field,
- const IAttributeVector &attr)
+setValue(DocumentIdT lid, Document &doc, const document::Field & field, const IAttributeVector &attr);
+
+template <typename T, typename FT>
+void
+setValue(DocumentIdT lid, Document &doc, const document::Field & field, const IAttributeVector &attr)
{
switch (attr.getCollectionType()) {
case CollectionType::SINGLE:
@@ -44,7 +43,7 @@ setValue(DocumentIdT lid,
if ( ! attr.isUndefined(lid) ) {
AttributeContent<T> content;
content.fill(attr, lid);
- doc.set(field, content[0]);
+ doc.setFieldValue(field, std::make_unique<FT>(content[0]));
} else {
doc.remove(field);
}
@@ -65,7 +64,7 @@ setValue(DocumentIdT lid,
ArrayFieldValue &array = static_cast<ArrayFieldValue &>(*fv.get());
array.resize(content.size());
for (uint32_t j(0); j < content.size(); ++j) {
- array[j] = content[j];
+ static_cast<FT &>(array[j]).setValue(content[j]);
}
doc.setValue(field, *fv);
break;
@@ -86,8 +85,8 @@ setValue(DocumentIdT lid,
wset.resize(content.size());
auto it(wset.begin());
for (uint32_t j(0); j < content.size(); ++j, ++it) {
- *it->first = content[j].getValue();
- *it->second = content[j].getWeight();
+ static_cast<FT &>(*it->first).setValue(content[j].getValue());
+ static_cast<document::IntFieldValue &>(*it->second).setValue(content[j].getWeight());
}
doc.setValue(field, *fv);
break;
@@ -124,27 +123,28 @@ DocumentFieldRetriever::populate(DocumentIdT lid,
{
switch (attr.getBasicType()) {
case BasicType::BOOL:
+ return setValue<IAttributeVector::largeint_t, document::BoolFieldValue>(lid, doc, field, attr);
case BasicType::UINT2:
case BasicType::UINT4:
case BasicType::INT8:
+ return setValue<IAttributeVector::largeint_t, document::ByteFieldValue>(lid, doc, field, attr);
case BasicType::INT16:
+ return setValue<IAttributeVector::largeint_t, document::ShortFieldValue>(lid, doc, field, attr);
case BasicType::INT32:
+ return setValue<IAttributeVector::largeint_t, document::IntFieldValue>(lid, doc, field, attr);
case BasicType::INT64:
- setValue<IAttributeVector::largeint_t>(lid, doc, field, attr);
- break;
+ return setValue<IAttributeVector::largeint_t, document::LongFieldValue>(lid, doc, field, attr);
case BasicType::FLOAT:
+ return setValue<double, document::FloatFieldValue>(lid, doc, field, attr);
case BasicType::DOUBLE:
- setValue<double>(lid, doc, field, attr);
- break;
+ return setValue<double, document::DoubleFieldValue>(lid, doc, field, attr);
case BasicType::STRING:
- setValue<const char *>(lid, doc, field, attr);
- break;
+ return setValue<const char *, document::StringFieldValue>(lid, doc, field, attr);
case BasicType::PREDICATE:
// Predicate attribute doesn't store documents, it only indexes them.
break;
case BasicType::TENSOR:
- setTensorValue(lid, doc, field, attr);
- break;
+ return setTensorValue(lid, doc, field, attr);
case BasicType::REFERENCE:
// Reference attribute doesn't store full document id.
break;
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp b/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp
index d3778b4d745..ee2af5b606c 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentretriever.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/datatype/positiondatatype.h>
#include <vespa/document/datatype/documenttype.h>
#include <vespa/document/fieldvalue/arrayfieldvalue.h>
+#include <vespa/document/fieldvalue/intfieldvalue.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/fieldset/fieldsets.h>
#include <vespa/searchcommon/attribute/attributecontent.h>
@@ -157,9 +158,9 @@ positionFromZcurve(int64_t zcurve) {
ZCurve::decode(zcurve, &x, &y);
FieldValue::UP value = PositionDataType::getInstance().createFieldValue();
- auto *position = static_cast<StructFieldValue *>(value.get());
- position->set(PositionDataType::FIELD_X, x);
- position->set(PositionDataType::FIELD_Y, y);
+ auto *pos = static_cast<StructFieldValue *>(value.get());
+ pos->setValue(pos->getField(PositionDataType::FIELD_X), std::make_unique<document::IntFieldValue>(x));
+ pos->setValue(pos->getField(PositionDataType::FIELD_Y), std::make_unique<document::IntFieldValue>(y));
return value;
}
diff --git a/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h b/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h
index 16feeb2ce24..67d6e034080 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h
+++ b/searchcorespi/src/vespa/searchcorespi/index/imemoryindex.h
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include <vespa/document/fieldvalue/document.h>
#include <vespa/searchcommon/common/schema.h>
#include <vespa/searchcorespi/index/indexsearchable.h>
#include <vespa/searchlib/common/serialnum.h>
@@ -9,7 +8,7 @@
#include <vespa/vespalib/util/memoryusage.h>
namespace vespalib { class IDestructorCallback; }
-
+namespace document { class Document; }
namespace searchcorespi::index {
/**
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
index 34a561dd2e2..f740cec7900 100644
--- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
+++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp
@@ -9,6 +9,7 @@
#include "indexreadutilities.h"
#include "indexwriteutilities.h"
#include "index_disk_dir.h"
+#include <vespa/document/fieldvalue//document.h>
#include <vespa/searchcorespi/flush/lambdaflushtask.h>
#include <vespa/searchlib/common/i_flush_token.h>
#include <vespa/searchlib/index/schemautil.h>
diff --git a/searchlib/src/apps/tests/memoryindexstress_test.cpp b/searchlib/src/apps/tests/memoryindexstress_test.cpp
index fcac0be8f85..07747a66892 100644
--- a/searchlib/src/apps/tests/memoryindexstress_test.cpp
+++ b/searchlib/src/apps/tests/memoryindexstress_test.cpp
@@ -137,7 +137,7 @@ setFieldValue(Document &doc, const vespalib::string &fieldName,
const vespalib::string &fieldString)
{
std::unique_ptr<StringFieldValue> fieldValue =
- std::make_unique<StringFieldValue>(fieldString);
+ StringFieldValue::make(fieldString);
document::FixedTypeRepo repo(*doc.getRepo(), doc.getType());
tokenizeStringFieldValue(repo, *fieldValue);
doc.setFieldValue(doc.getField(fieldName), std::move(fieldValue));
diff --git a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp
index 072efb06a07..c08aa7ce9fc 100644
--- a/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp
+++ b/searchlib/src/tests/docstore/document_store_visitor/document_store_visitor_test.cpp
@@ -8,6 +8,7 @@
#include <vespa/searchlib/common/bitvector.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/datatype/documenttype.h>
+#include <vespa/document/fieldvalue/stringfieldvalue.h>
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/vespalib/io/fileutil.h>
@@ -26,6 +27,7 @@ using document::Document;
using document::DocumentId;
using document::DocumentType;
using document::DocumentTypeRepo;
+using document::StringFieldValue;
using vespalib::compression::CompressionConfig;
using vespalib::asciistream;
using index::DummyFileHeaderContext;
@@ -66,9 +68,9 @@ makeDoc(const DocumentTypeRepo &repo, uint32_t i, bool before)
mainstr << (j + i * 1000) << " ";
}
mainstr << " and end field";
- doc->set("main", mainstr.c_str());
+ doc->setValue("main", StringFieldValue::make(mainstr.str()));
if (!before) {
- doc->set("extra", "foo");
+ doc->setValue("extra", StringFieldValue::make("foo"));
}
return doc;
@@ -160,7 +162,7 @@ MyRewriteVisitor::visit(uint32_t lid, const std::shared_ptr<Document> &doc)
Document::UP expDoc(makeDoc(_repo, lid, _before));
EXPECT_TRUE(*expDoc == *doc);
_valid->setBitAndMaintainCount(lid);
- doc->set("extra", "foo");
+ doc->setValue("extra", StringFieldValue::make("foo"));
}
diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
index 378babb6ee1..bb2d0177dd9 100644
--- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
+++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
@@ -4,6 +4,7 @@
#include <vespa/document/repo/configbuilder.h>
#include <vespa/document/repo/documenttyperepo.h>
#include <vespa/document/datatype/documenttype.h>
+#include <vespa/document/fieldvalue/stringfieldvalue.h>
#include <vespa/document/fieldvalue/document.h>
#include <vespa/searchlib/docstore/chunkformats.h>
#include <vespa/searchlib/docstore/logdocumentstore.h>
@@ -19,6 +20,7 @@
#include <iomanip>
using document::BucketId;
+using document::StringFieldValue;
using namespace search::docstore;
using namespace search;
using namespace vespalib::alloc;
@@ -429,9 +431,9 @@ makeDoc(const DocumentTypeRepo &repo, uint32_t i, bool extra_field, size_t numRe
mainstr << (j + i * 1000) << " ";
}
mainstr << " and end field";
- doc->set("main", mainstr.c_str());
+ doc->setValue("main", StringFieldValue::make(mainstr.str()));
if (extra_field) {
- doc->set("extra", "foo");
+ doc->setValue("extra", StringFieldValue::make("foo"));
}
return doc;
}
diff --git a/searchlib/src/tests/grouping/grouping_serialization_test.cpp b/searchlib/src/tests/grouping/grouping_serialization_test.cpp
index ea96c698a02..39a5feab111 100644
--- a/searchlib/src/tests/grouping/grouping_serialization_test.cpp
+++ b/searchlib/src/tests/grouping/grouping_serialization_test.cpp
@@ -7,6 +7,7 @@
#include <vespa/searchlib/expression/getdocidnamespacespecificfunctionnode.h>
#include <vespa/searchlib/expression/getymumchecksumfunctionnode.h>
#include <vespa/searchlib/expression/documentfieldnode.h>
+#include <vespa/document/base/documentid.h>
#include <vespa/vespalib/testkit/test_kit.h>
#include <fstream>
#include <vespa/log/log.h>
diff --git a/searchlib/src/vespa/searchlib/expression/documentaccessornode.h b/searchlib/src/vespa/searchlib/expression/documentaccessornode.h
index 0efe7d023f6..453b8f82bf0 100644
--- a/searchlib/src/vespa/searchlib/expression/documentaccessornode.h
+++ b/searchlib/src/vespa/searchlib/expression/documentaccessornode.h
@@ -2,12 +2,14 @@
#pragma once
#include "expressionnode.h"
-#include <vespa/document/fieldvalue/document.h>
#include <vespa/vespalib/objects/objectoperation.h>
#include <vespa/vespalib/objects/objectpredicate.h>
-namespace search {
-namespace expression {
+namespace document {
+ class DocumentType;
+ class Document;
+}
+namespace search::expression {
class DocumentAccessorNode : public ExpressionNode
{
@@ -33,5 +35,3 @@ private:
};
}
-}
-
diff --git a/searchlib/src/vespa/searchlib/expression/documentfieldnode.h b/searchlib/src/vespa/searchlib/expression/documentfieldnode.h
index b85ba0f4e9b..fd3923bd4a0 100644
--- a/searchlib/src/vespa/searchlib/expression/documentfieldnode.h
+++ b/searchlib/src/vespa/searchlib/expression/documentfieldnode.h
@@ -5,6 +5,7 @@
#include "resultnode.h"
#include "resultvector.h"
#include <vespa/document/fieldvalue/iteratorhandler.h>
+#include <vespa/document/base/fieldpath.h>
namespace search::expression {
diff --git a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h
index 1c1998fb423..5a7c8d0f7bc 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h
+++ b/searchlib/src/vespa/searchlib/memoryindex/field_inverter.h
@@ -4,7 +4,6 @@
#include "i_field_index_remove_listener.h"
#include <vespa/document/annotation/span.h>
-#include <vespa/document/fieldvalue/document.h>
#include <vespa/searchlib/index/docidandfeatures.h>
#include <vespa/vespalib/stllike/allocator.h>
#include <vespa/vespalib/stllike/hash_map.h>
@@ -15,6 +14,12 @@ namespace search::index {
class Schema;
}
+namespace document {
+ class FieldValue;
+ class StringFieldValue;
+ class ArrayFieldValue;
+ class WeightedSetFieldValue;
+}
namespace search::memoryindex {
class IOrderedFieldIndexInserter;
@@ -299,7 +304,7 @@ public:
/**
* Invert a normal text field, based on annotations.
*/
- void invertField(uint32_t docId, const document::FieldValue::UP &val);
+ void invertField(uint32_t docId, const std::unique_ptr<document::FieldValue> &val);
/**
* Setup remove of word in old version of document.
diff --git a/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp b/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp
index fb6e1328b8b..8fa9de7da74 100644
--- a/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp
+++ b/searchlib/src/vespa/searchlib/memoryindex/invert_task.cpp
@@ -5,6 +5,7 @@
#include "field_inverter.h"
#include "invert_context.h"
#include "url_field_inverter.h"
+#include <vespa/document/fieldvalue/document.h>
namespace search::memoryindex {
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp
index 597cfe8eb40..487fb9e329f 100644
--- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp
+++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp
@@ -322,7 +322,7 @@ public:
if (_field_value.get()) {
return std::move(_field_value);
}
- return std::make_unique<StringFieldValue>(_str.str());
+ return StringFieldValue::make(_str.str());
}
};
diff --git a/storage/src/tests/storageserver/documentapiconvertertest.cpp b/storage/src/tests/storageserver/documentapiconvertertest.cpp
index 4b3cd3dfe17..c375443b265 100644
--- a/storage/src/tests/storageserver/documentapiconvertertest.cpp
+++ b/storage/src/tests/storageserver/documentapiconvertertest.cpp
@@ -8,6 +8,7 @@
#include <vespa/document/select/parser.h>
#include <vespa/document/test/make_document_bucket.h>
#include <vespa/document/update/documentupdate.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/documentapi/documentapi.h>
#include <vespa/messagebus/emptyreply.h>
#include <vespa/messagebus/error.h>
diff --git a/storage/src/vespa/storage/persistence/CMakeLists.txt b/storage/src/vespa/storage/persistence/CMakeLists.txt
index c737d2bed28..7715517a791 100644
--- a/storage/src/vespa/storage/persistence/CMakeLists.txt
+++ b/storage/src/vespa/storage/persistence/CMakeLists.txt
@@ -18,6 +18,5 @@ vespa_add_library(storage_spersistence OBJECT
splitbitdetector.cpp
splitjoinhandler.cpp
testandsethelper.cpp
- types.cpp
DEPENDS
)
diff --git a/storage/src/vespa/storage/persistence/asynchandler.h b/storage/src/vespa/storage/persistence/asynchandler.h
index 71c54e99f75..d50ebf36c81 100644
--- a/storage/src/vespa/storage/persistence/asynchandler.h
+++ b/storage/src/vespa/storage/persistence/asynchandler.h
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include "types.h"
#include "messages.h"
#include <vespa/storageapi/message/persistence.h>
#include <vespa/storageapi/message/removelocation.h>
@@ -16,12 +15,14 @@ namespace spi {
}
class PersistenceUtil;
class BucketOwnershipNotifier;
+class MessageTracker;
/**
* Handle async operations that uses a sequenced executor.
* It is stateless and thread safe.
*/
-class AsyncHandler : public Types {
+class AsyncHandler {
+ using MessageTrackerUP = std::unique_ptr<MessageTracker>;
public:
AsyncHandler(const PersistenceUtil&, spi::PersistenceProvider&, BucketOwnershipNotifier &,
vespalib::ISequencedTaskExecutor & executor, const document::BucketIdFactory & bucketIdFactory);
diff --git a/storage/src/vespa/storage/persistence/merge_bucket_info_syncer.h b/storage/src/vespa/storage/persistence/merge_bucket_info_syncer.h
index b3386c591e6..cd7e9690316 100644
--- a/storage/src/vespa/storage/persistence/merge_bucket_info_syncer.h
+++ b/storage/src/vespa/storage/persistence/merge_bucket_info_syncer.h
@@ -2,6 +2,8 @@
#pragma once
+#include <memory>
+
namespace storage::spi { class Bucket; }
namespace storage {
diff --git a/storage/src/vespa/storage/persistence/mergehandler.cpp b/storage/src/vespa/storage/persistence/mergehandler.cpp
index 8287fe27509..73361c7e8d6 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.cpp
+++ b/storage/src/vespa/storage/persistence/mergehandler.cpp
@@ -10,6 +10,7 @@
#include <vespa/persistence/spi/docentry.h>
#include <vespa/vdslib/distribution/distribution.h>
#include <vespa/document/fieldset/fieldsets.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/vespalib/util/isequencedtaskexecutor.h>
@@ -239,7 +240,7 @@ MergeHandler::buildBucketInfoList(
for (const auto& entry : entries) {
api::GetBucketDiffCommand::Entry diff;
- diff._gid = GlobalId();
+ diff._gid = document::GlobalId();
// We do not know doc sizes at this point, so just set to 0
diff._headerSize = 0;
diff._bodySize = 0;
@@ -449,7 +450,7 @@ MergeHandler::fetchLocalData(
api::ApplyBucketDiffCommand::Entry& e(*iter);
if (!docEntry.isRemove()) {
- const Document* doc = docEntry.getDocument();
+ const document::Document* doc = docEntry.getDocument();
assert(doc != nullptr);
assertContainedInBucket(doc->getId(), bucket, idFactory);
e._docName = doc->getId().toString();
@@ -459,7 +460,7 @@ MergeHandler::fetchLocalData(
memcpy(&e._headerBlob[0], stream.peek(), stream.size());
e._bodyBlob.clear();
} else {
- const DocumentId* docId = docEntry.getDocumentId();
+ const document::DocumentId* docId = docEntry.getDocumentId();
assert(docId != nullptr);
assertContainedInBucket(*docId, bucket, idFactory);
if (e._entry._flags & DELETED) {
@@ -495,7 +496,7 @@ MergeHandler::deserializeDiffDocument(
const api::ApplyBucketDiffCommand::Entry& e,
const document::DocumentTypeRepo& repo) const
{
- auto doc = std::make_unique<Document>();
+ auto doc = std::make_unique<document::Document>();
vespalib::nbostream hbuf(&e._headerBlob[0], e._headerBlob.size());
if (e._bodyBlob.size() > 0) {
// TODO Remove this branch and add warning on error.
@@ -519,8 +520,8 @@ MergeHandler::applyDiffEntry(std::shared_ptr<ApplyBucketDiffState> async_results
spi::Timestamp timestamp(e._entry._timestamp);
if (!(e._entry._flags & (DELETED | DELETED_IN_PLACE))) {
// Regular put entry
- Document::SP doc(deserializeDiffDocument(e, repo));
- DocumentId docId = doc->getId();
+ std::shared_ptr<document::Document> doc(deserializeDiffDocument(e, repo));
+ document::DocumentId docId = doc->getId();
auto complete = std::make_unique<ApplyBucketDiffEntryComplete>(std::move(async_results), std::move(docId),
std::move(throttle_token), "put",
_clock, _env._metrics.merge_handler_metrics.put_latency);
@@ -557,7 +558,7 @@ MergeHandler::applyDiffLocally(
async_results->mark_stale_bucket_info();
DocEntryList entries;
- populateMetaData(bucket, MAX_TIMESTAMP, entries, context);
+ populateMetaData(bucket, Timestamp::max(), entries, context);
const document::DocumentTypeRepo & repo = _env.getDocumentTypeRepo();
diff --git a/storage/src/vespa/storage/persistence/mergehandler.h b/storage/src/vespa/storage/persistence/mergehandler.h
index 1ed2fa878bc..3f631acbef5 100644
--- a/storage/src/vespa/storage/persistence/mergehandler.h
+++ b/storage/src/vespa/storage/persistence/mergehandler.h
@@ -13,19 +13,17 @@
*/
#pragma once
-#include "types.h"
#include "merge_bucket_info_syncer.h"
#include <vespa/persistence/spi/bucket.h>
#include <vespa/storageapi/message/bucket.h>
#include <vespa/storage/common/cluster_context.h>
#include <vespa/storage/common/messagesender.h>
#include <vespa/vespalib/util/monitored_refcount.h>
+#include <vespa/storageframework/generic/clock/time.h>
#include <atomic>
-namespace vespalib {
-class ISequencedTaskExecutor;
-}
-
+namespace vespalib { class ISequencedTaskExecutor; }
+namespace document { class Document; }
namespace storage {
namespace spi {
@@ -36,10 +34,12 @@ namespace spi {
class PersistenceUtil;
class ApplyBucketDiffState;
class MergeStatus;
+class MessageTracker;
-class MergeHandler : public Types,
- public MergeBucketInfoSyncer {
-
+class MergeHandler : public MergeBucketInfoSyncer {
+private:
+ using MessageTrackerUP = std::unique_ptr<MessageTracker>;
+ using Timestamp = framework::MicroSecTime;
public:
enum StateFlag {
IN_USE = 0x01,
@@ -92,7 +92,7 @@ public:
private:
using DocEntryList = std::vector<std::unique_ptr<spi::DocEntry>>;
const framework::Clock &_clock;
- const ClusterContext &_cluster_context;
+ const ClusterContext &_cluster_context;
PersistenceUtil &_env;
spi::PersistenceProvider &_spi;
std::unique_ptr<vespalib::MonitoredRefCount> _monitored_ref_count;
@@ -129,9 +129,8 @@ private:
DocEntryList & entries,
spi::Context& context) const;
- Document::UP deserializeDiffDocument(
- const api::ApplyBucketDiffCommand::Entry& e,
- const document::DocumentTypeRepo& repo) const;
+ std::unique_ptr<document::Document>
+ deserializeDiffDocument(const api::ApplyBucketDiffCommand::Entry& e, const document::DocumentTypeRepo& repo) const;
};
} // storage
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.cpp b/storage/src/vespa/storage/persistence/persistenceutil.cpp
index 2781cc61b83..77e8532f0d2 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.cpp
+++ b/storage/src/vespa/storage/persistence/persistenceutil.cpp
@@ -3,6 +3,7 @@
#include "persistenceutil.h"
#include <vespa/persistence/spi/persistenceprovider.h>
#include <vespa/storageapi/messageapi/bucketinforeply.h>
+#include <vespa/document/base/documentid.h>
#include <vespa/vespalib/util/exceptions.h>
#include <vespa/log/bufferedlogger.h>
diff --git a/storage/src/vespa/storage/persistence/persistenceutil.h b/storage/src/vespa/storage/persistence/persistenceutil.h
index 4130a276239..c3fcb68ddc8 100644
--- a/storage/src/vespa/storage/persistence/persistenceutil.h
+++ b/storage/src/vespa/storage/persistence/persistenceutil.h
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include "types.h"
#include <vespa/storage/common/servicelayercomponent.h>
#include <vespa/storage/persistence/filestorage/filestorhandler.h>
#include <vespa/storage/persistence/filestorage/filestormetrics.h>
+#include <vespa/storage/bucketdb/storbucketdb.h>
#include <vespa/storageframework/generic/clock/timer.h>
#include <vespa/storageapi/messageapi/returncode.h>
#include <vespa/persistence/spi/result.h>
@@ -15,6 +15,7 @@
namespace storage::api {
class StorageMessage;
class StorageReply;
+ class BucketInfo;
}
namespace storage::spi {
@@ -25,7 +26,7 @@ namespace storage {
class PersistenceUtil;
-class MessageTracker : protected Types {
+class MessageTracker {
public:
using UP = std::unique_ptr<MessageTracker>;
@@ -48,7 +49,7 @@ public:
}
/** Utility function to be able to write a bit less in client. */
- void fail(uint32_t result, const String& message = "") {
+ void fail(uint32_t result, const vespalib::string & message = "") {
fail(api::ReturnCode((api::ReturnCode::Result)result, message));
}
/** Set the request to fail with the given failure. */
diff --git a/storage/src/vespa/storage/persistence/processallhandler.cpp b/storage/src/vespa/storage/persistence/processallhandler.cpp
index 6d6723a0185..c22b08c5ca5 100644
--- a/storage/src/vespa/storage/persistence/processallhandler.cpp
+++ b/storage/src/vespa/storage/persistence/processallhandler.cpp
@@ -4,6 +4,7 @@
#include "bucketprocessor.h"
#include "persistenceutil.h"
#include <vespa/document/fieldset/fieldsets.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/persistence/spi/persistenceprovider.h>
#include <vespa/persistence/spi/docentry.h>
#include <vespa/vespalib/util/stringfmt.h>
diff --git a/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp b/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp
index b7344098698..6d15cc06cdf 100644
--- a/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp
+++ b/storage/src/vespa/storage/persistence/provider_error_wrapper.cpp
@@ -1,7 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "provider_error_wrapper.h"
-#include "persistenceutil.h"
#include <vespa/persistence/spi/docentry.h>
#include <vespa/vespalib/util/idestructorcallback.h>
diff --git a/storage/src/vespa/storage/persistence/types.cpp b/storage/src/vespa/storage/persistence/types.cpp
deleted file mode 100644
index 3bf116bb2ee..00000000000
--- a/storage/src/vespa/storage/persistence/types.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#include "types.h"
-
-namespace storage {
-
-const framework::MicroSecTime Types::MAX_TIMESTAMP(framework::MicroSecTime::max());
-const framework::MicroSecTime Types::UNSET_TIMESTAMP(0);
-
-} // storage
diff --git a/storage/src/vespa/storage/persistence/types.h b/storage/src/vespa/storage/persistence/types.h
index 8dff11468a0..da004f85075 100644
--- a/storage/src/vespa/storage/persistence/types.h
+++ b/storage/src/vespa/storage/persistence/types.h
@@ -4,7 +4,6 @@
#include <iosfwd>
#include <vespa/document/bucket/bucketid.h>
#include <vespa/document/base/documentid.h>
-#include <vespa/document/fieldvalue/document.h>
#include <vespa/storage/bucketdb/storbucketdb.h>
#include <vespa/storageapi/buckets/bucketinfo.h>
#include <vespa/storageapi/defs.h>
@@ -17,18 +16,12 @@ class MessageTracker;
struct Types {
typedef document::BucketId BucketId;
- typedef document::Document Document;
typedef document::DocumentId DocumentId;
typedef document::GlobalId GlobalId;
typedef framework::MicroSecTime Timestamp;
- typedef Timestamp RevertToken;
typedef vespalib::string String;
typedef api::BucketInfo BucketInfo;
using MessageTrackerUP = std::unique_ptr<MessageTracker>;
-
- static const framework::MicroSecTime MAX_TIMESTAMP;
- static const framework::MicroSecTime UNSET_TIMESTAMP;
-
protected:
~Types() {} // Noone should refer to objects as Types objects
};
diff --git a/storage/src/vespa/storage/storageserver/documentapiconverter.cpp b/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
index d95349fc88b..c465f974a9b 100644
--- a/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
+++ b/storage/src/vespa/storage/storageserver/documentapiconverter.cpp
@@ -5,6 +5,7 @@
#include <vespa/document/bucket/bucketidfactory.h>
#include <vespa/document/update/documentupdate.h>
#include <vespa/documentapi/documentapi.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/storage/common/bucket_resolver.h>
#include <vespa/storageapi/message/datagram.h>
#include <vespa/storageapi/message/documentsummary.h>
diff --git a/storage/src/vespa/storage/visiting/recoveryvisitor.cpp b/storage/src/vespa/storage/visiting/recoveryvisitor.cpp
index 1c3c97d7dcb..9d1b2c83266 100644
--- a/storage/src/vespa/storage/visiting/recoveryvisitor.cpp
+++ b/storage/src/vespa/storage/visiting/recoveryvisitor.cpp
@@ -1,10 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
#include "recoveryvisitor.h"
#include <vespa/persistence/spi/docentry.h>
#include <vespa/vespalib/objects/nbostream.h>
#include <vespa/documentapi/messagebus/messages/visitor.h>
+#include <vespa/document/fieldvalue/document.h>
#include <vespa/vespalib/text/stringtokenizer.h>
#include <vespa/vespalib/stllike/hash_map.hpp>