diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-03-17 10:09:46 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-03-17 10:09:46 +0000 |
commit | da2394528ea86f38bb2d00bbbe09142ac61d0faf (patch) | |
tree | eff5edd9ad715ae8f5900f416df0e671c9fe4e2c /config-model | |
parent | 66cd9e646c66b255d2259ec39a72f5b3fd8ce100 (diff) |
switch to NewDocumentReferenceDataType
Diffstat (limited to 'config-model')
23 files changed, 87 insertions, 86 deletions
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 4ff54d7ff1c..a6571ef819d 100644 --- a/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java +++ b/config-model/src/main/java/com/yahoo/documentmodel/NewDocumentType.java @@ -4,7 +4,7 @@ package com.yahoo.documentmodel; import com.yahoo.document.DataType; import com.yahoo.document.Document; import com.yahoo.document.Field; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.document.StructuredDataType; import com.yahoo.document.TemporaryStructuredDataType; @@ -385,16 +385,12 @@ public final class NewDocumentType extends StructuredDataType implements DataTyp } - private ReferenceDataType refToThis = null; + private NewDocumentReferenceDataType refToThis = null; @SuppressWarnings("deprecation") - public ReferenceDataType getReferenceDataType() { + public NewDocumentReferenceDataType getReferenceDataType() { if (refToThis == null) { - // super ugly, the APIs for this are horribly inconsistent - var tmptmp = TemporaryStructuredDataType.create(getName()); - var tmp = ReferenceDataType.createWithInferredId(tmptmp); - tmp.setTargetType((StructuredDataType) this); - refToThis = tmp; + refToThis = new NewDocumentReferenceDataType(this); } return refToThis; } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java index 2edf4e57105..16f60e40809 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java @@ -7,7 +7,7 @@ import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.Field; import com.yahoo.document.MapDataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.document.StructuredDataType; import com.yahoo.document.TemporaryStructuredDataType; @@ -304,8 +304,8 @@ public class DocumentModelBuilder { type = new WeightedSetDataType(nt, c, r, t.getId()); } } - else if (type instanceof ReferenceDataType) { - ReferenceDataType t = (ReferenceDataType) type; + else if (type instanceof NewDocumentReferenceDataType) { + var t = (NewDocumentReferenceDataType) type; var tt = t.getTargetType(); var doc = getDocumentType(docs, tt.getId()); type = doc.getReferenceDataType(); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java index 14d4d67edfb..446187eed00 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/DocumentReferenceResolver.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition; import com.yahoo.document.Field; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -16,7 +16,7 @@ import static java.util.stream.Collectors.toMap; /** * Resolves all document references in the search definitions * - * Iterates through all document fields having a {@link ReferenceDataType} and uses {@link ReferenceDataType#getTargetType()} + * Iterates through all document fields having a {@link NewDocumentReferenceDataType} and uses {@link NewDocumentReferenceDataType#getTargetType()} * to determine the referenced document. This information is aggregated into a {@link DocumentReferences} object. * * @author bjorncs @@ -50,7 +50,7 @@ public class DocumentReferenceResolver { private Map<String, DocumentReference> createFieldToDocumentReferenceMapping(SDDocumentType documentType) { return fieldStream(documentType) - .filter(field -> field.getDataType() instanceof ReferenceDataType) + .filter(field -> field.getDataType() instanceof NewDocumentReferenceDataType) .collect(toMap(Field::getName, this::createDocumentReference)); } @@ -61,7 +61,7 @@ public class DocumentReferenceResolver { "The field '%s' is an invalid document reference. The field must be an attribute.", field.getName())); } - ReferenceDataType reference = (ReferenceDataType) field.getDataType(); + NewDocumentReferenceDataType reference = (NewDocumentReferenceDataType) field.getDataType(); String targetDocumentName = getTargetDocumentName(reference); Schema schema = schemaMapping.get(targetDocumentName); if (schema == null) { @@ -87,7 +87,7 @@ public class DocumentReferenceResolver { return documentType.getDocumentType().getFields().stream(); } - private static String getTargetDocumentName(ReferenceDataType reference) { + private static String getTargetDocumentName(NewDocumentReferenceDataType reference) { return reference.getTargetType().getName(); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/SDDocumentTypeOrderer.java b/config-model/src/main/java/com/yahoo/searchdefinition/SDDocumentTypeOrderer.java index 848631f1739..ece1b0bab0a 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/SDDocumentTypeOrderer.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/SDDocumentTypeOrderer.java @@ -4,6 +4,7 @@ package com.yahoo.searchdefinition; import com.yahoo.config.application.api.DeployLogger; import com.yahoo.document.*; import com.yahoo.document.annotation.AnnotationReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.TemporarySDDocumentType; @@ -133,7 +134,7 @@ public class SDDocumentTypeOrderer { //do nothing } else if (type instanceof TensorDataType) { //do nothing - } else if (type instanceof ReferenceDataType) { + } else if (type instanceof NewDocumentReferenceDataType) { //do nothing } else { deployLogger.logApplicationPackage(Level.WARNING, "Unknown type : " + type); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java index 83ce2efb801..e9dd2ac321c 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/SummaryClassField.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.document.MapDataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.datatypes.BoolFieldValue; import com.yahoo.document.datatypes.ByteFieldValue; import com.yahoo.document.datatypes.DoubleFieldValue; @@ -118,7 +118,7 @@ public class SummaryClassField { } } else if (fieldType instanceof MapDataType) { return Type.JSONSTRING; - } else if (fieldType instanceof ReferenceDataType) { + } else if (fieldType instanceof NewDocumentReferenceDataType) { return Type.LONGSTRING; } else { throw new IllegalArgumentException("Don't know which summary type to convert " + fieldType + " to"); diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java b/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java index 3edc93fc7c7..c9ad8ad2838 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/derived/VsmFields.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.document.NumericDataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.datatypes.BoolFieldValue; import com.yahoo.document.datatypes.FieldValue; import com.yahoo.document.datatypes.PredicateFieldValue; @@ -214,7 +214,7 @@ public class VsmFields extends Derived implements VsmfieldsConfig.Producer { return Type.UNSEARCHABLESTRING; } else if (fieldType instanceof CollectionDataType) { return convertType(((CollectionDataType) fieldType).getNestedType()); - } else if (fieldType instanceof ReferenceDataType) { + } else if (fieldType instanceof NewDocumentReferenceDataType) { return Type.UNSEARCHABLESTRING; } else { throw new IllegalArgumentException("Don't know which streaming field type to convert " + diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java index fce128d80f3..c592e4842a9 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/Attribute.java @@ -6,7 +6,7 @@ import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.PrimitiveDataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructuredDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.document.TensorDataType; @@ -255,6 +255,11 @@ public final class Attribute implements Cloneable, Serializable { /** Converts to the right attribute type from a field datatype */ public static Type convertDataType(DataType fieldType) { + if (fieldType instanceof NewDocumentReferenceDataType) { + return Type.REFERENCE; + } else if (fieldType instanceof CollectionDataType) { + return convertDataType(((CollectionDataType) fieldType).getNestedType()); + } FieldValue fval = fieldType.createFieldValue(); if (fval instanceof StringFieldValue) { return Type.STRING; @@ -278,13 +283,9 @@ public final class Attribute implements Cloneable, Serializable { return Type.PREDICATE; } else if (fval instanceof TensorFieldValue) { return Type.TENSOR; - } else if (fieldType instanceof CollectionDataType) { - return convertDataType(((CollectionDataType) fieldType).getNestedType()); - } else if (fieldType instanceof ReferenceDataType) { - return Type.REFERENCE; } else { - throw new IllegalArgumentException("Don't know which attribute type to " + - "convert " + fieldType + " to"); + throw new IllegalArgumentException("Don't know which attribute type to convert " + + fieldType + " [" + fieldType.getClass() + "] to"); } } @@ -298,7 +299,7 @@ public final class Attribute implements Cloneable, Serializable { return CollectionType.SINGLE; } else if (fieldType instanceof PrimitiveDataType) { return CollectionType.SINGLE; - } else if (fieldType instanceof ReferenceDataType) { + } else if (fieldType instanceof NewDocumentReferenceDataType) { return CollectionType.SINGLE; } else { throw new IllegalArgumentException("Field " + fieldType + " not supported in convertCollectionType"); @@ -312,9 +313,9 @@ public final class Attribute implements Cloneable, Serializable { private static Optional<StructuredDataType> convertTargetType(DataType fieldType) { return Optional.of(fieldType) - .filter(ReferenceDataType.class::isInstance) - .map(ReferenceDataType.class::cast) - .map(ReferenceDataType::getTargetType); + .filter(NewDocumentReferenceDataType.class::isInstance) + .map(NewDocumentReferenceDataType.class::cast) + .map(NewDocumentReferenceDataType::getTargetType); } /** Converts to the right field type from an attribute type */ @@ -342,9 +343,9 @@ public final class Attribute implements Cloneable, Serializable { } StructuredDataType type = referenceDocumentType.get(); if (type instanceof DocumentType) { - return ReferenceDataType.createWithInferredId((DocumentType) type); + return new NewDocumentReferenceDataType((DocumentType) type); } else { - return ReferenceDataType.createWithInferredId((TemporaryStructuredDataType) type); + return NewDocumentReferenceDataType.forDocumentName(type.getName()); } } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java index ed20bc0a94d..f628db85429 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/parser/ConvertParsedTypes.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.parser; import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.DocumentTypeManager; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.document.PositionDataType; import com.yahoo.document.WeightedSetDataType; @@ -244,7 +244,7 @@ public class ConvertParsedTypes { private DataType createDocRef(ParsedType pType) { var ref = pType.getReferencedDocumentType(); assert(ref.getVariant() == ParsedType.Variant.DOCUMENT); - return ReferenceDataType.createWithInferredId(findDocFromSchemas(ref.name())); + return new NewDocumentReferenceDataType(findDocFromSchemas(ref.name())); } private DataType resolveFromContext(ParsedType pType, ParsedDocument context) { diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java index 57833fecc7a..edb55dae5bf 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/processing/ReferenceFieldsProcessor.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.searchdefinition.RankProfileRegistry; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.document.SDField; @@ -36,14 +36,14 @@ public class ReferenceFieldsProcessor extends Processor { private void clearSummaryAttributeAspectForExplicitSummaryFields() { for (DocumentSummary docSum : schema.getSummaries().values()) { docSum.getSummaryFields().values().stream() - .filter(summaryField -> summaryField.getDataType() instanceof ReferenceDataType) + .filter(summaryField -> summaryField.getDataType() instanceof NewDocumentReferenceDataType) .forEach(summaryField -> summaryField.setTransform(SummaryTransform.NONE)); } } private void clearSummaryAttributeAspectForConcreteFields() { for (SDField field : schema.allConcreteFields()) { - if (field.getDataType() instanceof ReferenceDataType) { + if (field.getDataType() instanceof NewDocumentReferenceDataType) { removeFromAttributePrefetchSummaryClass(field); clearSummaryTransformOnSummaryFields(field); } diff --git a/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentManager.java b/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentManager.java index 4dbeaef17ac..6f52a384a36 100644 --- a/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentManager.java +++ b/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentManager.java @@ -7,6 +7,7 @@ import com.yahoo.document.*; import com.yahoo.document.annotation.AnnotationReferenceDataType; import com.yahoo.document.annotation.AnnotationType; import com.yahoo.documentmodel.DataTypeCollection; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.documentmodel.VespaDocumentType; import com.yahoo.searchdefinition.document.FieldSet; @@ -172,8 +173,11 @@ public class DocumentManager { // Nothing to do; the type of the tensor is instead stored in each field as detailed type information // to provide better compatibility. A tensor field can have its tensorType changed (in compatible ways) // without changing the field type and thus requiring data refeed - } else if (type instanceof ReferenceDataType) { - ReferenceDataType refType = (ReferenceDataType) type; + } else if (type instanceof NewDocumentReferenceDataType) { + NewDocumentReferenceDataType refType = (NewDocumentReferenceDataType) type; + if (refType.isTemporary()) { + throw new IllegalArgumentException("Still temporary: " + refType); + } builder.referencetype(new Datatype.Referencetype.Builder().target_type_id(refType.getTargetType().getId())); } else { throw new IllegalArgumentException("Can not create config for data type " + type + " of class " + type.getClass()); @@ -356,8 +360,12 @@ public class DocumentManager { docTypeBuildOneType((AnnotationReferenceDataType) type, documentBuilder, indexMap); } else if (type instanceof TensorDataType) { docTypeBuildOneType((TensorDataType) type, documentBuilder, indexMap); - } else if (type instanceof ReferenceDataType) { - docTypeBuildOneType((ReferenceDataType) type, documentBuilder, indexMap); + } else if (type instanceof NewDocumentReferenceDataType) { + var refType = (NewDocumentReferenceDataType) type; + if (refType.isTemporary()) { + throw new IllegalArgumentException("Still temporary: " + refType); + } + docTypeBuildOneType(refType, documentBuilder, indexMap); } else if (type instanceof PrimitiveDataType) { docTypeBuildOneType((PrimitiveDataType) type, documentBuilder, indexMap); } else if (type instanceof DocumentType) { @@ -465,7 +473,7 @@ public class DocumentManager { .annotationtype(indexMap.idxOf(type.getAnnotationType()))); } - private void docTypeBuildOneType(ReferenceDataType type, + private void docTypeBuildOneType(NewDocumentReferenceDataType type, DocumentmanagerConfig.Doctype.Builder builder, IdxMap indexMap) { diff --git a/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentTypes.java b/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentTypes.java index 1bd80988d58..2f0814bd664 100644 --- a/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentTypes.java +++ b/config-model/src/main/java/com/yahoo/vespa/configmodel/producers/DocumentTypes.java @@ -6,6 +6,7 @@ import com.yahoo.document.config.DocumenttypesConfig; import com.yahoo.document.annotation.AnnotationReferenceDataType; import com.yahoo.document.annotation.AnnotationType; import com.yahoo.documentmodel.DataTypeCollection; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.documentmodel.VespaDocumentType; import com.yahoo.searchdefinition.document.FieldSet; @@ -125,8 +126,12 @@ public class DocumentTypes { // to provide better compatibility. A tensor field can have its tensorType changed (in compatible ways) // without changing the field type and thus requiring data refeed return; - } else if (type instanceof ReferenceDataType) { - buildConfig((ReferenceDataType) type, documentBuilder); + } else if (type instanceof NewDocumentReferenceDataType) { + var refType = (NewDocumentReferenceDataType) type; + if (refType.isTemporary()) { + throw new IllegalArgumentException("Still temporary: " + refType); + } + buildConfig(refType, documentBuilder); return; } else { return; @@ -213,9 +218,9 @@ public class DocumentTypes { id(type.getAnnotationType().getId()))); } - private void buildConfig(ReferenceDataType type, + private void buildConfig(NewDocumentReferenceDataType type, DocumenttypesConfig.Documenttype.Builder documentBuilder) { - ReferenceDataType refType = type; + NewDocumentReferenceDataType refType = type; DocumenttypesConfig.Documenttype.Referencetype.Builder refBuilder = new DocumenttypesConfig.Documenttype.Referencetype.Builder(); refBuilder.id(refType.getId()); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java index 976ed0a0219..1379ba3fae9 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/SearchDataTypeValidator.java @@ -7,7 +7,7 @@ import com.yahoo.document.CollectionDataType; import com.yahoo.document.DataType; import com.yahoo.document.Field; import com.yahoo.document.MapDataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.document.TensorDataType; import com.yahoo.document.WeightedSetDataType; @@ -68,7 +68,7 @@ public class SearchDataTypeValidator extends Validator { return true; // Maps will work for summary, see disallowIndexingOfMaps() } else if (dataType instanceof TensorDataType) { return true; - } else if (dataType instanceof ReferenceDataType) { + } else if (dataType instanceof NewDocumentReferenceDataType) { return true; } else { return dataType.equals(DataType.INT) || diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java index dc5ffa7ecc7..4e3d2cbb61b 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/StreamingValidator.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.model.deploy.DeployState; import com.yahoo.document.DataType; import com.yahoo.document.NumericDataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.ImmutableSDField; import com.yahoo.searchdefinition.document.Matching; @@ -75,7 +75,7 @@ public class StreamingValidator extends Validator { private static void failStreamingDocumentReferences(SearchCluster sc) { for (Attribute attribute : sc.getSdConfig().getAttributeFields().attributes()) { DataType dataType = attribute.getDataType(); - if (dataType instanceof ReferenceDataType) { + if (dataType instanceof NewDocumentReferenceDataType) { String errorMessage = String.format( "For streaming search cluster '%s': Attribute '%s' has type '%s'. " + "Document references and imported fields are not allowed in streaming search.", diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index e90df2776e0..018531616fb 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -848,6 +848,7 @@ DataType dataType() : DataType wsetType = null; TensorType tensorType; TemporaryStructuredDataType referenceType; + String referencedDoc; } { ( LOOKAHEAD(<ARRAY> <LESSTHAN>) ( <ARRAY> <LESSTHAN> arrayType = dataType() <GREATERTHAN> { return DataType.getArray(arrayType); } ) @@ -855,7 +856,7 @@ DataType dataType() : | LOOKAHEAD(<MAP> <LESSTHAN>) ( mapType = mapDataType() { return mapType; } ) | LOOKAHEAD(<ANNOTATIONREFERENCE> <LESSTHAN>) ( mapType = annotationRefDataType() { return mapType; } ) | LOOKAHEAD(<TENSOR_TYPE>) ( tensorType = tensorType("Field type") { return DataType.getTensor(tensorType); } ) - | LOOKAHEAD(<REFERENCE>) ( <REFERENCE> <LESSTHAN> referenceType = referenceType() <GREATERTHAN> { return ReferenceDataType.createWithInferredId(referenceType); } ) + | LOOKAHEAD(<REFERENCE>) ( <REFERENCE> <LESSTHAN> referencedDoc = identifier() <GREATERTHAN> { return NewDocumentReferenceDataType.forDocumentName(referencedDoc); } ) | ( typeName = identifier() ["[]" { isArrayOldStyle = true; }] ) ) { @@ -876,17 +877,6 @@ DataType dataType() : } } -TemporaryStructuredDataType referenceType() : -{ - String documentName; -} -{ - ( documentName = identifier() ) - { - return TemporaryStructuredDataType.create(documentName); - } -} - DataType annotationRefDataType() : { DataType dataType; diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java index 8edbd789a27..8c8cb59e9d9 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentGraphValidatorTest.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition; import com.yahoo.config.model.test.MockApplicationPackage; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -157,7 +157,7 @@ public class DocumentGraphValidatorTest { @SuppressWarnings("deprecation") private static void createDocumentReference(Schema from, Schema to, String refFieldName) { SDDocumentType fromDocument = from.getDocument(); - SDField refField = new TemporarySDField(fromDocument, refFieldName, ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create(to.getName()))); + SDField refField = new TemporarySDField(fromDocument, refFieldName, NewDocumentReferenceDataType.forDocumentName(to.getName())); fromDocument.addField(refField); Map<String, DocumentReference> originalMap = fromDocument.getDocumentReferences().get().referenceMap(); HashMap<String, DocumentReference> modifiedMap = new HashMap<>(originalMap); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java index 4fa145afae9..b23ad4eb5b6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/DocumentReferenceResolverTest.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; @@ -41,7 +41,7 @@ public class DocumentReferenceResolverTest { Schema fooSchema = new Schema(FOO, MockApplicationPackage.createEmpty()); SDDocumentType fooDocument = new SDDocumentType("foo", fooSchema); SDField fooRefToBarField = new SDField - (fooDocument, "bar_ref", ReferenceDataType.createWithInferredId(barDocument.getDocumentType())); + (fooDocument, "bar_ref", new NewDocumentReferenceDataType(barDocument.getDocumentType())); AttributeUtils.addAttributeAspect(fooRefToBarField); SDField irrelevantField = new SDField(fooDocument, "irrelevant_stuff", DataType.INT); fooDocument.addField(fooRefToBarField); @@ -66,7 +66,7 @@ public class DocumentReferenceResolverTest { SDDocumentType fooDocument = new SDDocumentType("foo", fooSchema); SDField fooRefToBarField = new SDField( fooDocument, - "bar_ref", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("bar"))); + "bar_ref", NewDocumentReferenceDataType.forDocumentName("bar")); AttributeUtils.addAttributeAspect(fooRefToBarField); fooDocument.addField(fooRefToBarField); fooSchema.addDocument(fooDocument); @@ -90,7 +90,7 @@ public class DocumentReferenceResolverTest { Schema fooSchema = new Schema(FOO, MockApplicationPackage.createEmpty()); SDDocumentType fooDocument = new SDDocumentType("foo", fooSchema); SDField fooRefToBarField = new SDField - (fooDocument, "bar_ref", ReferenceDataType.createWithInferredId(barDocument.getDocumentType())); + (fooDocument, "bar_ref", new NewDocumentReferenceDataType(barDocument.getDocumentType())); fooDocument.addField(fooRefToBarField); fooSchema.addDocument(fooDocument); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java b/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java index 7e708f93a96..f486126ba4f 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/ImportedFieldsEnumeratorTest.java @@ -3,7 +3,7 @@ package com.yahoo.searchdefinition; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.searchdefinition.document.SDDocumentType; import com.yahoo.searchdefinition.document.SDField; import com.yahoo.searchdefinition.document.TemporaryImportedField; @@ -31,7 +31,7 @@ public class ImportedFieldsEnumeratorTest { Schema fooSchema = new Schema(FOO, MockApplicationPackage.createEmpty()); /* SDField fooRefToParent = new SDField( - "foo_ref", ReferenceDataType.createWithInferredId(parentDocument.getDocumentType())); + "foo_ref", NewDocumentReferenceDataType.createWithInferredId(parentDocument.getDocumentType())); AttributeUtils.addAttributeAspect(fooRefToParent); */ var fooImports = fooSchema.temporaryImportedFields().get(); @@ -44,7 +44,7 @@ public class ImportedFieldsEnumeratorTest { Schema barSchema = new Schema(BAR, MockApplicationPackage.createEmpty()); /* SDField barRefToParent = new SDField( - "bar_ref", ReferenceDataType.createWithInferredId(parentDocument.getDocumentType())); + "bar_ref", NewDocumentReferenceDataType.createWithInferredId(parentDocument.getDocumentType())); AttributeUtils.addAttributeAspect(barRefToParent); */ var barImports = barSchema.temporaryImportedFields().get(); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java index 2522f8f56e2..ed3f5cb0ba6 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/SchemaOrdererTestCase.java @@ -2,7 +2,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.test.MockApplicationPackage; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.DocumentReference; import com.yahoo.searchdefinition.DocumentReferences; @@ -92,7 +92,7 @@ public class SchemaOrdererTestCase extends AbstractSchemaTestCase { @SuppressWarnings("deprecation") private static void createDocumentReference(Schema from, Schema to, String refFieldName) { SDDocumentType fromDocument = from.getDocument(); - SDField refField = new TemporarySDField(fromDocument, refFieldName, ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create(to.getName()))); + SDField refField = new TemporarySDField(fromDocument, refFieldName, NewDocumentReferenceDataType.forDocumentName(to.getName())); fromDocument.addField(refField); Map<String, DocumentReference> originalMap = fromDocument.getDocumentReferences().get().referenceMap(); HashMap<String, DocumentReference> modifiedMap = new HashMap<>(originalMap); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java index 9c974225605..2d6b3acc4dd 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/derived/VsmFieldsTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.derived; import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.config.model.test.MockApplicationPackage; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.Application; import com.yahoo.searchdefinition.Schema; @@ -27,7 +27,7 @@ public class VsmFieldsTestCase { Schema schema = new Schema("test", MockApplicationPackage.createEmpty(), new MockFileRegistry(), new TestableDeployLogger(), new TestProperties()); var sdoc = new SDDocumentType("test"); schema.addDocument(sdoc); - SDField refField = new TemporarySDField(sdoc, "ref_field", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("parent_type"))); + SDField refField = new TemporarySDField(sdoc, "ref_field", NewDocumentReferenceDataType.forDocumentName("parent_type")); refField.parseIndexingScript("{ summary }"); schema.getDocument().addField(refField); diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java index 3b4612ee87a..0b615595794 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ParentChildSearchModel.java @@ -6,7 +6,7 @@ import com.yahoo.config.model.application.provider.MockFileRegistry; import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.config.model.test.MockApplicationPackage; import com.yahoo.document.DataType; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.searchdefinition.Application; import com.yahoo.searchdefinition.DocumentReference; @@ -45,7 +45,7 @@ public class ParentChildSearchModel { @SuppressWarnings("deprecation") protected static SDField createRefField(SDDocumentType repo, String parentType, String fieldName) { - return new TemporarySDField(repo, fieldName, ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create(parentType))); + return new TemporarySDField(repo, fieldName, NewDocumentReferenceDataType.forDocumentName(parentType)); } protected static void addRefField(Schema child, Schema parent, String fieldName) { diff --git a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java index d353e070976..c517e36bce1 100644 --- a/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java +++ b/config-model/src/test/java/com/yahoo/searchdefinition/processing/ReferenceFieldTestCase.java @@ -4,7 +4,7 @@ package com.yahoo.searchdefinition.processing; import com.yahoo.config.model.deploy.TestProperties; import com.yahoo.document.DataType; import com.yahoo.document.Field; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.searchdefinition.DocumentGraphValidator; import com.yahoo.searchdefinition.Schema; import com.yahoo.searchdefinition.ApplicationBuilder; @@ -106,8 +106,8 @@ public class ReferenceFieldTestCase { Field field = documentType.getDocumentType().getField(expectedFieldname); assertNotNull("Field does not exist in document type: " + expectedFieldname, field); DataType dataType = field.getDataType(); - assertTrue(dataType instanceof ReferenceDataType); - ReferenceDataType refField = (ReferenceDataType) dataType; + assertTrue(dataType instanceof NewDocumentReferenceDataType); + NewDocumentReferenceDataType refField = (NewDocumentReferenceDataType) dataType; assertEquals(referencedDocType, refField.getTargetType().getName()); } diff --git a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java index 00f39a23a8f..ebb4156f3c0 100644 --- a/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java +++ b/config-model/src/test/java/com/yahoo/vespa/documentmodel/DocumentModelBuilderReferenceTypeTestCase.java @@ -1,7 +1,7 @@ // Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.documentmodel; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.searchdefinition.ApplicationBuilder; import com.yahoo.searchdefinition.parser.ParseException; @@ -51,7 +51,7 @@ public class DocumentModelBuilderReferenceTypeTestCase extends AbstractReference "}")); NewDocumentType campaignType = model.getDocumentManager().getDocumentType("campaign"); NewDocumentType adType = model.getDocumentManager().getDocumentType("ad"); - ReferenceDataType campaignRefType = (ReferenceDataType) adType.getField("campaign_ref").getDataType(); + NewDocumentReferenceDataType campaignRefType = (NewDocumentReferenceDataType) adType.getField("campaign_ref").getDataType(); assertEquals(campaignRefType.getTargetType(), campaignType); } diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java index 0e96420f03c..86385b2f80d 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/search/DocumentTypeChangeValidatorTest.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.ValidationId; import com.yahoo.config.provision.ClusterSpec; import com.yahoo.document.DocumentType; import com.yahoo.document.Field; -import com.yahoo.document.ReferenceDataType; +import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.documentmodel.NewDocumentType; import com.yahoo.searchdefinition.FieldSets; @@ -205,7 +205,7 @@ public class DocumentTypeChangeValidatorTest { private static NewDocumentType createDocumentTypeWithReferenceField(String nameReferencedDocumentType) { StructDataType headerfields = new StructDataType("headerfields"); - headerfields.addField(new Field("ref", new ReferenceDataType(new DocumentType(nameReferencedDocumentType), 0))); + headerfields.addField(new Field("ref", new NewDocumentReferenceDataType(new DocumentType(nameReferencedDocumentType)))); return new NewDocumentType( new NewDocumentType.Name("mydoc"), headerfields, |