diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-10-26 23:49:36 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-26 23:49:36 +0200 |
commit | 9c9e59fa2c6a7551fa271246d0dd36b955ecc6ea (patch) | |
tree | 36241f4dc9c87f64abc72bc5a1028724dcd25f4b | |
parent | fad4f51d0a2c7b3133aff31567ef3d1475152f54 (diff) | |
parent | ad7099d4eb77eecbe41f59600652006105b5d4af (diff) |
Merge pull request #7464 from vespa-engine/balder/remove-deprecated-usage
Remove use of deprecated methods.
6 files changed, 71 insertions, 24 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentUpdate.java b/document/src/main/java/com/yahoo/document/DocumentUpdate.java index 54ced1321a0..535a3bc9a9a 100644 --- a/document/src/main/java/com/yahoo/document/DocumentUpdate.java +++ b/document/src/main/java/com/yahoo/document/DocumentUpdate.java @@ -279,9 +279,8 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP /** * Assigns the field updates of this document update. - * This document update receives ownership of the list - it can not be subsequently used - * by the caller. Also note that there no assumptions can be made on the order of items - * after this call. They might have been joined if for the same field or reordered. + * Also note that no assumptions can be made on the order of item after this call. + * They might have been joined if for the same field or reordered. * * @param fieldUpdates the new list of updates of this * @throws NullPointerException if the argument passed is null @@ -378,9 +377,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP */ @Deprecated public FieldUpdate removeFieldUpdate(int index) { - FieldUpdate prev = getFieldUpdate(index); - fieldUpdates.remove(index); - return removeFieldUpdate(prev.getField()); + return fieldUpdates.remove(index); } public FieldUpdate removeFieldUpdate(Field field) { @@ -391,7 +388,8 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP return fieldUpdate; } } - return null; } + return null; + } public FieldUpdate removeFieldUpdate(String fieldName) { Field field = documentType.getField(fieldName); @@ -448,7 +446,7 @@ public class DocumentUpdate extends DocumentOperation implements Iterable<FieldP string.append(docId); string.append("': "); string.append("create-if-non-existent="); - string.append(createIfNonExistent); + string.append(getCreateIfNonExistent()); string.append(": "); string.append("["); diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java index 3f885844987..f4c40980608 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializer42.java @@ -471,7 +471,6 @@ public class VespaDocumentDeserializer42 extends VespaDocumentSerializer42 imple int size = getInt(null); for (int i = 0; i < size; i++) { - // TODO: Should use checked method, but doesn't work according to test now. update.addFieldUpdate(new FieldUpdate(this, update.getDocumentType(), serializationVersion)); } } diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java index 4f8a26d3777..44a1ca6e749 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentDeserializerHead.java @@ -28,7 +28,6 @@ public class VespaDocumentDeserializerHead extends VespaDocumentDeserializer42 { int size = getInt(null); for (int i = 0; i < size; i++) { - // TODO: Should use checked method, but doesn't work according to test now. update.addFieldUpdate(new FieldUpdate(this, update.getDocumentType(), 8)); } diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java index 33e4831185b..c3bf9303529 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializer42.java @@ -2,18 +2,61 @@ package com.yahoo.document.serialization; import com.yahoo.compress.Compressor; -import com.yahoo.document.*; -import com.yahoo.document.annotation.*; -import com.yahoo.document.datatypes.*; + +import com.yahoo.document.ArrayDataType; +import com.yahoo.document.CollectionDataType; +import com.yahoo.document.DataType; +import com.yahoo.document.Document; +import com.yahoo.document.DocumentId; +import com.yahoo.document.DocumentType; +import com.yahoo.document.DocumentUpdate; +import com.yahoo.document.Field; +import com.yahoo.document.WeightedSetDataType; +import com.yahoo.document.annotation.AlternateSpanList; +import com.yahoo.document.annotation.Annotation; +import com.yahoo.document.annotation.AnnotationReference; +import com.yahoo.document.annotation.Span; +import com.yahoo.document.annotation.SpanList; +import com.yahoo.document.annotation.SpanNode; +import com.yahoo.document.annotation.SpanTree; +import com.yahoo.document.datatypes.Array; +import com.yahoo.document.datatypes.ByteFieldValue; +import com.yahoo.document.datatypes.CollectionFieldValue; +import com.yahoo.document.datatypes.DoubleFieldValue; +import com.yahoo.document.datatypes.FieldValue; +import com.yahoo.document.datatypes.FloatFieldValue; +import com.yahoo.document.datatypes.IntegerFieldValue; +import com.yahoo.document.datatypes.LongFieldValue; +import com.yahoo.document.datatypes.MapFieldValue; +import com.yahoo.document.datatypes.PredicateFieldValue; +import com.yahoo.document.datatypes.Raw; +import com.yahoo.document.datatypes.ReferenceFieldValue; +import com.yahoo.document.datatypes.StringFieldValue; +import com.yahoo.document.datatypes.Struct; +import com.yahoo.document.datatypes.StructuredFieldValue; +import com.yahoo.document.datatypes.TensorFieldValue; +import com.yahoo.document.datatypes.WeightedSet; import com.yahoo.document.predicate.BinaryFormat; -import com.yahoo.document.update.*; +import com.yahoo.document.update.AddValueUpdate; +import com.yahoo.document.update.ArithmeticValueUpdate; +import com.yahoo.document.update.AssignValueUpdate; +import com.yahoo.document.update.ClearValueUpdate; +import com.yahoo.document.update.FieldUpdate; +import com.yahoo.document.update.MapValueUpdate; +import com.yahoo.document.update.RemoveValueUpdate; +import com.yahoo.document.update.ValueUpdate; import com.yahoo.io.GrowableByteBuffer; import com.yahoo.tensor.serialization.TypedBinaryFormat; import com.yahoo.vespa.objects.BufferSerializer; import com.yahoo.vespa.objects.FieldBase; import java.nio.ByteBuffer; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import java.util.logging.Logger; import static com.yahoo.text.Utf8.calculateBytePositions; @@ -563,9 +606,9 @@ public class VespaDocumentSerializer42 extends BufferSerializer implements Docum putByte(null, contents); update.getDocumentType().serialize(this); - putInt(null, update.getFieldUpdates().size()); + putInt(null, update.fieldUpdates().size()); - for (FieldUpdate up : update.getFieldUpdates()) { + for (FieldUpdate up : update.fieldUpdates()) { up.serialize(this); } } diff --git a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializerHead.java b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializerHead.java index 9629ed94f47..ae995371125 100644 --- a/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializerHead.java +++ b/document/src/main/java/com/yahoo/document/serialization/VespaDocumentSerializerHead.java @@ -26,17 +26,17 @@ public class VespaDocumentSerializerHead extends VespaDocumentSerializer42 { update.getDocumentType().serialize(this); - putInt(null, update.getFieldUpdates().size()); + putInt(null, update.fieldUpdates().size()); - for (FieldUpdate up : update.getFieldUpdates()) { + for (FieldUpdate up : update.fieldUpdates()) { up.serialize(this); } DocumentUpdateFlags flags = new DocumentUpdateFlags(); flags.setCreateIfNonExistent(update.getCreateIfNonExistent()); - putInt(null, flags.injectInto(update.getFieldPathUpdates().size())); + putInt(null, flags.injectInto(update.fieldPathUpdates().size())); - for (FieldPathUpdate up : update.getFieldPathUpdates()) { + for (FieldPathUpdate up : update.fieldPathUpdates()) { up.serialize(this); } } diff --git a/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java b/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java index eaf9e576a5b..cae51440400 100644 --- a/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java +++ b/vdslib/src/test/java/com/yahoo/vdslib/DocumentListTestCase.java @@ -1,7 +1,14 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vdslib; -import com.yahoo.document.*; +import com.yahoo.document.DocumentId; +import com.yahoo.document.DocumentPut; +import com.yahoo.document.DocumentRemove; +import com.yahoo.document.DocumentType; +import com.yahoo.document.DocumentTypeManager; +import com.yahoo.document.DocumentTypeManagerConfigurer; +import com.yahoo.document.DocumentUpdate; +import com.yahoo.document.Field; import com.yahoo.document.datatypes.FloatFieldValue; import com.yahoo.document.datatypes.StringFieldValue; import com.yahoo.document.serialization.DocumentSerializer; @@ -33,8 +40,9 @@ public class DocumentListTestCase { put3.getDocument().setFieldValue("bodyfloat", new FloatFieldValue(5.5f)); + Field bodystringField = bmType.getField("bodystring"); DocumentUpdate docUp = new DocumentUpdate(docMan.getDocumentType("benchmark"), new DocumentId("userdoc:foo:99999999:4")); - docUp.addFieldUpdate(FieldUpdate.createAssign(docUp.getType().getField("bodystring"), new StringFieldValue("ballooooo"))); + docUp.addFieldUpdate(FieldUpdate.createAssign(bodystringField, new StringFieldValue("ballooooo"))); List<Entry> entries = new ArrayList<>(); entries.add(Entry.create(put1)); @@ -91,7 +99,7 @@ public class DocumentListTestCase { assertFalse(entry4.isRemoveEntry()); assertTrue(entry4.isUpdateEntry()); assertTrue(entry4.getDocumentOperation() instanceof DocumentUpdate); - assertEquals(new StringFieldValue("ballooooo"),((DocumentUpdate) entry4.getDocumentOperation()).getFieldUpdate(0).getValueUpdate(0).getValue()); + assertEquals(new StringFieldValue("ballooooo"),((DocumentUpdate) entry4.getDocumentOperation()).getFieldUpdate(bodystringField).getValueUpdate(0).getValue()); } @Test |