aboutsummaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-01-30 11:29:46 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-01-30 11:29:46 +0000
commitd30cb8d388a56ea1f02d87e3da3a1fcbacc639c8 (patch)
treea358a5b6969afc049308aab060ac0db454cdd46f /document
parent70915ed4ea7fe40bcacc2f2bf3b93f36ae79163d (diff)
Header/body does not exist anymore. Deprecate and remove own internal usage.
Diffstat (limited to 'document')
-rw-r--r--document/abi-spec.json2
-rwxr-xr-xdocument/src/main/java/com/yahoo/document/DocumentType.java15
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java4
-rw-r--r--document/src/main/java/com/yahoo/document/Field.java26
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java2
-rw-r--r--document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java2
-rwxr-xr-xdocument/src/test/java/com/yahoo/document/DocumentCalculatorTestCase.java10
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentIdTestCase.java6
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java28
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentTestCase.java64
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentTestCaseBase.java12
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java14
-rw-r--r--document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java4
-rw-r--r--document/src/test/java/com/yahoo/document/IncompatibleFieldTypesTest.java4
-rw-r--r--document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java24
-rw-r--r--document/src/test/java/com/yahoo/document/fieldset/FieldSetTestCase.java22
-rw-r--r--document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java12
17 files changed, 125 insertions, 126 deletions
diff --git a/document/abi-spec.json b/document/abi-spec.json
index e4917a174a6..9b67eeb97ee 100644
--- a/document/abi-spec.json
+++ b/document/abi-spec.json
@@ -1457,8 +1457,10 @@
],
"methods": [
"public void <init>(java.lang.String, int, com.yahoo.document.DataType, boolean)",
+ "public void <init>(java.lang.String, int, com.yahoo.document.DataType)",
"public void <init>(java.lang.String)",
"public void <init>(java.lang.String, com.yahoo.document.DataType, boolean, com.yahoo.document.DocumentType)",
+ "public void <init>(java.lang.String, com.yahoo.document.DataType, com.yahoo.document.DocumentType)",
"public void <init>(java.lang.String, com.yahoo.document.DataType, boolean)",
"public void <init>(java.lang.String, com.yahoo.document.DataType)",
"public void <init>(java.lang.String, com.yahoo.document.Field)",
diff --git a/document/src/main/java/com/yahoo/document/DocumentType.java b/document/src/main/java/com/yahoo/document/DocumentType.java
index f3ff6e4ed30..42ccca9f477 100755
--- a/document/src/main/java/com/yahoo/document/DocumentType.java
+++ b/document/src/main/java/com/yahoo/document/DocumentType.java
@@ -181,8 +181,7 @@ public class DocumentType extends StructuredDataType {
if (isRegistered()) {
throw new IllegalStateException("You cannot add fields to a document type that is already registered.");
}
- StructDataType struct = (field.isHeader() ? headerType : bodyType);
- struct.addField(field);
+ headerType.addField(field);
}
// Do not use, public only for testing
@@ -221,8 +220,8 @@ public class DocumentType extends StructuredDataType {
if (isRegistered()) {
throw new IllegalStateException("You cannot add fields to a document type that is already registered.");
}
- Field field = new Field(name, type, false);
- bodyType.addField(field);
+ Field field = new Field(name, type);
+ headerType.addField(field);
return field;
}
@@ -234,13 +233,9 @@ public class DocumentType extends StructuredDataType {
* @return The field created
* TODO Fix searchdefinition so that exception can be thrown if filed is already registerd
*/
+ @Deprecated
public Field addHeaderField(String name, DataType type) {
- if (isRegistered()) {
- throw new IllegalStateException("You cannot add fields to a document type that is already registered.");
- }
- Field field = new Field(name, type, true);
- headerType.addField(field);
- return field;
+ return addField(name, type);
}
/**
diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
index 154c25880a9..5e698e980ff 100644
--- a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
+++ b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java
@@ -180,9 +180,9 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub
: manager.getDataType(field.datatype(), field.detailedtype());
if (field.id().size() == 1) {
- type.addField(new Field(field.name(), field.id().get(0).id(), fieldType, true));
+ type.addField(new Field(field.name(), field.id().get(0).id(), fieldType));
} else {
- type.addField(new Field(field.name(), fieldType, true));
+ type.addField(new Field(field.name(), fieldType));
}
}
manager.register(type);
diff --git a/document/src/main/java/com/yahoo/document/Field.java b/document/src/main/java/com/yahoo/document/Field.java
index 671c8c7f763..9be4036174c 100644
--- a/document/src/main/java/com/yahoo/document/Field.java
+++ b/document/src/main/java/com/yahoo/document/Field.java
@@ -21,7 +21,6 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
protected DataType dataType;
protected int fieldId;
- private boolean isHeader;
private boolean forcedId;
/**
@@ -32,11 +31,14 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
* @param isHeader Whether this is a "header" field or a "content" field
* (true = "header").
*/
+ @Deprecated
public Field(String name, int id, DataType dataType, boolean isHeader) {
+ this(name, id, dataType);
+ }
+ public Field(String name, int id, DataType dataType) {
super(name);
this.fieldId = id;
this.dataType = dataType;
- this.isHeader = isHeader;
this.forcedId = true;
validateId(id, null);
}
@@ -55,8 +57,13 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
* (true = "header").
* @param owner the owning document (used to check for id collisions)
*/
+ @Deprecated
public Field(String name, DataType dataType, boolean isHeader, DocumentType owner) {
- this(name, 0, dataType, isHeader);
+ this(name, dataType, owner);
+ }
+
+ public Field(String name, DataType dataType, DocumentType owner) {
+ this(name, 0, dataType);
this.fieldId = calculateIdV7(owner);
this.forcedId = false;
}
@@ -69,8 +76,9 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
* @param isHeader Whether this is a "header" field or a "content" field
* (true = "header").
*/
+ @Deprecated
public Field(String name, DataType dataType, boolean isHeader) {
- this(name, dataType, isHeader, null);
+ this(name, dataType);
}
/**
@@ -80,7 +88,7 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
* @param dataType The datatype of the field
*/
public Field(String name, DataType dataType) {
- this(name, dataType, true);
+ this(name, dataType, null);
}
/**
@@ -89,7 +97,7 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
*/
// TODO: Decide on one copy/clone idiom and do it for this and all it is calling
public Field(String name, Field field) {
- this(name, field.dataType, field.isHeader, null);
+ this(name, field.dataType, null);
}
public int compareTo(Object o) {
@@ -196,14 +204,12 @@ public class Field extends FieldBase implements FieldSet, Comparable, Serializab
/** @deprecated this has no longer any semantic meaning as this is no longer an aspect with a field */
@Deprecated // TODO: Remove on Vespa 8
public boolean isHeader() {
- return isHeader;
+ return true;
}
/** @deprecated this has no longer any semantic meaning as this is no longer an aspect with a field */
@Deprecated // TODO: Remove on Vespa 8
- public void setHeader(boolean header) {
- this.isHeader = header;
- }
+ public void setHeader(boolean header) { }
/** Two fields are equal if they have the same name and the same data type */
@Override
diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java
index c2111edfd10..630f204c44d 100644
--- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java
+++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java
@@ -82,7 +82,7 @@ public class VespaDocumentSerializer6 extends BufferSerializer implements Docume
}
public void write(Document doc) {
- write(new Field(doc.getDataType().getName(), 0, doc.getDataType(), true), doc);
+ write(new Field(doc.getDataType().getName(), 0, doc.getDataType()), doc);
}
@SuppressWarnings("deprecation")
diff --git a/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java b/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java
index 0d6b0cae926..5db98f26141 100644
--- a/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java
+++ b/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java
@@ -320,7 +320,7 @@ public final class XmlDocumentWriter implements DocumentWriter {
buffer = new XmlStream();
buffer.setIndent(indent);
optionalWrapperMarker.clear();
- write(new Field(document.getDataType().getName(), 0, document.getDataType(), true), document);
+ write(new Field(document.getDataType().getName(), 0, document.getDataType()), document);
}
@Override
diff --git a/document/src/test/java/com/yahoo/document/DocumentCalculatorTestCase.java b/document/src/test/java/com/yahoo/document/DocumentCalculatorTestCase.java
index fb2d478d38b..36cc18ebd6b 100755
--- a/document/src/test/java/com/yahoo/document/DocumentCalculatorTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentCalculatorTestCase.java
@@ -27,11 +27,11 @@ public class DocumentCalculatorTestCase {
docMan = new DocumentTypeManager();
testDocType = new DocumentType("testdoc");
- testDocType.addHeaderField("byteattr", DataType.BYTE);
- testDocType.addHeaderField("intattr", DataType.INT);
- testDocType.addHeaderField("longattr", DataType.LONG);
- testDocType.addHeaderField("doubleattr", DataType.DOUBLE);
- testDocType.addHeaderField("missingattr", DataType.INT);
+ testDocType.addField("byteattr", DataType.BYTE);
+ testDocType.addField("intattr", DataType.INT);
+ testDocType.addField("longattr", DataType.LONG);
+ testDocType.addField("doubleattr", DataType.DOUBLE);
+ testDocType.addField("missingattr", DataType.INT);
docMan.registerDocumentType(testDocType);
doc = new Document(testDocType, new DocumentId("id:ns:testdoc::testdoc:http://www.ntnu.no/"));
diff --git a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
index 08abd6e6a2d..fea3b265b6d 100644
--- a/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentIdTestCase.java
@@ -34,11 +34,11 @@ public class DocumentIdTestCase {
public void setUp() {
DocumentType testDocType = new DocumentType("testdoc");
- testDocType.addHeaderField("intattr", DataType.INT);
+ testDocType.addField("intattr", DataType.INT);
testDocType.addField("rawattr", DataType.RAW);
testDocType.addField("floatattr", DataType.FLOAT);
- testDocType.addHeaderField("stringattr", DataType.STRING);
- testDocType.addHeaderField("Minattr", DataType.INT);
+ testDocType.addField("stringattr", DataType.STRING);
+ testDocType.addField("Minattr", DataType.INT);
manager.registerDocumentType(testDocType);
}
diff --git a/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java b/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java
index bc1224ca8ea..fa47c80c6fb 100644
--- a/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java
@@ -62,25 +62,25 @@ public class DocumentSerializationTestCase extends AbstractTypesTest {
public void testSerializationAllVersions() throws IOException {
DocumentType docInDocType = new DocumentType("docindoc");
- docInDocType.addField(new Field("stringindocfield", DataType.STRING, false));
+ docInDocType.addField(new Field("stringindocfield", DataType.STRING));
DocumentType docType = new DocumentType("serializetest");
- docType.addField(new Field("floatfield", DataType.FLOAT, true));
- docType.addField(new Field("stringfield", DataType.STRING, true));
- docType.addField(new Field("longfield", DataType.LONG, true));
- docType.addField(new Field("urifield", DataType.URI, true));
- docType.addField(new Field("intfield", DataType.INT, false));
- docType.addField(new Field("rawfield", DataType.RAW, false));
- docType.addField(new Field("doublefield", DataType.DOUBLE, false));
- docType.addField(new Field("bytefield", DataType.BYTE, false));
- docType.addField(new Field("boolfield", DataType.BOOL, false));
+ docType.addField(new Field("floatfield", DataType.FLOAT));
+ docType.addField(new Field("stringfield", DataType.STRING));
+ docType.addField(new Field("longfield", DataType.LONG));
+ docType.addField(new Field("urifield", DataType.URI));
+ docType.addField(new Field("intfield", DataType.INT));
+ docType.addField(new Field("rawfield", DataType.RAW));
+ docType.addField(new Field("doublefield", DataType.DOUBLE));
+ docType.addField(new Field("bytefield", DataType.BYTE));
+ docType.addField(new Field("boolfield", DataType.BOOL));
DataType arrayOfFloatDataType = new ArrayDataType(DataType.FLOAT);
- docType.addField(new Field("arrayoffloatfield", arrayOfFloatDataType, false));
+ docType.addField(new Field("arrayoffloatfield", arrayOfFloatDataType));
DataType arrayOfArrayOfFloatDataType = new ArrayDataType(arrayOfFloatDataType);
- docType.addField(new Field("arrayofarrayoffloatfield", arrayOfArrayOfFloatDataType, false));
- docType.addField(new Field("docfield", DataType.DOCUMENT, false));
+ docType.addField(new Field("arrayofarrayoffloatfield", arrayOfArrayOfFloatDataType));
+ docType.addField(new Field("docfield", DataType.DOCUMENT));
DataType weightedSetDataType = DataType.getWeightedSet(DataType.STRING, false, false);
- docType.addField(new Field("wsfield", weightedSetDataType, false));
+ docType.addField(new Field("wsfield", weightedSetDataType));
DocumentTypeManager docMan = new DocumentTypeManager();
docMan.register(docInDocType);
diff --git a/document/src/test/java/com/yahoo/document/DocumentTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTestCase.java
index 141a74a24fe..dcd4622b3f4 100644
--- a/document/src/test/java/com/yahoo/document/DocumentTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentTestCase.java
@@ -107,26 +107,26 @@ public class DocumentTestCase extends DocumentTestCaseBase {
docMan = new DocumentTypeManager();
DocumentType docInDocType = new DocumentType("docindoc");
- docInDocType.addField(new Field("tull", 2, docMan.getDataType(2), true));
+ docInDocType.addField(new Field("tull", 2, docMan.getDataType(2)));
docMan.registerDocumentType(docInDocType);
DocumentType sertestDocType = new DocumentType("sertest");
- sertestDocType.addField(new Field("mailid", 2, docMan.getDataType(2), true));
- sertestDocType.addField(new Field("date", 3, docMan.getDataType(0), true));
- sertestDocType.addField(new Field("from", 4, docMan.getDataType(2), true));
- sertestDocType.addField(new Field("to", 6, docMan.getDataType(2), true));
- sertestDocType.addField(new Field("subject", 9, docMan.getDataType(2), true));
- sertestDocType.addField(new Field("body", 10, docMan.getDataType(2), false));
- sertestDocType.addField(new Field("attachmentcount", 11, docMan.getDataType(0), false));
- sertestDocType.addField(new Field("attachments", 1081629685, DataType.getArray(docMan.getDataType(2)), false));
- sertestDocType.addField(new Field("rawfield", 879, DataType.RAW, false));
- sertestDocType.addField(new Field("weightedfield", 880, DataType.getWeightedSet(DataType.STRING), false));
- sertestDocType.addField(new Field("weightedfieldCreate", 881, DataType.getWeightedSet(DataType.STRING, true, false), false));
- sertestDocType.addField(new Field("docindoc", 882, docInDocType, false));
- sertestDocType.addField(new Field("mapfield", 883, new MapDataType(DataType.STRING, DataType.STRING), false));
- sertestDocType.addField(new Field("myposfield", 884, PositionDataType.INSTANCE, false));
- sertestDocType.addField(new Field("myboolfield", 885, DataType.BOOL, false));
+ sertestDocType.addField(new Field("mailid", 2, docMan.getDataType(2)));
+ sertestDocType.addField(new Field("date", 3, docMan.getDataType(0)));
+ sertestDocType.addField(new Field("from", 4, docMan.getDataType(2)));
+ sertestDocType.addField(new Field("to", 6, docMan.getDataType(2)));
+ sertestDocType.addField(new Field("subject", 9, docMan.getDataType(2)));
+ sertestDocType.addField(new Field("body", 10, docMan.getDataType(2)));
+ sertestDocType.addField(new Field("attachmentcount", 11, docMan.getDataType(0)));
+ sertestDocType.addField(new Field("attachments", 1081629685, DataType.getArray(docMan.getDataType(2))));
+ sertestDocType.addField(new Field("rawfield", 879, DataType.RAW));
+ sertestDocType.addField(new Field("weightedfield", 880, DataType.getWeightedSet(DataType.STRING)));
+ sertestDocType.addField(new Field("weightedfieldCreate", 881, DataType.getWeightedSet(DataType.STRING, true, false)));
+ sertestDocType.addField(new Field("docindoc", 882, docInDocType));
+ sertestDocType.addField(new Field("mapfield", 883, new MapDataType(DataType.STRING, DataType.STRING)));
+ sertestDocType.addField(new Field("myposfield", 884, PositionDataType.INSTANCE));
+ sertestDocType.addField(new Field("myboolfield", 885, DataType.BOOL));
docMan.registerDocumentType(sertestDocType);
}
@@ -880,13 +880,13 @@ public class DocumentTestCase extends DocumentTestCaseBase {
public void testInheritance() {
// Create types that inherit each other.. And test that it works..
DocumentType parentType = new DocumentType("parent");
- parentType.addField(new Field("parentbodyint", DataType.INT, false));
- parentType.addField(new Field("parentheaderint", DataType.INT, true));
- parentType.addField(new Field("overwritten", DataType.INT, true));
+ parentType.addField(new Field("parentbodyint", DataType.INT));
+ parentType.addField(new Field("parentheaderint", DataType.INT));
+ parentType.addField(new Field("overwritten", DataType.INT));
DocumentType childType = new DocumentType("child");
- childType.addField(new Field("childbodyint", DataType.INT, false));
- childType.addField(new Field("childheaderint", DataType.INT, true));
- childType.addField(new Field("overwritten", DataType.INT, true));
+ childType.addField(new Field("childbodyint", DataType.INT));
+ childType.addField(new Field("childheaderint", DataType.INT));
+ childType.addField(new Field("overwritten", DataType.INT));
childType.inherit(parentType);
DocumentTypeManager manager = new DocumentTypeManager();
@@ -914,13 +914,13 @@ public class DocumentTestCase extends DocumentTestCaseBase {
@Test
public void testInheritanceTypeMismatch() {
DocumentType parentType = new DocumentType("parent");
- parentType.addField(new Field("parentbodyint", DataType.INT, false));
- parentType.addField(new Field("parentheaderint", DataType.INT, true));
- parentType.addField(new Field("overwritten", DataType.STRING, true));
+ parentType.addField(new Field("parentbodyint", DataType.INT));
+ parentType.addField(new Field("parentheaderint", DataType.INT));
+ parentType.addField(new Field("overwritten", DataType.STRING));
DocumentType childType = new DocumentType("child");
- childType.addField(new Field("childbodyint", DataType.INT, false));
- childType.addField(new Field("childheaderint", DataType.INT, true));
- childType.addField(new Field("overwritten", DataType.INT, true));
+ childType.addField(new Field("childbodyint", DataType.INT));
+ childType.addField(new Field("childheaderint", DataType.INT));
+ childType.addField(new Field("overwritten", DataType.INT));
try {
childType.inherit(parentType);
fail("Inheritance with conflicting types worked.");
@@ -934,7 +934,7 @@ public class DocumentTestCase extends DocumentTestCaseBase {
public void testFieldValueImplementations() {
docMan = new DocumentTypeManager();
DocumentType docType = new DocumentType("impl");
- docType.addField(new Field("something", DataType.getArray(DataType.STRING), false));
+ docType.addField(new Field("something", DataType.getArray(DataType.STRING)));
docMan.register(docType);
//just checks that isAssignableFrom() in Document.setFieldValue() goes the right way
@@ -1276,9 +1276,9 @@ public class DocumentTestCase extends DocumentTestCaseBase {
public void testDocumentComparisonDoesNotCorruptStateBug6394548() {
DocumentTypeManager docMan = new DocumentTypeManager();
DocumentType docType = new DocumentType("bug2354045");
- docType.addField(new Field("string", 2, DataType.STRING, true));
- docType.addField(new Field("int", 1, DataType.INT, true));
- docType.addField(new Field("float", 0, DataType.FLOAT, true));
+ docType.addField(new Field("string", 2, DataType.STRING));
+ docType.addField(new Field("int", 1, DataType.INT));
+ docType.addField(new Field("float", 0, DataType.FLOAT));
docMan.register(docType);
Document doc1 = new Document(docType, new DocumentId("id:ns:bug2354045::bug6394548"));
diff --git a/document/src/test/java/com/yahoo/document/DocumentTestCaseBase.java b/document/src/test/java/com/yahoo/document/DocumentTestCaseBase.java
index 68fe1c8cc57..6f95f77f08c 100644
--- a/document/src/test/java/com/yahoo/document/DocumentTestCaseBase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentTestCaseBase.java
@@ -23,14 +23,14 @@ public class DocumentTestCaseBase {
docMan = new DocumentTypeManager();
testDocType = new DocumentType("testdoc");
- testDocType.addHeaderField("byteattr", DataType.BYTE);
- testDocType.addHeaderField("intattr", DataType.INT);
+ testDocType.addField("byteattr", DataType.BYTE);
+ testDocType.addField("intattr", DataType.INT);
testDocType.addField("rawattr", DataType.RAW);
testDocType.addField("floatattr", DataType.FLOAT);
- testDocType.addHeaderField("stringattr", DataType.STRING);
- testDocType.addHeaderField("Minattr", DataType.INT);
- testDocType.addHeaderField("Minattr2", DataType.INT);
- testDocType.addHeaderField("primitive1", DataType.INT);
+ testDocType.addField("stringattr", DataType.STRING);
+ testDocType.addField("Minattr", DataType.INT);
+ testDocType.addField("Minattr2", DataType.INT);
+ testDocType.addField("primitive1", DataType.INT);
StructDataType sdt = new StructDataType("struct1");
sdt.addField(new Field("primitive1", DataType.INT));
diff --git a/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java
index 65c217e09e1..cac77dba434 100644
--- a/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentTypeManagerTestCase.java
@@ -30,7 +30,7 @@ public class DocumentTypeManagerTestCase {
DocumentType newDocType = new DocumentType("testdoc");
newDocType.addField("Fjomp", DataType.INT);
- newDocType.addHeaderField("Fjols", DataType.STRING);
+ newDocType.addField("Fjols", DataType.STRING);
manager.registerDocumentType(newDocType);
@@ -40,7 +40,6 @@ public class DocumentTypeManagerTestCase {
assertEquals("Fjomp", fetched4.getName());
assertEquals(fetched4.getDataType(), DataType.INT);
- assertEquals(fetched4.isHeader(), false);
}
@Test
@@ -64,8 +63,8 @@ public class DocumentTypeManagerTestCase {
StructDataType struct = new StructDataType("mystruct");
DataType wset1 = DataType.getWeightedSet(DataType.getArray(DataType.INT));
DataType wset2 = DataType.getWeightedSet(DataType.getArray(DataType.TAG));
- struct.addField(new Field("foo", wset1, true));
- struct.addField(new Field("bar", wset2, false));
+ struct.addField(new Field("foo", wset1));
+ struct.addField(new Field("bar", wset2));
DataType array = DataType.getArray(struct);
DocumentType docType = new DocumentType("mydoc");
docType.addField("hmm", array);
@@ -148,7 +147,6 @@ public class DocumentTypeManagerTestCase {
assertTrue(type.hasField("foobarfield1"));
Field foobarfield0 = type.getField("foobarfield0");
- assertTrue(!foobarfield0.isHeader());
assertTrue(foobarfield0.getDataType().getCode() == 2);
Field foobarfield1 = type.getField("foobarfield1");
@@ -190,7 +188,6 @@ public class DocumentTypeManagerTestCase {
assertTrue(type.hasField("arrayarrayfloat"));
Field arrayfloat = type.getField("arrayfloat");
- assertTrue(!arrayfloat.isHeader());
ArrayDataType dataType = (ArrayDataType) arrayfloat.getDataType();
assertTrue(dataType.getCode() == 99);
assertTrue(dataType.getValueClass().equals(Array.class));
@@ -200,7 +197,6 @@ public class DocumentTypeManagerTestCase {
Field arrayarrayfloat = type.getField("arrayarrayfloat");
ArrayDataType subType = (ArrayDataType) arrayarrayfloat.getDataType();
- assertTrue(!arrayarrayfloat.isHeader());
assertTrue(subType.getCode() == 4003);
assertTrue(subType.getValueClass().equals(Array.class));
assertTrue(subType.getNestedType().getCode() == 99);
@@ -218,14 +214,14 @@ public class DocumentTypeManagerTestCase {
DocumentType customtypes = manager.getDocumentType(new DataTypeName("customtypes"));
assertNull(banana.getField("newfield"));
- assertEquals(new Field("arrayfloat", 9489, new ArrayDataType(DataType.FLOAT, 99), false), customtypes.getField("arrayfloat"));
+ assertEquals(new Field("arrayfloat", 9489, new ArrayDataType(DataType.FLOAT, 99)), customtypes.getField("arrayfloat"));
DocumentTypeManagerConfigurer.configure(manager, "file:src/test/document/documentmanager.updated.cfg");
banana = manager.getDocumentType(new DataTypeName("banana"));
customtypes = manager.getDocumentType(new DataTypeName("customtypes"));
- assertEquals(new Field("newfield", 12345, DataType.STRING, true), banana.getField("newfield"));
+ assertEquals(new Field("newfield", 12345, DataType.STRING), banana.getField("newfield"));
assertNull(customtypes.getField("arrayfloat"));
}
diff --git a/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java b/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java
index c381a093b4e..9f05a4441b2 100644
--- a/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java
+++ b/document/src/test/java/com/yahoo/document/DocumentUpdateTestCase.java
@@ -799,8 +799,8 @@ public class DocumentUpdateTestCase {
public TensorUpdateSerializeFixture() {
docMan = new DocumentTypeManager();
docType = new DocumentType("test");
- docType.addHeaderField("sparse_tensor", new TensorDataType(TensorType.fromSpec("tensor(x{})")));
- docType.addHeaderField("dense_tensor", new TensorDataType(TensorType.fromSpec("tensor(x[4])")));
+ docType.addField("sparse_tensor", new TensorDataType(TensorType.fromSpec("tensor(x{})")));
+ docType.addField("dense_tensor", new TensorDataType(TensorType.fromSpec("tensor(x[4])")));
docMan.registerDocumentType(docType);
}
diff --git a/document/src/test/java/com/yahoo/document/IncompatibleFieldTypesTest.java b/document/src/test/java/com/yahoo/document/IncompatibleFieldTypesTest.java
index 286f7d72b24..7cf0adf6ed1 100644
--- a/document/src/test/java/com/yahoo/document/IncompatibleFieldTypesTest.java
+++ b/document/src/test/java/com/yahoo/document/IncompatibleFieldTypesTest.java
@@ -17,9 +17,9 @@ public class IncompatibleFieldTypesTest {
public void setUp() {
arrayOfStrings = new ArrayDataType(DataType.STRING);
struct = new StructDataType("fancypants");
- struct.addField(new Field("stringarray", arrayOfStrings, false));
+ struct.addField(new Field("stringarray", arrayOfStrings));
DataType weightedSetOfStrings = DataType.getWeightedSet(DataType.STRING, false, false);
- struct.addField(new Field("stringws", weightedSetOfStrings, false));
+ struct.addField(new Field("stringws", weightedSetOfStrings));
root = struct.createFieldValue();
root.setFieldValue("stringarray", arrayOfStrings.createFieldValue());
diff --git a/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java b/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java
index 4197938f0ee..295cfa37e89 100644
--- a/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java
+++ b/document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java
@@ -20,14 +20,14 @@ public class StructTestCase {
@Test
public void testBasicStuff() throws Exception {
StructDataType type = new StructDataType("teststr");
- type.addField(new Field("int", 0, DataType.INT, true));
- type.addField(new Field("flt", 1, DataType.FLOAT, true));
- type.addField(new Field("str", 2, DataType.STRING, true));
- type.addField(new Field("raw", 3, DataType.RAW, true));
- type.addField(new Field("lng", 4, DataType.LONG, true));
- type.addField(new Field("dbl", 5, DataType.DOUBLE, true));
- type.addField(new Field("uri", 6, DataType.URI, true));
- type.addField(new Field("byt", 8, DataType.BYTE, true));
+ type.addField(new Field("int", 0, DataType.INT));
+ type.addField(new Field("flt", 1, DataType.FLOAT));
+ type.addField(new Field("str", 2, DataType.STRING));
+ type.addField(new Field("raw", 3, DataType.RAW));
+ type.addField(new Field("lng", 4, DataType.LONG));
+ type.addField(new Field("dbl", 5, DataType.DOUBLE));
+ type.addField(new Field("uri", 6, DataType.URI));
+ type.addField(new Field("byt", 8, DataType.BYTE));
Struct struct = new Struct(type);
{
@@ -236,7 +236,7 @@ public class StructTestCase {
@Test
public void testSetUnknownType() {
StructDataType type = new StructDataType("teststr");
- type.addField(new Field("int", 0, DataType.INT, true));
+ type.addField(new Field("int", 0, DataType.INT));
Struct struct = new Struct(type);
try {
@@ -251,9 +251,9 @@ public class StructTestCase {
public void testCompareToDoesNotMutateStateBug6394548() {
StructDataType type = new StructDataType("test");
// NOTE: non-increasing ID order!
- type.addField(new Field("int", 2, DataType.INT, true));
- type.addField(new Field("flt", 1, DataType.FLOAT, true));
- type.addField(new Field("str", 0, DataType.STRING, true));
+ type.addField(new Field("int", 2, DataType.INT));
+ type.addField(new Field("flt", 1, DataType.FLOAT));
+ type.addField(new Field("str", 0, DataType.STRING));
Struct a = new Struct(type);
a.setFieldValue("int", new IntegerFieldValue(123));
diff --git a/document/src/test/java/com/yahoo/document/fieldset/FieldSetTestCase.java b/document/src/test/java/com/yahoo/document/fieldset/FieldSetTestCase.java
index c11c58ff729..404b069277b 100644
--- a/document/src/test/java/com/yahoo/document/fieldset/FieldSetTestCase.java
+++ b/document/src/test/java/com/yahoo/document/fieldset/FieldSetTestCase.java
@@ -98,13 +98,13 @@ public class FieldSetTestCase extends DocumentTestCaseBase {
assertFalse(new DocIdOnly().contains(headerField));
assertTrue(new HeaderFields().contains(headerField));
- assertFalse(new HeaderFields().contains(bodyField));
+ assertTrue(new HeaderFields().contains(bodyField));
assertTrue(new HeaderFields().contains(new DocIdOnly()));
assertTrue(new HeaderFields().contains(new NoFields()));
- assertContains("[body]", "testdoc:rawattr");
+ assertNotContains("[body]", "testdoc:rawattr");
assertContains("[header]", "testdoc:intattr");
- assertNotContains("[header]", "testdoc:rawattr");
+ assertContains("[header]", "testdoc:rawattr");
assertContains("testdoc:rawattr,intattr", "testdoc:intattr");
assertNotContains("testdoc:intattr", "testdoc:rawattr,intattr");
assertContains("testdoc:intattr,rawattr", "testdoc:rawattr,intattr");
@@ -141,10 +141,10 @@ public class FieldSetTestCase extends DocumentTestCaseBase {
Document doc = getTestDocument();
doc.removeFieldValue("rawattr");
- assertEquals("floatattr:3.56", doCopyFields(doc, "[body]"));
- assertEquals("stringattr:tjohei,intattr:50,byteattr:30,floatattr:3.56", doCopyFields(doc, "[all]"));
- assertEquals("stringattr:tjohei,intattr:50,byteattr:30", doCopyFields(doc, "[header]"));
- assertEquals("byteattr:30,floatattr:3.56", doCopyFields(doc, "testdoc:floatattr,byteattr"));
+ assertEquals("", doCopyFields(doc, "[body]"));
+ assertEquals("floatattr:3.56,stringattr:tjohei,intattr:50,byteattr:30", doCopyFields(doc, "[header]"));
+ assertEquals("floatattr:3.56,stringattr:tjohei,intattr:50,byteattr:30", doCopyFields(doc, "[all]"));
+ assertEquals("floatattr:3.56,byteattr:30", doCopyFields(doc, "testdoc:floatattr,byteattr"));
}
String doStripFields(Document source, String fieldSet) {
@@ -159,10 +159,10 @@ public class FieldSetTestCase extends DocumentTestCaseBase {
Document doc = getTestDocument();
doc.removeFieldValue("rawattr");
- assertEquals("floatattr:3.56", doStripFields(doc, "[body]"));
- assertEquals("stringattr:tjohei,intattr:50,byteattr:30,floatattr:3.56", doStripFields(doc, "[all]"));
- assertEquals("stringattr:tjohei,intattr:50,byteattr:30", doStripFields(doc, "[header]"));
- assertEquals("byteattr:30,floatattr:3.56", doStripFields(doc, "testdoc:floatattr,byteattr"));
+ assertEquals("", doStripFields(doc, "[body]"));
+ assertEquals("floatattr:3.56,stringattr:tjohei,intattr:50,byteattr:30", doStripFields(doc, "[header]"));
+ assertEquals("floatattr:3.56,stringattr:tjohei,intattr:50,byteattr:30", doStripFields(doc, "[all]"));
+ assertEquals("floatattr:3.56,byteattr:30", doStripFields(doc, "testdoc:floatattr,byteattr"));
}
@Test
diff --git a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
index 0ff0bd81d90..b33d81ffdea 100644
--- a/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
+++ b/document/src/test/java/com/yahoo/document/select/DocumentSelectorTestCase.java
@@ -31,15 +31,15 @@ public class DocumentSelectorTestCase {
@Before
public void setUp() {
DocumentType type = new DocumentType("test");
- type.addHeaderField("hint", DataType.INT);
- type.addHeaderField("hfloat", DataType.FLOAT);
- type.addHeaderField("hstring", DataType.STRING);
+ type.addField("hint", DataType.INT);
+ type.addField("hfloat", DataType.FLOAT);
+ type.addField("hstring", DataType.STRING);
type.addField("content", DataType.STRING);
StructDataType mystruct = new StructDataType("mystruct");
- mystruct.addField(new Field("key", DataType.INT, false));
- mystruct.addField(new Field("value", DataType.STRING, false));
- type.addHeaderField("mystruct", mystruct);
+ mystruct.addField(new Field("key", DataType.INT));
+ mystruct.addField(new Field("value", DataType.STRING));
+ type.addField("mystruct", mystruct);
ArrayDataType structarray = new ArrayDataType(mystruct);
type.addField("structarray", structarray);