diff options
author | Arne H Juul <arnej@yahooinc.com> | 2022-03-23 11:54:21 +0000 |
---|---|---|
committer | Arne H Juul <arnej@yahooinc.com> | 2022-03-23 11:54:51 +0000 |
commit | 4b92154f846964e26d2a5df47c0669c42689e9ee (patch) | |
tree | d85aac1b4cf73be92d63b7f7afdb81a39528623b /config-model/src/main/java/com/yahoo | |
parent | d2d55010845f33ecde00082ad085e34c50135d0b (diff) |
handle new temporaries
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/DocumentModelBuilder.java | 25 | ||||
-rw-r--r-- | config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java | 9 |
2 files changed, 28 insertions, 6 deletions
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 4660b81ff72..1ac3f80c743 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,6 @@ import com.yahoo.document.DataType; import com.yahoo.document.DocumentType; import com.yahoo.document.Field; import com.yahoo.document.MapDataType; -import com.yahoo.documentmodel.NewDocumentReferenceDataType; import com.yahoo.document.StructDataType; import com.yahoo.document.StructuredDataType; import com.yahoo.document.TemporaryStructuredDataType; @@ -15,7 +14,10 @@ import com.yahoo.document.WeightedSetDataType; 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.OwnedTemporaryType; +import com.yahoo.documentmodel.TemporaryUnknownType; import com.yahoo.documentmodel.VespaDocumentType; import com.yahoo.searchdefinition.document.Attribute; import com.yahoo.searchdefinition.document.SDDocumentType; @@ -232,13 +234,26 @@ public class DocumentModelBuilder { } DataType original = type; if (type instanceof TemporaryStructuredDataType) { + throw new IllegalArgumentException("Cannot handle temporary: " + type); + } + if (type instanceof TemporaryUnknownType) { + // must be a known struct or document type DataType other = repo.getDataType(type.getId()); if (other == null || other == type) { + // maybe it is the name of a document type: other = getDocumentType(docs, type.getName()); } - if (other != null) { - type = other; + if (other == null) { + throw new IllegalArgumentException("No replacement found for temporary type: " + type); + } + type = other; + } else if (type instanceof OwnedTemporaryType) { + // must be replaced with the real struct type + DataType other = repo.getDataType(type.getId()); + if (other == null || other == type) { + throw new IllegalArgumentException("No replacement found for temporary type: " + type); } + type = other; } else if (type instanceof DocumentType) { DataType other = getDocumentType(docs, type.getName()); if (other != null) { @@ -532,11 +547,13 @@ public class DocumentModelBuilder { @SuppressWarnings("deprecation") private StructDataType handleStruct(SDDocumentType type) { + // System.err.println("handle struct " + type + " for doc " + targetDt.getName()); if (type.isStruct()) { var st = type.getStruct(); if (st.getName().equals(type.getName()) && (st instanceof StructDataType) && - ! (st instanceof TemporaryStructuredDataType)) + (! (st instanceof TemporaryUnknownType)) && + (! (st instanceof OwnedTemporaryType))) { return handleStruct((StructDataType) st); } diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java index 621e7ce8571..49ae00d0663 100644 --- a/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java +++ b/config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java @@ -7,9 +7,10 @@ import com.yahoo.document.DocumentType; import com.yahoo.document.Field; import com.yahoo.document.MapDataType; import com.yahoo.document.StructDataType; -import com.yahoo.document.TemporaryStructuredDataType; import com.yahoo.document.TensorDataType; import com.yahoo.document.WeightedSetDataType; +import com.yahoo.documentmodel.OwnedTemporaryType; +import com.yahoo.documentmodel.TemporaryUnknownType; import com.yahoo.language.Linguistics; import com.yahoo.language.process.Embedder; import com.yahoo.language.simple.SimpleLinguistics; @@ -307,7 +308,11 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer, return; } SDDocumentType subType = sdoc != null ? sdoc.getType(dataType.getName()) : null; - if (dataType instanceof TemporaryStructuredDataType && subType != null) { + if (dataType instanceof TemporaryUnknownType && subType != null) { + for (Field field : subType.fieldSet()) { + supplyStructField.accept(field.getName(), field.getDataType()); + } + } else if (dataType instanceof OwnedTemporaryType && subType != null) { for (Field field : subType.fieldSet()) { supplyStructField.accept(field.getName(), field.getDataType()); } |