diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2020-06-18 07:24:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 07:24:48 +0200 |
commit | b0bc165e64dbcbb9e8e357f92f46f8bf1c84dbb8 (patch) | |
tree | 77970c6b1e66c1eb4f69365f12e1374d6874b433 /document | |
parent | 193c96ee9dd092d3f6c483a9d65f9a7dd8efa575 (diff) | |
parent | 78d1292783fd65b431462e9ab969a570c5f200fb (diff) |
Merge pull request #13601 from vespa-engine/balder/remove-leftovers-from-head-body-period-and-depcrecate-methods-levaing-on-vespa-8
- Removing body struct from our own usage.
Diffstat (limited to 'document')
16 files changed, 104 insertions, 232 deletions
diff --git a/document/abi-spec.json b/document/abi-spec.json index 3764015b917..7a0637db1aa 100644 --- a/document/abi-spec.json +++ b/document/abi-spec.json @@ -426,7 +426,9 @@ ], "methods": [ "public void <init>(java.lang.String)", + "public void <init>(java.lang.String, com.yahoo.document.StructDataType)", "public void <init>(java.lang.String, com.yahoo.document.StructDataType, com.yahoo.document.StructDataType)", + "public void <init>(java.lang.String, com.yahoo.document.StructDataType, java.util.Set)", "public void <init>(java.lang.String, com.yahoo.document.StructDataType, com.yahoo.document.StructDataType, java.util.Set)", "public void <init>(java.lang.String, java.util.Set)", "public com.yahoo.document.DocumentType clone()", @@ -435,7 +437,6 @@ "public boolean isValueCompatible(com.yahoo.document.datatypes.FieldValue)", "public com.yahoo.document.StructDataType contentStruct()", "public com.yahoo.document.StructDataType getHeaderType()", - "public com.yahoo.document.StructDataType getBodyType()", "protected void register(com.yahoo.document.DocumentTypeManager, java.util.List)", "public boolean isA(java.lang.String)", "public void addField(com.yahoo.document.Field)", diff --git a/document/src/main/java/com/yahoo/document/Document.java b/document/src/main/java/com/yahoo/document/Document.java index 375d8d962a5..568fe9265d5 100644 --- a/document/src/main/java/com/yahoo/document/Document.java +++ b/document/src/main/java/com/yahoo/document/Document.java @@ -44,7 +44,6 @@ public class Document extends StructuredFieldValue { public static final short SERIALIZED_VERSION = 8; private DocumentId docId; private Struct header; - private Struct body; private Long lastModified = null; /** @@ -75,7 +74,6 @@ public class Document extends StructuredFieldValue { public Document(Document doc) { this(doc.getDataType(), doc.getId()); header = doc.header; - body = doc.body; lastModified = doc.lastModified; } @@ -104,7 +102,7 @@ public class Document extends StructuredFieldValue { /** @deprecated do not use: Use getField(), getFieldValue() or iterator() instead */ @Deprecated // TODO: Remove on Vespa 8 - public Struct getBody() { return body; } + public Struct getBody() { return null; } @Override public void assign(Object o) { @@ -116,14 +114,11 @@ public class Document extends StructuredFieldValue { Document doc = (Document) super.clone(); doc.docId = docId.clone(); doc.header = header.clone(); - doc.body = body.clone(); return doc; } - @SuppressWarnings("deprecation") private void setNewType(DocumentType type) { header = type.contentStruct().createFieldValue(); - body = type.getBodyType().createFieldValue(); } public void setDataType(DataType type) { @@ -178,9 +173,6 @@ public class Document extends StructuredFieldValue { public Field getField(String fieldName) { Field field = header.getField(fieldName); if (field == null) { - field = body.getField(fieldName); - } - if (field == null) { for(DocumentType parent : getDataType().getInheritedTypes()) { field = parent.getField(fieldName); if (field != null) { @@ -193,68 +185,27 @@ public class Document extends StructuredFieldValue { @Override public FieldValue getFieldValue(Field field) { - FieldValue fv = header.getFieldValue(field); - if (fv == null) { - fv = body.getFieldValue(field); - } - return fv; + return header.getFieldValue(field); } @Override - @SuppressWarnings("deprecation") protected void doSetFieldValue(Field field, FieldValue value) { - if (field.isHeader()) { - header.setFieldValue(field, value); - } else { - body.setFieldValue(field, value); - } + header.setFieldValue(field, value); } @Override public FieldValue removeFieldValue(Field field) { - FieldValue removed = header.removeFieldValue(field); - if (removed == null) { - removed = body.removeFieldValue(field); - } - return removed; + return header.removeFieldValue(field); } @Override public void clear() { header.clear(); - body.clear(); } @Override public Iterator<Map.Entry<Field, FieldValue>> iterator() { - return new Iterator<>() { - - private Iterator<Map.Entry<Field, FieldValue>> headerIt = header.iterator(); - private Iterator<Map.Entry<Field, FieldValue>> bodyIt = body.iterator(); - - public boolean hasNext() { - if (headerIt != null) { - if (headerIt.hasNext()) { - return true; - } else { - headerIt = null; - } - } - return bodyIt.hasNext(); - } - - public Map.Entry<Field, FieldValue> next() { - return (headerIt == null ? bodyIt.next() : headerIt.next()); - } - - public void remove() { - if (headerIt == null) { - bodyIt.remove(); - } else { - headerIt.remove(); - } - } - }; + return header.iterator(); } public String toString() { @@ -302,7 +253,7 @@ public class Document extends StructuredFieldValue { if (!(o instanceof Document)) return false; Document other = (Document) o; return (super.equals(o) && docId.equals(other.docId) && - header.equals(other.header) && body.equals(other.body)); + header.equals(other.header)); } @Override @@ -347,7 +298,7 @@ public class Document extends StructuredFieldValue { @Override public int getFieldCount() { - return header.getFieldCount() + body.getFieldCount(); + return header.getFieldCount(); } public void serialize(DocumentWriter writer) { @@ -393,7 +344,6 @@ public class Document extends StructuredFieldValue { return comp; } - comp = body.compareTo(otherValue.body); return comp; } diff --git a/document/src/main/java/com/yahoo/document/DocumentType.java b/document/src/main/java/com/yahoo/document/DocumentType.java index 23559878fbb..f73fd634e0e 100755 --- a/document/src/main/java/com/yahoo/document/DocumentType.java +++ b/document/src/main/java/com/yahoo/document/DocumentType.java @@ -38,7 +38,6 @@ public class DocumentType extends StructuredDataType { public static final String DOCUMENT = "[document]"; public static final int classId = registerClass(Ids.document + 58, DocumentType.class); private StructDataType headerType; - private StructDataType bodyType; private List<DocumentType> inherits = new ArrayList<>(1); private Map<String, Set<Field>> fieldSets = new HashMap<>(); private final Set<String> importedFieldNames; @@ -52,7 +51,7 @@ public class DocumentType extends StructuredDataType { * @param name The name of the new document type */ public DocumentType(String name) { - this(name, createHeaderStructType(name), createBodyStructType(name)); + this(name, createHeaderStructType(name)); } /** @@ -62,37 +61,46 @@ public class DocumentType extends StructuredDataType { * * @param name The name of the new document type * @param headerType The type of the header struct - * @param bodyType The type of the body struct */ + public DocumentType(String name, StructDataType headerType) { + this(name, headerType, Collections.emptySet()); + } + + /** + * @deprecated //TODO Will be removed on Vespa 8 + */ + @Deprecated public DocumentType(String name, StructDataType headerType, StructDataType bodyType) { - this(name, headerType, bodyType, Collections.emptySet()); + this(name, headerType, Collections.emptySet()); } - public DocumentType(String name, StructDataType headerType, - StructDataType bodyType, Set<String> importedFieldNames) { + public DocumentType(String name, StructDataType headerType, Set<String> importedFieldNames) { super(name); this.headerType = headerType; - this.bodyType = bodyType; this.importedFieldNames = Collections.unmodifiableSet(importedFieldNames); } + /** + * @deprecated //TODO Will be removed on Vespa 8 + */ + @Deprecated + public DocumentType(String name, StructDataType headerType, + StructDataType bodyType, Set<String> importedFieldNames) { + this(name, headerType, importedFieldNames); + } + public DocumentType(String name, Set<String> importedFieldNames) { - this(name, createHeaderStructType(name), createBodyStructType(name), importedFieldNames); + this(name, createHeaderStructType(name), importedFieldNames); } private static StructDataType createHeaderStructType(String name) { return new StructDataType(name + ".header"); } - private static StructDataType createBodyStructType(String name) { - return new StructDataType(name + ".body"); - } - @Override public DocumentType clone() { DocumentType type = (DocumentType) super.clone(); type.headerType = headerType.clone(); - type.bodyType = bodyType.clone(); type.inherits = new ArrayList<>(inherits.size()); type.inherits.addAll(inherits); return type; @@ -136,14 +144,7 @@ public class DocumentType extends StructuredDataType { return contentStruct(); } - @Deprecated // TODO: Remove on Vespa 8 - /** @deprecated use contentStruct instead */ - public StructDataType getBodyType() { - return bodyType; - } - @Override - @SuppressWarnings("deprecation") protected void register(DocumentTypeManager manager, List<DataType> seenTypes) { seenTypes.add(this); for (DocumentType type : getInheritedTypes()) { @@ -153,23 +154,17 @@ public class DocumentType extends StructuredDataType { } // Get parent fields into fields specified in this type StructDataType header = headerType.clone(); - StructDataType body = bodyType.clone(); header.clearFields(); - body.clearFields(); for (Field field : getAllUniqueFields()) { - (field.isHeader() ? header : body).addField(field); + header.addField(field); } headerType.assign(header); - bodyType.assign(body); if (!seenTypes.contains(headerType)) { headerType.register(manager, seenTypes); } - if (!seenTypes.contains(bodyType)) { - bodyType.register(manager, seenTypes); - } manager.registerSingleType(this); } @@ -194,7 +189,6 @@ public class DocumentType extends StructuredDataType { * * @param field the field to add */ - @SuppressWarnings("deprecation") public void addField(Field field) { if (isRegistered()) { throw new IllegalStateException("You cannot add fields to a document type that is already registered."); @@ -227,7 +221,7 @@ public class DocumentType extends StructuredDataType { } /** - * Adds a new body field to this document type and returns the new field object + * Adds a new field to this document type and returns the new field object * * @param name The name of the field to add * @param type The datatype of the field to add @@ -346,9 +340,6 @@ public class DocumentType extends StructuredDataType { */ public Field getField(String name) { Field field = headerType.getField(name); - if (field == null) { - field = bodyType.getField(name); - } if (field == null && !isRegistered()) { for (DocumentType inheritedType : inherits) { field = inheritedType.getField(name); @@ -361,9 +352,6 @@ public class DocumentType extends StructuredDataType { @Override public Field getField(int id) { Field field = headerType.getField(id); - if (field == null) { - field = bodyType.getField(id); - } if (field == null && !isRegistered()) { for (DocumentType inheritedType : inherits) { field = inheritedType.getField(id); @@ -384,7 +372,7 @@ public class DocumentType extends StructuredDataType { } public int getFieldCount() { - return headerType.getFieldCount() + bodyType.getFieldCount(); + return headerType.getFieldCount(); } public Set<String> getImportedFieldNames() { @@ -407,9 +395,6 @@ public class DocumentType extends StructuredDataType { } Field field = headerType.removeField(name); if (field == null) { - field = bodyType.removeField(name); - } - if (field == null) { for (DocumentType inheritedType : inherits) { field = inheritedType.removeField(name); if (field != null) break; @@ -433,7 +418,6 @@ public class DocumentType extends StructuredDataType { } collection.addAll(headerType.getFields()); - collection.addAll(bodyType.getFields()); return ImmutableList.copyOf(collection); } @@ -483,39 +467,14 @@ public class DocumentType extends StructuredDataType { * @return An iterator for iterating the fields in this documenttype. */ public Iterator<Field> fieldIteratorThisTypeOnly() { - return new Iterator<>() { - Iterator<Field> headerIt = headerType.getFields().iterator(); - Iterator<Field> bodyIt = bodyType.getFields().iterator(); - - public boolean hasNext() { - if (headerIt != null) { - if (headerIt.hasNext()) return true; - headerIt = null; - } - return bodyIt.hasNext(); - } - - public Field next() { - return (headerIt != null ? headerIt.next() : bodyIt.next()); - } - - - public void remove() { - if (headerIt != null) { - headerIt.remove(); - } else { - bodyIt.remove(); - } - } - }; + return headerType.getFields().iterator(); } public boolean equals(Object o) { if (!(o instanceof DocumentType)) return false; DocumentType other = (DocumentType) o; // Ignore whether one of them have added inheritance to super Document.0 type - if (super.equals(o) && headerType.equals(other.headerType) && - bodyType.equals(other.bodyType)) { + if (super.equals(o) && headerType.equals(other.headerType)) { if ((inherits.size() > 1 || other.inherits.size() > 1) || (inherits.size() == 1 && other.inherits.size() == 1)) { return inherits.equals(other.inherits); @@ -527,7 +486,7 @@ public class DocumentType extends StructuredDataType { } public int hashCode() { - return super.hashCode() + headerType.hashCode() + bodyType.hashCode() + inherits.hashCode(); + return super.hashCode() + headerType.hashCode() + inherits.hashCode(); } @Override @@ -543,7 +502,6 @@ public class DocumentType extends StructuredDataType { public void visitMembers(ObjectVisitor visitor) { super.visitMembers(visitor); visitor.visit("headertype", headerType); - visitor.visit("bodytype", bodyType); visitor.visit("inherits", inherits); } } diff --git a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java index 1d81d9e6e78..c802d2307c0 100644 --- a/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java +++ b/document/src/main/java/com/yahoo/document/DocumentTypeManagerConfigurer.java @@ -142,14 +142,10 @@ public class DocumentTypeManagerConfigurer implements ConfigSubscriber.SingleSub @SuppressWarnings("deprecation") private static void registerDocumentType(DocumentTypeManager manager, DocumentmanagerConfig.Datatype.Documenttype doc) { StructDataType header = (StructDataType) manager.getDataType(doc.headerstruct(), ""); - StructDataType body = (StructDataType) manager.getDataType(doc.bodystruct(), ""); - for (Field field : body.getFields()) { - field.setHeader(false); - } var importedFields = doc.importedfield().stream() .map(f -> f.name()) .collect(Collectors.toUnmodifiableSet()); - DocumentType type = new DocumentType(doc.name(), header, body, importedFields); + DocumentType type = new DocumentType(doc.name(), header, importedFields); for (Object j : doc.inherits()) { DocumentmanagerConfig.Datatype.Documenttype.Inherits parent = (DocumentmanagerConfig.Datatype.Documenttype.Inherits) j; diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java index 27327daab47..cac05fb7879 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer6.java @@ -118,14 +118,12 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu doc.setId(documentId); Struct h = doc.getHeader(); - Struct b = doc.getBody(); h.clear(); - b.clear(); if ((content & 0x2) != 0) { - readHeaderBody(h, b); + readHeaderBody(h); } if ((content & 0x4) != 0) { - readHeaderBody(b, h); + readHeaderBody(h); } if (dataLength != (position() - dataPos)) { @@ -326,7 +324,7 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu buf = bigBuf; } - private void readHeaderBody(Struct primary, Struct alternate) { + private void readHeaderBody(Struct primary) { primary.setVersion(version); if (version < 8) { @@ -371,24 +369,14 @@ public class VespaDocumentDeserializer6 extends BufferSerializer implements Docu buf = GrowableByteBuffer.wrap(destination); StructDataType priType = primary.getDataType(); - StructDataType altType = alternate.getDataType(); for (int i=0; i<numberOfFields; ++i) { int posBefore = position(); - Struct s = null; Integer f_id = fieldIdsAndLengths.get(i).first; Field structField = priType.getField(f_id); if (structField != null) { - s = primary; - } else { - structField = altType.getField(f_id); - if (structField != null) { - s = alternate; - } - } - if (s != null) { FieldValue value = structField.getDataType().createFieldValue(); value.deserialize(structField, this); - s.setFieldValue(structField, value); + primary.setFieldValue(structField, value); } //jump to beginning of next field: position(posBefore + fieldIdsAndLengths.get(i).second.intValue()); 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 630f204c44d..3fca853b4d1 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer6.java @@ -96,27 +96,20 @@ public class VespaDocumentSerializer6 extends BufferSerializer implements Docume doc.getId().serialize(this); - Struct head = doc.getHeader(); - Struct body = doc.getBody(); - boolean hasHead = (head.getFieldCount() != 0); - boolean hasBody = (body.getFieldCount() != 0); + boolean hasHead = (doc.getFieldCount() != 0); byte contents = 0x01; // Indicating we have document type which we always have if (hasHead) { contents |= 0x2; // Indicate we have header } - if (hasBody) { - contents |= 0x4; // Indicate we have a body - } + buf.put(contents); doc.getDataType().serialize(this); if (hasHead) { - head.serialize(null, this); - } - if (hasBody) { - body.serialize(null, this); + doc.getHeader().serialize(null, this); } + int finalPos = buf.position(); buf.position(lenPos); buf.putInt(finalPos - lenPos - 4); // Don't include the length itself or the version 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 5db98f26141..9dc5b7c2480 100644 --- a/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java +++ b/document/src/main/java/com/yahoo/document/serialization/XmlDocumentWriter.java @@ -106,7 +106,6 @@ public final class XmlDocumentWriter implements DocumentWriter { buffer.addAttribute("lastmodifiedtime", lastModified); } write(null, value.getHeader()); - write(null, value.getBody()); buffer.endTag(); } diff --git a/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java b/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java index 85bc4d032ff..8c6444fb853 100644 --- a/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java +++ b/document/src/main/java/com/yahoo/document/serialization/XmlSerializationHelper.java @@ -55,7 +55,6 @@ public class XmlSerializationHelper { xml.addAttribute("lastmodifiedtime", lastModified); } doc.getHeader().printXml(xml); - doc.getBody().printXml(xml); } public static void printDoubleXml(DoubleFieldValue d, XmlStream xml) { diff --git a/document/src/test/document/documentmanager.cfg b/document/src/test/document/documentmanager.cfg index d77c2b17460..e4c581304ce 100644 --- a/document/src/test/document/documentmanager.cfg +++ b/document/src/test/document/documentmanager.cfg @@ -5,10 +5,13 @@ datatype[0].weightedsettype[0] datatype[0].structtype[1] datatype[0].structtype[0].name foobar.header datatype[0].structtype[0].version 9 -datatype[0].structtype[0].field[1] +datatype[0].structtype[0].field[2] datatype[0].structtype[0].field[0].name foobarfield1 datatype[0].structtype[0].field[0].id[0] datatype[0].structtype[0].field[0].datatype 4 +datatype[0].structtype[0].field[1].name foobarfield0 +datatype[0].structtype[0].field[1].id[0] +datatype[0].structtype[0].field[1].datatype 2 datatype[0].documenttype[0] datatype[1].id 278604398 datatype[1].arraytype[0] @@ -16,10 +19,6 @@ datatype[1].weightedsettype[0] datatype[1].structtype[1] datatype[1].structtype[0].name foobar.body datatype[1].structtype[0].version 9 -datatype[1].structtype[0].field[1] -datatype[1].structtype[0].field[0].name foobarfield0 -datatype[1].structtype[0].field[0].id[0] -datatype[1].structtype[0].field[0].datatype 2 datatype[1].documenttype[0] datatype[2].id 378030104 datatype[2].arraytype[0] @@ -48,7 +47,6 @@ datatype[4].weightedsettype[0] datatype[4].structtype[1] datatype[4].structtype[0].name banana.body datatype[4].structtype[0].version 234 -datatype[4].structtype[0].field[0] datatype[4].documenttype[0] datatype[5].id 556449802 datatype[5].arraytype[0] @@ -68,7 +66,13 @@ datatype[6].weightedsettype[0] datatype[6].structtype[1] datatype[6].structtype[0].name customtypes.header datatype[6].structtype[0].version 3 -datatype[6].structtype[0].field[0] +datatype[6].structtype[0].field[2] +datatype[6].structtype[0].field[0].name arrayfloat +datatype[6].structtype[0].field[0].id[0] +datatype[6].structtype[0].field[0].datatype 99 +datatype[6].structtype[0].field[1].name arrayarrayfloat +datatype[6].structtype[0].field[1].id[0] +datatype[6].structtype[0].field[1].datatype 4003 datatype[6].documenttype[0] datatype[7].id 99 datatype[7].arraytype[1] @@ -88,13 +92,6 @@ datatype[9].weightedsettype[0] datatype[9].structtype[1] datatype[9].structtype[0].name customtypes.body datatype[9].structtype[0].version 3 -datatype[9].structtype[0].field[2] -datatype[9].structtype[0].field[0].name arrayfloat -datatype[9].structtype[0].field[0].id[0] -datatype[9].structtype[0].field[0].datatype 99 -datatype[9].structtype[0].field[1].name arrayarrayfloat -datatype[9].structtype[0].field[1].id[0] -datatype[9].structtype[0].field[1].datatype 4003 datatype[9].documenttype[0] datatype[10].id -1500313747 datatype[10].arraytype[0] diff --git a/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java b/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java index fa47c80c6fb..b2be93bfff9 100644 --- a/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentSerializationTestCase.java @@ -116,18 +116,15 @@ public class DocumentSerializationTestCase extends AbstractTypesTest { CompressionConfig lz4comp = new CompressionConfig(CompressionType.LZ4); { doc.getDataType().contentStruct().setCompressionConfig(noncomp); - doc.getDataType().getBodyType().setCompressionConfig(noncomp); FileOutputStream fout = new FileOutputStream(path + "document-java-currentversion-uncompressed.dat", false); doc.serialize(fout); fout.close(); } { doc.getDataType().contentStruct().setCompressionConfig(lz4comp); - doc.getDataType().getBodyType().setCompressionConfig(lz4comp); FileOutputStream fout = new FileOutputStream(path + "document-java-currentversion-lz4-9.dat", false); doc.serialize(fout); doc.getDataType().contentStruct().setCompressionConfig(noncomp); - doc.getDataType().getBodyType().setCompressionConfig(noncomp); fout.close(); } } diff --git a/document/src/test/java/com/yahoo/document/DocumentTestCase.java b/document/src/test/java/com/yahoo/document/DocumentTestCase.java index dcd4622b3f4..be6544563ed 100644 --- a/document/src/test/java/com/yahoo/document/DocumentTestCase.java +++ b/document/src/test/java/com/yahoo/document/DocumentTestCase.java @@ -753,12 +753,10 @@ public class DocumentTestCase extends DocumentTestCaseBase { CompressionConfig lz4comp = new CompressionConfig(CompressionType.LZ4); doc.getDataType().contentStruct().setCompressionConfig(lz4comp); - doc.getDataType().getBodyType().setCompressionConfig(lz4comp); buf = new GrowableByteBuffer(size, 2.0f); doc.serialize(buf); doc.getDataType().contentStruct().setCompressionConfig(noncomp); - doc.getDataType().getBodyType().setCompressionConfig(noncomp); fos = new FileOutputStream("src/tests/data/serializejava-compressed.dat"); fos.write(buf.array(), 0, buf.position()); fos.close(); @@ -816,13 +814,11 @@ public class DocumentTestCase extends DocumentTestCaseBase { CompressionConfig lz4comp = new CompressionConfig(CompressionType.LZ4); doc.getDataType().contentStruct().setCompressionConfig(lz4comp); - doc.getDataType().getBodyType().setCompressionConfig(lz4comp); GrowableByteBuffer data = new GrowableByteBuffer(); doc.serialize(data); int size = doc.getSerializedSize(); doc.getDataType().contentStruct().setCompressionConfig(noncomp); - doc.getDataType().getBodyType().setCompressionConfig(noncomp); assertEquals(size, data.position()); diff --git a/document/src/test/java/com/yahoo/document/documentmanager.docindoc.cfg b/document/src/test/java/com/yahoo/document/documentmanager.docindoc.cfg index 3347c3127b5..65ce1b56811 100644 --- a/document/src/test/java/com/yahoo/document/documentmanager.docindoc.cfg +++ b/document/src/test/java/com/yahoo/document/documentmanager.docindoc.cfg @@ -4,16 +4,15 @@ datatype[0].id -1407012075 datatype[0].structtype[1] datatype[0].structtype[0].name "outerdoc.body" datatype[0].structtype[0].version 0 -datatype[0].structtype[0].field[1] -datatype[0].structtype[0].field[0].datatype -2035324352 -datatype[0].structtype[0].field[0].name "innerdocuments" datatype[1].id -1686125086 datatype[1].structtype[1] datatype[1].structtype[0].name "docindoc.header" datatype[1].structtype[0].version 0 -datatype[1].structtype[0].field[1] +datatype[1].structtype[0].field[2] datatype[1].structtype[0].field[0].datatype 2 datatype[1].structtype[0].field[0].name "name" +datatype[1].structtype[0].field[1].datatype 2 +datatype[1].structtype[0].field[1].name "content" datatype[2].id -2035324352 datatype[2].arraytype[1] datatype[2].arraytype[0].datatype 1447635645 @@ -21,6 +20,9 @@ datatype[3].id -2040625920 datatype[3].structtype[1] datatype[3].structtype[0].name "outerdoc.header" datatype[3].structtype[0].version 0 +datatype[3].structtype[0].field[1] +datatype[3].structtype[0].field[0].datatype -2035324352 +datatype[3].structtype[0].field[0].name "innerdocuments" datatype[4].id 1447635645 datatype[4].documenttype[1] datatype[4].documenttype[0].bodystruct 2030224503 @@ -37,6 +39,3 @@ datatype[6].id 2030224503 datatype[6].structtype[1] datatype[6].structtype[0].name "docindoc.body" datatype[6].structtype[0].version 0 -datatype[6].structtype[0].field[1] -datatype[6].structtype[0].field[0].datatype 2 -datatype[6].structtype[0].field[0].name "content" diff --git a/document/src/test/java/com/yahoo/document/serialization/VespaDocumentSerializerTestCase.java b/document/src/test/java/com/yahoo/document/serialization/VespaDocumentSerializerTestCase.java index 598369bae39..079e16915e1 100644 --- a/document/src/test/java/com/yahoo/document/serialization/VespaDocumentSerializerTestCase.java +++ b/document/src/test/java/com/yahoo/document/serialization/VespaDocumentSerializerTestCase.java @@ -68,7 +68,7 @@ public class VespaDocumentSerializerTestCase { CompressionFixture() { docType = new DocumentType("map_of_structs"); - docType.getHeaderType().setCompressionConfig(new CompressionConfig(CompressionType.LZ4)); + docType.contentStruct().setCompressionConfig(new CompressionConfig(CompressionType.LZ4)); nestedType = new StructDataType("nested_type"); nestedType.addField(new Field("str", DataType.STRING)); diff --git a/document/src/tests/data/crossplatform-java-cpp-document.cfg b/document/src/tests/data/crossplatform-java-cpp-document.cfg index 134d31b1831..3ebe56b8671 100644 --- a/document/src/tests/data/crossplatform-java-cpp-document.cfg +++ b/document/src/tests/data/crossplatform-java-cpp-document.cfg @@ -34,7 +34,10 @@ datatype[4].weightedsettype[0] datatype[4].structtype[1] datatype[4].structtype[0].name docindoc.header datatype[4].structtype[0].version 0 -datatype[4].structtype[0].field[0] +datatype[4].structtype[0].field[1] +datatype[4].structtype[0].field[0].name stringindocfield +datatype[4].structtype[0].field[0].id[0] +datatype[4].structtype[0].field[0].datatype 2 datatype[4].documenttype[0] datatype[5].id 2030224503 datatype[5].arraytype[0] @@ -42,10 +45,6 @@ datatype[5].weightedsettype[0] datatype[5].structtype[1] datatype[5].structtype[0].name docindoc.body datatype[5].structtype[0].version 0 -datatype[5].structtype[0].field[1] -datatype[5].structtype[0].field[0].name stringindocfield -datatype[5].structtype[0].field[0].id[0] -datatype[5].structtype[0].field[0].datatype 2 datatype[5].documenttype[0] datatype[6].id 1447635645 datatype[6].arraytype[0] @@ -63,7 +62,7 @@ datatype[7].weightedsettype[0] datatype[7].structtype[1] datatype[7].structtype[0].name serializetest.header datatype[7].structtype[0].version 0 -datatype[7].structtype[0].field[4] +datatype[7].structtype[0].field[15] datatype[7].structtype[0].field[0].name floatfield datatype[7].structtype[0].field[0].id[0] datatype[7].structtype[0].field[0].datatype 1 @@ -76,6 +75,39 @@ datatype[7].structtype[0].field[2].datatype 4 datatype[7].structtype[0].field[3].name urifield datatype[7].structtype[0].field[3].id[0] datatype[7].structtype[0].field[3].datatype 10 +datatype[7].structtype[0].field[4].name intfield +datatype[7].structtype[0].field[4].id[0] +datatype[7].structtype[0].field[4].datatype 0 +datatype[7].structtype[0].field[5].name rawfield +datatype[7].structtype[0].field[5].id[0] +datatype[7].structtype[0].field[5].datatype 3 +datatype[7].structtype[0].field[6].name doublefield +datatype[7].structtype[0].field[6].id[0] +datatype[7].structtype[0].field[6].datatype 5 +datatype[7].structtype[0].field[7].name contentfield +datatype[7].structtype[0].field[7].id[0] +datatype[7].structtype[0].field[7].datatype 2 +datatype[7].structtype[0].field[8].name bytefield +datatype[7].structtype[0].field[8].id[0] +datatype[7].structtype[0].field[8].datatype 16 +datatype[7].structtype[0].field[9].name arrayoffloatfield +datatype[7].structtype[0].field[9].id[0] +datatype[7].structtype[0].field[9].datatype 1001 +datatype[7].structtype[0].field[10].name arrayofarrayoffloatfield +datatype[7].structtype[0].field[10].id[0] +datatype[7].structtype[0].field[10].datatype 2001 +datatype[7].structtype[0].field[11].name docfield +datatype[7].structtype[0].field[11].id[0] +datatype[7].structtype[0].field[11].datatype 8 +datatype[7].structtype[0].field[12].name wsfield +datatype[7].structtype[0].field[12].id[0] +datatype[7].structtype[0].field[12].datatype 437829 +datatype[7].structtype[0].field[13].name mapfield +datatype[7].structtype[0].field[13].id[0] +datatype[7].structtype[0].field[13].datatype 9999 +datatype[7].structtype[0].field[14].name boolfield +datatype[7].structtype[0].field[14].id[0] +datatype[7].structtype[0].field[14].datatype 6 datatype[7].documenttype[0] datatype[8].id 1026122976 datatype[8].arraytype[0] @@ -83,40 +115,7 @@ datatype[8].weightedsettype[0] datatype[8].structtype[1] datatype[8].structtype[0].name serializetest.body datatype[8].structtype[0].version 0 -datatype[8].structtype[0].field[11] -datatype[8].structtype[0].field[0].name intfield -datatype[8].structtype[0].field[0].id[0] -datatype[8].structtype[0].field[0].datatype 0 -datatype[8].structtype[0].field[1].name rawfield -datatype[8].structtype[0].field[1].id[0] -datatype[8].structtype[0].field[1].datatype 3 -datatype[8].structtype[0].field[2].name doublefield -datatype[8].structtype[0].field[2].id[0] -datatype[8].structtype[0].field[2].datatype 5 -datatype[8].structtype[0].field[3].name contentfield -datatype[8].structtype[0].field[3].id[0] -datatype[8].structtype[0].field[3].datatype 2 -datatype[8].structtype[0].field[4].name bytefield -datatype[8].structtype[0].field[4].id[0] -datatype[8].structtype[0].field[4].datatype 16 -datatype[8].structtype[0].field[5].name arrayoffloatfield -datatype[8].structtype[0].field[5].id[0] -datatype[8].structtype[0].field[5].datatype 1001 -datatype[8].structtype[0].field[6].name arrayofarrayoffloatfield -datatype[8].structtype[0].field[6].id[0] -datatype[8].structtype[0].field[6].datatype 2001 -datatype[8].structtype[0].field[7].name docfield -datatype[8].structtype[0].field[7].id[0] -datatype[8].structtype[0].field[7].datatype 8 -datatype[8].structtype[0].field[8].name wsfield -datatype[8].structtype[0].field[8].id[0] -datatype[8].structtype[0].field[8].datatype 437829 -datatype[8].structtype[0].field[9].name mapfield -datatype[8].structtype[0].field[9].id[0] -datatype[8].structtype[0].field[9].datatype 9999 -datatype[8].structtype[0].field[10].name boolfield -datatype[8].structtype[0].field[10].id[0] -datatype[8].structtype[0].field[10].datatype 6 +datatype[8].structtype[0].field[0] datatype[8].documenttype[0] datatype[9].id 1306012852 datatype[9].arraytype[0] diff --git a/document/src/vespa/document/config/documentmanager.def b/document/src/vespa/document/config/documentmanager.def index 092a29d9293..d53fec43e5d 100644 --- a/document/src/vespa/document/config/documentmanager.def +++ b/document/src/vespa/document/config/documentmanager.def @@ -88,7 +88,7 @@ datatype[].documenttype[].inherits[].version int default=0 datatype[].documenttype[].headerstruct int ## Specify a document field id. Must be unique within the document type. -datatype[].documenttype[].bodystruct int +datatype[].documenttype[].bodystruct int default=0 ## Field sets datatype[].documenttype[].fieldsets{}.fields[] string diff --git a/document/src/vespa/document/config/documenttypes.def b/document/src/vespa/document/config/documenttypes.def index 0f0a9e3e37c..d02e9fe49f2 100644 --- a/document/src/vespa/document/config/documenttypes.def +++ b/document/src/vespa/document/config/documenttypes.def @@ -18,7 +18,7 @@ documenttype[].version int default=0 documenttype[].headerstruct int ## Specify a document field id. Must be unique within the document type. -documenttype[].bodystruct int +documenttype[].bodystruct int default=0 ## Specify a document type to inherit (id) documenttype[].inherits[].id int |