From 8becab6c0ef366812526617d963a26745d1abf9c Mon Sep 17 00:00:00 2001 From: Henning Baldersheim Date: Tue, 7 Jun 2022 16:20:08 +0200 Subject: GC deprecation warnings. --- .../com/yahoo/documentmodel/NewDocumentType.java | 41 ++-------------------- .../com/yahoo/schema/DocumentModelBuilder.java | 14 +++----- .../java/com/yahoo/schema/derived/IndexSchema.java | 37 ++++--------------- .../java/com/yahoo/schema/document/SDField.java | 7 +--- .../yahoo/schema/parser/ConvertParsedTypes.java | 12 ++----- .../java/com/yahoo/schema/processing/TagType.java | 3 +- 6 files changed, 19 insertions(+), 95 deletions(-) (limited to 'config-model/src') diff --git a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java index 7f15da3179f..8c644279281 100644 --- a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java +++ b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java @@ -91,25 +91,6 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp public DataType getContentStruct() { return contentStruct; } public Collection getInherited() { return inherits.values(); } public NewDocumentType getInherited(Name inherited) { return inherits.get(inherited.getId()); } - public NewDocumentType removeInherited(Name inherited) { return inherits.remove(inherited.getId()); } - - /** - * Data type of the header fields of this and all inherited document types - * Used by DocumentGenMojo - * @return merged {@link StructDataType} - */ - public StructDataType allHeader() { - StructDataType ret = new StructDataType(contentStruct.getName()); - for (Field f : contentStruct.getFields()) { - ret.addField(f); - } - for (NewDocumentType inherited : getInherited()) { - for (Field f : ((StructDataType) inherited.getContentStruct()).getFields()) { - ret.addField(f); - } - } - return ret; - } @Override public Class getValueClass() { @@ -132,7 +113,7 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp return false; } - private boolean verifyInheritance(NewDocumentType inherited) { + private void verifyInheritance(NewDocumentType inherited) { for (Field f : getFields()) { Field inhF = inherited.getField(f.getName()); if (inhF != null && !inhF.equals(f)) { @@ -151,7 +132,6 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp } } } - return true; } public void inherit(NewDocumentType inherited) { @@ -213,9 +193,7 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp } public Collection getFields() { - Collection collection = new LinkedList<>(); - collection.addAll(contentStruct.getFields()); - return Collections.unmodifiableCollection(collection); + return contentStruct.getFields(); } @Override @@ -311,20 +289,6 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp } return null; } - public AnnotationType getAnnotationType(int id) { - AnnotationType a = annotations.getType(id); - if (a != null) { - return a; - } else { - for (NewDocumentType dt : getInherited()) { - a = dt.getAnnotationType(id); - if (a != null) { - return a; - } - } - } - return null; - } public NewDocumentType add(AnnotationType type) { annotations.register(type); @@ -386,7 +350,6 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp private NewDocumentReferenceDataType refToThis = null; - @SuppressWarnings("deprecation") public NewDocumentReferenceDataType getReferenceDataType() { if (refToThis == null) { refToThis = new NewDocumentReferenceDataType(this); diff --git a/config-model/src/main/java/com/yahoo/schema/DocumentModelBuilder.java b/config-model/src/main/java/com/yahoo/schema/DocumentModelBuilder.java index 50ae4b72e13..57867bc7807 100644 --- a/config-model/src/main/java/com/yahoo/schema/DocumentModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/schema/DocumentModelBuilder.java @@ -189,11 +189,6 @@ public class DocumentModelBuilder { } } - private static String descT(DataType type) { - if (type == null) { return ""; } - return "'" + type.getName() + "' [" + type.getId() + "] {"+type.getClass() + "}"; - } - private void addDocumentTypes(List docList) { LinkedList lst = new LinkedList<>(); for (SDDocumentType doc : docList) { @@ -266,7 +261,7 @@ public class DocumentModelBuilder { type = other; } else if (type != DataType.DOCUMENT) { throw new IllegalArgumentException - ("Can not handle nested document definitions. Undefined document type: " + type.toString()); + ("Can not handle nested document definitions. Undefined document type: " + type); } } else if (type instanceof NewDocumentType) { DataType other = getDocumentType(docs, type.getName()); @@ -378,7 +373,7 @@ public class DocumentModelBuilder { if (type.isStruct()) { handleStruct(type); } else { - throw new IllegalArgumentException("Data type '" + type.getName() + "' is not a struct => tostring='" + type.toString() + "'."); + throw new IllegalArgumentException("Data type '" + type.getName() + "' is not a struct => tostring='" + type + "'."); } } for (SDDocumentType type : sdoc.getTypes()) { @@ -470,7 +465,7 @@ public class DocumentModelBuilder { private boolean testAddType(DataType type) { return internalAddType(type, true); } - private boolean addType(DataType type) { return internalAddType(type, false); } + private void addType(DataType type) { internalAddType(type, false); } private boolean internalAddType(DataType type, boolean dryRun) { DataType oldType = targetDt.getDataTypeRecursive(type.getId()); @@ -573,7 +568,6 @@ public class DocumentModelBuilder { return null; } - @SuppressWarnings("deprecation") private StructDataType handleStruct(SDDocumentType type) { if (type.isStruct()) { var st = type.getStruct(); @@ -610,7 +604,7 @@ public class DocumentModelBuilder { } private static Set convertDocumentReferencesToNames(Optional documentReferences) { - if (!documentReferences.isPresent()) { + if (documentReferences.isEmpty()) { return Set.of(); } return documentReferences.get().referenceMap().values().stream() diff --git a/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java b/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java index 7f6c824b979..0e58b4cdb3b 100644 --- a/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java +++ b/config-model/src/main/java/com/yahoo/schema/derived/IndexSchema.java @@ -8,7 +8,6 @@ import com.yahoo.document.StructuredDataType; import com.yahoo.document.TensorDataType; import com.yahoo.document.WeightedSetDataType; import com.yahoo.schema.Schema; -import com.yahoo.schema.document.BooleanIndexDefinition; import com.yahoo.schema.document.FieldSet; import com.yahoo.schema.document.ImmutableSDField; import com.yahoo.vespa.config.search.IndexschemaConfig; @@ -112,14 +111,13 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { @Override public void getConfig(IndexschemaConfig.Builder icB) { - for (int i = 0; i < fields.size(); ++i) { - IndexField f = fields.get(i); + for (IndexField f : fields) { IndexschemaConfig.Indexfield.Builder ifB = new IndexschemaConfig.Indexfield.Builder() .name(f.getName()) .datatype(IndexschemaConfig.Indexfield.Datatype.Enum.valueOf(f.getType())) .prefix(f.hasPrefix()) - .phrases(f.hasPhrases()) - .positions(f.hasPositions()) + .phrases(false) + .positions(true) .interleavedfeatures(f.useInterleavedFeatures()); if (!f.getCollectionType().equals("SINGLE")) { ifB.collectiontype(IndexschemaConfig.Indexfield.Collectiontype.Enum.valueOf(f.getCollectionType())); @@ -137,7 +135,6 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { } } - @SuppressWarnings("deprecation") static List flattenField(Field field) { DataType fieldType = field.getDataType(); if (fieldType.getPrimitiveType() != null){ @@ -172,14 +169,11 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { * Representation of an index field with name and data type. */ public static class IndexField { - private String name; - private Index.Type type; - private com.yahoo.schema.Index.Type sdType; // The index type in "user intent land" - private DataType sdFieldType; + private final String name; + private final Index.Type type; + private final DataType sdFieldType; private boolean prefix = false; - private boolean phrases = false; // TODO dead, but keep a while to ensure config compatibility? - private boolean positions = true;// TODO dead, but keep a while to ensure config compatibility? - private BooleanIndexDefinition boolIndex = null; + // Whether the posting lists of this index field should have interleaved features (num occs, field length) in document id stream. private boolean interleavedFeatures = false; @@ -193,11 +187,8 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { prefix = index.isPrefix(); interleavedFeatures = index.useInterleavedFeatures(); } - sdType = index.getType(); - boolIndex = index.getBooleanIndexDefiniton(); } public String getName() { return name; } - public Index.Type getRawType() { return type; } public String getType() { return type.equals(Index.Type.INT64) ? "INT64" : "STRING"; @@ -212,21 +203,7 @@ public class IndexSchema extends Derived implements IndexschemaConfig.Producer { : "SINGLE"; } public boolean hasPrefix() { return prefix; } - public boolean hasPhrases() { return phrases; } - public boolean hasPositions() { return positions; } public boolean useInterleavedFeatures() { return interleavedFeatures; } - - public BooleanIndexDefinition getBooleanIndexDefinition() { - return boolIndex; - } - - /** - * The user set index type - * @return the type - */ - public com.yahoo.schema.Index.Type getSdType() { - return sdType; - } } /** diff --git a/config-model/src/main/java/com/yahoo/schema/document/SDField.java b/config-model/src/main/java/com/yahoo/schema/document/SDField.java index fbb2b2dc21f..8f285bdd113 100644 --- a/config-model/src/main/java/com/yahoo/schema/document/SDField.java +++ b/config-model/src/main/java/com/yahoo/schema/document/SDField.java @@ -33,9 +33,7 @@ import com.yahoo.vespa.indexinglanguage.parser.ParseException; import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.LinkedList; import java.util.List; -import java.util.ListIterator; import java.util.Map; import java.util.TreeMap; @@ -111,7 +109,7 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { private final Map structFields = new java.util.LinkedHashMap<>(0); /** The document that this field was declared in, or null */ - private SDDocumentType repoDocType = null; + private final SDDocumentType repoDocType; /** The aliases declared for this field. May pertain to indexes or attributes */ private final Map aliasToName = new HashMap<>(); @@ -263,7 +261,6 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { private boolean doneStructFields = false; - @SuppressWarnings("deprecation") private void actuallyMakeStructFields() { if (doneStructFields) return; if (getFirstStructOrMapRecursive() == null) { @@ -344,8 +341,6 @@ public class SDField extends Field implements TypedKey, ImmutableSDField { doneStructFields = true; } - private Matching matchingForStructFields = null; - public void setId(int fieldId, DocumentType owner) { super.setId(fieldId, owner); idOverride = true; diff --git a/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedTypes.java b/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedTypes.java index fd493a90249..efe1547f146 100644 --- a/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedTypes.java +++ b/config-model/src/main/java/com/yahoo/schema/parser/ConvertParsedTypes.java @@ -28,11 +28,6 @@ public class ConvertParsedTypes { private final List orderedInput; private final DocumentTypeManager docMan; - ConvertParsedTypes(List input) { - this.orderedInput = input; - this.docMan = new DocumentTypeManager(); - } - public ConvertParsedTypes(List input, DocumentTypeManager docMan) { this.orderedInput = input; this.docMan = docMan; @@ -46,9 +41,9 @@ public class ConvertParsedTypes { } } - private Map documentsFromSchemas = new HashMap<>(); - private Map structsFromSchemas = new HashMap<>(); - private Map annotationsFromSchemas = new HashMap<>(); + private final Map documentsFromSchemas = new HashMap<>(); + private final Map structsFromSchemas = new HashMap<>(); + private final Map annotationsFromSchemas = new HashMap<>(); private void startDataTypes() { for (var schema : orderedInput) { @@ -297,7 +292,6 @@ public class ConvertParsedTypes { throw new IllegalArgumentException("unknown type named '" + name + "' in context "+context); } - @SuppressWarnings("deprecation") private void registerDataTypes() { for (DataType t : structsFromSchemas.values()) { docMan.register(t); diff --git a/config-model/src/main/java/com/yahoo/schema/processing/TagType.java b/config-model/src/main/java/com/yahoo/schema/processing/TagType.java index f511d572bc6..112d3c4cad0 100644 --- a/config-model/src/main/java/com/yahoo/schema/processing/TagType.java +++ b/config-model/src/main/java/com/yahoo/schema/processing/TagType.java @@ -2,8 +2,9 @@ package com.yahoo.schema.processing; import com.yahoo.config.application.api.DeployLogger; +import com.yahoo.document.DataType; +import com.yahoo.document.WeightedSetDataType; import com.yahoo.schema.RankProfileRegistry; -import com.yahoo.document.*; import com.yahoo.schema.Schema; import com.yahoo.schema.document.Matching; import com.yahoo.schema.document.MatchType; -- cgit v1.2.3