summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2022-04-07 12:41:38 +0000
committerArne H Juul <arnej@yahooinc.com>2022-04-07 14:01:28 +0000
commit402027bcbddb7bbae84a643acdc7fcef9dfe6c11 (patch)
treeea6a5f3b6fb137b5fdba4dbe12f4e7b664e685a7 /config-model
parent1d04fdd423900847ddfc22f2a0f50134b5ea47d7 (diff)
handle different SDDocumentType instances with same name
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/SDDocumentTypeOrderer.java23
-rw-r--r--config-model/src/main/java/com/yahoo/searchdefinition/document/SDField.java4
2 files changed, 15 insertions, 12 deletions
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 5b1a9595b94..ce32f323f22 100644
--- a/config-model/src/main/java/com/yahoo/searchdefinition/SDDocumentTypeOrderer.java
+++ b/config-model/src/main/java/com/yahoo/searchdefinition/SDDocumentTypeOrderer.java
@@ -18,7 +18,7 @@ import java.util.logging.Level;
public class SDDocumentTypeOrderer {
private final Map<DataTypeName, SDDocumentType> createdSDTypes = new LinkedHashMap<>();
- private final Set<String> seenTypes = new LinkedHashSet<>();
+ private final Set<Object> seenTypes = Collections.newSetFromMap(new IdentityHashMap<>());
List<SDDocumentType> processingOrder = new LinkedList<>();
private final DeployLogger deployLogger;
@@ -27,7 +27,6 @@ public class SDDocumentTypeOrderer {
for (SDDocumentType type : sdTypes) {
createdSDTypes.put(type.getDocumentName(), type);
}
- seenTypes.add("document");
}
List<SDDocumentType> getOrdered() { return processingOrder; }
@@ -40,16 +39,17 @@ public class SDDocumentTypeOrderer {
private void process(SDDocumentType docOrStruct, SDDocumentType owningDocument) {
resolveAndProcessInheritedTemporaryTypes(docOrStruct, owningDocument);
- if (seenTypes.contains(docOrStruct.getName())) {
+ if (seenTypes.contains(docOrStruct)) {
return;
}
- seenTypes.add(docOrStruct.getName());
+ seenTypes.add(docOrStruct);
for (Field field : docOrStruct.fieldSet()) {
- String typeName = field.getDataType().getName();
- if (!seenTypes.contains(typeName)) {
- seenTypes.add(typeName);
+ var type = field.getDataType();
+ String typeName = type.getName();
+ if (!seenTypes.contains(type)) {
+ seenTypes.add(type);
//we haven't seen this before, do it
- visit(field.getDataType(), owningDocument);
+ visit(type, owningDocument);
}
}
processingOrder.add(docOrStruct);
@@ -89,7 +89,7 @@ public class SDDocumentTypeOrderer {
for(SDDocumentType sdoc : createdSDTypes.values()) {
for (SDDocumentType stype : sdoc.getTypes()) {
if (stype.getName().equals(name)) {
- return stype;
+ return stype;
}
}
}
@@ -99,7 +99,10 @@ public class SDDocumentTypeOrderer {
private void visit(DataType type, SDDocumentType owningDocument) {
if (type instanceof StructuredDataType) {
StructuredDataType structType = (StructuredDataType) type;
- SDDocumentType sdDocType = find(structType.getName());
+ SDDocumentType sdDocType = owningDocument.getType(structType.getName());
+ if (sdDocType == null) {
+ sdDocType = find(structType.getName());
+ }
if (sdDocType == null) {
throw new IllegalArgumentException("Could not find struct '" + type.getName() + "'");
}
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 256c628a1cb..382c0d0ceb5 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
@@ -493,7 +493,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
@Override
public boolean hasIndex() {
- return (getIndexingScript() != null) && doesIndexing();
+ return (getIndexingScript() != null) && doesIndexing();
}
/** Sets the literal boost of this field */
@@ -712,7 +712,7 @@ public class SDField extends Field implements TypedKey, FieldOperationContainer,
* @param create true to create the summary field and add it to this field before returning if it is missing
* @return the summary field, or null if not present and create is false
*/
- public SummaryField getSummaryField(String name,boolean create) {
+ public SummaryField getSummaryField(String name, boolean create) {
SummaryField summaryField=summaryFields.get(name);
if (summaryField==null && create) {
summaryField=new SummaryField(name, getDataType());